0.30
This article describes flashing of HW 0.30 and later based on the STM32F4 (Cortex-M4) microcontroller.
Flashing on Linux
Flashing using DFU (USB)
DFU (Device Firmware Upgrade) is a standardized and official USB device class which allows to flash devices over USB. The STM32F4 has a built-in USB boot loader which allows to use the DFU protocol to write to the internal flash.
To enter the USB DFU firmware update mode, press the “FC-boot” button first and then “reset”. There should be no LED’s blinking at this time, but when connected using USB a new device should appear:
$ lsusb
...
Bus 002 Device 105: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
...To use the DFU protocol the utility dfu-utils (typically part of the dfu-utils package) can be used. By using the -l command, the attached device can be listed:
$ dfu-util -d 0x0483:0xdf11 -l
dfu-util 0.8
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Found DFU: [0483:df11] ver=2200, devnum=106, cfg=1, intf=0, alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="346C366B3332"
Found DFU: [0483:df11] ver=2200, devnum=106, cfg=1, intf=0, alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="346C366B3332"
Found DFU: [0483:df11] ver=2200, devnum=106, cfg=1, intf=0, alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="346C366B3332"
Found DFU: [0483:df11] ver=2200, devnum=106, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="346C366B3332"To flash a new version of NGOS, download command (-D) can be used:
$ dfu-util -d 0x0483:0xdf11 -c 1 -i 0 -a0 -s 0x08000000 -D ngos.bin
...
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08000000, size = 1048576
Download [=========================] 100% 1048576 bytes
Download done.
File downloaded successfullyNote: Sometimes NGOS does not boot anymore because the saved settings causes trouble for the new version. A wipe of the whole device is needed in that case. Unfortunately there is no command provided by dfu-utils to wipe the whole flash. However, by using dd one can create a firmware which is appended by zeros to completely consume the whole flash and hence clear the unused space too:
$ dd if=/dev/zero bs=1 count=$((8*128*1024-$(wc -c <"ngos.bin"))) > pad.bin
$ cat ngos.bin pad.bin > ngos-padded.bin