This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM62X: The GPIO appears problem when exporting pin and writing value.

Part Number: PROCESSOR-SDK-AM62X

Hi Team,

Device tree related description

leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&usr_led_pins_default>;
		status = "disabled"

		led-0 {
			label = "heartbeat";
			gpios = <&main_gpio0 42 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
			function = LED_FUNCTION_HEARTBEAT;
			default-state = "off";
		};

		led-1 {
			label = "led1";
			gpios = <&main_gpio1 16 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "timer";
			led-pattern = <200 800>;
			default-state = "on";
		};

		led-2 {
			label = "led2";
			gpios = <&main_gpio1 17 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "timer";
			led-pattern = <300 700>;
			default-state = "on";
		};

		led-3 {
			label = "led3";
			gpios = <&main_gpio1 18 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "timer";
			led-pattern = <400 600>;
			default-state = "on";
		};

		led-4 {
			label = "led4";
			gpios = <&main_gpio1 19 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "timer";
			led-pattern = <500 500>;
			default-state = "on";
		};

	};

.....
&main_pmx0 {
......
	usr_led_pins_default: usr-led-pins-default {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x0ac, PIN_OUTPUT, 7) /* (L21) GPMC0_CSn1.GPIO0_42 */
			AM62X_IOPAD(0x1b8, PIN_OUTPUT, 7) /* (C13) SPI0_CS1.GPIO1_16 */
			AM62X_IOPAD(0x1bc, PIN_OUTPUT, 7) /* (A14) SPI0_CLK.GPIO1_17*/
			AM62X_IOPAD(0x1c0, PIN_OUTPUT, 7) /* (B13) SPI0_D0.GPIO1_18 */
			AM62X_IOPAD(0x1c4, PIN_OUTPUT, 7) /* (B14) SPI0_D1.GPIO1_19 */
		>;
	};
......
};

Reboot after changing the device tree

First operation:

echo 330 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio330/direction
echo 1 >/sys/class/gpio/gpio330/value
echo 0 >/sys/class/gpio/gpio330/value

The led light connected to the gpio will be on and off normally, the value of the GPIO register is

The GPIO is not released (echo 330> / sys / class / gpio / unexport) and there have three below cases:

reboot

Do the same operation after rebooting, the led light turns on and off normally, all the operation is the same as the first one .

reset

GPIO is not exported this time

when export the button, the error appears

The power button turn off and then turn on

The GPIO is also not exported currently , and the exported GPIO doesnt report an error, but cannot write the value.  Writes 1 or 0, cat is 0. The value of pin register is

Is this the bug of drive or GPIO pin has a mechanism of protection?

Beat Regards,

