Browse Source

AP_Bootloader: allow external flash load in middle

gps-1.3.1
Andy Piper 3 years ago committed by Peter Hall
parent
commit
10d99a52eb
  1. 2
      Tools/AP_Bootloader/AP_Bootloader.cpp
  2. 11
      Tools/AP_Bootloader/bl_protocol.cpp

2
Tools/AP_Bootloader/AP_Bootloader.cpp

@ -44,7 +44,7 @@ struct boardinfo board_info = {
.board_type = APJ_BOARD_ID, .board_type = APJ_BOARD_ID,
.board_rev = 0, .board_rev = 0,
.fw_size = (BOARD_FLASH_SIZE - (FLASH_BOOTLOADER_LOAD_KB + FLASH_RESERVE_END_KB + APP_START_OFFSET_KB))*1024, .fw_size = (BOARD_FLASH_SIZE - (FLASH_BOOTLOADER_LOAD_KB + FLASH_RESERVE_END_KB + APP_START_OFFSET_KB))*1024,
.extf_size = (EXT_FLASH_SIZE_MB * 1024 * 1024) .extf_size = (EXT_FLASH_SIZE_MB * 1024 * 1024) - (EXT_FLASH_RESERVE_START_KB + EXT_FLASH_RESERVE_END_KB) * 1024
}; };
#ifndef HAL_BOOTLOADER_TIMEOUT #ifndef HAL_BOOTLOADER_TIMEOUT

11
Tools/AP_Bootloader/bl_protocol.cpp

@ -643,7 +643,7 @@ bootloader(unsigned timeout)
goto cmd_bad; goto cmd_bad;
} }
uint32_t erased_bytes = 0; uint32_t erased_bytes = 0;
uint32_t sector_number = 0; uint32_t sector_number = EXT_FLASH_RESERVE_START_KB * 1024 / ext_flash.get_sector_size();
uint8_t pct_done = 0; uint8_t pct_done = 0;
if (cmd_erase_bytes > (ext_flash.get_sector_size() * ext_flash.get_sector_count())) { if (cmd_erase_bytes > (ext_flash.get_sector_size() * ext_flash.get_sector_count())) {
uprintf("Requested to erase more than we can\n"); uprintf("Requested to erase more than we can\n");
@ -752,7 +752,8 @@ bootloader(unsigned timeout)
extf_address += arg; extf_address += arg;
break; break;
} }
if (!ext_flash.start_program_offset(extf_address+offset, &flash_buffer.c[offset], size, programming, delay_us, timeout_us)) { if (!ext_flash.start_program_offset(extf_address+offset+EXT_FLASH_RESERVE_START_KB*1024,
&flash_buffer.c[offset], size, programming, delay_us, timeout_us)) {
// uprintf("ext flash write command failed\n"); // uprintf("ext flash write command failed\n");
goto cmd_fail; goto cmd_fail;
} }
@ -906,13 +907,13 @@ bootloader(unsigned timeout)
} else } else
#endif #endif
{ {
ext_flash.read(p, (uint8_t *)&bytes, sizeof(bytes)); ext_flash.read(p+EXT_FLASH_RESERVE_START_KB*1024, (uint8_t *)&bytes, sizeof(bytes));
} }
sum = crc32_small(sum, (uint8_t *)&bytes, sizeof(bytes)); sum = crc32_small(sum, (uint8_t *)&bytes, sizeof(bytes));
} }
if (rembytes) { if (rembytes) {
uint8_t bytes[3]; uint8_t bytes[3];
ext_flash.read(cmd_verify_bytes-rembytes, bytes, rembytes); ext_flash.read(EXT_FLASH_RESERVE_START_KB*1024+cmd_verify_bytes-rembytes, bytes, rembytes);
sum = crc32_small(sum, bytes, rembytes); sum = crc32_small(sum, bytes, rembytes);
} }
cout_word(sum); cout_word(sum);
@ -1091,7 +1092,7 @@ bootloader(unsigned timeout)
uint32_t programming; uint32_t programming;
uint32_t delay_us; uint32_t delay_us;
uint32_t timeout_us; uint32_t timeout_us;
if (!ext_flash.start_program_offset(0, (const uint8_t*)first_words, sizeof(first_words), programming, delay_us, timeout_us)) { if (!ext_flash.start_program_offset(EXT_FLASH_RESERVE_START_KB*1024, (const uint8_t*)first_words, sizeof(first_words), programming, delay_us, timeout_us)) {
// uprintf("ext flash write command failed\n"); // uprintf("ext flash write command failed\n");
goto cmd_fail; goto cmd_fail;
} }

Loading…
Cancel
Save