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

nRf52: ble uart example not working with S132 ver. 2.0.0 alpha

Hi,

the example ble_app_uart_s132 from the SDK 0.9.2 is not longer working with the new release of S132 ( s132_nrf52_2.0.0-7.alpha). I had to go back to s132_nrf52_1.0.0-3.alpha to get it working. I am using Keil 5.17 and the lastest nrfGoStudio 1.21 as toolchain.

What is the migration path form s132_nrf52_1.0.0-3.alpha to s132_nrf52_2.0.0-7.alpha?

Yours Johannes

  • Hi jolo,

    I don't have 100% of the details to give you but in the download for version 2.0 is a new set of headers. There are some additional parameters that need to be configured for the SoftDevice to run.

    See this question thread with more details on what to add.

    HTH,

    Eric

  • Hi Johannes,

    There are a couple of things that needs to be changed in the example to make it work with the newest alpha release of the SoftDevice.

    Update 05.01.2016: There is now a migration document in the zip folder of SD v2.0.0-8 alpha. This document explains in more depth what changes need to be made. For examples on how to use the new SoftDevice, check the SDK 11 examples ble_stack_init() function.

    Update 09.12.2015: The new alpha SoftDevices allows for configurable RAM size. This is calculated by the SoftDevice. sd_ble_enable will return error if the RAM size is too little. The way to do this is to run the code once to see how much RAM the SoftDevice uses with the configuration and then set this in the project. You can also set the RAM size to a higher value than what is required, this will only waste RAM. There will be a document describing this more in depth.

    • The SoftDevice headers need to be updated. Copy the files in \s132_nrf52_2.0.0-7.alpha\s132_nrf52_2.0.0-7.alpha_API\include to \nRF52_SDK_0.9.2\components\softdevice\s132\headers (copy and replace all files and folders)

    • Change ble_stack_init() to include the RAM base in the SoftDevice enable function, like this or similar:

       static void ble_stack_init(void)
       {
       uint32_t err_code;
       uint32_t app_ram_base;
       
       // Initialize SoftDevice.
       SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);
      
       // Enable BLE stack.
       ble_enable_params_t ble_enable_params;
       memset(&ble_enable_params, 0, sizeof(ble_enable_params));
       #if (defined(S130) || defined(S132))
           ble_enable_params.gatts_enable_params.attr_tab_size   = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
       #endif
       ble_enable_params.common_enable_params.vs_uuid_count = 5;
       ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
       ble_enable_params.gap_enable_params.central_conn_count = 1;
       ble_enable_params.gap_enable_params.central_sec_count = 1;
       ble_enable_params.gap_enable_params.periph_conn_count = 1;
       app_ram_base = __LINKER_APP_RAM_BASE;
       err_code = sd_ble_enable(&ble_enable_params,app_ram_base);
       if(err_code == NRF_SUCCESS)
       {
       // Verify that __LINKER_APP_RAM_BASE matches the SD calculations 
       if(app_ram_base != __LINKER_APP_RAM_BASE)
           {
               uart_print("Warning: unused memory: 0x%x", __LINKER_APP_RAM_BASE - app_ram_base);
           }
       }
       else if(err_code == NRF_ERROR_DATA_SIZE)
       {
           // Not enough memory for the SoftDevice. place a breakpoint here or output app_ram_base
           uart_print("Fatal: Not enough memory for the selected configuration. Required: 0x%x", app_ram_base);
           ASSERT(0);
       }
       
       // Subscribe for BLE events.
       err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
       APP_ERROR_CHECK(err_code);
       }
      

    The reason for this is explained in the link Eric sent you.

    • The softdevice_assertion_handler(...) is changed in the new alpha release. Change it to something like this:

       void softdevice_assertion_handler(uint32_t id, uint32_t pc, uint32_t info)
       {
           //error code
       }
      
    • The APP_CODE_BASE is changed to 0x1B000. Change ROM start to 0x1B000 and ROM size to 0x65000 in Keil (Options for target->Target->IROM1)

    Ole

  • Thank you very much Eric and Ole,

    your answers helped a lot to get a better understanding of the softdevice 123 ver. 2.x.

    Yours Johannes

  • I gave this method a try and I'm getting the following error message when I try to load:

    Load "C:\\Nordic\\nRF51_SDK_10.0.0_dc26b5e\\examples\\Throughput_Central\\ble_app_uart_c\\pca10028\\s130\\arm5_no_packs\\_build\\nrf51422_xxac_s120.axf" 
    Set JLink Project File to "C:\Nordic\nRF51_SDK_10.0.0_dc26b5e\examples\Throughput_Central\ble_app_uart_c\pca10028\s130\arm5_no_packs\JLinkSettings.ini"
    * JLink Info: Device "NRF51422_XXAC" selected.
     
    JLink info:
    ------------
    DLL: V5.02e, compiled Sep 25 2015 18:24:14
    Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Aug 28 2015 19:26:24
    Hardware: V1.00
    S/N : 681440137 
     
    * JLink Info: Found SWD-DP with ID 0x0BB11477
    * JLink Info: Found Cortex-M0 r0p0, Little endian.
    * JLink Info: FPUnit: 4 code (BP) slots and 0 literal slots
    * JLink Info: CoreSight components:
    * JLink Info: ROMTbl 0 @ F0000000
    * JLink Info: ROMTbl 0 [0]: F00FF000, CID: B105100D, PID: 000BB471 ROM Table
    * JLink Info: ROMTbl 1 @ E00FF000
    * JLink Info: ROMTbl 1 [0]: FFF0F000, CID: B105E00D, PID: 000BB008 SCS
    * JLink Info: ROMTbl 1 [1]: FFF02000, CID: B105E00D, PID: 000BB00A DWT
    * JLink Info: ROMTbl 1 [2]: FFF03000, CID: B105E00D, PID: 000BB00B FPB
    * JLink Info: ROMTbl 0 [1]: 00002000, CID: B105900D, PID: 000BB9A3 ???
    ROMTableAddr = 0xF0000003
     
    Target info:
    ------------
    Device: nRF51422_xxAC
    VTarget = 3.300V
    State of Pins: 
    TCK: 0, TDI: 1, TDO: 1, TMS: 1, TRES: 1, TRST: 1
    Hardware-Breakpoints: 4
    Software-Breakpoints: 8192
    Watchpoints:          2
    JTAG speed: 1000 kHz
     
    Erase Failed!
    Error: Flash Download failed  -  "Cortex-M0"
    Flash Load finished at 13:41:57
    

    On thing: I don't have a macro called APP_CODE_BASE in my project. What is it?

Related