[SOLVED] Flashing a Node via SWD port

All discussions related to the Loco Positioning system
Post Reply
shuraux
Beginner
Posts: 7
Joined: Tue Apr 21, 2020 3:48 pm

[SOLVED] Flashing a Node via SWD port

Post 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
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Flashing a Node via SWD port

Post 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" ?
shuraux
Beginner
Posts: 7
Joined: Tue Apr 21, 2020 3:48 pm

Re: Flashing a Node via SWD port

Post 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.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Flashing a Node via SWD port

Post by tobias »

Could it be access rights problem to the st-link? Have you managed to flash the NUCLEO with the st-link?
shuraux
Beginner
Posts: 7
Joined: Tue Apr 21, 2020 3:48 pm

Re: Flashing a Node via SWD port

Post 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.
shuraux
Beginner
Posts: 7
Joined: Tue Apr 21, 2020 3:48 pm

Re: Flashing a Node via SWD port

Post 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
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Flashing a Node via SWD port

Post by tobias »

Great that you got it solved!
Post Reply