2021-11-16 11:46 PM
I am using STM32L562E-DK.
I have ported SBSBFU for it. It is working fine. I want to store my custom data into internal flash and read it on bootup time in the bootloader.
For testing I am flashing one binary of 16 byte which's content is "Hello World!" at 0x73000 using SBSFU_UPDATE.bat.
If I read Data using STM32Cube programmer and read data at 0x73000, it shows "Hello World!". But If I read Data (16 bytes) using flash read API, it returns success but the data is 0x00(all zero).
int test_Storage()
{
uint32_t addr = 0x73000;
uint8_t data[32];
int test_ret = 1;
test_ret = TFM_Driver_FLASH0.ReadData(addr,data,sizeof(data));
if(test_ret != 0)
{
printf("\r\n Read Fail\r\n");
}
else
{
printf("\r\n Read Successfull\r\n");
for(int i =0;i<16;i++)
{
printf("%02x ",data[i]);
}
printf("\r\n");
}
return test_ret;
}
Also, I have changed the range in "low_level_device.c" file for erase and write as well. But I am getting the same result.
@Frantz LEFRERE Can you please help me regarding it?
Am I missing anything from my side?
2021-11-17 06:51 AM
Dear PYada.1,
please check the secure context execution of test_Storage and if the location "0x73000" is part of secure or non secure word.
Depending on this you should read address 0x8073000 or 0xC073000.
2021-11-17 07:32 AM
@Frantz LEFRERE , Thanks for your input.
That logic is already added in "low_level_flash.c" file. In my case 0x73000 is non-secure context and internally in Flash_ReadData() API 0x8073000 address is passed. I have set the RDP level to 0xAA. Still, I am getting 0x00 data after the read operation.
FYI, my image partition size is 0x73000, any change is required in MPU or flash layout file to read data from flash after image partition size?
2021-11-18 12:57 AM
2021-11-21 09:27 PM
@Frantz LEFRERE , Can you please help me regarding this issue?
2021-11-21 11:18 PM
I would advise to try to access this location with memory viewer in a debugger.
Then just debug your access code.
You can also try to remove the MPU protection to check if it has an impact.
2021-11-30 10:14 PM
Thanks, @Frantz LEFRERE for your input,
The issue was due to the wrong flash limit being set in the Secure attribute, After setting the correct value in the SAU->RLAR register I am able to read data properly.