Cannot get blinky working with nRF52805 on custom board

Hello!

I have a custom board with an nRF52805 on it and I am simply trying to run the Zephyr blinky example and verify I can see a GPIO toggling as my first step. I installed the nRF Connect desktop and all associated toolchains on Windows 11 and I'm using the VS Code extension to manage/build/flash etc. I have been able to build the blinky example code with a custom board build configuration + device tree (attached below) and flash it onto the board, but I have yet to be able to get GPIO P0.20 to toggle. This seems so basic, yet I can't even get this working Disappointed

This is my setup:

  1. Operating System: Windows 11
  2. Development Environment: VS Code with the nRF Connect extention, nRF Connect SDK v2.6.1
  3. Programmer: J-Link Edu
  4. MCU: nRF52805

Here is my main.c (unmodified blinky example code)

/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   1000

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)

/*
 * A build error on this line means your board is unsupported.
 * See the sample documentation for information on how to fix this.
 */
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);

int main(void)
{
	int ret;

	if (!gpio_is_ready_dt(&led)) {
		return 0;
	}

	ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
	if (ret < 0) {
		return 0;
	}

	while (1) {
		ret = gpio_pin_toggle_dt(&led);
		if (ret < 0) {
			return 0;
		}
		k_msleep(SLEEP_TIME_MS);
	}
	return 0;
}

and here is my custom board device tree :

(created using "create new board" option in VS Code nRF Connect, and then added gpio definitions following the nRF52-dk device tree)

// Copyright (c) 2024 Nordic Semiconductor ASA
// SPDX-License-Identifier: Apache-2.0

/dts-v1/;
#include <nordic/nrf52805_caaa.dtsi>

/ {
	model = "FreeFly-Main-Flex-V1";
	compatible = "aimrl,freefly-main-flex-v1";

	chosen {
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
	};


	leds {
		compatible = "gpio-leds";
		led0: led_0 {
			gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
			label = "Green LED 0";
		};
	
	};

	/* These aliases are provided for compatibility with samples */
	aliases {
		led0 = &led0;
	};

};


&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 0xc000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0xc000 0xa000>;
		};
		slot1_partition: partition@16000 {
			label = "image-1";
			reg = <0x16000 0xa000>;
		};
		scratch_partition: partition@20000 {
			label = "image-scratch";
			reg = <0x20000 0xa000>;
		};
		storage_partition: partition@2a000 {
			label = "storage";
			reg = <0x2a000 0x6000>;
		};
	};
};

&gpio0 {
	status = "okay";
};

&gpiote {
	status = "okay";
};

The only device I've added to my device tree so far is simply gpio0 and gpiote, and set gpio0 P0.20 as active high. I'm confused as to why I'm not getting P0,20 to toggle.

Cheers,

Parker

  • Hello,

    I don't see any issues with your code or device tree; everything looks good to me. You have configured the pin as `GPIO_OUTPUT_ACTIVE`, which means the LED should be ON initially. If the LED is off by default, you should use `GPIO_OUTPUT_INACTIVE` instead.

    Kind regards,

    Abhijith

  • I'm not entirely sure what the fix was, will have to do some more careful experiments, but I got the code to run after changing the build configuration optimization level to "Optimize for debugging" and power cycling the board. I might have inadvertently changed something else that I'm unaware of. Or maybe the MCU wasn't resetting properly after getting flashed. 

  • Hello,

    I'm glad to hear that you're making progress.
    To ensure everything is set up correctly, could you confirm whether your custom board includes a DC-DC converter? Additionally, please check your `prj.conf` file to see if there is a configuration enabling the DC-DC converter. You might want to try disabling it by setting `CONFIG_BOARD_ENABLE_DC_DC=n` and see if that resolves the issue.

    Kind regards,

    Abhijith

  • Hi Abhijith,

    The nRF52805 is wired to use the internal LDO, not the DC-DC converter on this board. There is nothing in the prj.conf that enables the DC-DC converter, just the GPIO. I tried adding CONFIG_BOARD_ENABLE_DC_DC=n, but it wouldn't compile. Also didn't see any other configuration options for enabling/disabling the nRF DC-DC converter.

    Thanks,

    Parker

  • Hello,

    Your software part (at least what you have shared) looks good to me. It might be something related to hardware, or maybe power cycling has reset peripherals and cleared states that might have been affected by previous runs, which made the board work. Optimizing for debugging configuration is ideal in the development stage but not when it comes to production/pre-production.

    Have you tested any other samples inside the custom board, and if so, how did it go?

    Kind regards,

    Abhijith

Related