mirror of https://github.com/ARMmbed/mbed-os.git
rtl8195am - move region headers to 0xb000 and 0xc000
The new layout is as follows: 0x000000 - 0x008000 => bootloader 0x008000 - 0x00b000 => system sectors 0x00b000 - 0x00c000 => region1 header 0x00c000 - 0x00d000 => region2 header 0x00d000 - 0x010000 => reserved 0x010000 - 0x040000 => mbed file system 0x040000 - 0x120000 => region1 image 0x120000 - 0x200000 => region2 image This is to ensure when daplink erases sections, both regions' headers are erased properly.pull/5851/head
parent
dc87f0b1e6
commit
a1b4b8f10a
|
@ -23,24 +23,24 @@
|
|||
|
||||
static flash_t flash_obj;
|
||||
|
||||
void OTA_ReadHeader(uint32_t base, imginfo_t *img)
|
||||
void OTA_ReadHeader(uint32_t addr, imginfo_t *img)
|
||||
{
|
||||
uint32_t epoch_hi, epoch_lo;
|
||||
|
||||
if (base != OTA_REGION1_BASE || base != OTA_REGION2_BASE) {
|
||||
if (addr != OTA_REGION1_HEADER || addr != OTA_REGION2_HEADER) {
|
||||
return;
|
||||
}
|
||||
|
||||
flash_ext_read_word(&flash_obj, base + OTA_TAG_OFS, &img->tag);
|
||||
flash_ext_read_word(&flash_obj, base + OTA_VER_OFS, &img->ver);
|
||||
flash_ext_read_word(&flash_obj, base + OTA_EPOCH_OFS, &epoch_hi);
|
||||
flash_ext_read_word(&flash_obj, base + OTA_EPOCH_OFS + 4, &epoch_lo);
|
||||
flash_ext_read_word(&flash_obj, addr + OTA_TAG_OFS, &img->tag);
|
||||
flash_ext_read_word(&flash_obj, addr + OTA_VER_OFS, &img->ver);
|
||||
flash_ext_read_word(&flash_obj, addr + OTA_EPOCH_OFS, &epoch_hi);
|
||||
flash_ext_read_word(&flash_obj, addr + OTA_EPOCH_OFS + 4, &epoch_lo);
|
||||
img->timestamp = ((uint64_t)epoch_hi << 32) | (uint64_t) epoch_lo;
|
||||
|
||||
flash_ext_read_word(&flash_obj, base + OTA_SIZE_OFS, &img->size);
|
||||
flash_ext_stream_read(&flash_obj, base + OTA_HASH_OFS, 32, img->hash);
|
||||
flash_ext_stream_read(&flash_obj, base + OTA_CAMPAIGN_OFS, 16, img->campaign);
|
||||
flash_ext_read_word(&flash_obj, base + OTA_CRC32_OFS, &img->crc32);
|
||||
flash_ext_read_word(&flash_obj, addr + OTA_SIZE_OFS, &img->size);
|
||||
flash_ext_stream_read(&flash_obj, addr + OTA_HASH_OFS, 32, img->hash);
|
||||
flash_ext_stream_read(&flash_obj, addr + OTA_CAMPAIGN_OFS, 16, img->campaign);
|
||||
flash_ext_read_word(&flash_obj, addr + OTA_CRC32_OFS, &img->crc32);
|
||||
}
|
||||
|
||||
bool OTA_CheckHeader(imginfo_t *img)
|
||||
|
@ -61,9 +61,9 @@ bool OTA_CheckHeader(imginfo_t *img)
|
|||
return true;
|
||||
}
|
||||
|
||||
void OTA_GetImageInfo(uint32_t base, imginfo_t *img)
|
||||
void OTA_GetImageInfo(uint32_t header, imginfo_t *img)
|
||||
{
|
||||
OTA_ReadHeader(base, img);
|
||||
OTA_ReadHeader(header, img);
|
||||
|
||||
if (!OTA_CheckHeader(img)) {
|
||||
img->timestamp = 0;
|
||||
|
@ -77,8 +77,8 @@ uint32_t OTA_GetUpdateBase(void)
|
|||
{
|
||||
imginfo_t img1, img2;
|
||||
|
||||
OTA_GetImageInfo(OTA_REGION1_BASE, &img1);
|
||||
OTA_GetImageInfo(OTA_REGION2_BASE, &img2);
|
||||
OTA_GetImageInfo(OTA_REGION1_HEADER, &img1);
|
||||
OTA_GetImageInfo(OTA_REGION2_HEADER, &img2);
|
||||
|
||||
if (img1.valid && img2.valid) {
|
||||
if (img1.timestamp < img2.timestamp) {
|
||||
|
|
|
@ -22,17 +22,20 @@
|
|||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
#define FLASH_SECTOR_MASK ~(FLASH_SECTOR_SIZE - 1)
|
||||
|
||||
#define OTA_REGION1_HEADER 0x0b000
|
||||
#define OTA_REGION2_HEADER 0x0c000
|
||||
#define OTA_REGION2_BASE 0x120000
|
||||
#define OTA_REGION1_BASE 0x40000
|
||||
#define OTA_REGION2_BASE 0x120000
|
||||
#define OTA_REGION1_SIZE 0xe0000
|
||||
#define OTA_REGION2_SIZE 0xe0000
|
||||
#define OTA_REGION_SIZE 0xe0000
|
||||
#define OTA_MBED_FS_BASE 0xb000
|
||||
#define OTA_MBED_FS_BASE 0x10000
|
||||
#define OTA_MBED_FS_SIZE 0x30000
|
||||
|
||||
#define OTA_CRC32_LEN 0x44
|
||||
#define OTA_HEADER_LEN 0x48
|
||||
|
||||
#define OTA_HEADER_OFS 0x0
|
||||
#define OTA_TAG_OFS 0x0
|
||||
#define OTA_VER_OFS 0x4
|
||||
#define OTA_EPOCH_OFS 0x8
|
||||
|
@ -57,6 +60,8 @@ typedef struct imginfo_s {
|
|||
uint8_t campaign[16];
|
||||
uint32_t crc32;
|
||||
bool valid;
|
||||
uint32_t header_addr;
|
||||
uint32_t image_addr;
|
||||
} imginfo_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -64,7 +69,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
extern void OTA_GetImageInfo(uint32_t base, imginfo_t *info);
|
||||
extern uint32_t OTA_GetUpdateBase(void);
|
||||
extern uint32_t OTA_GetUpdateRegion(void);
|
||||
|
||||
extern uint32_t OTA_UpdateHeader(uint32_t base, imginfo_t *img);
|
||||
extern uint32_t OTA_UpdateImage(uint32_t base, uint32_t offset, uint32_t len, uint8_t *data);
|
||||
|
|
Binary file not shown.
|
@ -255,7 +255,9 @@ def create_daplink(image_bin, ram1_bin, ram2_bin):
|
|||
|
||||
output = open(image_bin, "wb")
|
||||
append_image_file(ram1_bin, output)
|
||||
append_image_file(ram2_bin, output)
|
||||
|
||||
output.seek(0xb000)
|
||||
line = ""
|
||||
for key in ['tag', 'ver', 'timestamp', 'size', 'hash', 'campaign']:
|
||||
line += RAM2_HEADER[key]
|
||||
|
@ -264,7 +266,6 @@ def create_daplink(image_bin, ram1_bin, ram2_bin):
|
|||
RAM2_HEADER['crc32'] = format_number(crc32_checksum(line), 8)
|
||||
|
||||
output.write(RAM2_HEADER['crc32'])
|
||||
append_image_file(ram2_bin, output)
|
||||
output.close()
|
||||
|
||||
# ----------------------------
|
||||
|
|
Loading…
Reference in New Issue