cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Secure Area does not create secure fault

PYada.1
Associate III

I am using TFM-SBSFU example provided in STM32L5.

Secure Area 1 which is already configured as below.

When I am trying to read 0x8012000 from non-secure application, I am getting secure fault.


_legacyfs_online_stmicro_images_0693W00000bhxEVQAY.png 

I want to add one Partition 0x807d000 of 4KB into secure after the non-secure partition.

I am able to add it by modifying the option byte by following the bootloader code

 start = 0x3D000/PAGE_SIZE; //0;

 end = (0x3D000+ PUBLIC_KEY_SECTOR_SIZE -1) / PAGE_SIZE;//(S_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_S_PARTITION_SIZE - 1) / PAGE_SIZE;

 printf("\r\n Start = %02x, End = %02x",start,end);

 if(end < PAGE_MAX_NUMBER_IN_BANK)

 {

  if ((start != flash_option_bytes_bank2.WMSecStartPage)

    || (end != flash_option_bytes_bank2.WMSecEndPage))

  {

  BOOT_LOG_INF("BANK 2 secure flash [%d, %d] : OB [%d, %d]", start, end, flash_option_bytes_bank2.WMSecStartPage,

          flash_option_bytes_bank2.WMSecEndPage);

#ifndef TFM_ENABLE_SET_OB

  BOOT_LOG_ERR("Unexpected value for secure flash protection");

  Error_Handler();

#else

  BOOT_LOG_ERR("Unexpected value for secure flash protection : set wmsec2");

  flash_option_bytes_bank2.WMSecStartPage = start;

  flash_option_bytes_bank2.WMSecEndPage = end;

  flash_option_bytes_bank2.OptionType = OPTIONBYTE_WMSEC;

  flash_option_bytes_bank2.WMSecConfig |= OB_WMSEC_AREA2 | OB_WMSEC_SECURE_AREA_CONFIG ;

#endif /* TFM_ENABLE_SET_OB */

  }

 }


_legacyfs_online_stmicro_images_0693W00000bhxE6QAI.png 

When I try to read that partition from the nonsecure application, It reads 0x00 but does not create a secure fault. Is it expected behavior? is there any other configuration required besides it?

@Frantz LEFRERE​ , Can you please help me with it?

1 REPLY 1
Bubbles
ST Employee

Hello @PYada.1​,

what is your DBANK setting? The SECWM2 final address range displayed in CubeProgrammer is probably only correct under certain circumstances. The actual range depends on memory mapping, it's too complex for the simple macro in the CubeProgrammer to display correctly.

Yo need to dive into the RM to get this right.

BR,

J

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.