Page 1 of 1

Firmware flashing methods?

Posted: Fri Mar 06, 2015 10:55 am
by Tetraeder
Hello everyone,

With which utilities can i flash the firmware to the pyboard?
For the firmware.dfu there is DFU-UTIL but how it works with .hex or .elf? :?

Re: Firmware flashing methods?

Posted: Fri Mar 06, 2015 5:24 pm
by dhylands
dfu-util requires a .dfu file.

To convert an .elf to .dfu we run:

Code: Select all

arm-none-eabi-objcopy -O binary -j .isr_vector build-PYBV10/firmware.elf build-PYBV10/firmware0.bin
arm-none-eabi-objcopy -O binary -j .text -j .data build-PYBV10/firmware.elf build-PYBV10/firmware1.bin
which extracts 2 binary blobs from the .elf file, and then run

Code: Select all

python ../tools/ -b 0x08000000:build-PYBV10/firmware0.bin -b 0x08020000:build-PYBV10/firmware1.bin build-PYBV10/firmware.dfu
to create the .dfu file.

The .elf and .hex may be useful with a debugger, but I'm not sure as I've never used the debugger with MicroPython.

To flash viia DFU you have to use the .dfu file.

You can also flash via the UART, but that requires a raw .bin file, as I described here: ... m32f4.html

Re: Firmware flashing methods?

Posted: Mon Mar 09, 2015 12:04 pm
by Tetraeder
Thanks, that works fine.

Re: Firmware flashing methods?

Posted: Mon Mar 09, 2015 2:15 pm
by Tetraeder
Hello again,

i have seen your commands are like the in the /stmhal/makefile.
Now i tried with the minimal/makefile but there occurs an error " unable to recognise the format of the input file `build-PYBV10/.firmware.elf " :?

Why it does not work with the minimal/makefile?

Re: Firmware flashing methods?

Posted: Tue Mar 10, 2015 1:00 pm
by blmorris
Just a guess here, as I haven't taken the time to play with the 'minimal' port yet, but my understanding is that it is intended to be the 'minimal' code to create a functional MicroPython build on an unspecified ARM target. This means that all of the vendor-specific peripheral support has been stripped out. The DFU format for the firmware is ST specific, as I understand it; since the minimal port isn't built for any specific processor, the build process doesn't produce a *.dfu firmware file.
Basically, if you aren't trying to port MicroPython to a new processor, then you don't need the minimal port; everything that you need for the pyboard is in micropython/stmhal.


Re: Firmware flashing methods?

Posted: Tue Mar 10, 2015 3:29 pm
by Tetraeder
Thanks Bryan,

After I now again a little deeper into MicroPython, I can confirm the acceptance.
Now I try to rebuild step by step MicroPython for the pyBoard with the minimal-directory.
I guess that's the best way to get an idea how MicroPython works for a later porting to another MCU.

Or have anybody a better idea?

Re: Firmware flashing methods?

Posted: Wed Mar 11, 2015 11:52 pm
by Damien
Bryan is correct: the minimal port doesn't build for a specific MCU (in particular it doesn't have UART for any MCU).

To compile minimal for an ARM CPU run: make -B CROSS=1

Getting the minimal port to run on the pyboard would not be too difficult. Basically you just need to add UART support and you'll get a prompt. That would be an excellent way of learning how to port uPy to other targets.

Re: Firmware flashing methods?

Posted: Tue Mar 17, 2015 8:20 am
by Tetraeder
Okay thanks I try it.

Back to my thread headline "Firmware flashing methods". I try to explain it.....

Firmware.dfu (Device Firmware Upgrade) -> is converted from the Firmware.elf and can be flashed to pyboard over DFU-UTIL (some posts above explained).

Firmware.elf (Executable and Linkable Format -> its a format for describing object code. Elf files are always platform independent. It offers the opportunity to identify the object files to parse and simultaneously interpret/execute.
As an example, ELF files can be loaded directly on the TI ez430. Thus a Programmer is required to flash a target.

Firmware.hex (Intel HEX) -> describes raw binary data to transmission and storage. These files are used by flash-programmers.

For any targets: source code -> .elf --[link]--> .hex --[flash programmer]--> target board
For pyboard: Source code -> .elf --[link]--> .dfu --[DFU-UTIL]--> pyboard

I hope that all is correct?

Re: Firmware flashing methods?

Posted: Fri Aug 26, 2016 1:34 pm
by kamikaze
Hi there. I'm using latest Gentoo Linux ~amd64 with 4.7.2 kernel. dfu-util -l -- lists nothing. What should I enable in kernel config or do something else to actually see my pyboard?

Re: Firmware flashing methods?

Posted: Fri Aug 26, 2016 6:31 pm
by dhylands
First thing to check is whether the pyboard is actually in DFU mode or not. When the pyboard is in DFU mode, then 3 of the LEDs (blue, yellow and red) will be very dimly lit.

lsusb will show a device with VID:PID of 0483:df11

Code: Select all

Bus 005 Device 003: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
As long as USB is supported by your kernel, I'm not aware of anything else needing to be installed to get the device to show up using lsusb.

If you see a device with a VID:PID of f055:9800:

Code: Select all

Bus 005 Device 004: ID f055:9800
then that means the pyboard is NOT in DFU mode.