Failure access to internal flash when enabling Soft device

Good day Nordic people, 
I am facing a problem when erasing or writing to internal flash memory after enabling softdevice. here the details and tests:

Setup:
- GCC, arm toolchain, make files under linux OS. Visual studio code for editing.

Exact problem:
- when trying to erase or write to internal flash, it throw an exception at PC address 0x15074. sure this after SD enable.

Testing and Tries:
- Am using SD flash APIs.
- I tried to access sd flash function directly and within fstorage APIs.
- I tried Segger Fstorage example and it was working fine so i moved this example to my setup but no luck.
- i tried to disable softdevice before Flash operation and enable after finishing, it is working sometimes... in all cases i don't recommend this way of solving this problem.
- before enabling softdevice, I was able to master flash operation without any problem.
- I tried many configuration for sofdevice lf_clock, RC, XTAL and SYNTH

I think, there is a missed configuration is done by IDE like Segger, I didn't use it. But what is this configuration, i don't know.

best regards
Hossam

  • add to testing:
    I have checked ACL registers and all are containing 0's values which means no memory protection.

  • Hi

    Have you checked what address you try to write to? If you try to write to an address occupied by the SoftDevice an error like this is likely to occur. What SDK are you using for development? The SoftDevice takes up flash up until ~0x26000. This varies depending on what SDK version you're using.

    Best regards,

    Simon

  • Hi Simon, 
    sure, it is a precaution to check the address. I have divided the memory in a custom linker file and i am accessing 0xf4000.
    here is memory partitions:

    _TOTAL_MEMORY_SIZE = 1024K;

    _SOFT_DEVICE_MEMORY_START = 0x00000000;
    _SOFT_DEVICE_MEMORY_LENGTH = 156K;
    _SOFT_DEVICE_END = _SOFT_DEVICE_MEMORY_START + _SOFT_DEVICE_MEMORY_LENGTH;

    _APP_MEMORY_START = _SOFT_DEVICE_END;
    _APP_MEMORY_SIZE = 400K;
    _APP_MEMORY_END = _APP_MEMORY_START + _APP_MEMORY_SIZE;

    _APP_FDS_START = _APP_MEMORY_END;
    _APP_FDS_SIZE = 28K;
    _APP_FDS_END = _APP_FDS_START + _APP_FDS_SIZE;

    _FUOTA_IMAGE_START = _APP_FDS_END;
    _FUOTA_IMAGE_SIZE = 392k;
    _FUOTA_IMAGE_END = _FUOTA_IMAGE_START + _FUOTA_IMAGE_SIZE;

    _APP_DATA_START = _FUOTA_IMAGE_END;
    _APP_DATA_SIZE = 20K;
    _APP_DATA_END = _APP_DATA_START + _APP_DATA_SIZE;

    _BOOTLOADER_MEMORY_START = _APP_DATA_END;
    _BOOTLOADER_LENGTH = 28K;
    _BOOT_ONLY_BOOTLOADER_MEMORY_END = _BOOTLOADER_MEMORY_START + _BOOTLOADER_LENGTH;

    _FLASH_MEMORY_END = _SOFT_DEVICE_MEMORY_START + _TOTAL_MEMORY_SIZE;

    MEMORY
    {
    FLASH (rx) : ORIGIN = _APP_MEMORY_START, LENGTH = _APP_MEMORY_SIZE
    RAM (rwx) : ORIGIN = 0x20002A48, LENGTH = 0x3D5B8
    CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x40000
    /*EXTFLASH (rx) : ORIGIN = 0x12000000, LENGTH = 0x8000000*/
    }


    - SDK 17.0.2

  • Hi

    Are you able to see any error message from the "thrown" exception? Since the address is in the SoftDevice I would assume there is an sd_() function returning an error in your application that might shed some light on what exactly is happening.

    Best regards,

    Simon

  • Hi, 
    Partially, I solved this problem and i am planning to post it here, may help some body else.
    Now I have internal error event when doing flash operation inside interrupt function like GPIO handler?.
    I am using interrupt sdh dispatch model , I tried appsch_SDH_dispatch and got the same result.

    BTW, return code is NRF_SUCCESS, so function call is fine 

    I think it is because GPIO handler is calling SVC by calling SD operation, so is there any way to work around without making a lot of changes?
    regards

Related