Skip to content

Commit 0dfc8fd

Browse files
committed
loader: ensure magic string is included in the build
1 parent 57bd3a4 commit 0dfc8fd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎libraries/SFU/extra/loader/ota.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#include <Arduino_DebugUtils.h>
2626
#endif
2727

28+
// Loader is checking this "magic" string is included in the OTA file.
29+
// If not included OTA is aborted.
30+
static const char sfu_version_magic_string[] __attribute__ ((section(".rodata"), used)) = "SFU version";
31+
2832

2933
static const uint32_t crc_table[256] = {
3034
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
@@ -214,7 +218,7 @@ int verify_sketch(FILE* file) {
214218
while (size_read < POST_APPLICATION_ADDR) {
215219
memset(page_buffer, 0, sizeof(char) * page_size);
216220
size_read += fread(page_buffer, 1, page_size, file);
217-
if (memmem((const char*)page_buffer, page_size, "SFU version", 11) != NULL) {
221+
if (memmem((const char*)page_buffer, page_size, sfu_version_magic_string, 11) != NULL) {
218222
#ifdef PORTENTA_C33_SFU_DEBUG_OTA
219223
DEBUG_ERROR("OTA binary signature string found\n");
220224
#endif

0 commit comments

Comments
 (0)