stm32-rs/stm32f407g-disc

ITM example isn't working

arkap opened this issue · 0 comments

arkap commented

I'm trying to get the ITM example working but I don't see any output.
Here is what I've done:

I've changed

openocd -c "init" -c "targets" -c "reset halt" -c "program $1 verify reset exit"

to

openocd -f openocd.cfg -c "init" -c "targets" -c "reset halt" -c "program $1 verify reset exit"

so openocd picks up the correct config file. I had to change the first line in openocd.cfg from

source [find interface/stlink.cfg]

to

source [find interface/stlink-v2.cfg]

to avoid an error about the wrong interface. Since this crate is for a specific board, that change should probably be unnecessary unless there's different versions of the STM32f4DISCOVERY with varying STLink adapters.

If I run ./openocd_program.sh target/thumbv7em-none-eabihf/debug/examples/itm I get the following output:

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v25 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.906461
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f4x.cpu       hla_target little stm32f4x.cpu       halted
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080023a0 msp: 0x20020000
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080023a0 msp: 0x20020000
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
adapter speed: 4000 kHz
** Programming Started **
auto erase enabled
Info : device id = 0x10016413
Info : flash size = 1024kbytes
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x20000046 msp: 0x20020000
wrote 16384 bytes from file target/thumbv7em-none-eabihf/debug/examples/itm in 0.598411s (26.737 KiB/s)
** Programming Finished **
** Verify Started **
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20020000
verified 11360 bytes in 0.050149s (221.216 KiB/s)
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
shutdown command invoked

This seems to work OK. However, I'm unsure what the different clock speeds are and why they seem to change over time. Maybe that's tied to my problem. Finally, I uncommented

monitor tpiu config internal itm.txt uart off 160000000

in openocd.gdb and changed the number to 168000000 since that's the STM32F4DISCOVERY's clock speed afaik.

If I run itmdump -f itm.txt -F, openocdf, and cargo run --example=itm (all in different terminals), I don't see any output from ITM even though gdb is showing me that I have reached the infinite loop.

The comments in openocd.gdb suggest that this example was copied from some other place since they seem to generic for this crate. I'd gladly open a PR fixing all the aforementioned details, giving more detailed instructions for the examples, and anything else that still needs to change for the example to work but I don't know where to look to narrow down the issue. Can someone point me in the right direction?