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

How to use serial port to show the RAM and modify the RAM start value in macOS?

I want to add a new ble service in hrs example(sdk15.3),I build and run the hrs example.and then I open the terminal emulator, but I can't find anything.I try to click the option"connect /dev/tty/usbserial",but makes nothing.How can I get something like this?(

<warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.

<warning> nrf_sdh_ble: Change the RAM start location from 0x20002B90 to 0x20002B98.

<warning> nrf_sdh_ble: Maximum RAM size for application is 0xD468.

<error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.

because if I don't change the RAM, I won't find any service by bluetooth.

Parents
  • Hi,

    Which compiler/IDE are you using? If you are using Segger Embedded studio, you can try building the application in Debug mode. See this and this video tutorial for more details. If using other compiler/IDE, try setting the DEBUG flag in preprocessor symbols.

    Best regards,
    Jørgen

  • Are you able to reach main() function if you start a debug session? Can you try erasing the board completely using command 'nrfjprog -e', or through nRF Connect Programmer app, before reflashing the application? If not, could you post your entire project for debugging?

  • Did you check with another phone, to make sure that your phone did not cache services from previous connections?

  • hi,Holmefjord

    yes,I checked it, in fact,when I erase the nrf52840 and finish "bulid and run" the project,The led1 on nrf52840 starts to blinky, and I can find the bluetooth named"nordic_uart" directly. and there is only the uart service.and then I mixed it with bootloader,setttings and softdevice.There is also the UART service only

    here is the change I add(by Infocenter Guide):

    1.Add source file
    Add a folder nRF_DFU to the project and add the following files:

    <sdk>\components\ble\ble_services\ble_dfu\ble_dfu.c
    <sdk>\components\ble\ble_services\ble_dfu\ble_dfu_bonded.c
    <sdk>\components\ble\ble_services\ble_dfu\ble_dfu_unbonded.c
    <sdk>\components\libraries\bootloader\dfu\nrf_dfu_svci.c

    ../../../../../../components/libraries/bootloader
    ../../../../../../components/libraries/bootloader/ble_dfu
    ../../../../../../components/libraries/bootloader/dfu
    ../../../../../../components/libraries/svc

    2.Add macro switch
    Find Preprocessor Definitions in the Project Configuration window and add the following items:

    NRF_DFU_SVCI_ENABLED
    NRF_DFU_TRANSPORT_BLE=1
    BL_SETTINGS_ACCESS_ONLY

    3.Configuring sdk_config
    In sdk_config.h, make the following changes:

    BLE_DFU_ENABLED = 1
    NRF_SDH_BLE_VS_UUID_COUNT += 1

    4.Add header file
    Add the following header file to main.c:

    #include "nrf_dfu_ble_svci_bond_sharing.h"
    #include "nrf_svci_async_function.h"
    #include "nrf_svci_async_handler.h"
    #include "ble_dfu.h"
    #include "nrf_power.h"
    #include "nrf_bootloader_info.h"

    5. add codes in main.c

    5.1 define m_ready_for_reset

    #define m_ready_for_reset               1

    5.2 Implement the DFU event handler

    static void ble_dfu_buttonless_evt_handler(ble_dfu_buttonless_evt_type_t event)
    {
        switch (event)
        {
            case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
                NRF_LOG_INFO("Device is preparing to enter bootloader mode\r\n");
                break;
            
            case BLE_DFU_EVT_BOOTLOADER_ENTER:
                NRF_LOG_INFO("Device will enter bootloader mode\r\n");
                break;
            
            case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
                NRF_LOG_ERROR("Device will enter bootloader mode\r\n");
                break;
            default:
                NRF_LOG_INFO("Unknown event from ble_dfu.\r\n");
                break;
        }
    }

    5.3 Enabling power management auto shutdown retry

    #ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY
    #define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 1
    #endif

    5.4 Implement the power management

    static bool app_shutdown_handler(nrf_pwr_mgmt_evt_t event)
    {
        switch (event)
        {
            case NRF_PWR_MGMT_EVT_PREPARE_DFU:
                NRF_LOG_INFO("Power management wants to reset to DFU mode\r\n");    
                // Change this code to tailor to your reset strategy.
                // Returning false here means that the device is not ready to jump to DFU mode yet.
                // 
                // Here is an example using a variable to delay resetting the device:
                if (!m_ready_for_reset)
                {
                     return false;
                }
                break;
            
            default:
                // Implement any of the other events available from the power management module:
                //      -NRF_PWR_MGMT_EVT_PREPARE_SYSOFF
                //      -NRF_PWR_MGMT_EVT_PREPARE_WAKEUP
                //      -NRF_PWR_MGMT_EVT_PREPARE_RESET
                return true;
        }
        NRF_LOG_INFO("Power management allowed to reset to DFU mode\r\n");
        return true;
    }

    5.5 Initializing the Buttonless Secure DFU Service(add the code in fonction service_init)

    static void services_init(void)
    {
        ...
        ble_dfu_buttonless_init_t dfus_init =
        {
            .evt_handler = ble_dfu_buttonless_evt_handler
        };
        
        err_code = ble_dfu_buttonless_init(&dfus_init);
        APP_ERROR_CHECK(err_code);
        
        ...
    }

    and then I allocate the RAM and mix the files,as the problem I had shown,I can connect the nrf52840 if I simplely click"build and run"(just find 1 service:UART),and if I run the mixed file,The result is the same,There is only a UART service.Which step is wrong?Looking forward to your reply.

    best regards,

    zhong

  • I can't see any obvious issues. Did you receive any error codes when running the code? Have you tried debugging it, to see if the dfu_service init functions are being called?

  • hello,Jorgen

    I don't receive any error and I debug it,and all the line in init_service (main.c)is running,like the image.

    and it's all the things in UART example I used(sdk15.3.0,pca10056),could you please help me to find the problem or give me some advise to finish add dfu_buttonless service in other application?Looking forward to your reply.1663.ble_app_uart.zip

    best regards,

    zhong

  • I tested your project, and I'm seeing both UART and DFU service. Try rebuilding the whole project, and try with a different phone model or nRF Connect for Desktop.

Reply Children
No Data
Related