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

SDK 7.2 - DFU Bootloader - HardFault after calling sd_mbr_command

  • SoftDevice : S110 7.1

  • SDK 7.2

  • Example : dfu\bootloader (using dual bank)

  • Using IAR 7.1

(Before debugging with IAR, I downloaded both the bootloader.hex and s110 7.1 hex with nrfjprog.exe)

  • Modified SDK files : bootloader_util_arm.c (copied asm code from SDK 8.1 files since I use ICCARM,

thanks to Vidar Berg for answering my prev question.)

  • Using nRFGo Studio 1.19.0

  • Board : PCA10001 V 2.0.0 (Rev. 2 MCU)

/****************/

First, I used the nrfjprog.exe. The command was

nrfjprog.exe --eraseall --programs s110_nrf51822_7.1.0_softdevice.hex --program bootloader.hex --dfu --verify --reset

After the board being reset, while running the example at debug mode,

the program fell into the HardFault_handler.

What is the problem?

Added : 8, July, 2015 DFU 7.2bootloader.zip Here you go.

I also attached the SDK 7.2 files since I changed bootloader_util_arm.c.

Also you can save time for setting include paths.

Yes, I migrated and made the project manually.

Added : 11, July, 2015 : I changed the linker script (dfu7_2.icf).

linker script

Thanks to Vidar Berg's answer, I followed Vidar's setting.

code opt

As Aryan said, the code optimization level is changed.

However, if I choose High - Speed (checked "No size constraints"),

linker

the linker showed an error about the size. So I chose "Balanced".

code

Without HardFault, it went well.

iOS 1

iOS 2

I checked with the iOS App. It was successful.

As well as Android, it was fine.

Android 1

Android 2

Before accepting the answer, pardon me for asking,

I want to correct my idea (which could be a serious misconception).

Previously I set the linker script as

// Previously, Linker Script of the bootloader example. My other projects also followed this setting.

.invec start = 0x00016000

ROM = 0x00016000 ~ 0x0003FFFFF

RAM = 0x20002000 ~ 0x20003FFFF

I used this setting all the time when trying other examples as well.

I understood as both the flash memory 0x0 ~ 0x00016000 (or lower) and

the RAM 0x20000000 ~ 0x20002000 (or lower)

was occupied with codes and data of S110 (ver 7.2).

  1. Am I thinking it correctly?

  2. The memory layout (dual bank) shows that the MBR (Master Boot Record) is at the bottom of the memory.

Does the SoftDevice moves it location from 0 to 0x001000 while initializing the bootloader?

Or when I program the SoftDevice with the nRFgo studio, does the studio

programs the SoftDevice at 0x001000 including the MBR?

  1. After this, I want to insert my firmware(Application, as specified at the memory layout)

to the board. Then, does my firmware's linker script settings follow the same value?

Or does it use the same value like I did?

// Linker Script of my Project (after downloading the bootloader)

.invec start = 0x0003C000 Or 0x00016000 ?

ROM = 0x0003C000 ~ 0x0003FBFF Or 0x00016000 ~ 0x0003FFFFF Or 0x00016000 ~ 0x0003BFFF ?

RAM = 0x20002C00 ~ 0x20003F7F Or 0x20002000 ~ 0x20003FFFF Or 0x20002000 ~ 0x20003F80?
  1. At Keil uVision, when setting iRAM and iROM, there is an option selecting "no init".

Is there the same feature in IAR? Or does this has to be done manually?

Added 15, July, 2015 : I added a picture about the RAM.

RAM

This is the original setting at the bootloader example (SDK 7.2).

-Regards, Mango922

Parents
  • Hi Mango922,

    Unfortunately, I do not have IAR installed on my home computer, but I can spot one issue. Your linker file, dfu7_2.icf, does not have the correct start address for the DFU bootloader start address set in dfu_types.h::BOOTLOADER_REGION_START.

    You'll then get a hardfault as the softdevice forwards you to an unprogrammed section of the flash. Change these sections in the linker script:

    *snip*
    /*-Specials-*/
    define symbol __ICFEDIT_intvec_start__ = 0x0003C000;
    /*-Memory Regions-*/
    define symbol __ICFEDIT_region_ROM_start__ = 0x0003C000;
    *snip*
    

    Forgive me if I am forgetting/not seeing any other issues, I'll team up with @Aryan tomorrow if you have any other issues.

    Cheers, Håkon

Reply
  • Hi Mango922,

    Unfortunately, I do not have IAR installed on my home computer, but I can spot one issue. Your linker file, dfu7_2.icf, does not have the correct start address for the DFU bootloader start address set in dfu_types.h::BOOTLOADER_REGION_START.

    You'll then get a hardfault as the softdevice forwards you to an unprogrammed section of the flash. Change these sections in the linker script:

    *snip*
    /*-Specials-*/
    define symbol __ICFEDIT_intvec_start__ = 0x0003C000;
    /*-Memory Regions-*/
    define symbol __ICFEDIT_region_ROM_start__ = 0x0003C000;
    *snip*
    

    Forgive me if I am forgetting/not seeing any other issues, I'll team up with @Aryan tomorrow if you have any other issues.

    Cheers, Håkon

Children
No Data
Related