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

How to decide the APP_RAM_BASE parameter for the new sd_ble_enable function in S140?

Hello, as oppose to S110, the function sd_ble_enable for S140 now includes one more parameter p_app_ram_base, which points to a value that stores the app base ram address, namely APP_RAM_BASE.

Since that the S140 technical documents are not officially released, I made reference to S132 softdevice and according to this page here:

infocenter.nordicsemi.com/index.jsp

and I quote:

The value of APP_RAM_BASE is obtained by calling sd_softdevice_enable, which will always return the required minimum start address of the application RAM region for the given configuration.

The problem is, in the program originally for S110, I did not find any functions calls made to sd_softdevice_enable, since it was working properly, I got this impression that softdevices work autonomously and needs no enabling (I could be completely wrong, but using a very capable software doing a thorough search gave a negative on the invoking of sd_softdevice_enable).

So it appears, if I were to use sd_ble_enable on S140 device, the appropriate steps should be:

  1. Call the sd_softdevice_enable function, and obtain a value and make sure it is stored in a global variant called "APP_RAM_BASE" (I hope this name is not problematic)
  2. use a pointer to point at "APP_RAM_BASE"
  3. Call sd_ble_enable, with that pointer passed to the corresponding parameter of the function.

So here are 3 questions that I can't possibly solve on my own in short term:

  1. Is this the only way? I mean it's kind of inefficient, or even dumb, there must be a better way to skip this step and come up with a all-encompassing, "can't possibly fail" value, like, setting the value really big?
  2. Interesting thing that "sd_softdevice_enable" does not seem to return an address at all, it's the same in S110, it's the same in S132, maybe different in S140?
  3. Where would be the best place to call sd_softdevice_enable, should that calling sd_softdevice_enable is inevitable?
Parents
  • No, I believe the right approach with all S13x and S140 Soft Devices is to call sd_ble_enable once with certain SD configuration, get the right RAM amount in return, print it out, correct LD script (or similar settings if you don't use GCC but other build chains) and be OK from that moment onwards (until you change settings influencing RAM allocation by SD when you need to repeat the procedure). Looks like plenty of Q&S on this forum answer this, just the first from hundreds of hits here.

Reply
  • No, I believe the right approach with all S13x and S140 Soft Devices is to call sd_ble_enable once with certain SD configuration, get the right RAM amount in return, print it out, correct LD script (or similar settings if you don't use GCC but other build chains) and be OK from that moment onwards (until you change settings influencing RAM allocation by SD when you need to repeat the procedure). Looks like plenty of Q&S on this forum answer this, just the first from hundreds of hits here.

Children
  • Hello endnode, the answer you gave me made it look like you have to give an arbitrary value, then leave the rest to trial and error?

    Edit: now I realize that the description in the offical doc and that answer you gave me led me to 2 completely different interpretation, one being that I must obtain a value using sd_ble_enable so I can use that value somewhere else, the other one being that I must input a value as its parameter into sd_ble_enable so I can use softdevice properly. I'm now totally confused???

  • @mitch996: The minimum RAM requirement of the S140 v5.0.0-2.alpha is 0x1468 bytes. The actual requirements will depend on the configuration chosen at sd_ble_enable() time. This is stated in the S140 v5.0.0-2.alpha Release notes, found in nRF5_SDK_13.0.0_04a0bfd\components\softdevice\s140\doc. Just set the minimum value, i.e 0x1468, in the linker script. Then run your application in debug mode with a breakpoint after sd_softdevice_enable and examine the app_ram_base value. Modify the linker script so that the application RAM start address corresponds with the app_ram_base value.

  • More or less yes. But it's just one trial and error, you will get the right value straight away. Note that Nordic explicitly say they cannot provide any RAM estimation formula for their Soft Devices at this moment so this is the way they suggest in their Soft Device release notes. Have you read all of them?:)

Related