rust-embedded / cortex-m-quickstart

Template to develop bare metal applications for Cortex-M microcontrollers
782 stars 164 forks source link

add a runner to flash program directly #116

Closed Narukara closed 1 year ago

Narukara commented 1 year ago

Can we add a runner to flash program directly through openocd? It can be annoying to start openocd and close gdb manually every time you flash.

In fact, I did this in my own project:

  1. Add runner = "./flash.sh" to config.toml
  2. Create a flash.sh in the project root directory, and its contents are:
openocd -f openocd.cfg -c init -c halt -c "flash write_image erase $1" -c reset -c shutdown

Then I can flash the program directly with cargo run. This may not be a good way to implement it, but it's really convenient.

crespum commented 1 year ago

Are you familiar with cargo-flash? I was doing something similar to what you propose but now I simply use something like cargo flash --release --chip NRF52820_XXAA. It works like a charm!

Narukara commented 1 year ago

Are you familiar with cargo-flash? I was doing something similar to what you propose but now I simply use something like cargo flash --release --chip NRF52820_XXAA. It works like a charm!

I tried cargo-flash as you said and it works perfectly. Thanks for your advice!

Now that there is a tool available, I think this issue can be closed.