SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
#199214
Hi all,

I am extremely new to OpenOCD so please be patient with me.

I have set up a OpenOCD Raspberry Pi in bit-banged SWD mode. I am flashing EFM32 chip. I am able to flash the chip using this command:
Code: Select all

[code]sudo openocd -f interface/raspberrypi2-native.cfg -c "transport select swd; bcm2835gpio_swd_nums 25 24; bcm2835gpio_srst_num 18; set CHIPNAME efm32; source [find target/efm32.cfg]; adapter_nsrst_assert_width 100; adapter_nsrst_delay 100; reset_config srst_nogate;" -c "init; reset halt; sleep 100; flash write_image erase fw.hex; sleep 100; reset run; shutdown"
Now I want to move further and integrate OpenOCD into the programming rig - add a button and some indication leds. Basically all I want is to know if OpenOCD was successfull in flashing the chip. To do all of this I want to integrate OpenOCD into some kind of scripting environment. I was thinking of starting OpenOCD as a server and then communicating with it via TCL from a Python script, however, I am not sure how to implement it properly.

Here is what I did:

I am starting OpenOCD with this config file:
Code: Select all
proc flashme {} {
   reset init
   reset halt
   wait_halt
   flash write_image erase fw.hex
   reset run
}

source [find interface/raspberrypi2-native.cfg]
transport select swd

bcm2835gpio_swd_nums 25 24
bcm2835gpio_srst_num 18
adapter_khz 1

set CHIPNAME efm32
source [find target/efm32.cfg]

adapter_nsrst_assert_width 100
adapter_nsrst_delay 100
reset_config srst_nogate

init
Then I try telnetting to it and issuing a 'flashme' command. The problem is - If I am connected to the target during the OpenOCD startup, I can issue the flashme command from telnet and everything works fine:
Code: Select all
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> flashme
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0fe10000 msp: 0x20000400
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0fe10000 msp: 0x20000400
auto erase enabled
detected part: EFR32MG1B Blue Gecko, rev 152
flash size = 256kbytes
flash page size = 2048bytes
wrote 262144 bytes from file fw.hex in 8.524932s (30.030 KiB/s)
but If I connect the target after OpenOCD startup, I get these errors:
Code: Select all
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> flashme
SWD DPIDR 0x2ba01477
Could not find MEM-AP to control the core
Target not examined, reset NOT asserted!
in procedure 'flashme' 
in procedure 'reset' called at file "openocd.cfg", line 2
in procedure 'ocd_bouncer'


> flashme
efm32.cpu: hardware has 6 breakpoints, 4 watchpoints
openocd.cfg:5: Error: invalid subcommand "write_image erase fw.hex"
in procedure 'flashme' 
in procedure 'flash' called at file "openocd.cfg", line 5
> 
What am I doing wrong? Can someone provide me some guidance on how can I achieve what I want - get feedback from OpenOCD if the flashing was successful?
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]