Can not modify GPIO number to use to enter DFU mode with MCUboot on nRF52840dk

Hello,

I followed this tutorial in order to build MCUboot with serial recovery (using NCS v2.2.0 and nRF52840dk): https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/serial_recovery/mcuboot_serial_recovery_uart

I wanted to modify the button used to enter serial recovery (DFU mode) but even if I set CONFIG_BOOT_SERIAL_DETECT_PIN it was not working. Button 1 was always used no matter which button I was trying to use.
So I checked mcuboot code in NCS, and it seems like this config is deprecated. The only way to change button is to change the mcuboot_button0 alias which is defined in this file:
zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts

So my question is, how can I change button without touching at the NCS code?

BR,
Damien

  • Hello,

    The parameter that sets the button is set in nrf52840dk_nrf52840.dts, as you say. You can modify these variables locally in your project by adding a file called nrf52840dk_nrf52840.overlay. Just copy everything. However, since this is a configuration used by the bootloader, and not the project, you need to make sure that this file is located in a place that the mcuboot project will find it. Create a file with the path:

    <your project>\child_image\mcuboot\boards\nrf52840dk_nrf52840.overlay

    And write the following into that file:

    /*
     * Copyright (c) 2022 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    / {
    	/* These aliases are provided for compatibility with samples */
    	aliases {
    		mcuboot-button0 = &button1;
    	};
    };

    (or something other than button_1. You can call it whatever you like, but if you want to use a gpio that is not a button, you need to define that name in a similar way that button1 is defined in nrf52840dk_nrf52840.dts in your nrf52840dk_nrf52840.overlay file. 

    Best regards,

    Edvin

  • Hei,

    Thank you. It worked to change the button used with the DK in the overlay.

    But now the next question is, how can I replace the button press by an output GPIO pin that is set HIGH/LOW.
    I have a custom board where a GPIO pin of a rapsberry compute module is directly connected to the pin P0.25 (used by button 3 on the DK). How am I supposed to configure the GPIO in order to get the signal from the compute module?

    I tried this in the overlay file (for mcuboot child_image):

    / {
    
    	buttons {
    		compatible = "gpio-keys";
    		button3: button_3 {
    			gpios = <&gpio0 25 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    			label = "Push button switch 3";
    		};
    	};
    
    	aliases {
    		// /delete-property/ mcuboot-button0;
    		mcuboot-button0 = &button3;
    		mcuboot-led0 = &button0;
    	};
    };

    This is not working. I set the corresponding GPIO pin on the CM and then reset but it never enters serial recovery mode.

    PS: I am able to reset the module with an other GPIO pin (from the CM) which is directly connected to P0.18 on the nRF52840 SoC. So this is working as expected.

    BR,
    Damien

  • Try to isolate the issue. Are you able to use button 3 put the DK in serial recovery mode without using the raspberry pi? Please note that P0.25 is Button 3, not Button 4 (well, it depends on whether you are counting from 0 to 3 or 1 to 4, I guess. But I just want to check that this is not the issue). 

    Are you able to use P0.25 (Button 3) while resetting from the raspberry pi? Or does it only work if you reset using the physical button?

    BR,

    Edvin

  • I found out that I was using the wrong prototype board version, and that P0.25 was not wired yet.

    After using the right board, it was working as expected.

    Thank you for your help.

Related