SWD interface disabled once Gnuk programmed?

Gary gary at mups.co.uk
Wed Nov 21 00:56:37 CET 2018


On 20/11/2018 22:16, Patrick van Staveren wrote:
> Hi there,
> 
> I am new to Gnuk so forgive me if this is a newbie mistake...
> 
> I have successfully built and programmed Gnuk onto a ST-Link V2 clone
> (target=ST_DONGLE). I have programmed it with OpenOCD using another ST-Link
> V2 :) it works.
> 
> However it now seems that the SWD interface on the Gnuk target board is
> disabled so I can't connect with OpenOCD to reprogram it. OpenOCD behaves
> as if I'm not plugged into any device.
> 
> Is this by design? I assume it might be, to close this off as a vector of
> attack. Is there a way to open it back up? I don't mind losing the key I've
> generated on it as this is just experimental so far.

Even if the device has been "locked" to prevent any reading back of 
flash via ST-Link, you should be able to wipe and flash new firmware 
(losing any keys on the device in the process).

I'm not sure if that's the issue you're facing when you say "OpenOCD 
behaves as if I'm not plugged into any device" but these are the steps I 
use to upgrade firmware with a locked device and relock it afterwards, 
make sure you double check the ST-Link is correctly connected to the 4 
vias on the GNUK too:-

openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg
telnet localhost 4444
 > reset halt
 > stm32f1x unlock 0
 > reset
 > reset halt
 > flash write_image erase /home/user/gnuk/src/build/gnuk.elf
 > reset
 > exit

Then to relock you can also do:
 > reset halt
 > stm32f1x lock 0
 > reset
 > shutdown

and verify you can no longer read flash back

dump_image mygnuk.img 0 10000

then inspect the img to see if it's blank or valid flash contents for 
example compare it to a read back prior to locking.

If that doesn't work, it may be worth including the output you get from 
ST-Link for the various commands. Someone should be able to help 
pinpoint the problem then.

Regards,

Gary



More information about the Gnuk-users mailing list