Page 1 of 1

devs: boot loader for RAM download and application selection

Posted: Mon Aug 06, 2012 5:23 am
by tormod
Except for the excellent BenF firmware, there is not much development activity on the Nano as far as I can tell. I believe one reason is that it is awkward to reflash the Nano when changing between the Benf application for real work, and your own application for tinkering and development. Another reason might be reluctance to reflash the device for testing out smaller things and between every development advancement - some might fear the ~10000 flash cycle limit coming closer for each little typo that has to be fixed :)

To help overcome this, and to simplify my own (wishfully planned) development on the Nano, I have written a small bootloader extension to the original USB DFU bootloader. The code is at

It currently adds these features:
  • 1. Let any application decide which application should start after reset (think boot selection applets here).
  • 2. Allow DFU downloading to RAM. This also uses (1) so that an application can be downloaded and run from RAM.
I have posted an example of dual-booting between two applications here: ... 618#p13618 but that is kind of an added hack and does not demonstrate 1 or 2 above. The corresponding code is in the "dualboot" branch of the git repo.

Later I will provide a "hello world" example for running from RAM.

More info in the README file at ... oot/README

If several applications become available on the Nano, it might call for some agreement between developers in order to simply multi-boot. I would suggest the following:
  • 1. We will avoid having to reprogram the original bootloader, since that can be a support burden. This leads to 2:
  • 2. No application should install in the first page at 0x08004000. This location is called from the original bootloader so the (link to a) new bootloader or application selector must be installed here. Otherwise the application in question must provide the multiboot selection facility.
  • 3. To allow space for more applications in flash, try to pack code segments together, because holes are difficult to use.
  • 4. Some convention for a identification tag or title that can be scanned for and displayed in a boot selection applet.
Take the example of the BenF firmware. Regarding (3) there is a unused gap between LIB and APP of 18KB. In the dualboot example I managed to fit a stripped down version of the DSO-FFT lib in there, but this is not a real solution. Since LIB and APP are shipped together anyway, this gap can be minimized without problems. The alignment of vector tables is the only practical issue.

Also, the calibration data resides 4 KB below the upper flash memory limit. Maybe it can be shifted up as high as possible so that other applications have more contiguous space? If it needs space for future growth, it can grow downwards.

Regarding (2) the LIB can simply be shifted one page up. The application provider can ship a separate 1-page image file to install in case there is no boot selection facility installed on the device. The 1-page image just needs to contain a copy of the 8 first bytes of the LIB image.

Looking forward to your comments, ideas, and... new applications :)

Re: devs: boot loader for RAM download and application selec

Posted: Tue Aug 07, 2012 1:39 am
by tormod
I made a little "hello world" applet that can be downloaded to RAM and run from there. The source code has been added to a "example-ram" folder of the above mentioned bootl git repo.

After downloading the applet to the Nano, the device must be reset for the applet to start. I believe the ST DfuSE demo application can do this, and dfu-util can do it from version 0.7 on.

After building the application with "make" it can be downloaded and run as follows:
dfu-util -d 0483: -a 1 -s 0x20001000:leave -D hello.bin

Note that this applet (like the bootl bootloader) calls functions in the original bootloader. A proper application would probably be better off providing its own functions, or use another library, to be independent on the bootloader and avoid issues related to calling convention mismatch.

EDITED: dfu-util 0.7 is needed.

Re: devs: boot loader for RAM download and application selection

Posted: Sat Jan 19, 2019 11:10 am
by thomasmappbe
The fastest way is to download RAM - Free Download more RAM - RAM upgrade! Everything is simple when you use ram from