Browse Source

Additional simplifications

Maarten van der Schrieck 1 year ago
parent
commit
ce8d3dbd73
1 changed files with 6 additions and 7 deletions
  1. 6
    7
      main.c

+ 6
- 7
main.c View File

88
 #define TCP_PORT 4242
88
 #define TCP_PORT 4242
89
 
89
 
90
 struct image_header app_image_header;
90
 struct image_header app_image_header;
91
-#define IMAGE_HEADER_OFFSET ((uint32_t)&app_image_header - XIP_BASE)
91
+#define IMAGE_HEADER_ADDR   ((uint32_t)&app_image_header)
92
+#define IMAGE_HEADER_OFFSET (IMAGE_HEADER_ADDR - XIP_BASE)
92
 
93
 
93
-#define WRITE_ADDR_MIN (XIP_BASE + IMAGE_HEADER_OFFSET + FLASH_SECTOR_SIZE)
94
-#define ERASE_ADDR_MIN (XIP_BASE + IMAGE_HEADER_OFFSET)
94
+#define WRITE_ADDR_MIN (IMAGE_HEADER_ADDR + FLASH_SECTOR_SIZE)
95
+#define ERASE_ADDR_MIN (IMAGE_HEADER_ADDR)
95
 #define FLASH_ADDR_MAX (XIP_BASE + PICO_FLASH_SIZE_BYTES)
96
 #define FLASH_ADDR_MAX (XIP_BASE + PICO_FLASH_SIZE_BYTES)
96
 
97
 
97
 #define CMD_SYNC          (('S' << 0) | ('Y' << 8) | ('N' << 16) | ('C' << 24))
98
 #define CMD_SYNC          (('S' << 0) | ('Y' << 8) | ('N' << 16) | ('C' << 24))
581
 
582
 
582
 	sleep_ms(10);
583
 	sleep_ms(10);
583
 
584
 
584
-	struct image_header *hdr = (struct image_header *)(XIP_BASE + IMAGE_HEADER_OFFSET);
585
-
586
-	if (!should_stay_in_bootloader() && image_header_ok(hdr)) {
587
-		uint32_t vtor = *((uint32_t *)(XIP_BASE + IMAGE_HEADER_OFFSET));
585
+	if (!should_stay_in_bootloader() && image_header_ok(&app_image_header)) {
586
+		uint32_t vtor = *(uint32_t *)IMAGE_HEADER_ADDR;
588
 		disable_interrupts();
587
 		disable_interrupts();
589
 		reset_peripherals();
588
 		reset_peripherals();
590
 		jump_to_vtor(vtor);
589
 		jump_to_vtor(vtor);

Loading…
Cancel
Save