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

nRF51_SDK_8.0.0 ble_stack_init() Hangs

My Problem

ble_app_uart app hangs at main.c line 503 "ble_stack_init();"

My Setup:

  • SDK: nRF51_SDK_8.0.0_5fc2c3a
  • Device: nRF51 DK
  • Editor: CrossWorks
  • SoftDevice: S110

These are the steps I've followed

  1. Setup "nRF51 SDK"
  2. unzip "nRF51_SDK_8.0.0_5fc2c3a_packs/nRF_SoftDevice_S110/NordicSemiconductor.nRF_SoftDevice_S110.8.0.0.pack"
  3. Load "$nRF51_SDK_8.0.0_5fc2c3a/components/softdevice/s110/hex/s110_softdevice.hex" on nRF51 with RKNRFGO.app
  4. In CrossWorks File->Import Project and select "$nRF51_SDK_8.0.0_5fc2c3a/examples/ble_peripheral/ble_app_uart/ble_app_uart.hzp"
  5. in "Select Template" select "nRF51_EXE - ..."template list
  6. Remove "retarget.c" from project
  7. Select Build->nrf51422_xxac_s110...
  8. Select Debug->Go
  9. Single step through code and app hangs at main.c line 503 "ble_stack_init();"

If I look at the project memory map I see this. I tried changing "FLASH" to "0x00018000" but that did not have any effect although I think that is what it should be.

flash_placement.xml

<!DOCTYPE Board_Memory_Definition_File>
<Root name="nRF51822_xxAA">
  <MemorySegment name="FLASH" access="ReadOnly" start="0x00000000" size="0x40000" />
  <MemorySegment name="FICR" start="0x10000000" size="0x100" />
  <MemorySegment name="UICR" start="0x10001000" size="0x100" />
  <MemorySegment name="RAM" start="0x20000000" size="0x4000" />
  <MemorySegment name="APB" start="0x40000000" size="0x00020000" />
  <MemorySegment name="AHB" start="0x50000000" size="0x00001000" />
</Root>

This is the project file (.hzp)

<!DOCTYPE CrossStudio_Project_File>
<solution Name="ble_app_uart_s110_pca10028" target="8" version="2">
  <project Name="nrf51422_xxac_s110">
    <configuration
      Name="Common"
      Placement="Flash"
      Target="nRF51822_xxAA"
      arm_architecture="v6M"
      arm_core_type="Cortex-M0"
      arm_gcc_target="arm-unknown-eabi"
      arm_linker_heap_size="0"
      arm_linker_stack_size="2048"
      arm_simulator_memory_simulation_filename="$(TargetsDir)/nRF51/nRF51SimulatorMemory.dll"
      arm_simulator_memory_simulation_parameter="nRF51822;0x40000;0x4000"
      arm_target_debug_interface_type="ADIv5"
      arm_target_interface_type="Default"
      arm_target_loader_applicable_loaders="Flash"
      arm_target_loader_default_loader="Flash"
      c_additional_options="-fms-extensions"
      c_preprocessor_definitions=";BLE_STACK_SUPPORT_REQD;BOARD_PCA10028;S110;NRF51;SOFTDEVICE_PRESENT"
          c_user_include_directories="$(TargetsDir)/CMSIS_3/CMSIS/Include;../../../../bsp;../../../../../components/softdevice/s110/headers;../../../../../components/ble/common;../../../../../components/drivers_nrf/hal;../../../../../components/drivers_nrf/uart;../../../../../components/libraries/button;../../../../../components/ble/ble_services/ble_nus;../../../../../components/device;../../../../../components/toolchain;../../../../../components/libraries/util;../../../../../components/libraries/fifo;../../../../../components/softdevice/common/softdevice_handler;../../../../../components/libraries/timer;../../../../../components/libraries/gpiote"
  debug_entry_point_symbol=""
  debug_register_definition_file="$(TargetsDir)/nRF51/nRF51_Peripherals.xml"
  linker_memory_map_file="$(TargetsDir)/nRF51/nRF51822_xxAA_MemoryMap.xml"
  linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml"
  linker_section_placement_macros=""
  package_dependencies="nRF51"
  project_directory=""
  project_type="Executable"
  property_groups_file_path="$(TargetsDir)/nRF51/propertyGroups.xml"
  target_reset_script="Reset()"
  target_script_file="$(TargetsDir)/nRF51/nRF51_Target.js" />
<folder Name="Source Files">
  <folder Name="Application">
    <file file_name="../../main.c" />
  </folder>
  <folder Name="Board Support">
    <file file_name="../../../../bsp/bsp.c" />
  </folder>
  <folder Name="Device">
    <file file_name="../../../../../components/toolchain/arm/arm_startup_nrf51.s">
      <configuration Name="Common" build_exclude_from_build="Yes" />
    </file>
    <file file_name="../../../../../components/toolchain/system_nrf51.c" />
  </folder>
  <folder Name="Documentation">
    <file file_name="../../Abstract.txt" />
    <file file_name="../../license.txt" />
  </folder>
  <folder Name="nRF_BLE">
    <file file_name="../../../../../components/ble/common/ble_advdata.c" />
    <file file_name="../../../../../components/ble/common/ble_conn_params.c" />
    <file file_name="../../../../../components/ble/ble_services/ble_nus/ble_nus.c" />
    <file file_name="../../../../../components/ble/common/ble_srv_common.c" />
  </folder>
  <folder Name="nRF_Drivers">
    <file file_name="../../../../../components/drivers_nrf/uart/app_uart_fifo.c" />
    <file file_name="../../../../../components/drivers_nrf/hal/nrf_delay.c" />
  </folder>
  <folder Name="nRF_Libraries">
    <file file_name="../../../../../components/libraries/button/app_button.c" />
    <file file_name="../../../../../components/libraries/util/app_error.c" />
    <file file_name="../../../../../components/libraries/fifo/app_fifo.c" />
    <file file_name="../../../../../components/libraries/gpiote/app_gpiote.c" />
    <file file_name="../../../../../components/libraries/timer/app_timer.c" />
  </folder>
  <folder Name="nRF_SoftDevice">
    <file file_name="../../../../../components/softdevice/s110/doc/s110_nrf51_8.0.0_licence-agreement.txt" />
    <file file_name="../../../../../components/softdevice/common/softdevice_handler/softdevice_handler.c" />
  </folder>
  <configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
