Node firmware update using DFU by software

All discussions related to the Loco Positioning system
rdagher
Beginner
Posts: 9
Joined: Tue Jul 04, 2017 12:27 pm

Node firmware update using DFU by software

Post by rdagher »

Hi,

I recently update the LPS node firmwareusing DFU over usb according to the documentation.
To enter the BSL, one has to reset while pushing the DFU button. I am interested in another way of entering the BSL by software. Once a character received on the serial (say 'b'), the code jumps to the bootloader located in system memory. This is can be done using the sequence of operations as described in AN2606 page 21.

An example of such sequence can be found inside the micropython project function machine_bootloader as explained by one of the authors in this thread.

I am not very familiar with FreeRTOS, and I want to know how such bootloader function can be safely implemented.

Thanks for your help,
Roudy
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Node firmware update using DFU by software

Post by arnaud »

Hi,

If should be possible safely, though because of all the things that needs to be disabled before calling the bootloader one way to do it would be to reset the MCU and make it jump to the address at startup, I have seen this described in a stackoverflow: https://stackoverflow.com/questions/282 ... stm32-f072

If reseting the MCU, then FreeRTOS will not be in the way and should not be a problem.

If you manage to implement it please consider sending a pull request, this is an interesting functionality.

Ps. As a side note the 'b' key is now taken by the binary sniffer.
rdagher
Beginner
Posts: 9
Joined: Tue Jul 04, 2017 12:27 pm

Re: Node firmware update using DFU by software

Post by rdagher »

Ok great, I will give it a try and let you know.
BTW, I noticed that flashing using dfu-util with the option -R does not reset the device after programming, and had to use the -s :leave option instead...
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Node firmware update using DFU by software

Post by arnaud »

Great that you managed to find a way to reset the anchor via DFU, thanks for the tip! This will make it much easier to work with the anchors.

I am currently working on the anchor so I can push a fix to the Makefile.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Node firmware update using DFU by software

Post by arnaud »

I created an issue for both reset to and from bootloader and pushed the change to reset from bootloader: https://github.com/bitcraze/lps-node-firmware/issues/18
rdagher
Beginner
Posts: 9
Joined: Tue Jul 04, 2017 12:27 pm

Re: Node firmware update using DFU by software

Post by rdagher »

Well, I have something that works. New command 'u' lets the code enter in DFU mode. Give it a try from this fork and let me know.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Node firmware update using DFU by software

Post by arnaud »

Hi, I finally got the time to test and I merged you pull request, thanks a lot!
I added a small python script to reset to DFU and added a make target so you can now "make reset_and_dfu" and it will reset to dfu, flash and then reset to firmware. We can now just have USB cable hanging from the anchors :-).
rdagher
Beginner
Posts: 9
Joined: Tue Jul 04, 2017 12:27 pm

Re: Node firmware update using DFU by software

Post by rdagher »

Great news !
This exactly why I looked into it, having an autonomous testbed so I can test it within Inria's IoT-Lab testbed.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Node firmware update using DFU by software

Post by arnaud »

Cool, are you going to attach raspberry-pi or something like that to the nodes to makes them autonomous?

We have wanted to implement a radio bootloader for the node, but there has been no time for it yet ....
rdagher
Beginner
Posts: 9
Joined: Tue Jul 04, 2017 12:27 pm

Re: Node firmware update using DFU by software

Post by rdagher »

There is a gateway (A8, Linux) that allows integration of custom open nodes using usb connector. I will be testing it on private testbed in dev.

For over the air upgrade, that would be nice. But this requires that the bootloader that is able to upgrade from external memory where the new firmware is previously downloaded by the app... and indeed that's a different story :)
Another option might be to write down a custom bootloader that downloads dfu file on radio from a (discovered) firmware provider node...
Post Reply