General troubleshooting

OpenOCD problems

can’t connect to OpenOCD - “Error: open failed”

Symptoms

Upon trying to establish a new connection with the device you get an errorthat looks like this:

  1. $ openocd -f (..)
  2. (..)
  3. Error: open failed
  4. in procedure 'init'
  5. in procedure 'ocd_bouncer'

Cause + Fix

  • All: The device is not (properly) connected. Check the USB connection usinglsusb or the Device Manager.
  • Linux: You may not have enough permission to open the device. Try again withsudo. If that works, you can use these instructions to make OpenOCD workwithout root privilege.
  • Windows: You are probably missing the ST-LINK USB driver. Installationinstructions here.

can’t connect to OpenOCD - “Polling again in X00ms”

Symptoms

Upon trying to establish a new connection with the device you get an errorthat looks like this:

  1. $ openocd -f (..)
  2. (..)
  3. Error: jtag status contains invalid mode value - communication failure
  4. Polling target stm32f3x.cpu failed, trying to reexamine
  5. Examination failed, GDB will be halted. Polling again in 100ms
  6. Info : Previous state query failed, trying to reconnect
  7. Error: jtag status contains invalid mode value - communication failure
  8. Polling target stm32f3x.cpu failed, trying to reexamine
  9. Examination failed, GDB will be halted. Polling again in 300ms
  10. Info : Previous state query failed, trying to reconnect

Cause

The microcontroller may have get stuck in some tight infinite loop or it may becontinuously raising an exception, e.g. the exception handler is raising anexception.

Fix

  • Close OpenOCD, if running
  • Press and hold the reset (black) button
  • Launch the OpenOCD command
  • Now, release the reset button

OpenOCD connection lost - “Polling again in X00ms”

Symptoms

A running OpenOCD session suddenly errors with:

  1. # openocd -f (..)
  2. Error: jtag status contains invalid mode value - communication failure
  3. Polling target stm32f3x.cpu failed, trying to reexamine
  4. Examination failed, GDB will be halted. Polling again in 100ms
  5. Info : Previous state query failed, trying to reconnect
  6. Error: jtag status contains invalid mode value - communication failure
  7. Polling target stm32f3x.cpu failed, trying to reexamine
  8. Examination failed, GDB will be halted. Polling again in 300ms
  9. Info : Previous state query failed, trying to reconnect

Cause

The USB connection was lost.

Fix

  • Close OpenOCD
  • Disconnect and re-connect the USB cable.
  • Re-launch OpenOCD

Can’t flash the device - “Ignoring packet error, continuing…”

Symptoms

While flashing the device, you get:

  1. $ arm-none-eabi-gdb $file
  2. Start address 0x8000194, load size 31588
  3. Transfer rate: 22 KB/sec, 5264 bytes/write.
  4. Ignoring packet error, continuing...
  5. Ignoring packet error, continuing...

Cause

Closed itmdump while a program that “printed” to the ITM was running. Thecurrent GDB session will appear to work normally, just without ITM output butthe next GDB session will error with the message that was shown in the previoussection.

Or, itmdump was called after the monitor tpiu was issued thus makingitmdump delete the file / named-pipe that OpenOCD was writing to.

Fix

  • Close/kill GDB, OpenOCD and itmdump
  • Remove the file / named-pipe that itmdump was using (for example,itm.txt).
  • Launch OpenOCD
  • Then, launch itmdump
  • Then, launch the GDB session that executes the monitor tpiu command.

Cargo problems

“can’t find crate for core

Symptoms

  1. Compiling volatile-register v0.1.2
  2. Compiling rlibc v1.0.0
  3. Compiling r0 v0.1.0
  4. error[E0463]: can't find crate for `core`
  5. error: aborting due to previous error
  6. error[E0463]: can't find crate for `core`
  7. error: aborting due to previous error
  8. error[E0463]: can't find crate for `core`
  9. error: aborting due to previous error
  10. Build failed, waiting for other jobs to finish...
  11. Build failed, waiting for other jobs to finish...
  12. error: Could not compile `r0`.
  13. To learn more, run the command again with --verbose.

Cause

You are using a toolchain older than nightly-2018-04-08 and forgot to call rustup target add thumbv7em-none-eabihf.

Fix

Update your nightly and install the thumbv7em-none-eabihf target.

  1. $ rustup update nightly
  2. $ rustup target add thumbv7em-none-eabihf