</folder>
<configuration
  Name="Flash"
  arm_target_flash_loader_file_path="$(TargetsDir)/nRF51/Release/Loader.elf"
  arm_target_loader_can_erase_all="Yes"
  arm_target_loader_can_lock_all="No"
  arm_target_loader_can_lock_range="No"
  arm_target_loader_can_unlock_all="No"
  arm_target_loader_can_unlock_range="No"
  target_reset_script="FLASHReset()" />
<folder Name="System Files">
  <file file_name="$(StudioDir)/source/thumb_crt0.s" />
  <file file_name="$(TargetsDir)/nRF51/nRF51_Startup.s" />
</folder>
  </project>
  <configuration Name="THUMB Debug" inherited_configurations="THUMB;Debug" />
  <configuration
    Name="THUMB"
    Platform="ARM"
    arm_instruction_set="Thumb"
    arm_library_instruction_set="Thumb"
    c_preprocessor_definitions="__THUMB"
    hidden="Yes" />
  <configuration
    Name="Debug"
    c_preprocessor_definitions="DEBUG"
    gcc_debugging_level="Level 3"
    gcc_optimization_level="None"
    hidden="Yes" />
  <configuration
    Name="THUMB Release"
    inherited_configurations="THUMB;Release" />
  <configuration
    Name="Release"
    c_preprocessor_definitions="NDEBUG"
    gcc_debugging_level="Level 1"
    gcc_optimization_level="Level 1"
    hidden="Yes" />
</solution>

Any ideas how to debug this or what I might be doing wrong?

[UPDATE March 10th 2015]

This is how I got it to work:

  1. Setup "nRF51 SDK"

  2. unzip "nRF51_SDK_8.0.0_5fc2c3a_packs/nRF_SoftDevice_S110/NordicSemiconductor.nRF_SoftDevice_S110.8.0.0.pack"

  3. Load "$nRF51_SDK_8.0.0_5fc2c3a/components/softdevice/s110/hex/s110_softdevice.hex" on nRF51 with RKNRFGO.app

  4. In CrossWorks File->Import Project and select "$nRF51_SDK_8.0.0_5fc2c3a/examples/ble_peripheral/ble_app_uart"

  5. in "Select Template" select "nRF51_EXE - ..."template list

  6. Remove "retarget.c" from project (it is easiest if you build now so you get the error)

  7. Select Project Item-> "Project 'nrf51422_xxac_s110'" in project explorer

  8. In "Properties Window" scroll down to "Linker Options" and set "Section Placement Macros" to:

    FLASH_START=0x18000

    RAM_START=0x20002000

  9. Select Build->nrf51422_xxac_s110...

  10. Select Debug->Go

Now the iOS app will connect to the nRF51 DK board.

[Update March 11 2015]

This is how I connect serial port to nRF51 so I can see it on the iOS device

screen /dev/cu.usbmodem1d111 38400

You will need to substitue "cu.usbmodem1d111" with the one your device connected too. I use the following to find mine:

ls /dev/cu*

when you type in the terminal you should see the characters on the iPhone or Android device.

To exit screen use "Ctrl+A" followed by "Ctrl+\"

[Update March 12 2015]

This discussion with CrossWorks support is how the "section" binary offset is supposed to work with Nordic SoftDevices. It is not currently compatible with Nordic SDK 8.x. You are supposed to be able to simply set the "Placement" project property to Flash_S110.

It is said you can do that if you manually edit propertyGroups.xml.

Parents
    1. no the FLASH in the memory map is correct - that's the flash on the device, don't change that
    2. I don't see anywhere in there you're telling it to build the code at 0x18000. Where is it building , you can tell after you build it from the memory line it shows at the end. I suspect it's 0x00000000 (it is, I just tried it)
    3. I don't see the line in the Flash segment telling it NOT to erase the whole flash when it loads up the code so it's just blowing away everything on the chip and then probably putting the code in the wrong place
    4. I don't see anywhere the definition of debug_entry_point_symbol to 'nonexistant' so debugging wouldn't work anyway
    5. That import most likely imports the arm_startup.s file for Keil which I don't recall ever getting to work properly with Crossworks although I never tried very hard and just used the one they supply.

    As I suggested in mail the other day, the Keil import to Crossworks isn't really softdevice-aware and gets you some of the way but not all of the way. I did also import using the template I sent you the other day, I had to remove the duplicated startup files and then go set a softdevice in the properties but that got it to build in the right place and the flash erase / debug options seemed correctly set. I didn't try the resulting code however.

    Anyway what you're doing wrong is expecting the Keil import into Crossworks to 'just work', it won't just work, it just gets the basic files imported ready to build which is far from everything you need.

    Oh and is the code really 'hanging' at the softdevice init? did you try pressing break to see where you are? I assume that, without a softdevice installed and the code at the wrong place you probably just looping in the default SWI0_IRQHandler which is an endless loop.

  • thanks for this, didn't know about the Nordic thread on the crossworks site!

Reply Children
No Data
Related