Cannot flash onto a nRF52832 QFAB custom board via a nRF52-DK

I have a custom board with a nRF52832 QFAB at its center, and I want to program it via a nRF52-DK. I have created a custom board directory and have initialized a few led pins on it using the description in the tutorial. I am also using the nRF Connect Extension for VS Code. I added a CONFIG_SECURE_BOOT=y, and am using the extension to build and flash onto the board. When I try to flash it, I get the following error. This happens whether or not I erase and flash or just simply flash.

-- west flash: using runner nrfjprog
-- runners.nrfjprog: reset after flashing requested
-- runners.nrfjprog: Flashing file: c:\ncs\blinky_evoke\build_4\zephyr\merged.hex
[ #################### ]   1.723s | Erase file - Done erasing                                                          
[error] [ Client] - Encountered error -102: Command program_file executed for 628 milliseconds with result -102        
[error] [  nRF52] - The write access failed, but no cause could be determined.
[error] [  nRF52] - It may be due to an unaligned access, accessing a nonexistent memory, or a communication issue.
[error] [  nRF52] - Failed while performing 'Write' operation on target address 0x00000000. 
-102: An unknown error.
[error] [  nRF52] - Failed while reading device information.
[error] [ Worker] - An unknown error.
ERROR: JLinkARM DLL reported an error. Try again. If error condition
ERROR: persists, run the same command again with argument --log, contact Nordic
ERROR: Semiconductor and provide the generated log.log file to them.
NOTE: For additional output, try running again with logging enabled (--log).
NOTE: Any generated log error messages will be displayed.
FATAL ERROR: command exited with status 33: nrfjprog --program 'c:\ncs\blinky_evoke\build_4\zephyr\merged.hex' --sectoranduicrerase --verify -f NRF52 --snr 1050398990

I get a similar error when I connect the board using the nRF connect for desktop programmer app.

13:08:25.932	Initialising nrfutil module: device
13:08:33.170	Using nrfutil-device core version: 7.13.0
13:08:34.329	Using nrfutil-device version: 2.1.1
13:08:34.329	Using nrf-device-lib version: 0.17.5
13:08:34.330	Using nrfjprog DLL version: 10.24.0
13:08:34.331	Using JLink version: JLink_V7.96e
13:08:34.331	Installed JLink version does not match the expected version (JLink_V7.94e)
13:08:34.917	Getting serialport options from persistent store 001050398990.pc-nrfconnect-programmer
13:08:39.583	Error: Failed with exit code 1. Failed to device info one or more devices: * 1050398990: [jlink] JLINKARM_DLL_ERROR, code: Nrfjlink. Message: Operation device-info failed, [jlink] JLINKARM_DLL_ERROR.
13:08:39.587	Using nrfutil device to communicate with target via JLink
13:08:43.617	Reading readback protection status for Application core
13:08:43.619	Failed "reading readback protection status for application core". Error: code: 9, description: Nrfjlink, message: Batch task protection-get failed, [jlink] JLINKARM_DLL_ERROR
13:08:43.901	Error: Failed with exit code 1. One or more batch tasks failed: - [jlink] JLINKARM_DLL_ERROR, code: Nrfjlink. Message: Batch task protection-get failed, [jlink] JLINKARM_DLL_ERROR.
13:08:43.902	Error: Failed with exit code 1. One or more batch tasks failed: - [jlink] JLINKARM_DLL_ERROR, code: Nrfjlink. Message: Batch task protection-get failed, [jlink] JLINKARM_DLL_ERROR.

The log.log  contains this 

[2024-Jul-03 12:43:27] [debug] --------------------------------------------------------------------------------
[2024-Jul-03 12:43:27] [debug] C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin\nrfjprog.exe --family NRF52 --program merged.hex --chiperase --log 
[2024-Jul-03 12:43:27] [debug] nrfjprog version 10.24.2 external
[2024-Jul-03 12:43:27] [debug] --------------------------------------------------------------------------------
[2024-Jul-03 12:43:27] [ info] Load library at C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin\nrfjprog.dll.
[2024-Jul-03 12:43:27] [ info] Library loaded, loading member functions.
[2024-Jul-03 12:43:27] [ info] Member functions succesfully loaded.
[2024-Jul-03 12:43:27] [debug] [ Client] - open
[2024-Jul-03 12:43:27] [debug] [ Client] - start
[2024-Jul-03 12:43:27] [ info] [ Client] - stdout: Jlinkarm nRF Worker ready. Handling sequence 3e50e784-bf23-424d-bc2f-d8baf62cd201.

[2024-Jul-03 12:43:27] [debug] [SeggerBackend] - Logger sink registered in Segger backend logger
[2024-Jul-03 12:43:27] [debug] [  JLink] - Logger sink registered in JLink logger
[2024-Jul-03 12:43:27] [debug] [  nRF52] - open
[2024-Jul-03 12:43:27] [debug] [  nRF52] - just_check_family
[2024-Jul-03 12:43:27] [debug] [SeggerBackend] - open_dll
[2024-Jul-03 12:43:27] [debug] [SeggerBackend] - No J-Link DLL path was provided. Attempting to auto detect.
[2024-Jul-03 12:43:27] [ info] [SeggerBackend] - Load library at C:\Program Files\SEGGER\JLink_V796e\JLink_x64.dll.
[2024-Jul-03 12:43:27] [trace] [ Client] - Command open executed for 95 milliseconds with result 0
[2024-Jul-03 12:43:27] [debug] [ Client] - config
[2024-Jul-03 12:43:27] [ info] [SeggerBackend] - Library loaded, loading member functions.
[2024-Jul-03 12:43:27] [trace] [ Client] - Command config executed for 14 milliseconds with result 0
[2024-Jul-03 12:43:27] [ info] [SeggerBackend] - Member functions succesfully loaded.
[2024-Jul-03 12:43:27] [debug] [ Client] - enum_emu_snr
[2024-Jul-03 12:43:27] [debug] [SeggerBackend] - Set batch mode
[2024-Jul-03 12:43:27] [debug] [SeggerBackend] - dll_version
[2024-Jul-03 12:43:27] [ info] [SeggerBackend] - Segger dll version 7.96.e loaded.
[2024-Jul-03 12:43:27] [trace] [ Worker] - Command open executed for 12 milliseconds with result 0
[2024-Jul-03 12:43:27] [debug] [  nRF52] - config
[2024-Jul-03 12:43:27] [debug] [SeggerBackend] - enum_emu_snr
[2024-Jul-03 12:43:27] [trace] [ Worker] - Command config executed for 10 milliseconds with result 0
[2024-Jul-03 12:43:28] [debug] [  nRF52] - enum_emu_con_info
[2024-Jul-03 12:43:28] [trace] [ Client] - Command enum_emu_con_info executed for 15 milliseconds with result 0
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - is_connected_to_emu
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - enum_emu_con_info
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - is_connected_to_emu
[2024-Jul-03 12:43:28] [trace] [ Worker] - Command enum_emu_con_info executed for 5 milliseconds with result 0
[2024-Jul-03 12:43:28] [debug] [  nRF52] - close
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - is_connected_to_emu
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - close
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - disconnect_from_emu
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - is_connected_to_emu
[2024-Jul-03 12:43:28] [debug] [SeggerBackend] - Segger Backend closed.
[2024-Jul-03 12:43:28] [debug] [  nRF52] - nRF family DLL closed
[2024-Jul-03 12:43:28] [trace] [ Worker] - Command close executed for 18 milliseconds with result 0
[2024-Jul-03 12:43:28] [trace] [ Client] - Command close executed for 27 milliseconds with result 0
[2024-Jul-03 12:43:28] [debug] [ Client] - terminate
[2024-Jul-03 12:43:28] [trace] [ Client] - Command terminate executed for 0 milliseconds with result 0
[2024-Jul-03 12:43:28] [trace] [ Worker] - Command terminate executed for 0 milliseconds with result 0
[2024-Jul-03 12:43:28] [trace] [ Worker] - Executed 5 commands for 45 milliseconds
[2024-Jul-03 12:43:28] [debug] [ Client] - Worker process exited with code: 0
[2024-Jul-03 12:43:28] [debug] [ Client] - Worker process exited with code: 0
[2024-Jul-03 12:43:28] [debug] [ Client] - Child process terminated with result 0
[2024-Jul-03 12:43:28] [trace] [ Client] - Executed 5 commands for 151 milliseconds
[2024-Jul-03 12:43:28] [debug] [ Client] - terminate

  • Hello,

    It's strange that it is failing to write to address 0x0 as this is an valid address. Please try running 'nrfjprog --recover' from the command line to see if this results in any errors. This should help us narrow down the problem. Additionally, please check that the VDD voltage on the DK matches the voltage on your custom board. The OB J-Link on the DK does not have a built-in level shifter, so it's important that the IO voltages match.

    Best regards,

    Vidar

  • Both the Vdd on the DK and the voltage on my custom board are 3.0V. The below is the result from the `nrfjprog --recover` command. It takes about 5-7 seconds to run. 

    nrfjprog --recover
    Recovering device. This operation might take 30s.
    Erasing user code and UICR flash areas.

    You mentioned that it failing to write at 0x0 is strange, could there be an issue in the way I am writing my code, or in the custom board definition somehow? 

  • Thanks. The fact that you are able to run the recover operation is a good indication that the chip is correctly powered and the SWD lines are correctly connected. My initial suspicion was that there might be an issue with the linker configuration since the xxAB package only has 256K of flash and 32K of RAM. However, address 0x0 is within the valid address range, so it seems like it might be something else.

    Here are some things you may want to check:

    - Check if your design includes the optional DCDC inductors. If not, it's important that you don't enable the internal DCDC regulator (i.e., CONFIG_BOARD_ENABLE_DCDC must not be selected). Without the inductors, the DCDC regulator will not be able to provide a stable supply internally on the chip, which usually leads to difficulties with programming the chip through the debug interface. However, I would have expected a different error message if this were the case.

    -  Check if the RAM and FLASH memory sections in the generated zephyr.map file under 'Output files' in the VS code extension has the correct address ranges. It should look like this if you are building an application without a bootloader:

    Name | Origin | Length | Attributes
    FLASH 0x0000000000000000 0x0000000000040000 xr
    RAM 0x0000000020000000 0x000000000008000 xw
    IDT_LIST 0x00000000fffff7ff 0x0000000000000800 xw
    *default* 0x0000000000000000 0xffffffffffffffff
     
    - If the optional 32KHz is not mounted on your board, set CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC to '=y' in your boards *_defconfig file to always use the internal RC oscillator. Having the wrong clock source selected will not cause issues with flashing, but it will prevent your programs from reaching main() since the startup code will get stuck waiting for the crystal to ramp up.
    I would also recommend trying a more basic sample first without CONFIG_SECURE_BOOT enabled. For instance, "hello_world" or "blinky.
  • Hey Vidar,
    I am trying a blinky example which works as expected on a nRF52DK.

    I added the flags you suggested. The memory config looks exactly as you suggested.

    When I remove "CONFIG_SECURE_BOOT=y" the build goes through and it flashes successfully, but I still don't see any GPIO toggles on my board. 


    The following is the overlay file for my custom board, which I use to define the pins which I wanna toggle. I expect to see a change in pins 14, 15 and 16. When I build the same code for the DK, as the led pin definitions are different, I see a toggle in led0, led1 and led2. With this overlay, I do not see any toggles in my custom board. How should I go ahead?

    / {
        aliases {
            led0 = &led0;
            led1 = &led1;
            led2 = &led2;
            // pin0 = &pin0;
        };
    
    
        soc{
            gpio0: gpio@50000000 {
                compatible = "nordic,nrf-gpio";
                reg = <0x50000000 0x300>;
                gpio-controller;
                #gpio-cells = <2>;
                status = "okay";
            };
        };
    
        // Optional: Define the LED node using GPIO pin 17
        leds {
            compatible = "gpio-leds";
            led0: led_0 {
                gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
            };
            led1: led_1 {
                gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
            };
            led2: led_2 {
                gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
            };
            // led3: led_3 {
            //     gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
            // };
        };
    
        zephyr,user{
            pin0-gpios = <&gpio0 17 0>;
        };
    };
    
    &gpiote {
        status = "okay";
    };

Related