Susan Ren

  • 正常情况、导出gpio后reboot后情况、导出gpio后电源关闭再打开情况
    root@ok6254:~# echo 330 > /sys/class/gpio/export 
    [   66.668165] wangguan export_store
    [   66.668183] wangguan gpio_to_desc
    [   66.671502] wangguan gpio 330
    [   66.674877] wangguan gdev->base:314    gdev->base + gdev->ngpio:402 
    [   66.677864] wangguan return normal
    [   66.684210] wangguan desc->gdev->chip
    [   66.687624] wangguan status1 :0
    [   66.691276] wangguan status1 :0
    [   66.694622] wangguan status1 :0
    
    
    root@ok6254:~# cat /sys/kernel/debug/gpio 
    gpiochip2: GPIOs 314-401, parent: platform/601000.gpio, 601000.gpio:
     gpio-330 (                    |sysfs               ) in  lo 
     gpio-336 (                    |fixed-regulator-rgb ) out lo 
    
    gpiochip1: GPIOs 402-488, parent: platform/600000.gpio, 600000.gpio:
     gpio-433 (                    |net-5g-rst          ) out lo ACTIVE LOW
     gpio-437 (                    |phy_rstn            ) out lo 
     gpio-438 (                    |id                  ) in  lo 
     gpio-440 (                    |RT9186              ) out lo 
     gpio-441 (                    |fixed-regulator-lvds) out lo 
     gpio-442 (                    |phy_rstn            ) out lo 
     gpio-473 (                    |regulator-6         ) out lo 
    
    gpiochip0: GPIOs 489-511, parent: platform/4201000.gpio, 4201000.gpio:
    
    
    导出gpio后按下复位按键情况
    root@ok6254:~# echo 330 > /sys/class/gpio/export 
    [   40.124132] wangguan export_store
    [   40.124150] wangguan gpio_to_desc
    [   40.127480] wangguan gpio 330
    [   40.130830] wangguan gdev->base:337    gdev->base + gdev->ngpio:425 
    [   40.133787] wangguan gdev->base:425    gdev->base + gdev->ngpio:512 
    [   40.140159] wangguan return null
    [   40.146506] wangguan !desc
    [   40.149738] export_store: invalid wangguan GPIO 330
    -sh: echo: write error: Invalid argument
    root@ok6254:~# cat /sys/kernel/debug/gpio 
    gpiochip1: GPIOs 337-424, parent: platform/601000.gpio, 601000.gpio:
     gpio-359 (                    |fixed-regulator-rgb ) out lo 
    
    gpiochip0: GPIOs 425-511, parent: platform/600000.gpio, 600000.gpio:
     gpio-456 (                    |net-5g-rst          ) out lo ACTIVE LOW
     gpio-460 (                    |phy_rstn            ) out lo 
     gpio-461 (                    |id                  ) in  lo 
     gpio-463 (                    |RT9186              ) out lo 
     gpio-464 (                    |fixed-regulator-lvds) out lo 
     gpio-465 (                    |phy_rstn            ) out lo 
     gpio-496 (                    |regulator-6         ) out lo 
    root@ok6254:~# 

    After button resetting,the base value of gpio is changed.

    Our resetting circuit:

  • Hi Susan,

    the console log you provided shows the MCU_GPIO0 doesn't exist after "reset", which makes the base pin number of MAIN_GPIO1 (which the LED pin 330 belongs to) changed from 314 to 337. That is why pin 330 is no longer valid after "reset".

    Basically you shouldn't use a fixed GPIO number (330 in this case), instead, you need to query the chipset base pin number, and plus the offset to get the GPIO number you are going to use.

  • Hi Bin,

    Thanks for your response.

    The customer's understanding is that although the reset of the A core does not affect the M core, due to the failure of the MCU_GPIO to reset normally, the gpio chip number of the A core has changed, which affects the use of the A core itself.

    Customer would like to know will this situation be avoided?

    Thanks,

    Annie

  • Hi Annie,

    Is power-cycle the board an option?

  • Yes, customer has tried power-cycle. After power-cycle, the gpiochip number is normal. And there is no problem with the A core and the M core being reset together.
    This startup process is normal: Start the A core --> initialize the device tree to allocate the pins of the A core and the M core --> M core startup call. Because the reset button resets the A core, if push the button of reset at this time, it will cause the use of the M core to be abnormal.  Even affects the gpiochip number of the A core. This makes it seem that the A core is also has problem.

  • Hi Susan,

    What you described is expected. If the reset button connects to MAIN domain warm reset or MAIN domain POR, it only resets the MAIN domain, the MCU GPIO module doesn't get reset.

    In this case, MCU GPIO is used by the A core, so the MCU domain should be reset while the MAIN domain resets, the reset button should connect to MCU RESETz or MCU PORz pin, so it can trigger both MAIN domain and MCU domain reset.

  • But TI advertised that this CPU can support the M core to run independently, and now the premise of the M core running independently is that the pins of the M core cannot be initialized in the device tree of the A core. But if it is not initialized, these functions of the M core cannot be used normally. So this is the contradictory.

  • Hi Susan,

    But TI advertised that this CPU can support the M core to run independently

    I believe what is advertised is that AM62x can support the MCU domain to run independently from the MAIN domain, so that MAIN domain reset won't affect the MCU domain.

    The M core is the M4F CPU, while the MCU domain includes the M4F and some peripherals.

    In this customer's case, the MAIN domain uses MCU domain GPIO module. When the MAIN domain gets reset, the MCU domain GPIO module should be reset too. Otherwise, the MCU_GPIO won't be in the clean state to be initialized again. MCU RESETz or MCU PORz should be used in this case to reset both MAIN domain and MCU domain.

    This customer's case is not "M core running independently" because the MCU_GPIO is used by the MAIN domain.

    I don't see here is any contradiction. Please let me know if my explanation is still not clear to you.