Skip to content

Commit 1a3dae7

Browse files
authored
Merge pull request #5858 from yangkunming99/relocate-image-header
RTL8195AM - move region headers to 0xb000 and 0xc000
2 parents 7c8e570 + c9fc521 commit 1a3dae7

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/ota_api.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@
2323

2424
static flash_t flash_obj;
2525

26-
void OTA_ReadHeader(uint32_t base, imginfo_t *img)
26+
void OTA_ReadHeader(uint32_t addr, imginfo_t *img)
2727
{
2828
uint32_t epoch_hi, epoch_lo;
2929

30-
if (base != OTA_REGION1_BASE || base != OTA_REGION2_BASE) {
30+
if (addr != OTA_REGION1_HEADER || addr != OTA_REGION2_HEADER) {
3131
return;
3232
}
3333

34-
flash_ext_read_word(&flash_obj, base + OTA_TAG_OFS, &img->tag);
35-
flash_ext_read_word(&flash_obj, base + OTA_VER_OFS, &img->ver);
36-
flash_ext_read_word(&flash_obj, base + OTA_EPOCH_OFS, &epoch_hi);
37-
flash_ext_read_word(&flash_obj, base + OTA_EPOCH_OFS + 4, &epoch_lo);
34+
flash_ext_read_word(&flash_obj, addr + OTA_TAG_OFS, &img->tag);
35+
flash_ext_read_word(&flash_obj, addr + OTA_VER_OFS, &img->ver);
36+
flash_ext_read_word(&flash_obj, addr + OTA_EPOCH_OFS, &epoch_hi);
37+
flash_ext_read_word(&flash_obj, addr + OTA_EPOCH_OFS + 4, &epoch_lo);
3838
img->timestamp = ((uint64_t)epoch_hi << 32) | (uint64_t) epoch_lo;
3939

40-
flash_ext_read_word(&flash_obj, base + OTA_SIZE_OFS, &img->size);
41-
flash_ext_stream_read(&flash_obj, base + OTA_HASH_OFS, 32, img->hash);
42-
flash_ext_stream_read(&flash_obj, base + OTA_CAMPAIGN_OFS, 16, img->campaign);
43-
flash_ext_read_word(&flash_obj, base + OTA_CRC32_OFS, &img->crc32);
40+
flash_ext_read_word(&flash_obj, addr + OTA_SIZE_OFS, &img->size);
41+
flash_ext_stream_read(&flash_obj, addr + OTA_HASH_OFS, 32, img->hash);
42+
flash_ext_stream_read(&flash_obj, addr + OTA_CAMPAIGN_OFS, 16, img->campaign);
43+
flash_ext_read_word(&flash_obj, addr + OTA_CRC32_OFS, &img->crc32);
4444
}
4545

4646
bool OTA_CheckHeader(imginfo_t *img)
@@ -61,9 +61,9 @@ bool OTA_CheckHeader(imginfo_t *img)
6161
return true;
6262
}
6363

64-
void OTA_GetImageInfo(uint32_t base, imginfo_t *img)
64+
void OTA_GetImageInfo(uint32_t header, imginfo_t *img)
6565
{
66-
OTA_ReadHeader(base, img);
66+
OTA_ReadHeader(header, img);
6767

6868
if (!OTA_CheckHeader(img)) {
6969
img->timestamp = 0;
@@ -77,8 +77,8 @@ uint32_t OTA_GetUpdateBase(void)
7777
{
7878
imginfo_t img1, img2;
7979

80-
OTA_GetImageInfo(OTA_REGION1_BASE, &img1);
81-
OTA_GetImageInfo(OTA_REGION2_BASE, &img2);
80+
OTA_GetImageInfo(OTA_REGION1_HEADER, &img1);
81+
OTA_GetImageInfo(OTA_REGION2_HEADER, &img2);
8282

8383
if (img1.valid && img2.valid) {
8484
if (img1.timestamp < img2.timestamp) {

targets/TARGET_Realtek/TARGET_AMEBA/ota_api.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@
2222
#define FLASH_SECTOR_SIZE 0x1000
2323
#define FLASH_SECTOR_MASK ~(FLASH_SECTOR_SIZE - 1)
2424

25+
#define OTA_REGION1_HEADER 0x0b000
26+
#define OTA_REGION2_HEADER 0x0c000
2527
#define OTA_REGION1_BASE 0x40000
2628
#define OTA_REGION2_BASE 0x120000
2729
#define OTA_REGION1_SIZE 0xe0000
2830
#define OTA_REGION2_SIZE 0xe0000
2931
#define OTA_REGION_SIZE 0xe0000
30-
#define OTA_MBED_FS_BASE 0xb000
32+
#define OTA_MBED_FS_BASE 0x10000
33+
#define OTA_MBED_FS_SIZE 0x30000
3134

3235
#define OTA_CRC32_LEN 0x44
3336
#define OTA_HEADER_LEN 0x48
3437

35-
#define OTA_HEADER_OFS 0x0
3638
#define OTA_TAG_OFS 0x0
3739
#define OTA_VER_OFS 0x4
3840
#define OTA_EPOCH_OFS 0x8
@@ -57,14 +59,16 @@ typedef struct imginfo_s {
5759
uint8_t campaign[16];
5860
uint32_t crc32;
5961
bool valid;
62+
uint32_t header_addr;
63+
uint32_t image_addr;
6064
} imginfo_t;
6165

6266
#ifdef __cplusplus
6367
extern "C" {
6468
#endif
6569

6670
extern void OTA_GetImageInfo(uint32_t base, imginfo_t *info);
67-
extern uint32_t OTA_GetUpdateBase(void);
71+
extern uint32_t OTA_GetUpdateRegion(void);
6872

6973
extern uint32_t OTA_UpdateHeader(uint32_t base, imginfo_t *img);
7074
extern uint32_t OTA_UpdateImage(uint32_t base, uint32_t offset, uint32_t len, uint8_t *data);
0 Bytes
Binary file not shown.

tools/targets/REALTEK_RTL8195AM.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ def create_daplink(image_bin, ram1_bin, ram2_bin):
255255

256256
output = open(image_bin, "wb")
257257
append_image_file(ram1_bin, output)
258+
append_image_file(ram2_bin, output)
258259

260+
output.seek(0xb000)
259261
line = ""
260262
for key in ['tag', 'ver', 'timestamp', 'size', 'hash', 'campaign']:
261263
line += RAM2_HEADER[key]
@@ -264,7 +266,6 @@ def create_daplink(image_bin, ram1_bin, ram2_bin):
264266
RAM2_HEADER['crc32'] = format_number(crc32_checksum(line), 8)
265267

266268
output.write(RAM2_HEADER['crc32'])
267-
append_image_file(ram2_bin, output)
268269
output.close()
269270

270271
# ----------------------------

0 commit comments

Comments
 (0)