Skip to content

stm32f4: flashing causes board to be ST-link to be locked #4651

@Siri2K

Description

@Siri2K

Hi everyone,

I'm trying to run a simple blinky.rs code on the nucleo-f446re (with stm32f446re chip) using the following commands
cargo run --bin blinky.rs --release
The first time, the cde flashes fine. However, if I try this command a second time, my board shows this error:

Image

The error indicates that the board is locked.

Although I have 2 work arounds, it is still frustrating the board gets locked everytime I use cargo to flash my code.

To reproduce:

  1. Connect NUCLEO board to the computer and ensure the computer can detect it
  2. Flash the board using cargo run --bin blinky.rs --release
  3. Unplug NUCLEO board
  4. PLug In NUCLEO board
  5. Attempt to flash again with cargo run --bin blinky.rs --release

Workaround 1

  1. If OpenOCD is not installed, then enter this command:
    sudo apt -y update sudo apt -y install openocd
  2. Copy the reset.txt and change the extension from .txt to .cfg
  3. Enter this command:
    openocd -f <path to reset.cfg file>/reset.cfg.
  4. If no errors occur, then try cargo run --bin blinky.rs --release again, it should work this time

Note: If at Step 3, there are errors, this workaround will not work as the board is deeply locked. At that point, switch to workaround 2

Workaround 2

  1. On the Nucleo board, connect the BOOT0 pin to the 3V3 pin
  2. Press the RESET button (black button)
  3. Enter this command
    openocd -f interface/stlink.cfg -f target/stm32f4x.cfg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions