Failing to run on nRF52805

I compiled some legacy code (once written for the nRF52832), trying to adapt it for the nRF52805.

I have already done the following:

  • defining -DNRF52805_XXAA
  • defining -mfloat-abi=soft
  • defining-DFLOAT_ABI_SOFT
  • adapted the linker script to this:

  FLASH (rx) : ORIGIN = 0x1C000, LENGTH = 0x30000 - 0x1C000
  RAM (rwx) :  ORIGIN = 0x20002730, LENGTH = 0x6000 - 0x2730

My SD is configured like this:

#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#define NRF_SDH_BLE_VS_UUID_COUNT 3
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 320
#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408

Now I would be thankful to have these questions answered:

  1. Why does the SD113 require so much RAM (0x2730 compared to 0x1198 as in the docs)? I am using 3 VS UUIDs, but does that really hog so much memory?
  2. Do I need to compile gcc_startup_nrf52805.S or gcc_startup_nrf52.S? Same for system_nrf52805.c? When do I use which?
  3. The code will simply not boot on my nRF52805. Is there any setting I am missing?

Thanks!

Parents
  • Hi,

    Why does the SD113 require so much RAM (0x2730 compared to 0x1198 as in the docs)? I am using 3 VS UUIDs, but does that really hog so much memory?

    Minimum RAM requirement is 0x1198 bytes. Call stack usage comes on top, with maximum 0x700 bytes. In addition, depending on configuration, additional RAM requirements apply. Ref. S113 Release notes "SoftDevice properties" section for the given release (in this caes s113_nrf52_7.3.0.)

    Do I need to compile gcc_startup_nrf52805.S or gcc_startup_nrf52.S? Same for system_nrf52805.c? When do I use which?

    Setup, includes, etc. depend on toolchain (nRF5 SDK support multiple). However, switch between different SoCs typically involve changing RAM and Flash settings and a simple define change; the rest (which SoC specific files are involved in builds) is then typically handled by the MDK. For instance, for Keil, there should be a selection in project settings. You may have to also switch between hardware and software floating point.

    The code will simply not boot on my nRF52805. Is there any setting I am missing?

    If it still fails, please consult Developing for the nRF52805 with nRF5 SDK.

    Worst case, it might be that the total memory requirements of your application is simply too large for what is available on the nRF52805.

    Regards,
    Terje

  • Hello,

    thanks for the reply!

    1. Is 0x2730 realistic? I see that the SD may require more than 0x1198, but 0x2730 seems extremely large. Is there some formula available for the calculation?

    2. I am using nRF5 SDK 17.1. Should I include gcc_startup_nrf52805.S or gcc_startup_nrf52.S?

    3. My linker script is written to top out at the physical limit of the chip (0x6000). The firmware should fail at compilation time if it needed to much RAM, right? Or can it really fail at runtime aswell?

    Thanks again!

    P.S.: Thinking about it again: Is the stack not filled up from the end of RAM backwards? And since the exact same binary runs on the nRF52832, should the stack not be sufficient?

  • Hi,

    Daniel Dakhno said:
    Is 0x2730 realistic? I see that the SD may require more than 0x1198, but 0x2730 seems extremely large. Is there some formula available for the calculation?

    RAM requirements correspond directly to the configuration. There is no calculator, but if you set aside too little RAM for the SoftDevice then you should get a build error returning the required minimum size for the current configuration.

    0x2730 is high.

    In your case, I do see you do have a large GATT table (#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408) accounting for 0x580 bytes, significantly higher than the minimum 216 bytes. Depending on the application, you might need that much, though. Since you use max MTU size of 247, I assume that you do have at least one large characteristic value which would need a lot of GATT table space. Therefore you might experience that you do in fact need that size. Still I would check the configurations you set (sd_ble_cfg_set()) for if anything could be lowered. There might be some settings there which can be reduced, depending on the needs of the application.

    Daniel Dakhno said:
    2. I am using nRF5 SDK 17.1. Should I include gcc_startup_nrf52805.S or gcc_startup_nrf52.S?

    gcc_startup_nrf52805.s as per Developing for the nRF52805 with nRF5 SDK.
    You should also have ASMFLAGS += -DNRF52805_XXAA, do you already have that?

    Daniel Dakhno said:
    The firmware should fail at compilation time if it needed to much RAM, right? Or can it really fail at runtime aswell?

    It may fail runtime if you overrun the stack (stack overflow).

    Daniel Dakhno said:
    since the exact same binary runs on the nRF52832, should the stack not be sufficient?

    The nRF52805 has 24 kB of RAM while the nRF52832 has 32 kB or 64 kB depending on variant. With less RAM on the nRF52805 overall, there is less RAM left for the stack. So no, the fact it runs on the nRF52832 does not mean it will run on the smaller nRF52805.

    Regards,
    Terje

Reply
  • Hi,

    Daniel Dakhno said:
    Is 0x2730 realistic? I see that the SD may require more than 0x1198, but 0x2730 seems extremely large. Is there some formula available for the calculation?

    RAM requirements correspond directly to the configuration. There is no calculator, but if you set aside too little RAM for the SoftDevice then you should get a build error returning the required minimum size for the current configuration.

    0x2730 is high.

    In your case, I do see you do have a large GATT table (#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408) accounting for 0x580 bytes, significantly higher than the minimum 216 bytes. Depending on the application, you might need that much, though. Since you use max MTU size of 247, I assume that you do have at least one large characteristic value which would need a lot of GATT table space. Therefore you might experience that you do in fact need that size. Still I would check the configurations you set (sd_ble_cfg_set()) for if anything could be lowered. There might be some settings there which can be reduced, depending on the needs of the application.

    Daniel Dakhno said:
    2. I am using nRF5 SDK 17.1. Should I include gcc_startup_nrf52805.S or gcc_startup_nrf52.S?

    gcc_startup_nrf52805.s as per Developing for the nRF52805 with nRF5 SDK.
    You should also have ASMFLAGS += -DNRF52805_XXAA, do you already have that?

    Daniel Dakhno said:
    The firmware should fail at compilation time if it needed to much RAM, right? Or can it really fail at runtime aswell?

    It may fail runtime if you overrun the stack (stack overflow).

    Daniel Dakhno said:
    since the exact same binary runs on the nRF52832, should the stack not be sufficient?

    The nRF52805 has 24 kB of RAM while the nRF52832 has 32 kB or 64 kB depending on variant. With less RAM on the nRF52805 overall, there is less RAM left for the stack. So no, the fact it runs on the nRF52832 does not mean it will run on the smaller nRF52805.

    Regards,
    Terje

Children
  • The nRF52805 has 24 kB of RAM while the nRF52832 has 32 kB or 64 kB depending on variant. With less RAM on the nRF52805 overall, there is less RAM left for the stack. So no, the fact it runs on the nRF52832 does not mean it will run on the smaller nRF52805.

    Please correct me if I'm wrong: 

    The stack grows downwards from the top of RAM. Since the top of RAM is set to 0x6000 on both the nRF52832 and nRF52805, the stack (growing down from 0x6000) should overflow exactly the same on both chips, right?

    Setting the RAM top to 0x6000 should just ignore the remaining RAM on the nRF52832, right?

  • Hi,

    You are correct.

    Then I see what you mean. With the same RAM settings the difference should not be large, no. There may be smaller differences e.g. due to floating point or other SoC differences, though.

    I assume you have gone through Developing for the nRF52805 with nRF5 SDK in case there are any configurations still missed, and also that the RAM requirement of 0x2730 is the same for both devices?

    Regards,
    Terje

  • Hi,

    I have performed all the steps listed in the article.

    I have set all flags to soft float.

    The exact same firmware file with the following linker script ran on the 32, but not the 05, without recompiling.

    FLASH (rx) : ORIGIN = 0x1C000, LENGTH = 0x30000 - 0x1C000
    RAM (rwx) :  ORIGIN = 0x20002730, LENGTH = 0x6000 - 0x2730

    Thanks for your time on this!

  • Hi,

    Right. What boards have you been using, and does it run in emulated mode on e.g. nRF52 DK with nRF52833, then with the DEVELOP_IN_NRF52832 flags? Those flags should be present when emulating on the nRF52832, but not when running natively on the nRF52805.

    Regards,
    Terje

Related