Question

I'm new on OpenOCD, has anyone attempted to use Olimex OpenOCD to actually flash program hex file (from Kiel say) into ARM CORTEX M0 (generic).

What do I need to setup script file to take each word of the hex file to performs mww (memory write word) within the MCU flash?, can anyone provide an example. I use python.

I open for suggestion.

I use Window PC.

Was it helpful?

Solution

All Cortex M0 that I know of have no JTAG, but only SWD support. SWD is not yet available in OpenOCD - it is still in development.

Another note: The method for writing the flash memory is specific for each vendor/chip.

OTHER TIPS

Sure, what platform in particular? some googling will find the exact sequence. flash unlock, erase, program, etc.

Section 6 of this page for example.

http://pygmy.utoh.org/riscy/cortex/led-lpc17xx.html

I am trying to figure out what board I did it on but those were pretty much the commands I followed and it worked just fine. It may have been the leaflabs maple mini. The steps are the same. To avoid the steps or scripting it, etc. what I ended up doing was writing a few lines of bootloader that said if ram+0 = 0x12345678, and ram+4 = 0x87654321 then branch to ram+8 else infinite loop. then it was trivial to use the jtag to load a program into ram with the two words and an entry point at 0x08 bytes into ram, press reset and run the program. On a cold power up it just hits the infinite loop. I spend my day on a bigger arm based system loading everything into ram using jtag so it made it quite comfortable. You could just script it in openocd and simply type the openocd command have the flash load happen.

Update for people stopping by...

You do not have to use mww, if you're just trying to flash-program (eg. upload your own code) to your microcontroller.

Some time ago, OpenOCD got a ("built-in") convenience-script, that you can use for programming, this "command" is called "program". Here's an example from the documentation on the "program" command:

openocd -f interface/ftdi/jtag-lock-pick_tiny_2.cfg -f board/stm32f3discovery.cfg -c "program filename.elf verify reset"

-Replace "stm32f3discovery" by your board. If you use a different adapter, replace the interface with the appropriate configuration file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top