This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Advertisement fails after writing an image(40kB) into the internal flash

Hi,

I need to store an image of size 40kB to internal flash memory. Actually i tried to store it from the address like 0x28400 and 0x2E984 (memory addresses after softdevice and bank 0 ). I am getting hard-fault error, in timer initialization itself ( fails in, is buffer word aligned). and sometimes i can write and display the images but advertisement is not happening (hard-fault in ble_stack_init) .

So how can i use the memory to store the images, without fail in advertisement.

Regards, Balaji.M

Parents
  • Are you sure no data is accidentally written somewhere it shouldn't be? Have you tried to do a readout of your device before and after the flash write, to verify that this is not the case?

    Also, do you reset after having done your flash write? If not, could it be that you see a stack overflow, so that the RAM use of your flash writing overwrites static RAM of other parts of your application? How big stack have you set?

    If you have further problems, I don't think we can do much more about this without seeing the code, and getting instructions to try reproducing the problem ourselves. If you can't share your code here, can you please create a regular support case and upload it there, along with a thorough explanation of how to reproduce the problem?

    Edit: This turned out to be a two-fold problem

    • First, the flash area used included the flash area used for static RAM values. This means that when the reset handler copied static RAM values from flash to RAM on reset, the values copied were just 0xFF, which in the end caused a HardFault when modules were trying to use this area.
    • Secondly, there is a bug in the calculation of page addresses in the function below, causing only every 4th page to be erased. This has to do with the pointer arithmetic of C, when incrementing a uint32_t pointer.
Reply
  • Are you sure no data is accidentally written somewhere it shouldn't be? Have you tried to do a readout of your device before and after the flash write, to verify that this is not the case?

    Also, do you reset after having done your flash write? If not, could it be that you see a stack overflow, so that the RAM use of your flash writing overwrites static RAM of other parts of your application? How big stack have you set?

    If you have further problems, I don't think we can do much more about this without seeing the code, and getting instructions to try reproducing the problem ourselves. If you can't share your code here, can you please create a regular support case and upload it there, along with a thorough explanation of how to reproduce the problem?

    Edit: This turned out to be a two-fold problem

    • First, the flash area used included the flash area used for static RAM values. This means that when the reset handler copied static RAM values from flash to RAM on reset, the values copied were just 0xFF, which in the end caused a HardFault when modules were trying to use this area.
    • Secondly, there is a bug in the calculation of page addresses in the function below, causing only every 4th page to be erased. This has to do with the pointer arithmetic of C, when incrementing a uint32_t pointer.
Children
No Data
Related