Dear @erikr,
I have managed to spend quite some time on what you described and tried to replicate it. It seems I may have found what is causing problems here.
I started with a FreeRTOS hello world project and proceeded to build it (simply to get a project on the R7). Following that I took over the relevant parts of your overlay. With that done I started to alter the hello world code to suite the interrupt handling of the GPIO. There were a few things that stood out here. First off, you will likely have to disable the gpio3 as well, since it will otherwise not take over the configurations made further down the line. I presume that this is in fact what is causing the trouble in your case.
looking into the source files used for the device tree I furthermore saw, that the node nau8822_1a
needs to be disabled as well as sound
.
I had access to both the linux CLI (via ttyUSB3
) as well as the serial console of the M7 (via ttyUSB2
). This was achieved with the instructions from this developer page in uboot. However, instead of the command:
setenv cm_boot "${load_cm_image}; cp.b ${loadaddr} 0x7e0000 ${cm_image_size}; dcache flush; bootaux 0x7e0000"
I used:
setenv cm_boot 'ext4load mmc 2:2 $ramdisk_addr_r $cm_image; dcache flush; bootaux $ramdisk_addr_r'
To get the serial console running while Linux was booted I used this command:
setenv tdxargs clk-imx8mp.mcore_booted=1
With all that said, here is what my overlay looks like:
/dts-v1/;
/plugin/;
/ {
compatible = "toradex,verdin-imx8mp";
};
&sai1 {
status = "disabled";
};
&sai5 {
status = "disabled";
};
&gpio3 {
status = "disabled";
};
&nau8822_1a {
status = "disabled";
};
&{/sound} {
status = "disabled";
};
Finally here is the altered hello world I used to test the gpio you mentioned:
/*
* Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
* Copyright 2016-2017, 2024 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "fsl_device_registers.h"
#include "fsl_debug_console.h"
#include "fsl_common_arm.h"
#include "fsl_gpio.h"
#include "board.h"
#include "app.h"
/*******************************************************************************
* Definitions
******************************************************************************/
// GPIO3 22 / SODIMM 32 / I2S_1_SYNC => BUTTON1
#define BUTTON1_GPIO GPIO3
#define BUTTON1_GPIO_PIN 22
/*******************************************************************************
* Prototypes
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/
/*******************************************************************************
* Code
******************************************************************************/
/*!
* @brief Main function
*/
void GPIO3_Combined_16_31_IRQHandler(void)
{
PRINTF("IRQ Handler\r\n");
IRQ_ClearPendingIRQ(GPIO3_Combined_16_31_IRQn);
GPIO_PortClearInterruptFlags(BUTTON1_GPIO, GPIO_PortGetInterruptFlags(BUTTON1_GPIO));
PRINTF("Button State: %d\r\n", GPIO_PinRead(BUTTON1_GPIO, BUTTON1_GPIO_PIN));
PRINTF("IRQ Handler done\r\n");
SDK_ISR_EXIT_BARRIER;
}
void BUTTON1_Init(void) {
PRINTF("Button init\r\n");
gpio_pin_config_t gpio_config = {kGPIO_DigitalInput, 0, kGPIO_IntRisingOrFallingEdge};
GPIO_PinInit(BUTTON1_GPIO, BUTTON1_GPIO_PIN, &gpio_config);
GPIO_SetPinInterruptConfig(BUTTON1_GPIO, BUTTON1_GPIO_PIN, kGPIO_IntRisingOrFallingEdge);
GPIO_PortEnableInterrupts(BUTTON1_GPIO, 1U << BUTTON1_GPIO_PIN);
NVIC_SetPriority(GPIO3_Combined_16_31_IRQn, 5);
EnableIRQ(GPIO3_Combined_16_31_IRQn);
PRINTF("Button init done\r\n");
}
int main(void)
{
char ch;
/* Init board hardware. */
BOARD_InitHardware();
BUTTON1_Init();
PRINTF("Button State: %d\r\n", GPIO_PinRead(BUTTON1_GPIO, BUTTON1_GPIO_PIN));
PRINTF("hello world.\r\n");
while (1)
{
ch = GETCHAR();
PUTCHAR(ch);
}
}
Please let me know if this approach works for you as well.
Best regards,
Collin