← index #16537PR #17364
Off-topic · high · value 0.902
QUERY · ISSUE

mboot fails to build

openby zeroby0opened 2025-01-07updated 2026-03-18
bugport-stm32needs-info

Port, board and/or hardware

ARDUINO_PORTENTA_H7

MicroPython version

git describe --dirty: v1.24.0-181-g495ce91ca; Building for ARDUINO_PORTENTA_H7.

But the board says MicroPython v1.25.0-preview.180.g495ce91ca on 2025-01-07; Arduino Portenta H7 with STM32H747 when I flash mpython (it already has mboot I guess).

I've also tried this for tag v1.24.0 and the same error occurs.

Reproduction

Following build instructions from here: https://github.com/micropython/micropython/tree/master/ports/stm32#build-instructions

git clone https://github.com/micropython/micropython.git
cd micropython/
make -C mpy-cross
cd ports/stm32/
make BOARD=ARDUINO_PORTENTA_H7 submodules
make BOARD=ARDUINO_PORTENTA_H7
make -C mboot BOARD=ARDUINO_PORTENTA_H7

Expected behaviour

mboot builds

Observed behaviour

....
....
CC ../../../lib/uzlib/header.c
CC ../../../lib/uzlib/tinflate.c
CC adc.c
CC main.c
main.c: In function 'build_flash_layout_str':
main.c:449:40: error: 'FLASH_LAYOUT_TEMPLATE' undeclared (first use in this function); did you mean 'FLASH_LAYOUT_STR_ALLOC'?
  449 | #define FLASH_LAYOUT_STR_ALLOC (sizeof(FLASH_LAYOUT_TEMPLATE))
      |                                        ^~~~~~~~~~~~~~~~~~~~~
main.c:453:18: note: in expansion of macro 'FLASH_LAYOUT_STR_ALLOC'
  453 |     size_t len = FLASH_LAYOUT_STR_ALLOC - 1;
      |                  ^~~~~~~~~~~~~~~~~~~~~~
main.c:449:40: note: each undeclared identifier is reported only once for each function it appears in
  449 | #define FLASH_LAYOUT_STR_ALLOC (sizeof(FLASH_LAYOUT_TEMPLATE))
      |                                        ^~~~~~~~~~~~~~~~~~~~~
main.c:453:18: note: in expansion of macro 'FLASH_LAYOUT_STR_ALLOC'
  453 |     size_t len = FLASH_LAYOUT_STR_ALLOC - 1;
      |                  ^~~~~~~~~~~~~~~~~~~~~~
main.c: In function 'pyb_usbdd_StrDescriptor':
main.c:449:40: error: 'FLASH_LAYOUT_TEMPLATE' undeclared (first use in this function); did you mean 'FLASH_LAYOUT_STR_ALLOC'?
  449 | #define FLASH_LAYOUT_STR_ALLOC (sizeof(FLASH_LAYOUT_TEMPLATE))
      |                                        ^~~~~~~~~~~~~~~~~~~~~
main.c:1191:26: note: in expansion of macro 'FLASH_LAYOUT_STR_ALLOC'
 1191 |                 char buf[FLASH_LAYOUT_STR_ALLOC];
      |                          ^~~~~~~~~~~~~~~~~~~~~~
main.c:1191:22: error: unused variable 'buf' [-Werror=unused-variable]
 1191 |                 char buf[FLASH_LAYOUT_STR_ALLOC];
      |                      ^~~
cc1: all warnings being treated as errors
make: *** [Makefile:295: build-ARDUINO_PORTENTA_H7/main.o] Error 1
make: Leaving directory '........./micropython/ports/stm32/mboot'

Additional Information

Link to offending line in main.c for your convenience: https://github.com/micropython/micropython/blob/master/ports/stm32/mboot/main.c#L449

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

lib/libhydrogen: Update to latest release.

mergedby andrewleechopened 2025-05-27updated 2025-06-02
lib

Summary

libhydrogen is used for stm32/mboot encrypted dfu support: MBOOT_ENABLE_PACKING=1

The currently pinned version of this fails to compile with newer gcc versions:

anl@STEP:~/micropython$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

results in

anl@STEP:~/micropython$ make -C ports/stm32/mboot BOARD=NUCLEO_WB55 USE_MBOOT=1 MBOOT_ENABLE_PACKING=1
make: Entering directory '/home/anl/micropython/ports/stm32/mboot'
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
CC ../../../lib/libhydrogen/hydrogen.c
In file included from ../../../lib/libhydrogen/hydrogen.c:14:
../../../lib/libhydrogen/impl/x25519.h: In function 'hydro_x25519_ladder_part1':
../../../lib/libhydrogen/impl/x25519.h:232:5: error: 'hydro_x25519_mul' reading 32 bytes from a region of size 4 [-Werror=stringop-overread]
  232 |     hydro_x25519_mul(z2, x2, hydro_x25519_a24, // z2 = E*a24
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  233 |                      sizeof(hydro_x25519_a24) / sizeof(hydro_x25519_a24[0]));
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../lib/libhydrogen/impl/x25519.h:232:5: note: referencing argument 3 of type 'const hydro_x25519_limb_t[8]' {aka 'const long unsigned int[8]'}
../../../lib/libhydrogen/impl/x25519.h:141:1: note: in a call to function 'hydro_x25519_mul'
  141 | hydro_x25519_mul(hydro_x25519_fe out, const hydro_x25519_fe a, const hydro_x25519_fe b, int nb)

and another ~14 or so similar errors.

Testing

The PR has been tested on a stm32F765 existing application that has been using USE_MBOOT=1 MBOOT_ENABLE_PACKING=1 for many years.

The new mboot and application both work with this change, old mboot successfully flashed new application, new mboot also works to flash application.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied