Page 1 of 1

No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Fri Mar 08, 2019 6:34 pm
by wghe
Hi!

I am trying to make mboot for default PYBV10 board.

I added MBOOT_BOOTPIN_PIN related defines in /PYBV10/mpconfigboard.h:
#define MBOOT_BOOTPIN_PIN (pin_A0)
#define MBOOT_BOOTPIN_PULL (MP_HAL_PIN_PULL_UP)
#define MBOOT_BOOTPIN_ACTIVE (0)

After $ make V=1 USE_MBOOT=1, mboot got following error:
In file included from ../../../py/mphal.h:34:0,
from fsload.c:29:
./mphalport.h:29:10: fatal error: genhdr/pins.h: No such file or directory
#include "genhdr/pins.h"
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [build-PYBV10/fsload.o] Error 1
make: *** Waiting for unfinished jobs....

I am looking into /stm32/Makefile to understand how to fix this, any help? Thanks in advance!

Regards,
WG

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Fri Mar 08, 2019 7:27 pm
by dhylands
I'd try doing a clean and starting again.

I did:

Code: Select all

make BOARD=PYBV10 clean
make BOARD=PYBV10 USE_MBOOT=1
and everything seemed to build fine for me. I always specify BOARD= because I often use a GNUmakefile which changes the default. I wouldn't expect it to make any difference for you.

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Fri Mar 08, 2019 9:11 pm
by wghe
Hi Dave

Thanks! You are correct, 'make' process works with your suggest.

Regards,
WG

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Fri Mar 08, 2019 10:23 pm
by dhylands
After modifying my mpconfigboard.h as you did, I was able to do the following:

Code: Select all

cd ports/stm32/mboot
make
...put board in DFU mode...
make deploy
After this is I connected A0 to ground and pressed reset, then I'd get the read led flashing, indicating that mboot was running. Also dfu-util -l reported:

Code: Select all

Found DFU: [0483:df11] ver=2200, devnum=13, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3650326B3432"
i.e. just one line, where dfu-util -l reports 4 lines when the builtin DFU bootloader is running.

I then tried to build micropython and flash it:

Code: Select all

cd ports/stm32
make USE_MBOOT=1
make deploy
and it seemed to flash, but I got the LEDs lit up like in DFU mode and no USB serial port, so it looks like MicroPython didn't actually run.

If I connect A0 (i.e. X1) to ground and press RESET I get back to the blinking red led.

So I need to figure out why the bootloader isn't working.

I downloaded the flash and it seems to match what it's supposed to....

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Fri Mar 08, 2019 10:49 pm
by wghe
Hi Dave,

I tried dfu-util, but it does not work for mboot.
1. dfu-util: dfu-util-0.9-win64
2. command: dfu-util -a 0 -d 0483:df11 -D firmware.dfu
3. error output: Cannot open DFU device 0483:df11
No DFU capable USB device available

So, I changed to use en.stsw-stm32080.zip from ST, it can write firmware.dfu properly.
link: https://www.st.com/en/development-tools ... 32080.html

I also made small change with /mboot/main.c:
//if (reset_mode != 4 && (msp & APP_VALIDITY_BITS) == 0) {
if ((msp & APP_VALIDITY_BITS) == 0) {

Regards,
WG

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Fri Mar 08, 2019 11:24 pm
by dhylands
For me, dfu-util is working fine (I'm running under linux). It flashes the dfu file and I can read it back and compare with the firmware.bin and it matches exactly. I'm actually using pydfu to flash the application code. And it is also working, since I can read it back using dfu-util and it compares with the firmware.bin that was built for micropython.

reset_mode = 4 means to enter the bootloader. So on the pyboard, you can press and hold the USR button while resetting. Then when the blue LED is lit, release the USR button. This sets reset_mode to 4, which causes mboot to not boot the program.

reset_mode 0 thru 3 get passed into the application (micropython).

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Sat Mar 09, 2019 12:41 pm
by wghe
Hi Dave,

Thanks for sharing more details!
I just ported mboot to other stm32 hardware with 1 USR switch and 1 LED, the change to remove reset_mode can jump to application automatically and run mboot if hold the USR switch after reboot.

I am using RaspberryPi 3B+ for cross-compiling MicroPython firmware, that saves a lot time.
[SOLVED] Under my Pi3, dfu-util: Cannot open Dfu device 0483:df11
8-) $ groups $USER & sudo dfu-util -l

Have a nice weekend!
WG

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Mon Mar 11, 2019 7:06 am
by Meekdai
Hi wghe, I am trying to use mboot and I am having the same problem when using dfu-util.

Code: Select all

Cannot open Dfu device 0483:df11
No DFU capable USB device available
I use https://zadig.akeo.ie/ to change the driver, then it works.

Hi Dave, The mboot on my PYBV10 board works fine, but the micropython firmware flash via mboot is not working properly.
Here is the issues https://github.com/micropython/micropython/issues/4586

Re: No genhdr/pins.h to make mboot with MBOOT_BOOTPIN_PIN

Posted: Mon Mar 11, 2019 2:35 pm
by wghe
Hi Meekdai,

Thanks, will try that zadig.

Regards,
WG