Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832 can not be flashed

I'm using a custom board designed around this nRF52832 module. I have broken out SWIO/SWCLK/SWO and nRF_RST to a standard Arm 10-pin header.

Using Black Magic Probe, I was able to flash a few test firmware to the device (but with errors).

At the end, I tried the sdk blinky example (nRF5_SDK_17.0.2_d674dde/examples/peripheral/blinky/pca10040/blank/armgcc) with my `custom_board.h` which is defined like this: 

#ifndef CUSTOM_BOARD_H
#define CUSTOM_BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "nrf_gpio.h"

// LEDs definitions for my custom board
#define LEDS_NUMBER    2

#define LED_START      4
#define LED_0          4
#define LED_1          5
#define LED_STOP       5

#define LEDS_ACTIVE_STATE 1
#define LEDS_LIST { LED_0, LED_1}

#define BSP_LED_0      LED_0
#define BSP_LED_1      LED_1
/* #define BSP_LED_0_MASK (1<<BSP_LED_0) */
/* #define BSP_LED_1_MASK (1<<BSP_LED_1) */

/* #define LEDS_MASK                                                        \ */
/*     (BSP_LED_0_MASK | BSP_LED_1_MASK | BSP_LED_2_MASK | BSP_LED_3_MASK | \ */
/*      BSP_LED_4_MASK) */
// Defines which LEDs are lit when the signal is high. 
#define LEDS_INV_MASK  ~LEDS_MASK



/* #define SPIM0_SCK_PIN       25 */     
/* #define SPIM0_MOSI_PIN      24 */     
/* #define SPIM0_MISO_PIN      23 */     
/* #define SPIM0_SS_PIN        30 */     


// UART
#define RX_PIN_NUMBER  2
#define TX_PIN_NUMBER  3
#define HWFC           false

// Low frequency clock source to be used by the SoftDevice
#define NRF_CLOCK_LFCLKSRC      NRF_CLOCK_LFCLKSRC_XTAL_20_PPM
/* #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \ */
/*                                  .rc_ctiv       = 0,                                \ */
/*                                  .rc_temp_ctiv  = 0,                                \ */
/*                                  .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} */

#ifdef __cplusplus
}
#endif

#endif

And here is the main.c: 

/** @file
 *
 * @defgroup blinky_example_main main.c
 * @{
 * @ingroup blinky_example
 * @brief Blinky Example Application main file.
 *
 * This file contains the source code for a sample application to blink LEDs.
 *
 */

#include <stdbool.h>
#include <stdint.h>

#include "boards.h"
#include "nrf_delay.h"
#define BOARD_CUSTOM 1

/**
 * @brief Function for application main entry.
 */
int main(void) {
    /* Configure board. */
    bsp_board_init(BSP_INIT_LEDS);

    /* Toggle LEDs. */
    while (true) {
        for (int i = 0; i < LEDS_NUMBER; i++) {
            bsp_board_led_invert(i);
            nrf_delay_ms(500);
        }
    }
}

/**
 *@}
 **/

BMP, flashed the firmware **with erros**. Upon recycling the voltage of the target, the blinky example works (the two leds blink sequentially) 

Problem is, I can no longer flash the MCU! BMP reports `SW-DP scan failed!` which means the target is not responding.  

1. Could the blinky firmware have bricked the device?

2. How can I recover from this state?

Parents
  • Maybe it's the system clock cycle issue. In your customer board definition. The system apply for 32Khz low frequency crystal. Have you ever check that the system clock is normal or not?...If it get some trouble, the jlink SW-DP will be scanned fail.  By the way, may you show the Jlink connection between customer board & segger EDU especial the target power side?

Reply
  • Maybe it's the system clock cycle issue. In your customer board definition. The system apply for 32Khz low frequency crystal. Have you ever check that the system clock is normal or not?...If it get some trouble, the jlink SW-DP will be scanned fail.  By the way, may you show the Jlink connection between customer board & segger EDU especial the target power side?

Children
  • Thanks for your reply.

    I'm using Black Magic Probe which is a FOSS firmware able to flash/debug Arm Cortex devices. I don't have any JLinks currently. I was able to flash/debug nRF51822 and STM32F103 with BMP.

    I'm powering the target directly from the 3v3 of BMP debugger.

    Do you think the clock define in line 46 of `custom_board.h` may have something to do with this?

    Even if that is the case, I don't know why the target is not responding to SW signals.

Related