mpconfigboard.h

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

mpconfigboard.h

Post by pythoncoder » Thu Jan 19, 2017 2:14 pm

I want to be able to update the firmware on a Pyboard V1.1 using UART 2 via an FTDI adaptor. I don't know if this is the correct general approach. I created a directory with the name BAR under stmhal/boards, copied the files from PYBV11 into it, and edited mpconfigboard.h to add the following after UART initialisation:

Code: Select all

#define MICROPY_HW_UART_REPL        PYB_UART_2
#define MICROPY_HW_UART_REPL_BAUD   115200
I built the firmware using the new board type and deployed it (via USB) successfully. But I still can't flash via UART2. I rebooted the board with USB replaced by an FTDI to UART cable on UART2. boot.py uses repl_uart and I put the board into DFU mode by issuing:

Code: Select all

rshell -p /dev/ftdi repl '~ pyb.bootloader()~'
This worked, but then I get:

Code: Select all

[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/micropython/tools
$ ./pydfu.py -l
No DFU capable devices found
I'm evidently missing something in my first attempt at a board config. Any pointers, please?
Peter Hinch
Index to my micropython libraries.

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

Re: mpconfigboard.h

Post by dhylands » Thu Jan 19, 2017 8:41 pm

pydfu and dfu-util can only update over USB (in particular directly connected USB).

You can update the firmware via other means. You don't need to redirect the REPL (except perhaps to help you get into bootloader mode).

I've written up what I've done in the past over here:
http://blog.davehylands.com/2014/02/ser ... m32f4.html

Note that because the micropython image is a split image and has the filesystem in the middle, this will wind up wiping out the contents of the filesystem.

I haven't tried it, but I think you can take the firmware0.bin and firmware1.bin files and flash them seperatley as long as you provide the appropriate address to stm32loader.py. I'm also not sure if you need to get back into DFU mode between the seperate flashing operations.

AN2606 from STM covers the various bootloader modes available.
http://www.st.com/content/ccc/resource/ ... 167594.pdf and in particular, Table 50 shows the various devices that can be used with the ROM based bootloader.

It looks like serial bootloading is only supported via USART1 and USART3.

If you wanted to update via UART2, then you'd need to write your own bootloader.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: mpconfigboard.h

Post by pythoncoder » Fri Jan 20, 2017 6:00 am

Thanks for that, Dave. I imagined a simple fix but the complexity is way beyond what the application merits. I can use USB with some adaptation to the hardware so I'll go that route.
Peter Hinch
Index to my micropython libraries.

Post Reply