cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to read Flash data of STM32l5

PYada.1
Associate III

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?

6 REPLIES 6
Frantz LEFRERE
ST Employee

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.

@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?

Attaching object byte option for reference purpose

PYada.1
Associate III

@Frantz LEFRERE​ , Can you please help me regarding this issue?

Frantz LEFRERE
ST Employee

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.

PYada.1
Associate III

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.