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

How to program RedBear BLE nano (MDBT40, which integrate nrf51822) using Nordic SDK 12 (S130)

Hello Folks,

I am currently try to program RedBear BLE nano board (which is essentially nrf51822) using Nordic SDK v12, which has features of secure OTA. However after trying out for few days, it doesn't work as expect for a simple blinking examples. It would be appreciated if any one can indicate some tutorial on it. The system I used is Ubuntu 16.04.

  • currently the source file can be successfully compiled whose output files are in /examples/peripheral/blinky/pca10028/s130/armgcc/_build/nrf51422_xxac.hex

currently I assume that nrf51422_xxac.hex can be used as application .hex file for nrf51822.. I don't know how to build output of nrf51822_xxac.hex. And also where can I find the boot loader or build application code??;

  • Then I tried to merge this file with SoftDevice by using mergehex: ./mergehex -m s130_nrf51_2.0.1_softdevice.hex nrf51422_xxac.hex -o out.hex

  • Finally, I drag out.hex to virtual file system, created by DAPLink.

For ease of demonstration, I modified the blinking program as below, which pin 39 is P0.19, which corresponding to RedBear on board LED (the number is given by MDBT40).

 /* Configure board. */
bsp_board_leds_init();

nrf_gpio_cfg_output(39);
nrf_gpio_pin_set(39);

/* Toggle LEDs. */
while (true)
{
     nrf_gpio_pin_set(39);
     nrf_delay_ms(500);
     nrf_gpio_pin_clear(39);
     nrf_delay_ms(500);
}

For convenience, you may refer to RedBear pin map here: http://redbearlab.com/blenano/

Please let me know if you have any clue on making this simple blinking example work. Thanks!

  • AFIK. The blinky example does not use the SD

    Just flash the Hex file to 0x00000000 on the device

    The only issue you may possibly have , depending on which nRF51822 is on that board is the RAM size

    Check the blink linker .ld file and confirm that the RAM size matches your board

    e.g if the RBL board uses a nRF51822QFAA (or QFAB) its only 16k and the example may be configured for a 32k (QFAC) device

  • Thanks for your response! The one that MDBT40 used is nrf51822QFN48. However when I open the linker file, it says:

    MEMORY
    {
        FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
        RAM (rwx) :  ORIGIN = 0x20002080, LENGTH = 0x1f80
    }
    

    Would you mind explaining how shall I configure these 4 parameters (or how can I find it out from datasheet?) Thanks again!

  • QFN48 is the package type not the device model number

    Look at your chip and read the model number it should be nRF51822QFAA or nRF58122QFAC

    (It could be QFAB but this seems unlikely)

    Looking at those figures, the RAM actually starts at 0x20002000 and for QFAA is 16k = 0x4000

    So your linker settings would be fine even for the QFAA as 0x2080 + 0x1f80 = 0x4000

    Did you try without the SD, and just flash the blinky hex to 0x00000000

  • Thanks again Roger!

    I tried both hex file with and without SoftDevice. But it still doesn't work.

    I felt that there are 2 possibilities:

    • it doesn't have bootloader?? or do I need to combine bootloader with application code that I wrote?
    • The programmer doesn't flash firmware to correct location.. the programmer I used is called DAPLink www.sparkfun.com/.../14071. The way I did flash is just drag the file into virtual file system (VFS) created by DAPLink. So I am wondering do I need to buy a new programmer.

    Great appreciate for the suggestions.

  • You don't need a bootloader. The bootloader is only required if you need to do an Over The Air (OTA) update, or possibly update via serial

    I've not used DAPLink, but I think a lot of people use that and it works fine.

    BTW. I didnt notice before but pin p0.19 is just 19 not 39

    Can you try that

    If thats no good..

    Have you tried flashing some of the pre-made hex files, I think the PCA10028 hex files, with or without SD should work

    But you may not have the LED on the same pins as that board (PC10028)

    You can try flashing the PCA10028 becaon example as that may work

Related