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

Programming custom board through SES corrupts host device's bootloader

I am using a nRF52 DK to program an externally powered board with a NRF52811. 

I am able to flash a blinky program onto the custom board successfully using the output .hex files after building in SES

However, when I try to Start Execution while Debug has been selected, the DK will only show up as a corrupted USB device and is not able to flashed until I re-upload the bootloader software onto it. It is still able to be found by nRFgo Studio but it requires that I select a NRF51 device as it is unknown to the version of J-link software.

Furthermore, my custom board will not be programmed by starting execution. The program will build successfully but it will usually give me a hardFault.

This is a problem as I need to test programs that use a serial terminal. Any direction would be appreciated

I am using VDDnRF, VDD, VTC, SWDIO, SWDCLK, RESET, GND DETECT from the development kit to program my board

Update 1: Since using the recover option that nRFgo provides on my development, I am no longer able to flash blinky onto my custom board

Update 2: A fresh install of everything Nordic related seemed to fix my issue regarding flashing blinky, however I am still faced with the hardFault errors for most examples (see my reply below)

Parents Reply Children
  • Hi Bjorn, this one worked. No idea why my one didn't work originally after modifying everything. For anyone having similar problems to me here is a guide for running the twi_scanner example on nRF52811 hardware, if starting from a non-emulated project (i.e. pca10056):

    .emProject file modifications

    1. Right Click the project in the Project Explorer. In this case it will be named 'twi_scanner_pca10056'
    2. Select 'Open Solution in Editor' from the menu that appears.
    3. Change arm_fp_abi from "Hard" to "Soft"
    4. Change arm_fpu_type from "FPv4-SP-D16" to "Soft"
    5. Change arm_target_device_name from "nRF52840_xxAA" to "nRF52811_xxAA"
    6. Add in any directories you might want to use to c_user_include_directories
    7. Change in c_preprocessor_definitions:
      1. BOARD_PCA10056 to your custom board
      2. FLOAT_ABI_HARD to FLOAT_ABI_SOFT
      3. NRF52840_XXAA to NRF52811_XXAA
    8. Change debug_register_definition_file from "../../../../../../modules/nrfx/mdk/nrf52840.svd" to "../../../../../../modules/nrfx/mdk/nrf52811.svd"
    9. Change linker_section_placement_macros:
      1. FLASH_PH_SIZE=0x100000 to 0x30000
      2. RAM_PH_SIZE=0x40000 to 0x6000
      3. FLASH_SIZE=0x100000 to 0x30000
      4. RAM_SIZE=0x40000 to 0x6000
    10. Under <folder Name="None">
      1. <file file_name="../../../../../../modules/nrfx/mdk/ses_startup_nrf52840.s" /> change to <file file_name="../../../../../../modules/nrfx/mdk/ses_startup_nrf52811.s" />
      2. <file file_name="../../../../../../modules/nrfx/mdk/system_nrf52840.c" /> change to <file file_name="../../../../../../modules/nrfx/mdk/system_nrf52811.c" />

    sdk_config.h modifcations

    The reason I have included these is to use them as an example of the things you might have to change in a separate example.

    1. NRFX_TWIM0_ENABLED from 0 to 1
    2. NRFX_TWI0_ENABLED from 0 to 1
    3. TWI1_ENABLED from 1 to 0
    4. UART_LEGACY_SUPPORT from 1 to 0

    In order to get things printing in the Debug Terminal

    1. NRF_LOG_BACKEND_RTT_ENABLED from 0 to 1
    2. NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED from 1 to 0
    3. NRF_LOG_BACKEND_UART_ENABLED from 1 to 0

    main.c modifications

    1. Change your pin assignments

    Thank you Bjorn for all your help.

    I suggest Nordic provide clearer instructions in future for this kind of thing, as their instructions left out many things that Bjorn has helped with that are crucial for transferring examples to different hardware.

Related