Hi Ozzy,
I ran a test based on the soc_nrf_flash sample and cannot see the same issue. If I use fprotect to lock the area of flash that the sample will try to write, the sample will crash as expected. Without the lock, the sample would run to completion.
Could you please give more details about your setup? Or perhaps, give me a minimal project that can reproduce the issue?
Attached is my test project for my reference.
Hieu
Hi Ozzy,
I will try to answer while Hieu is away. I am not sure if I understood the question right but if you are asking about the maximum flash size that can be used with fprotect_area and its alignment restrictions then both start and length address needs be multiple of 4KB (0x1000) and the whole RRAM can be used to be protected (using address is 0x0 and length as 0x80000)
#define pro_len (0x1000 *400) void flash_test(void) { printf("Lock 0x%x from 0\n",pro_len); errno = fprotect_area(0x0000, pro_len); if (errno) { printf("Failed lock err %d\n", errno); } else{ printf("Lock ok\n"); } }
Sorry for late reply. The pro_len size is clearly wrong as 0x1000 = 4096 and multiplied by 400 gives you about 1.6 MB and you do not have this much storage in nRF54L05. As mentioned here, you have only 0.5MB of storage on this SoC so max value you can use on pro_len is (0x80000)
#define pro_len (0x1000 *0x80) /* To ensure the operation is successful, the value of this macro definition needs to be less than or equal to 0x7000. */ void flash_test(void) { printf("Lock 0x%x from 0\n",pro_len); errno = fprotect_area(0x0000, pro_len); if (errno) { printf("Failed lock err %d\n", errno); } else{ printf("Lock ok\n"); } }
#define pro_len (0x1000 *0x80) /* To ensure the operation is successful, the value of this macro definition needs to be less than or equal to 0x7000. */ void flash_test(void) { printf("Lock 0x%x from 0\n",pro_len); errno = fprotect_area(0x0000, pro_len); if (errno) { printf("Failed lock err %d\n", errno); } else{ printf("Lock ok\n"); } }