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

Am I setting the correct memory settings?

As a follow up from devzone.nordicsemi.com/.../, I am now trying to find out if I am getting all of the memory settings put together correctly. When I have them at higher values then the program crashes and targets 0x00000000 rather than going to the error handler function, however, if I set it to a smaller value that I suspect is the correct value, it enters the error handler but is giving me a error 0x00000004 error which I believe is mapping to a not enough memory error. If somebody can take a moment and check my understanding, that would be great.

I'm using an nrf51822 qfaa chip which says it has 256k flash and 16k ram.

I'm using sdk12.2 which is using the s130 v2.0 soft device (2.0.1) and has the listed memory requirements shown on page 52 in infocenter.nordicsemi.com/.../S130_SDS_v2.0.pdf as follows image description

So I have set the following configuration for my project, image description

I now do not enter 0x00000000 upon crashing after a few main loops, but instead I crash right at the start when the following function is called and then checked.

err_code = softdevice_enable(&ble_enable_params);
APP_ERROR_CHECK(err_code);

the error is 0x00000004 and the program never is able to make a full loop.

If my understanding is correct, the 'size' value on memory areas is measured in bytes correct?

Edit: I just stepped through the softdevice enable code and it is comparing the starting memory value against the expected value of 0x20001fe8 against my value I set. I originally started with this value in the project but since it wasn't in line with the documentation, I changed it. I have since adjusted and changed IRAM1 to 0x20001fe8 and size value of 0x1e98.

I am still crashing and entering 0x00000000.

Edit 2: I just started looking at other softdevice options because I am wondering if maybe this chip is just too small in memory to use the s130 softdevice, so I moved over to s110 in sdk10, I selected the ble_beacon example and changed the target chip to the nrf51822_xxaa target. I then modified the start and size values to what seemed appropriate, but according to the s110 documentation the app IRam1 starting address looks like it should be at 0x20008188 but the project had previously set it at 0x20002000. Since the memory in the chip can't go up to 8188 I kept it at the preset value. It all seemed to work fine. Why is it that the doucentation says the default and minimum ram values for the s110 is larger than the example code settings, and then when I use the example code settings it works fine? infocenter.nordicsemi.com/.../S110_SDS_v2.0.pdf

Parents
  • Hi Tyler,

    if your using a nRF51822 QFAA with 256 kB Flash and 16kB RAM with the S130 v2.0.1 then you will have 148kB Flash and at the most ~11kB RAM left for the application(if the SoftDevice uses the minimum required RAM). However, keep in mind that the RAM usage of the SoftDevice is dependent on the configuration you enable it with.

    If you're unsure if you've set the correct memory settings, then you can take a look at the The sd_ble_enable function, which is used to enable the SoftDevice. It will return the minimum start address of the application RAM region required by the SoftDevice for the given configuration in the app_ram_base variable. The value of app_ram_base will be printed on the UART/RTT if you have logging enabled. You can also open a debug session, set a breakpoint after the in softdevice_enable(ble_enable_params_t * p_ble_enable_params) function in softdevice_handler.c and examine the value of app_ram_base that way.

    Unfortunately, the S110 does not have this feature so finding the correct RAM start address is a process of trial and error, but setting it to 0x20002000 should for most applications be fine. You are correct that its not possible to set the start address to 0x20008188, as the nRF51822 QFAA only has 16kB, i.e. 0x4000 bytes of RAM. Could you explain how you calculated the IRAM1 Start address to be 0x20008188 based on the S110 documentation?

Reply
  • Hi Tyler,

    if your using a nRF51822 QFAA with 256 kB Flash and 16kB RAM with the S130 v2.0.1 then you will have 148kB Flash and at the most ~11kB RAM left for the application(if the SoftDevice uses the minimum required RAM). However, keep in mind that the RAM usage of the SoftDevice is dependent on the configuration you enable it with.

    If you're unsure if you've set the correct memory settings, then you can take a look at the The sd_ble_enable function, which is used to enable the SoftDevice. It will return the minimum start address of the application RAM region required by the SoftDevice for the given configuration in the app_ram_base variable. The value of app_ram_base will be printed on the UART/RTT if you have logging enabled. You can also open a debug session, set a breakpoint after the in softdevice_enable(ble_enable_params_t * p_ble_enable_params) function in softdevice_handler.c and examine the value of app_ram_base that way.

    Unfortunately, the S110 does not have this feature so finding the correct RAM start address is a process of trial and error, but setting it to 0x20002000 should for most applications be fine. You are correct that its not possible to set the start address to 0x20008188, as the nRF51822 QFAA only has 16kB, i.e. 0x4000 bytes of RAM. Could you explain how you calculated the IRAM1 Start address to be 0x20008188 based on the S110 documentation?

Children
Related