Skip to content

Commit f48c79f

Browse files
committed
Update boot_info mechanism
Data from boot_info gets changed after reboot when Read protection was enabled for H7, this is a hacky fix until it is clear what is going on.
1 parent cedde21 commit f48c79f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Bootloader/Inc/binary_update.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
typedef struct bootInfo {
4444
uint32_t jump_address; //!< Address for BL to jump
4545
bool skip_bl_loop; //!< Flag to skip BL loop
46-
signatureType_E previus_binary; //!< Previous detected binary
46+
uint8_t end; // FIXME: added here because after restart something is messing up with data in the structure and if there is an extra byte at the end it messes only with it
4747
} bootInfo_S;
4848
#pragma pack(pop)
4949

Bootloader/Inc/signature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef enum signatureType_ENUM {
5454
signatureType_BOOTLOADER_FLASH = 0x02, //!< New bootloader for FLASH
5555
signatureType_BOOTLOADER_RAM = 0x03, //!< Bootloader for RAM
5656
signatureType_UNKNOWN = 0xFF, //!< Not existing or unknown signature
57-
} signatureType_E __attribute__ ((__packed__));
57+
} signatureType_E;
5858

5959
signatureType_E Signature_verification(const signature_S* signature);
6060

Bootloader/Src/binary_update.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
#include "signature.h"
4141

4242
__attribute__ ((section(".restart_info")))
43-
bootInfo_S boot_info; //!< Instruction on where to jump after the restart
43+
volatile bootInfo_S boot_info; //!< Instruction on where to jump after the restart
4444
static uint64_t s_address; //!< Address from where to erase flash and write binary
45-
static signatureType_E s_detected_binary; //!< Detected binary
45+
static signatureType_E s_detected_binary; //!< Detected binary
4646

4747
static bool BinaryUpdate_writeToFlash(uint8_t* write_buffer, const uint32_t data_length);
4848

@@ -93,7 +93,6 @@ BinaryUpdate_handleBootInfo(void) {
9393
default:
9494
boot_info.jump_address = FLASH_FIRMWARE_ADDRESS;
9595
boot_info.skip_bl_loop = false;
96-
boot_info.previus_binary = signatureType_FIRMWARE_FLASH;
9796
break;
9897
}
9998
}
@@ -128,7 +127,7 @@ BinaryUpdate_erase(uint32_t firmware_size) {
128127
success = FlashAdapter_erase(firmware_size, s_address);
129128
break;
130129
case signatureType_BOOTLOADER_FLASH:
131-
if (signatureType_BOOTLOADER_RAM == boot_info.previus_binary) {
130+
if (boot_info.jump_address == RAM_FIRMWARE_ADDRESS) {
132131
//Only allowed to erase if RAM version is running
133132
success = FlashAdapter_erase(firmware_size, s_address);
134133
}
@@ -233,7 +232,8 @@ BinaryUpdate_finish(void) {
233232
break;
234233
}
235234

236-
boot_info.previus_binary = s_detected_binary;
235+
boot_info.end = 0xFF;
236+
237237
return success;
238238
}
239239

0 commit comments

Comments
 (0)