Hello, I am developing a project with BW16 module, 4Mb flash integrated. Using latest dev standard SDK.
The problem is, OTA HTTP example is erasing the wrong (currently running) OTA image leading to a crash. The following function:
u32 ota_get_cur_index(void) ;
returns the wrong image index, as the bootloader has not properly set up the MMU regions.
I changed the default memory map, to make use of 4Mb flash, and to have a few space pages. I have my first image at 0x08010000 and second at 0x08210000. Both images run normally when programmed through the serial port and Imagetool app (full erase, with programming only bootloaders and OTA1 or OTA2)
As described in AN0400 I changed
In rtl8721d_bootcfg.c:
u32 OTA_Region[2] = {
0x08010000,
0x08210000,
};
In rtl8721d_ota.h
#define LS_IMG2_OTA1_ADDR 0x08010000
#define LS_IMG2_OTA2_ADDR 0x08210000
rtl8721dhp_intfcfg.c
const u32 ftl_phy_page_start_addr = 0x00202000;
platform_opts.h
#define FAST_RECONNECT_DATA 0x00205000
I fully erased the chip and programmed bootloaders and OTA1 and I am getting the following log:
[update_ota_http_connect_server] Create socket: 0 success!
[http_update_ota] Download new firmware begin, total size : 852000
(following was added by me to see MMU regions)
MMU0 START 0xc000000 END 0xc018fff OFFS 0x3df0000 PHY ADDRESS: 0x8210000
MMU1 START 0xe000000 END 0xe0b6fff OFFS 0x5dd7000 PHY ADDRESS: 0x8229000
OTA ADDRESS: 8210000 MUST BE 8010000 or 8210000
[http_update_ota] OTA1 address space will be upgradedHard Fault Error!!!
R0 = 0x8a210
R1 = 0x4
R2 = 0x80000000
R3 = 0xffffffff
R12 = 0xc005425
LR = 0xffffffbc
PC = 0xc000ff6
xPSR = 0x6100020e
PriMask: 0x0
And it seems the bootloader has set up the MMU to map the invalid OTA image (OTA2). Then it tries to erase OTA1, resulting in a crash. As bootloader is in static library, I cannot trace how it sets up the MMU based on the changes in SDK. Do I have to modify the following MMU config when I change the memory map?
/*
- @brif MMU Configuration.
- There are 8 MMU entries totally. Entry 0 & Entry 1 are already used by OTA, Entry 2~7 can be used by Users.
*/
BOOT_RAM_DATA_SECTION
MMU_ConfDef Flash_MMU_Config = {
/VAddrStart, VAddrEnd, PAddrStart, PAddrEnd/
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, //Entry 2
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, //Entry 3
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, //Entry 4
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, //Entry 5
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, //Entry 6
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, //Entry 7
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
};
Thanks for the help!