Add firmware signing and verification

This commit is contained in:
cpq committed 2026-05-28 10:39:45 +01:00
1 parent 8012a5943a
commit bbcda0c9af
7 files changed
+132 -3

No files matched your search

@@ -622,7 +622,7 @@ a, a:visited, a:link { text-decoration: none; }
<path d="M5 21h14" />
</svg>
Select .bin file
<input type="file" accept=".bin" hidden data-upload="1" />
<input type="file" accept=".bin" hidden data-ota="1" />
</label>
</div>
@@ -12,7 +12,6 @@ SOURCES = main.c hal.c
SOURCES += cmsis_h5/Source/Templates/gcc/startup_stm32h563xx.s
SOURCES += mongoose/mongoose.c
all build example: firmware.bin
mongoose/mongoose.c mongoose/mongoose.h:
@@ -26,6 +25,9 @@ firmware.bin: firmware.elf
@echo
@echo "To flash, run 'make flash', or use STM32CubeProgrammer"
sign firmware.signed.bin: firmware.bin
node ../../../../resources/sign.js sign firmware.bin private.pem
flash: firmware.bin
STM32_Programmer_CLI -c port=swd mode=UR -w firmware.elf -hardRst
@@ -37,7 +39,6 @@ CUBEPROG_DIR ?= $(dir $(shell which STM32_Programmer_CLI))
gdb_server:
ST-LINK_gdbserver --port-number 61234 --log-level 1 --swd --verify --stm32cubeprogrammer-path $(CUBEPROG_DIR) --apid 1 --initialize-reset
cmsis_core:
git clone -q -c advice.detachedHead=false --depth 1 -b 5.9.0 https://github.com/ARM-software/CMSIS_5 $@
@@ -12,6 +12,17 @@
#define MG_ENABLE_PACKED_FS 1
#define MG_ENABLE_DRIVER_STM32H 1
#define MG_OTA_PUBLIC_KEY { \
0x19, 0x7f, 0xed, 0x81, 0x8b, 0xb7, 0xb2, 0xa5, \
0xde, 0xe0, 0xde, 0x04, 0x83, 0x60, 0xc8, 0x69, \
0x61, 0x39, 0x30, 0x1f, 0xc1, 0x52, 0x11, 0x4b, \
0xb7, 0xa4, 0xd7, 0x52, 0x03, 0x36, 0xc6, 0xc1, \
0xbf, 0x22, 0x75, 0x04, 0x49, 0xf8, 0x46, 0x47, \
0xec, 0x20, 0xd6, 0x8d, 0x48, 0x29, 0x7d, 0x63, \
0xb3, 0xf7, 0x1f, 0x58, 0x44, 0x82, 0xcc, 0x7a, \
0x4b, 0x5e, 0x68, 0x98, 0x24, 0x1f, 0x86, 0xf4, \
}
// #define MG_DRIVER_MDC_CR 4 // RMII MDC clock divider, from 0 to 4
// #define MG_TCPIP_PHY_ADDR 0 // PHY address
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgto6awcVrVzHfgSaD
WFiy6JrXahab3F5lfGvb7A1XzjShRANCAAQZf+2Bi7eypd7g3gSDYMhpYTkwH8FS
EUu3pNdSAzbGwb8idQRJ+EZH7CDWjUgpfWOz9x9YRILMekteaJgkH4b0
-----END PRIVATE KEY-----