Hi there!
After some weeks of googling I managed to get a gnu-arm-none-eabi toolchain running under OSX. I can now flash a small binary (blinky.bin) from the Stellaris-Ware examples to the lm3s9b92 (Luminary Micro ICDI Eval-Board) using openocd (0.4.0) and its working. However, when I try to flash a more complex example (hello.bin) I get a segmentation fault while flashing.
My openocd.cfg for both examples is as follows (and works for the blinky example)
# ====== interface configuration ==========================================
interface ft2232
ft2232_device_desc "Luminary Micro ICDI Board"
ft2232_layout luminary_icdi
ft2232_vid_pid 0x0403 0xbcda
# ====== target configuration ============================================
set _CHIPNAME lm3s9b92
# Fourth generation "Tempest" device
set _CPUTAPID 0x4ba00477
# jtag scan chain
jtag_nsrst_delay 100
jtag_ntrst_delay 100
jtag_khz 3000
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 1 -irmask 0xf -expected-id $_CPUTAPID
# Cortex-M3 with Luminary lm3s variant
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m3 -chain-position $_TARGETNAME
# 16k working area at base of ram, not backed up
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 0x4000 -work-area-backup 0
# flash configuration
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME stellaris 0 0 0 0 $_TARGETNAME
targets
# ====== end of configuration ==========================================
init
debug_level 3
reset halt
flash write_image erase hello.bin 0x0
reset run
shutdown
The openocd debug_level 3 output while flashing the hello.bin example looks like this:
...
User : 290 63157 target.c:1234 target_arch_state(): target state: halted
User : 291 63157 armv7m.c:489 armv7m_arch_state(): target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x010009c8 msp: 0x20000800
Debug: 292 63157 target.c:968 target_call_event_callbacks(): target event 8 (gdb-end)
Debug: 293 63157 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_lm3s9b92.cpu curstate
Debug: 294 63157 command.c:133 script_debug(): command - ocd_lm3s9b92.cpu ocd_lm3s9b92.cpu curstate
Debug: 295 63157 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_lm3s9b92.cpu invoke-event reset-end
Debug: 296 63157 command.c:133 script_debug(): command - ocd_lm3s9b92.cpu ocd_lm3s9b92.cpu invoke-event reset-end
Debug: 297 68563 gdb_server.c:2147 gdb_input_inner(): received packet: 'vFlashErase:00000000,00000800'
Debug: 298 68563 target.c:968 target_call_event_callbacks(): target event 27 (gdb-flash-erase-start)
Debug: 299 68564 target.c:1488 target_read_u32(): address: 0x400fe060, value: 0x078e3ad1
Debug: 300 68564 stellaris.c:386 stellaris_read_clock_info(): Stellaris RCC 78e3ad1
Debug: 301 68566 target.c:1488 target_read_u32(): address: 0x400fe070, value: 0x07c06810
Debug: 302 68566 stellaris.c:389 stellaris_read_clock_info(): Stellaris RCC2 78e3ad1
Debug: 303 68568 target.c:1488 target_read_u32(): address: 0x400fe064, value: 0x00000641
Debug: 304 68568 stellaris.c:392 stellaris_read_clock_info(): Stellaris PLLCFG 641
Debug: 305 68568 stellaris.c:339 stellaris_set_flash_timing(): usecrl = 15
Debug: 306 68568 target.c:1565 target_write_u32(): address: 0x400fe140, value: 0x0000000f
Debug: 307 68570 target.c:1565 target_write_u32(): address: 0x400fd010, value: 0x00000000
Debug: 308 68572 target.c:1565 target_write_u32(): address: 0x400fd014, value: 0x00000003
Debug: 309 68574 target.c:1565 target_write_u32(): address: 0x400fd000, value: 0x00000000
Debug: 310 68576 target.c:1565 target_write_u32(): address: 0x400fd008, value: 0xa4420002
Debug: 311 68580 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 312 68582 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 313 68584 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 314 68586 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 315 68588 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 316 68590 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 317 68592 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 318 68594 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 319 68596 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000000
Debug: 320 68598 target.c:1488 target_read_u32(): address: 0x400fd00c, value: 0x00000002
Debug: 321 68598 target.c:1565 target_write_u32(): address: 0x400fd000, value: 0x00000400
Debug: 322 68600 target.c:1565 target_write_u32(): address: 0x400fd008, value: 0xa4420002
Debug: 323 68604 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 324 68606 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 325 68608 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 326 68610 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 327 68612 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 328 68614 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 329 68616 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 330 68618 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000002
Debug: 331 68620 target.c:1488 target_read_u32(): address: 0x400fd008, value: 0x00000000
Debug: 332 68622 target.c:1488 target_read_u32(): address: 0x400fd00c, value: 0x00000002
Debug: 333 68622 target.c:968 target_call_event_callbacks(): target event 28 (gdb-flash-erase-end)
Debug: 334 68622 gdb_server.c:2147 gdb_input_inner(): received packet: 'vFlashWrite:0:'
Debug: 335 68622 gdb_server.c:2147 gdb_input_inner(): received packet: 'vFlashDone'
Debug: 336 68622 target.c:968 target_call_event_callbacks(): target event 29 (gdb-flash-write-start)
Debug: 337 68622 stellaris.c:937 stellaris_write(): (bank=0x100229130 buffer=0x10082d400 offset=00000000 count=00000544
Debug: 338 68624 target.c:1488 target_read_u32(): address: 0x400fe060, value: 0x078e3ad1
Debug: 339 68624 stellaris.c:386 stellaris_read_clock_info(): Stellaris RCC 78e3ad1
Debug: 340 68626 target.c:1488 target_read_u32(): address: 0x400fe070, value: 0x07c06810
Debug: 341 68626 stellaris.c:389 stellaris_read_clock_info(): Stellaris RCC2 78e3ad1
Debug: 342 68628 target.c:1488 target_read_u32(): address: 0x400fe064, value: 0x00000641
Debug: 343 68628 stellaris.c:392 stellaris_read_clock_info(): Stellaris PLLCFG 641
Debug: 344 68628 stellaris.c:339 stellaris_set_flash_timing(): usecrl = 15
Debug: 345 68628 target.c:1565 target_write_u32(): address: 0x400fe140, value: 0x0000000f
Debug: 346 68630 target.c:1565 target_write_u32(): address: 0x400fd010, value: 0x00000000
Debug: 347 68632 target.c:1565 target_write_u32(): address: 0x400fd014, value: 0x00000003
Debug: 348 68634 stellaris.c:836 stellaris_write_block(): (bank=0x100229130 buffer=0x10082d400 offset=00000000 wcount=00000151
Debug: 349 68634 target.c:1072 target_alloc_working_area(): MMU disabled, using physical address for working memory 0x20000000
Debug: 350 68634 target.c:1134 target_alloc_working_area(): allocated new working area at address 0x20000000
Debug: 351 68634 target.c:1134 target_alloc_working_area(): allocated new working area at address 0x20000028
Debug: 352 68634 target.c:1251 target_write_buffer(): writing buffer of 40 byte at 0x20000000
Debug: 353 68636 target.c:1251 target_write_buffer(): writing buffer of 1348 byte at 0x20000028
Segmentation fault
logos:hello Ashitaka$
The critical part in the openocd output for the working blinky example is
...
Debug: 207 69143 target.c:1072 target_alloc_working_area(): MMU disabled, using physical address for working memory 0x20000000
Debug: 208 69143 target.c:1134 target_alloc_working_area(): allocated new working area at address 0x20000000
Debug: 209 69143 target.c:1134 target_alloc_working_area(): allocated new working area at address 0x20000028
Debug: 210 69143 target.c:1251 target_write_buffer(): writing buffer of 40 byte at 0x20000000
Debug: 211 69145 target.c:1251 target_write_buffer(): writing buffer of 476 byte at 0x20000028
Debug: 212 69151 stellaris.c:885 stellaris_write_block(): Algorithm flash write 119 words to 0x0, 0 remaining
Debug: 213 69155 cortex_m3.c:999 cortex_m3_set_breakpoint(): BPID: 0, Type: 1, Address: 0x2000001e Length: 2 (set=1)
Debug: 214 69155 breakpoints.c:102 breakpoint_add(): added software breakpoint at 0x2000001e of length 0x00000002, (BPID: 0)
Debug: 215 69155 armv7m.c:129 armv7m_restore_context():
...
After some googling I came across the “stellaris recover bank_id” openocd command (Performs the Recovering a “Locked” Device procedure to restore the flash specified by bank_id and its associated nonvolatile registers to their factory default values (erased).) Unfortunately, that command didn’t work for me (“command requires more arguments” failure, no matter what arguments I specified) but it brought me to the idea that my flash may be locked in some kind. So I used the M$-Windows flash utility (from TI/Stellaris) to “unlock” the device. But that didn’t solve the segfault problem neither.
Flashing of the hello.bin using the Stellaris flash utility works without problems. But I didn’t work me through all the compiling and debugging of my OSX-ARM-toolchain to use Windows to flash the device.
Of corse I tried different jtag speeds, different file formats, different flash commands, the use of gdb to control openocd… without success.
So, if someone has any idea what I could try or what I am missing here, please speak up!
Cheers,
ashitaka