Skip to content

Commit a2c53f8

Browse files
bdracokuba2k2
andauthored
[realtek-ambz2] Fix OTA build failures (include order + public key escaping) (#345)
* Fix include order in lt_ota.c for compilation * Write public key to header file instead of command line * simplify to just use braces and replace inline * Separate include groups --------- Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
1 parent 46240c0 commit a2c53f8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

builder/family/realtek-ambz2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ def get_public_key(private: bytes) -> bytes:
2525
return key.public_key()
2626

2727

28-
def encode_for_define(data: bytes) -> str:
29-
# use C array initializer syntax to avoid shell escaping issues on Windows
30-
return "{" + ",".join(f"0x{byte:02x}" for byte in data) + "}"
28+
def encode_public_key(data: bytes) -> str:
29+
# Output without braces - the C code wraps it in braces
30+
# This avoids shell escaping issues with {} on different platforms
31+
return ",".join(f"0x{byte:02x}" for byte in data)
3132

3233

3334
public_key_bytes = get_public_key(ImageConfig(**board.get("image")).keys.decryption)
@@ -56,7 +57,7 @@ def encode_for_define(data: bytes) -> str:
5657
("__ARM_ARCH_8M_MAIN__", "1"),
5758
("CONFIG_BUILD_RAM", "1"),
5859
"V8M_STKOVF",
59-
("IMAGE_PUBLIC_KEY", encode_for_define(public_key_bytes)),
60+
("IMAGE_PUBLIC_KEY", encode_public_key(public_key_bytes)),
6061
],
6162
CPPPATH=[
6263
# allow including <ctype.h> from GCC instead of RTL SDK

cores/realtek-ambz2/base/api/lt_ota.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
/* Copyright (c) Martin Prokopič 2024-12-03. */
22

3-
#include <device_lock.h>
43
#include <libretiny.h>
5-
#include <osdep_service.h>
64
#include <sdk_private.h>
75

6+
#include <device_lock.h>
7+
#include <osdep_service.h>
8+
89
// from SDK
910
extern uint32_t sys_update_ota_get_curr_fw_idx(void);
1011

1112
#define FLASH_SECTOR_SIZE 0x1000
12-
// IMAGE_PUBLIC_KEY is defined by the build script as an array initializer
1313
#define IMAGE_PUBLIC_KEY_OFFSET 32
1414
#define IMAGE_PUBLIC_KEY_LENGTH 32
1515

16-
static const uint8_t lt_image_public_key[] = IMAGE_PUBLIC_KEY;
16+
// IMAGE_PUBLIC_KEY is defined by build script without braces to avoid shell escaping issues
17+
static const uint8_t lt_image_public_key[] = {IMAGE_PUBLIC_KEY};
1718

1819
typedef enum {
1920
INVALID = 0,

0 commit comments

Comments
 (0)