zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.85k stars 6.61k forks source link

tests: gpio_basic_api: arduino not valid on different gpio controllers #78381

Closed FRASTM closed 3 weeks ago

FRASTM commented 1 month ago

Describe the bug test execution drivers.gpio.2pin_arduino fails in kernel panic on some stm32 boards because the overlay selects arduino connector pins on different GPIO controllers

Please also mention any information which could help others to understand the problem you're facing:

On some stm32 boards, like the nucleo_g474re, the arduino pins 8 & 9 are NOT on the same gpio bank

pin 8 <8 0 &gpioa 10 0>, / D2/ pîn 9 <9 0 &gpiob 3 0>, / D3 /

So the testcase runs into k_panic(); in the board_setup function:

    /* PIN_IN and PIN_OUT must be on same controller. */

    if (in_dev != out_dev) {
        printk("FATAL: output controller %s != input controller %s\n",
               out_dev->name, in_dev->name);
        k_panic();
    }

To Reproduce

Expected behavior Test passed or excluded

Impact CI failure

Logs and console output

FATAL: output controller gpio@48000400 != input controller gpio@48000000                                         
E: r0/a1:  0x00000004  r1/a2:  0x0000000a  r2/a3:  0x00000000                                                    
E: r3/a4:  0x00000004 r12/ip:  0x0800925f r14/lr:  0x080004d5                                                    
E:  xpsr:  0x21000000                                                                                            
E: Faulting instruction address (r15/pc): 0x080004e4                                                             
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0                                                               
E: Current thread: 0x20000228 (main)                                                                             
E: Halting system  

Environment (please complete the following information):

hakehuang commented 1 month ago

I think this is ST gpio dedicated issue, it requires the gpio on same bank, right? in this case, there is an customize case with allows you to custom for your boards, like below:


  drivers.gpio.2pin_arduino:
    min_flash: 34
    depends_on:
      - gpio
      - arduino_gpio
    filter: dt_compat_enabled("test-gpio-basic-api") and dt_compat_enabled("arduino-header-r3")
    extra_args: "DTC_OVERLAY_FILE=arduino.overlay"
    integration_platforms:
      - frdm_k64f
    platform_exclude:
      # below boards are mikro bus not arduino
      - da14695_dk_usb
      - mimxrt595_evk/mimxrt595s/cm33

  drivers.gpio.2pin_arduino_customized:
    min_flash: 34
    depends_on:
      - gpio
      - arduino_gpio
    filter: dt_compat_enabled("test-gpio-basic-api") and dt_compat_enabled("arduino-header-r3")
    platform_allow:
      - mimxrt595_evk/mimxrt595s/cm33

@FRASTM, can you give me a board list so that I can add your platforms to the customer list?

FRASTM commented 1 month ago

I think this is ST gpio dedicated issue, it requires the gpio on same bank, right?

No sure, the test main.c is implemented that way:

if (in_dev != out_dev) {
        printk("FATAL: output controller %s != input controller %s\n",
               out_dev->name, in_dev->name);
        k_panic();

No matter what the SOC family

FRASTM commented 1 month ago

on different connector excep> @FRASTM, can you give me a board list so that I can add your platforms to the customer list?

Indeed, all the boards/st/ have arduino pin8 & 9 except a few ones (nucleo_wbaXX, nucleo_wl55, stm32l562_dk)

hakehuang commented 1 month ago

No matter what the SOC family

NXP platform does not have such limitation, Can I add a config to disable this check? @FRASTM

yes but testcase will probably fail later.

START - test_gpio_port                                                          
Validate device gpio@48000000                                                   
Check gpio@48000000 output 10 connected to input 3                              
FATAL output pin not wired to input pin? (out low => in high) 

connecting output 10 of gpio A to input 3 GPIOB coming from the arduino. overlay : it means "arduino connector pin 8 to pin 9" = D2 to D3

hakehuang commented 1 month ago

connecting output 10 of gpio A to input 3 GPIOB coming from the arduino. overlay : it means "arduino connector pin 8 to pin 9" = D2 to D3

@FRASTM , I will add a ne instance for ST platforms with CONFIG_ONE_PORT=y

hakehuang commented 1 month ago

@FRASTM can you try the fixes? I do not have st boards.