Use the serial port to update the firmware

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
User avatar
Meekdai
Posts: 45
Joined: Mon Jan 29, 2018 12:45 pm

Use the serial port to update the firmware

Post by Meekdai » Mon May 21, 2018 3:45 am

Hello everyone,
As far as I know, only use DFU to update the firmware.
Is there a way to update the firmware on Pyboard through the serial port?

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

Re: Use the serial port to update the firmware

Post by dhylands » Mon May 21, 2018 5:49 pm

Yes. I wrote a blog post about it over here:
http://blog.davehylands.com/2014/02/ser ... m32f4.html
That blog post is 4 years old, so its possible it might not work. I'd be interested to hear if it works for you.

User avatar
Meekdai
Posts: 45
Joined: Mon Jan 29, 2018 12:45 pm

Re: Use the serial port to update the firmware

Post by Meekdai » Tue May 22, 2018 5:35 am

dhylands wrote:
Mon May 21, 2018 5:49 pm
To initiate the bootloader on the UART you need to make BOOT0 high, and then press and release RESET (keep BOOT0 high while releasing RESET).
As you said, it goes into bootloader mode by make BOOT0 high.
I found another way initiate the bootloader over here:
http://docs.micropython.org/en/latest/p ... bootloader

Here is the source code in micropython:
https://github.com/micropython/micropyt ... #L197-L223

I found that this assembly code is entering the DFU mode, can be modified to enter the USART mode?
I know nothing about Assembly Language.

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

Re: Use the serial port to update the firmware

Post by dhylands » Tue May 22, 2018 7:43 pm

That code is actually doing a RESET from the code. So it should launch the bootloader. The bootloader will then select which mode to use by following the flow chart shown on page 97 of the AN2606 document:
http://www.st.com/resource/en/applicati ... 167594.pdf

User avatar
Meekdai
Posts: 45
Joined: Mon Jan 29, 2018 12:45 pm

Re: Use the serial port to update the firmware

Post by Meekdai » Wed May 23, 2018 2:05 am

1. I use pyb.bootloader() to initiate the bootloader, and send 0x7f in USART1, device reply 0x0 0x0 0x0.
2. I use pyb.bootloader() to initiate the bootloader,and use DfuSeDemo software ,device enter DFU mode.
3. I make BOOT0 high to initiate the bootloader, and send 0x7f in USART1,device reply 0x79.
4. I make BOOT0 high to initiate the bootloader, and use DfuSeDemo software ,device enter DFU mode.

The above 4 steps illustrate that make BOOT0 high and pyb.bootloader() are different in some cases.

Here is USART bootloader code sequence:
http://www.st.com/content/ccc/resource/ ... 264342.pdf

Post Reply