Page 1 of 1

[SOLVED] Flashing a Node via SWD port

Posted: Mon Sep 14, 2020 10:19 am
by shuraux
Hello everyone,

Following this topic : https://forum.bitcraze.io/viewtopic.php?f=16&t=4263, we made a first custom version of a sniffing Node, simplified to have minimum amount of component on it (no LEDs, no DC regulator...). We flash it via USB (dfu mode) and get sniffing data over UART 1 (called "FTDI" UART on the schematic).

The fact is, for this first version of custom Node, we need to have it powered by the RPI in order to be able to flash and configure it via USB (because USB gives 5V, and we don't have a 3.3DC regulator in the board).

So, we are planning to do a 2nd version of the Tag, keeping the UART for data output, but using the SWD port to flash the STM, since it will allow us to flash the tag without having the need for it to be powered by an RPI.

For now, I am trying to flash an "Official" Node using a ST-LINK V2.1 based on a NUCLEO-64 STM32F072 board. I am working on Debian, and, while in lps-node-firmware repository, flashing with

Code: Select all

make dfu
command works well. Also, the ST-LINK is correctly detected by the computer when I plug it.

To connect the ST-LINK to the Node, I use the Cortex SWV adapter that Bitcraze designed. And I have plugged off the two jumper on the NUCLEO ST-LINK in order to use it to flash an external MCU and not the one on the NUCLEO Board.

The problem is, when I try to flash with

Code: Select all

make flash
the Node or even the NUCLEO STM directly, I got the following message :

Code: Select all

openocd -d2 -f interface/stlink-v2.cfg -f target/stm32f0x.cfg -c init -c targets -c "reset halt" \
           -c "flash write_image erase bin/lps-node-firmware.elf" -c "verify_image bin/lps-node-firmware.elf" -c "reset run" -c shutdown
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Error: open failed
in procedure 'init' 
in procedure 'ocd_bouncer'

make: *** [Makefile:91: flash] Error 1
I am new to this, I know I was able to use the Nucleo board on Debian with the STM32CUBEIDE, but I am a bit lost on how to use the ST-LINK via command line.

I hope this is as clear as possible for you.

Thanks in advance,

Sylvain

Re: Flashing a Node via SWD port

Posted: Tue Sep 15, 2020 1:54 pm
by tobias
I'm guessing a bit now but "open failed" might be that it can not find the file "bin/lps-node-firmware.elf" ?

Re: Flashing a Node via SWD port

Posted: Tue Sep 15, 2020 3:14 pm
by shuraux
"bin/lps-node-firmware.elf" is here though, so I don't think it is here. I have just tried with absolute path, and it does the same output. Also, I got no error when I do a make clean, so the elf can be found.

Re: Flashing a Node via SWD port

Posted: Wed Sep 16, 2020 6:53 am
by tobias
Could it be access rights problem to the st-link? Have you managed to flash the NUCLEO with the st-link?

Re: Flashing a Node via SWD port

Posted: Wed Sep 16, 2020 11:16 am
by shuraux
Update : I made it worked. Actually my mistake was quite obvious. I didn't change the OPENOCD_INTERFACE to interface/stlink-v2-1.cfg. It is now working correctly.

The only issue I have left is that this ST-LINK doesn't power on the Node. I may find the info on how to do this on the Nucleo documentation though.

Anyway, thanks for your quick answers,

Sylvain

EDIT : In fact, the VDD_TARGET pin of the SWD port is note here to give power to the external MCU. But the ST-LINK of the Nucleo has a 3.3V output pin available, so I can use this one instead in order to directly power the Node via the ST-Link. Problem solved.

Re: Flashing a Node via SWD port

Posted: Wed Sep 16, 2020 12:47 pm
by shuraux
One last question though : Do you have a part reference for the SWD connector used on the Node (P1 on the schematic : https://wiki.bitcraze.io/_media/project ... e_reve.pdf) ?

I can't find anything on the Internet about what these kind of connectors are called.

EDIT : Found it on DIgikey : https://www.digikey.com/products/en?key ... -1806-1-ND

Re: Flashing a Node via SWD port

Posted: Thu Sep 17, 2020 7:46 am
by tobias
Great that you got it solved!