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

nrf52810 basics in Keil

I'm new to the NRF series, and for that matter Keil.  I have a BT832A which is apparently an NRF52810.

I am able to flash my own code using Keil and and control GPIOs to Charlieplex LEDs using an ST-Link and the following settings:

Debug or Utilities:

Use ST-Link Debugger -> Settings

  • Flash Download:
    • Erase Full Chip
    • RAM for Algorithm: Start: 0x20000000  Size: 0x2000
    • Programming Algorithm: NRF52xxx SoftDevice Erase
    • Size 2M 00000000H - 001FFFFFH

Device:

Nordic Semiconductor

  • NRF52 Series:
    • nRF52832_xxAA

Target:

  • R/O Memory Areas: 
    • IROM1: Start:0x0 Size:0x9A4
  • R/W Memory Areas:
    • IRAM1: Start: 0x20000000 Size: 0x2008

On build: Program Size: Code=1336 RO-data=1128 RW-data=4 ZI-data=8196  

I use RW+ZI for Ram Size in the target and I use Code+RO+RW for Rom Size in the target.  This appears to be right because if I reduce either my Ram or Rom size by 1 I get an error that it wont fit and if I use the calculation as is the program loads and my lights flash.

Ok so basics work, I know my stlink works, I know keil works, and I know my basic understanding of the R/O and R/W target settings is good.

-----

My problem is when it comes to actually using a soft device I cant get anything to load from the examples that will let me see a BLE device.  

Using either SoftDevice S112 or SoftDevice S132 I have tried to load the soft device first with Keil uVision by creating a blank project, locating the hex file on the output tab, setting up my stlink with the NRF52xxx SoftDevice Erase as above, and target sizes based on the same algorithm.

s112_nrf52810_5.1.0  s112_nrf52810_5.1.0_softdevice.hex

  • Flash 96k (0x18000 bytes)
  • RAM 3.68k (0xeb8 bytes)

s132_nrf52_6.1.0  s132_nrf52_6.1.0_softdevice.hex

  • Flash 152k (0x26000 bytes)
  • Ram 5.54k (0x1628 bytes)

Load "..\\Downloads\\s112_nrf52810_5.1.0\\s112_nrf52810_5.1.0_softdevice.hex"
Full Chip Erase Done.
Programming Done.
Verify OK.
Flash Load finished at 17:24:34

Next I open one of the example projects, such as UART over BLE:

ble_app_uart_s132_pca10040.uvprojx

Builds to: Program Size: Code=16456 RO-data=708 RW-data=216 ZI-data=10112  

Program Size: 17,380 (0x43E4)

Ram Size: 10,328 (0x2858)

So I also setup my programming algorithm the same to NRF52xxx SoftDevice Erase but I tell it not to erase anything because I did that in the previous load.  I set my target as follows:

  • IROM1: Start: 0x18000  Size: 0x43E4
  • IRAM1: Start: 0x20000eb8 Size: 0x2858

Builds with no errors.

Loads with no errors:

*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'nrf52832_xxaa_s132'
linking...
Program Size: Code=16456 RO-data=708 RW-data=216 ZI-data=10112
FromELF: creating hex file...
".\_build\nrf52832_xxaa_s132.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:00
Load "C:\\Users\\packe\\Documents\\ble_peripheral\\ble_app_uart\\pca10040\\s132\\arm5\\_build\\nrf52832_xxaa_s132.axf"
Programming Done.
Verify OK.
Application running ...
Flash Load finished at 17:38:24

----

But no BLE devices!?

---- 

If I take the same soft device and I use my generic gpio flashing code set using the same calculation it builds and loads into 0x18000 and 0x20000EB8 with only "erase sectors" selected and it runs!  

So the BLE Soft device must be loading and running to 0x18000 or it wouldnt be flashing my lights afterwards.

Why no BLE device?  

Parents
  • Hi,

    If you have not done so already then you should have a look at the Developing for nRF52810 User Guide, as well as Using the SDK with other boards.

    Flash and memory placement/usage for the SoftDevice is shown in Memory resource map and usage. The MBR is part of the SoftDevice, and so the SoftDevice hex files contains MBR Vector Table, Master Boot Record, SoftDevice Vector Table and Softdevice.

    For s112 v5.1.0 APP_CODE_BASE should be 0x18000 and APP_RAM_BASE should be at least 0x20000eb8, but depending on SoftDevice configuration it may be more. If more is needed than what is given you should get debug output from the application. That means if you enable UART or RTT logging you should get notified about the correct APP_RAM_BASE.

    If you try an example from the SDK this should already be in order, as long as you make sure to use a pca10040e example and a compatible version of the s112 SoftDevice. For instance, for s112 v5.1.0 this means you can use the examples from SDK 14.2.

    Regards,
    Terje

Reply
  • Hi,

    If you have not done so already then you should have a look at the Developing for nRF52810 User Guide, as well as Using the SDK with other boards.

    Flash and memory placement/usage for the SoftDevice is shown in Memory resource map and usage. The MBR is part of the SoftDevice, and so the SoftDevice hex files contains MBR Vector Table, Master Boot Record, SoftDevice Vector Table and Softdevice.

    For s112 v5.1.0 APP_CODE_BASE should be 0x18000 and APP_RAM_BASE should be at least 0x20000eb8, but depending on SoftDevice configuration it may be more. If more is needed than what is given you should get debug output from the application. That means if you enable UART or RTT logging you should get notified about the correct APP_RAM_BASE.

    If you try an example from the SDK this should already be in order, as long as you make sure to use a pca10040e example and a compatible version of the s112 SoftDevice. For instance, for s112 v5.1.0 this means you can use the examples from SDK 14.2.

    Regards,
    Terje

Children
  • It looks like SDK14.2 is not available to download anymore, however the pca10040e device with s112 does exist in examples in nRF5_SDK_15.0.0_a53641a.

    I tried loading multiple examples from the examples\ble_peripheral folder including ble_app_blinky, beacon, uart, and template.  

    In each case I would load the .uvprojx file from ble_peripheral\[examplename]\pca10040e\s112\arm5_no_packs.

    The examples in SDK 15.0.0 use s112_nrf_6.0.0 which according to documentation has the following properties:

    • Flash: 0x19000
    • Ram: 0xF70

    The default target app codebase options for the project files specify the following which does not match calculations:

    • rom: start: 0x19000, size: 0x17000
    • ram: start: 0x20002480, size 0x3b80

    First I switch to change the target to:

    • rom start: 0x0 size: 0x19000
    • ram start: 0x20000000 size: 0xf70

    Then I switch to the project, comple, and set my new targets starting at where the soft device ended.  I can get everything to load fine but I never see any advertising.

    I do not have an external xtal or buttons, I'm just working with the bt232a package.

Related