99extern uint32_t sys_update_ota_get_curr_fw_idx (void );
1010
1111#define FLASH_SECTOR_SIZE 0x1000
12- // IMAGE_PUBLIC_KEY is defined by the build script
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 ;
17+
1618typedef enum {
1719 INVALID = 0 ,
1820 DISABLED = 1 ,
@@ -47,11 +49,11 @@ static lt_ota_image_state_t lt_ota_get_image_state(uint8_t index) {
4749 if (num_read != sizeof (public_key ))
4850 return INVALID ;
4951
50- if (memcmp (public_key , IMAGE_PUBLIC_KEY , sizeof (public_key )) == 0 )
52+ if (memcmp (public_key , lt_image_public_key , sizeof (public_key )) == 0 )
5153 return ENABLED ;
5254
5355 public_key [0 ] = ~(public_key [0 ]);
54- if (memcmp (public_key , IMAGE_PUBLIC_KEY , sizeof (public_key )) == 0 )
56+ if (memcmp (public_key , lt_image_public_key , sizeof (public_key )) == 0 )
5557 return DISABLED ;
5658
5759 return INVALID ;
@@ -69,7 +71,7 @@ static bool lt_ota_set_image_enabled(uint8_t index, bool new_enabled) {
6971 device_mutex_lock (RT_DEV_LOCK_FLASH );
7072 flash_stream_read (& lt_flash_obj , offset , FLASH_SECTOR_SIZE , header );
7173
72- bool enabled = header [IMAGE_PUBLIC_KEY_OFFSET ] == IMAGE_PUBLIC_KEY [0 ];
74+ bool enabled = header [IMAGE_PUBLIC_KEY_OFFSET ] == lt_image_public_key [0 ];
7375 if (enabled != new_enabled ) {
7476 // negate first byte of OTA signature
7577 header [0 ] = ~(header [0 ]);
0 commit comments