libhydrogen error when trying to build mboot with packing enabled
Port, board and/or hardware
stm32
MicroPython version
MicroPython v1.22-release
Reproduction
make BOARD=PYBV11
Expected behaviour
building mboot with packing enabled i.e. MBOOT_ENABLE_PACKING = 1
Observed behaviour
I get a couple of these lines:
../../../lib/libhydrogen/impl/random/Particle.h:8:1: note: previous definition of 'hydro_random_init' with type 'int(void)'
8 | hydro_random_init(void)
| ^~~~~~~~~~~~~~~~~
and I get a couple of these lines:
../../../lib/libhydrogen/impl/random/Particle.h:8:1: error: 'hydro_random_init' defined but not used [-Werror=unused-function]
8 | hydro_random_init(void)
| ^~~~~~~~~~~~~~~~~
Build outcome:
cc1: all warnings being treated as errors
make: *** [build-PYBV11/lib/libhydrogen/hydrogen.o] Error 1
The pyhy version that is installed is 0.0.9
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
lib/libhydrogen: Update to latest release.
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.