Firmware flashing methods?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Firmware flashing methods?

Post by Tetraeder » Fri Mar 06, 2015 10:55 am

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? :?

User avatar
dhylands
Posts: 3268
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Firmware flashing methods?

Post by dhylands » Fri Mar 06, 2015 5:24 pm

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/dfu.py -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: http://blog.davehylands.com/2014/02/ser ... m32f4.html

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Firmware flashing methods?

Post by Tetraeder » Mon Mar 09, 2015 12:04 pm

Thanks, that works fine.

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Firmware flashing methods?

Post by Tetraeder » Mon Mar 09, 2015 2:15 pm

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?

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Firmware flashing methods?

Post by blmorris » Tue Mar 10, 2015 1:00 pm

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.

-Bryan

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Firmware flashing methods?

Post by Tetraeder » Tue Mar 10, 2015 3:29 pm

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?

Damien
Site Admin
Posts: 626
Joined: Mon Dec 09, 2013 5:02 pm

Re: Firmware flashing methods?

Post by Damien » Wed Mar 11, 2015 11:52 pm

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.

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Firmware flashing methods?

Post by Tetraeder » Tue Mar 17, 2015 8:20 am

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.

Summary:
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?

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: СССР
Contact:

Re: Firmware flashing methods?

Post by kamikaze » Fri Aug 26, 2016 1:34 pm

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?

User avatar
dhylands
Posts: 3268
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Firmware flashing methods?

Post by dhylands » Fri Aug 26, 2016 6:31 pm

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.

Post Reply