Wrong order of gpiochip0..3

My problem is that the four symbolic links /sys/class/gpio/gpiochip0…3 are pointing to the wrong addresses:

gpiochip0 → 4804c000.gpio
gpiochip1 → 481ac000.gpio
gpiochip2 → 481ae000.gpio
gpiochip3 → 44e07000.gpio

I have build a new root filesystem with buildroot and then build a new kernel v5.10.153-bone69 using the same toolchain that I used to build the root filesystem. The system boots and I can login and work with the system, but the gpio mappings are wrong. There are some kernel messages that might point to the problem:

[    2.098987] wkup_m3_rproc 44d00000.cpu: Platform data missing!
[    2.166946] gpiochip_add_data_with_key: GPIOs 0..31 (gpio-0-31) failed to register, -517
[    2.369097] pinctrl-single 44e10800.pinmux: 142 pins, size 568
[    2.473599] wkup_m3_ipc 44e11324.wkup_m3_ipc: IPC Request for A8->M3 Channel failed! -517
[    2.520816] ti-sysc: probe of 44e31000.target-module failed with error -16
[    2.565592] omap_wdt: OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec
[    2.610341] omap_rtc 44e3e000.rtc: registered as rtc0
[    2.610419] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01T00:00:00 UTC (946684800)
[    2.652515] 48022000.serial: ttyS1 at MMIO 0x48022000 (irq = 26, base_baud = 3000000) is a 8250
[    2.675013] 48024000.serial: ttyS2 at MMIO 0x48024000 (irq = 27, base_baud = 3000000) is a 8250
[    2.697744] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[    2.749841] ti-sysc: probe of 48040000.target-module failed with error -16

There are also a lot of wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle messages. Here is the full kernel log:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.10.153-bone69 (**@**) (arm-none-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621, GNU ld (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 2.36.1.20210621) #1 SMP PREEMPT Fri Jan 27 11:14:08 CET 2023
[    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=50c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: TI AM335x BeagleBone Black
[    0.000000] Memory policy: Data cache writeback
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 48 MiB at 0x9c800000
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000080000000-0x000000009fefffff]
[    0.000000]   HighMem  empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x000000009fefffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x000000009fefffff]
[    0.000000] On node 0 totalpages: 130816
[    0.000000]   Normal zone: 1150 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 130816 pages, LIFO batch:31
[    0.000000] CPU: All CPU(s) started in SVC mode.
[    0.000000] AM335X ES2.1 (sgx neon)
[    0.000000] percpu: Embedded 21 pages/cpu s54220 r8192 d23604 u86016
[    0.000000] pcpu-alloc: s54220 r8192 d23604 u86016 alloc=21*4096
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129666
[    0.000000] Kernel command line: console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 max_loop=255
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 443812K/523264K available (10240K kernel code, 1585K rwdata, 3500K rodata, 1024K init, 370K bss, 30300K reserved, 49152K cma-reserved, 0K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] ftrace: allocating 43682 entries in 129 pages
[    0.000000] ftrace: allocated 128 pages with 1 groups
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
[    0.000000] 	Trampoline variant of Tasks RCU enabled.
[    0.000000] 	Rude variant of Tasks RCU enabled.
[    0.000000] 	Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] IRQ: Found an INTC at 0x(ptrval) (revision 5.0) with 128 interrupts
[    0.000000] TI gptimer clocksource: always-on /ocp/interconnect@44c00000/segment@200000/target-module@31000
[    0.000010] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[    0.000031] clocksource: dmtimer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000422] TI gptimer clockevent: 24000000 Hz at /ocp/interconnect@48000000/segment@0/target-module@40000
[    0.002321] Console: colour dummy device 80x30
[    0.002363] WARNING: Your 'console=ttyO0' has been replaced by 'ttyS0'
[    0.002374] This ensures that you still see kernel messages. Please
[    0.002383] update your kernel commandline.
[    0.002439] Calibrating delay loop (skipped) preset value.. 995.32 BogoMIPS (lpj=1990656)
[    0.002466] pid_max: default: 32768 minimum: 301
[    0.003041] LSM: Security Framework initializing
[    0.003156] Yama: becoming mindful.
[    0.003386] AppArmor: AppArmor initialized
[    0.003407] TOMOYO Linux initialized
[    0.003596] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.003614] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.005212] CPU: Testing write buffer coherency: ok
[    0.005290] CPU0: Spectre v2: using BPIALL workaround
[    0.029011] Setting up static identity map for 0x80100000 - 0x80100054
[    0.036492] rcu: Hierarchical SRCU implementation.
[    0.045590] EFI services will not be available.
[    0.052494] smp: Bringing up secondary CPUs ...
[    0.052516] smp: Brought up 1 node, 1 CPU
[    0.052529] SMP: Total of 1 processors activated (995.32 BogoMIPS).
[    0.052540] CPU: All CPU(s) started in SVC mode.
[    0.053296] devtmpfs: initialized
[    0.092871] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[    0.093340] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.093373] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.097224] pinctrl core: initialized pinctrl subsystem
[    0.099184] NET: Registered protocol family 16
[    0.104043] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.104727] audit: initializing netlink subsys (disabled)
[    0.105913] thermal_sys: Registered thermal governor 'fair_share'
[    0.105927] thermal_sys: Registered thermal governor 'bang_bang'
[    0.105943] thermal_sys: Registered thermal governor 'step_wise'
[    0.106928] cpuidle: using governor menu
[    0.112555] audit: type=2000 audit(0.104:1): state=initialized audit_enabled=0 res=1
[    0.187366] hw-breakpoint: debug architecture 0x4 unsupported.
[    0.224797] raid6: skip pq benchmark and using algorithm neonx8
[    0.224828] raid6: using neon recovery algorithm
[    0.228570] iommu: Default domain type: Translated 
[    0.231225] SCSI subsystem initialized
[    0.231344] libata version 3.00 loaded.
[    0.231606] usbcore: registered new interface driver usbfs
[    0.231669] usbcore: registered new interface driver hub
[    0.231732] usbcore: registered new device driver usb
[    0.232168] pps_core: LinuxPPS API ver. 1 registered
[    0.232182] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.232210] PTP clock support registered
[    0.237504] NetLabel: Initializing
[    0.237529] NetLabel:  domain hash size = 128
[    0.237539] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.237623] NetLabel:  unlabeled traffic allowed by default
[    0.238701] clocksource: Switched to clocksource dmtimer
[    1.403911] VFS: Disk quotas dquot_6.6.0
[    1.404046] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    1.405139] AppArmor: AppArmor Filesystem Enabled
[    1.417324] NET: Registered protocol family 2
[    1.417607] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    1.419049] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    1.419162] TCP established hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    1.419211] TCP bind hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    1.419275] TCP: Hash tables configured (established 4096 bind 4096)
[    1.419415] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    1.419445] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    1.419703] NET: Registered protocol family 1
[    1.432928] RPC: Registered named UNIX socket transport module.
[    1.432950] RPC: Registered udp transport module.
[    1.432960] RPC: Registered tcp transport module.
[    1.432970] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    1.432988] NET: Registered protocol family 44
[    1.433286] Trying to unpack rootfs image as initramfs...
[    1.789053] Freeing initrd memory: 6600K
[    1.791467] Initialise system trusted keyrings
[    1.791859] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[    1.799660] zbud: loaded
[    1.807505] NFS: Registering the id_resolver key type
[    1.807569] Key type id_resolver registered
[    1.807581] Key type id_legacy registered
[    1.807770] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    1.807786] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    1.808136] fuse: init (API version 7.32)
[    1.901320] xor: automatically using best checksumming function   neon      
[    1.901350] Key type asymmetric registered
[    1.901363] Asymmetric key parser 'x509' registered
[    1.901440] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[    1.905787] io scheduler mq-deadline registered
[    1.909508] hw perfevents: enabled with armv7_cortex_a8 PMU driver, 5 counters available
[    1.914663] l3-aon-clkctrl:0000:0: failed to disable
[    1.918125] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
[    1.926541] CAN device driver interface
[    1.927345] usbcore: registered new interface driver smsc95xx
[    1.931934] usbcore: registered new interface driver uas
[    1.932009] usbcore: registered new interface driver usb-storage
[    1.932051] usbcore: registered new interface driver ums-alauda
[    1.932089] usbcore: registered new interface driver ums-cypress
[    1.932178] usbcore: registered new interface driver ums-datafab
[    1.932221] usbcore: registered new interface driver ums_eneub6250
[    1.932261] usbcore: registered new interface driver ums-freecom
[    1.932300] usbcore: registered new interface driver ums-isd200
[    1.932339] usbcore: registered new interface driver ums-jumpshot
[    1.932377] usbcore: registered new interface driver ums-karma
[    1.932416] usbcore: registered new interface driver ums-onetouch
[    1.932471] usbcore: registered new interface driver ums-realtek
[    1.932510] usbcore: registered new interface driver ums-sddr09
[    1.932547] usbcore: registered new interface driver ums-sddr55
[    1.932585] usbcore: registered new interface driver ums-usbat
[    1.934564] i2c /dev entries driver
[    1.934844] Driver for 1-wire Dallas network protocol.
[    1.935973] softdog: initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
[    1.935993] softdog:              soft_reboot_cmd=<not set> soft_active_on_boot=0
[    1.937154] cpuidle: enable-method property 'ti,am3352' found operations
[    1.937865] sdhci: Secure Digital Host Controller Interface driver
[    1.937882] sdhci: Copyright(c) Pierre Ossman
[    1.938040] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.938392] ledtrig-cpu: registered to indicate activity on CPUs
[    1.939095] hid: raw HID events driver (C) Jiri Kosina
[    1.939455] usbcore: registered new interface driver usbhid
[    1.939469] usbhid: USB HID core driver
[    1.940080] drop_monitor: Initializing network drop monitor service
[    1.941215] NET: Registered protocol family 10
[    2.017520] Segment Routing with IPv6
[    2.017672] mip6: Mobile IPv6
[    2.017693] NET: Registered protocol family 17
[    2.017724] can: controller area network core
[    2.017838] NET: Registered protocol family 29
[    2.022387] Key type dns_resolver registered
[    2.022408] mpls_gso: MPLS GSO support
[    2.022792] ThumbEE CPU extension supported.
[    2.022821] Registering SWP/SWPB emulation handler
[    2.022837] omap_voltage_late_init: Voltage driver support not added
[    2.023165] PM: Cannot get wkup_m3_ipc handle
[    2.023838] registered taskstats version 1
[    2.023865] Loading compiled-in X.509 certificates
[    2.024056] zswap: loaded using pool lzo/zbud
[    2.028986] Key type ._fscrypt registered
[    2.029005] Key type .fscrypt registered
[    2.029016] Key type fscrypt-provisioning registered
[    2.033434] Btrfs loaded, crc32c=crc32c-generic
[    2.033614] AppArmor: AppArmor sha1 policy hashing enabled
[    2.098987] wkup_m3_rproc 44d00000.cpu: Platform data missing!
[    2.166946] gpiochip_add_data_with_key: GPIOs 0..31 (gpio-0-31) failed to register, -517
[    2.369097] pinctrl-single 44e10800.pinmux: 142 pins, size 568
[    2.473599] wkup_m3_ipc 44e11324.wkup_m3_ipc: IPC Request for A8->M3 Channel failed! -517
[    2.520816] ti-sysc: probe of 44e31000.target-module failed with error -16
[    2.565592] omap_wdt: OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec
[    2.610341] omap_rtc 44e3e000.rtc: registered as rtc0
[    2.610419] omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01T00:00:00 UTC (946684800)
[    2.652515] 48022000.serial: ttyS1 at MMIO 0x48022000 (irq = 26, base_baud = 3000000) is a 8250
[    2.675013] 48024000.serial: ttyS2 at MMIO 0x48024000 (irq = 27, base_baud = 3000000) is a 8250
[    2.697744] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[    2.749841] ti-sysc: probe of 48040000.target-module failed with error -16
[    2.876998] OMAP GPIO hardware version 0.1
[    2.931330] omap-mailbox 480c8000.mailbox: omap mailbox rev 0x400
[    2.962826] at24 2-0054: supply vcc not found, using dummy regulator
[    2.998903] at24 2-0055: supply vcc not found, using dummy regulator
[    3.034807] at24 2-0056: supply vcc not found, using dummy regulator
[    3.069577] at24 2-0057: supply vcc not found, using dummy regulator
[    3.097927] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
[    3.120076] 481a6000.serial: ttyS3 at MMIO 0x481a6000 (irq = 40, base_baud = 3000000) is a 8250
[    3.131994] 481a8000.serial: ttyS4 at MMIO 0x481a8000 (irq = 41, base_baud = 3000000) is a 8250
[    3.143850] 481aa000.serial: ttyS5 at MMIO 0x481aa000 (irq = 42, base_baud = 3000000) is a 8250
[    3.177959] c_can_platform 481cc000.can: c_can_platform device registered (regs=(ptrval), irq=45)
[    3.189415] c_can_platform 481d0000.can: c_can_platform device registered (regs=(ptrval), irq=46)
[    3.201610] sdhci-omap 481d8000.mmc: supply vqmmc not found, using dummy regulator
[    3.296524] omap_rng 48310000.rng: Random Number Generator ver. 20
[    3.299128] random: crng init done
[    3.346788] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6, bus freq 1000000
[    3.364212] davinci_mdio 4a101000.mdio: phy[0]: device 4a101000.mdio:00, driver SMSC LAN8710/LAN8720
[    3.364862] cpsw 4a100000.ethernet: initialized cpsw ale version 1.4
[    3.364884] cpsw 4a100000.ethernet: ALE Table size 1024
[    3.365001] cpsw 4a100000.ethernet: cpts: overflow check period 1250 (jiffies)
[    3.365073] cpsw 4a100000.ethernet: Detected MACID = 2c:ab:33:6a:bb:5e
[    3.387136] debugfs: Directory '49000000.dma' with parent 'dmaengine' already present!
[    3.387182] edma 49000000.dma: TI EDMA DMA engine driver
[    3.396823] am335x-phy-driver 47401300.usb-phy: supply vcc not found, using dummy regulator
[    3.397173] am335x-phy-driver 47401300.usb-phy: dummy supplies not allowed for exclusive requests
[    3.412408] am335x-phy-driver 47401b00.usb-phy: supply vcc not found, using dummy regulator
[    3.412707] am335x-phy-driver 47401b00.usb-phy: dummy supplies not allowed for exclusive requests
[    3.440805] omap-sham 53100000.sham: hw accel on OMAP rev 4.3
[    3.441203] omap-sham 53100000.sham: will run requests pump with realtime priority
[    3.447154] omap-aes 53500000.aes: OMAP AES hw accel rev: 3.2
[    3.447687] omap-aes 53500000.aes: will run requests pump with realtime priority
[    3.632729] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0 name='P8_03'
[    3.632954] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1 name='P8_04'
[    3.633127] gpio-of-helper ocp:cape-universal: Allocated GPIO id=2 name='P8_05'
[    3.633314] gpio-of-helper ocp:cape-universal: Allocated GPIO id=3 name='P8_06'
[    3.633706] gpio-of-helper ocp:cape-universal: Allocated GPIO id=4 name='P8_07'
[    3.633898] gpio-of-helper ocp:cape-universal: Allocated GPIO id=5 name='P8_08'
[    3.634095] gpio-of-helper ocp:cape-universal: Allocated GPIO id=6 name='P8_09'
[    3.634270] gpio-of-helper ocp:cape-universal: Allocated GPIO id=7 name='P8_10'
[    3.634451] gpio-of-helper ocp:cape-universal: Allocated GPIO id=8 name='P8_11'
[    3.634622] gpio-of-helper ocp:cape-universal: Allocated GPIO id=9 name='P8_12'
[    3.634763] gpio-of-helper ocp:cape-universal: Failed to get gpio property of 'P8_13'
[    3.634779] gpio-of-helper ocp:cape-universal: Failed to create gpio entry
[    3.639451] PM: Cannot get wkup_m3_ipc handle
[    3.642968] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 19, base_baud = 3000000) is a 8250
[    5.074816] printk: console [ttyS0] enabled
[    5.107360] tps65217-pmic: Failed to locate of_node [id: -1]
[    5.124877] tps65217-bl: Failed to locate of_node [id: -1]
[    5.133433] tps6521x_pwrbutton tps65217-pwrbutton: DMA mask not set
[    5.140980] input: tps65217_pwr_but as /devices/platform/ocp/44c00000.interconnect/44c00000.interconnect:segment@200000/44e0b000.target-module/44e0b000.i2c/i2c-0/0-0024/tps65217-pwrbutton/input/input0
[    5.159606] tps65217 0-0024: TPS65217 ID 0xe version 1.2
[    5.166911] at24 0-0050: 32768 byte 24c256 EEPROM, writable, 1 bytes/write
[    5.174148] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[    5.375272] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    5.388837] omap_gpio 44e07000.gpio: Could not set line 6 debounce to 200000 microseconds (-22)
[    5.406169] sdhci-omap 48060000.mmc: Got CD GPIO
[    5.412392] sdhci-omap 481d8000.mmc: supply vqmmc not found, using dummy regulator
[    5.424927] musb-hdrc musb-hdrc.1: MUSB HDRC host driver
[    5.430565] sdhci-omap 48060000.mmc: supply vqmmc not found, using dummy regulator
[    5.439751] musb-hdrc musb-hdrc.1: new USB bus registered, assigned bus number 1
[    5.449562] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
[    5.458216] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    5.466250] usb usb1: Product: MUSB HDRC host driver
[    5.471305] usb usb1: Manufacturer: Linux 5.10.153-bone69 musb-hcd
[    5.477569] mmc1: SDHCI controller on 481d8000.mmc [481d8000.mmc] using External DMA
[    5.485497] usb usb1: SerialNumber: musb-hdrc.1
[    5.492321] hub 1-0:1.0: USB hub found
[    5.496303] hub 1-0:1.0: 1 port detected
[    5.502491] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0 name='P8_03'
[    5.510239] mmc0: SDHCI controller on 48060000.mmc [48060000.mmc] using External DMA
[    5.519097] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1 name='P8_04'
[    5.526756] gpio-of-helper ocp:cape-universal: Allocated GPIO id=2 name='P8_05'
[    5.534376] gpio-of-helper ocp:cape-universal: Allocated GPIO id=3 name='P8_06'
[    5.542503] gpio-of-helper ocp:cape-universal: Allocated GPIO id=4 name='P8_07'
[    5.550172] gpio-of-helper ocp:cape-universal: Allocated GPIO id=5 name='P8_08'
[    5.557839] gpio-of-helper ocp:cape-universal: Allocated GPIO id=6 name='P8_09'
[    5.565399] gpio-of-helper ocp:cape-universal: Allocated GPIO id=7 name='P8_10'
[    5.572890] gpio-of-helper ocp:cape-universal: Allocated GPIO id=8 name='P8_11'
[    5.580429] gpio-of-helper ocp:cape-universal: Allocated GPIO id=9 name='P8_12'
[    5.588067] gpio-of-helper ocp:cape-universal: Allocated GPIO id=10 name='P8_13'
[    5.595815] gpio-of-helper ocp:cape-universal: Allocated GPIO id=11 name='P8_14'
[    5.603501] gpio-of-helper ocp:cape-universal: Allocated GPIO id=12 name='P8_15'
[    5.611188] gpio-of-helper ocp:cape-universal: Allocated GPIO id=13 name='P8_16'
[    5.618883] gpio-of-helper ocp:cape-universal: Allocated GPIO id=14 name='P8_17'
[    5.626522] gpio-of-helper ocp:cape-universal: Allocated GPIO id=15 name='P8_18'
[    5.634207] gpio-of-helper ocp:cape-universal: Allocated GPIO id=16 name='P8_19'
[    5.641896] gpio-of-helper ocp:cape-universal: Allocated GPIO id=17 name='P8_20'
[    5.649577] gpio-of-helper ocp:cape-universal: Allocated GPIO id=18 name='P8_21'
[    5.657271] gpio-of-helper ocp:cape-universal: Allocated GPIO id=19 name='P8_22'
[    5.664967] gpio-of-helper ocp:cape-universal: Allocated GPIO id=20 name='P8_23'
[    5.672684] gpio-of-helper ocp:cape-universal: Allocated GPIO id=21 name='P8_24'
[    5.680335] gpio-of-helper ocp:cape-universal: Allocated GPIO id=22 name='P8_25'
[    5.688132] gpio-of-helper ocp:cape-universal: Allocated GPIO id=23 name='P8_26'
[    5.695927] gpio-of-helper ocp:cape-universal: Allocated GPIO id=24 name='P8_27'
[    5.703621] gpio-of-helper ocp:cape-universal: Allocated GPIO id=25 name='P8_28'
[    5.711354] gpio-of-helper ocp:cape-universal: Allocated GPIO id=26 name='P8_29'
[    5.719061] gpio-of-helper ocp:cape-universal: Allocated GPIO id=27 name='P8_30'
[    5.726818] gpio-of-helper ocp:cape-universal: Allocated GPIO id=28 name='P8_31'
[    5.734698] gpio-of-helper ocp:cape-universal: Allocated GPIO id=29 name='P8_32'
[    5.742454] gpio-of-helper ocp:cape-universal: Allocated GPIO id=30 name='P8_33'
[    5.750343] mmc1: new high speed MMC card at address 0001
[    5.755808] gpio-of-helper ocp:cape-universal: Allocated GPIO id=31 name='P8_34'
[    5.764444] gpio-of-helper ocp:cape-universal: Allocated GPIO id=32 name='P8_35'
[    5.772444] mmcblk1: mmc1:0001 W62704 3.56 GiB 
[    5.777308] gpio-of-helper ocp:cape-universal: Allocated GPIO id=33 name='P8_36'
[    5.785169] mmcblk1boot0: mmc1:0001 W62704 partition 1 2.00 MiB
[    5.791377] gpio-of-helper ocp:cape-universal: Allocated GPIO id=34 name='P8_37'
[    5.799205] mmcblk1boot1: mmc1:0001 W62704 partition 2 2.00 MiB
[    5.805470] mmcblk1rpmb: mmc1:0001 W62704 partition 3 512 KiB, chardev (242:0)
[    5.812991] gpio-of-helper ocp:cape-universal: Allocated GPIO id=35 name='P8_38'
[    5.820700] gpio-of-helper ocp:cape-universal: Allocated GPIO id=36 name='P8_39'
[    5.828360] gpio-of-helper ocp:cape-universal: Allocated GPIO id=37 name='P8_40'
[    5.835993] gpio-of-helper ocp:cape-universal: Allocated GPIO id=38 name='P8_41'
[    5.843612] gpio-of-helper ocp:cape-universal: Allocated GPIO id=39 name='P8_42'
[    5.851240] gpio-of-helper ocp:cape-universal: Allocated GPIO id=40 name='P8_43'
[    5.858941] gpio-of-helper ocp:cape-universal: Allocated GPIO id=41 name='P8_44'
[    5.866585] gpio-of-helper ocp:cape-universal: Allocated GPIO id=42 name='P8_45'
[    5.874228] gpio-of-helper ocp:cape-universal: Allocated GPIO id=43 name='P8_46'
[    5.881856] gpio-of-helper ocp:cape-universal: Allocated GPIO id=44 name='P9_11'
[    5.889504] gpio-of-helper ocp:cape-universal: Allocated GPIO id=45 name='P9_12'
[    5.897132] gpio-of-helper ocp:cape-universal: Allocated GPIO id=46 name='P9_13'
[    5.904753] gpio-of-helper ocp:cape-universal: Allocated GPIO id=47 name='P9_14'
[    5.912382] gpio-of-helper ocp:cape-universal: Allocated GPIO id=48 name='P9_15'
[    5.920003] gpio-of-helper ocp:cape-universal: Allocated GPIO id=49 name='P9_16'
[    5.927638] gpio-of-helper ocp:cape-universal: Allocated GPIO id=50 name='P9_17'
[    5.935278] gpio-of-helper ocp:cape-universal: Allocated GPIO id=51 name='P9_18'
[    5.942912] gpio-of-helper ocp:cape-universal: Allocated GPIO id=52 name='P9_19'
[    5.950548] gpio-of-helper ocp:cape-universal: Allocated GPIO id=53 name='P9_20'
[    5.958167] gpio-of-helper ocp:cape-universal: Allocated GPIO id=54 name='P9_21'
[    5.965792] gpio-of-helper ocp:cape-universal: Allocated GPIO id=55 name='P9_22'
[    5.973420] gpio-of-helper ocp:cape-universal: Allocated GPIO id=56 name='P9_23'
[    5.981042] gpio-of-helper ocp:cape-universal: Allocated GPIO id=57 name='P9_24'
[    5.989060] gpio-of-helper ocp:cape-universal: Allocated GPIO id=58 name='P9_25'
[    5.996747] gpio-of-helper ocp:cape-universal: Allocated GPIO id=59 name='P9_26'
[    6.004384] gpio-of-helper ocp:cape-universal: Allocated GPIO id=60 name='P9_27'
[    6.012027] gpio-of-helper ocp:cape-universal: Allocated GPIO id=61 name='P9_28'
[    6.019661] gpio-of-helper ocp:cape-universal: Allocated GPIO id=62 name='P9_29'
[    6.027319] gpio-of-helper ocp:cape-universal: Allocated GPIO id=63 name='P9_30'
[    6.034950] gpio-of-helper ocp:cape-universal: Allocated GPIO id=64 name='P9_31'
[    6.042580] gpio-of-helper ocp:cape-universal: Allocated GPIO id=65 name='P9_41'
[    6.050211] gpio-of-helper ocp:cape-universal: Allocated GPIO id=66 name='P9_91'
[    6.057827] gpio-of-helper ocp:cape-universal: Allocated GPIO id=67 name='P9_42'
[    6.065462] gpio-of-helper ocp:cape-universal: Allocated GPIO id=68 name='P9_92'
[    6.072923] gpio-of-helper ocp:cape-universal: ready
[    6.082108]  mmcblk1: p1
[    6.087722] PM: Cannot get wkup_m3_ipc handle
[    6.093957] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    6.101796] PM: Cannot get wkup_m3_ipc handle
[    6.107208] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    6.128494] Freeing unused kernel memory: 1024K
[    6.143533] mmc0: new high speed SDHC card at address 59b4
[    6.150080] Run /init as init process
[    6.154984] PM: Cannot get wkup_m3_ipc handle
[    6.159446]   with arguments:
[    6.159456]     /init
[    6.159463]   with environment:
[    6.159471]     HOME=/
[    6.159478]     TERM=linux
[    6.159485]     max_loop=255
[    6.160005] process '/usr/bin/sh' started with executable stack
[    6.166805] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[    6.174100] mmcblk0: mmc0:59b4 JB1Q5 29.8 GiB 
[    6.184014]  mmcblk0: p1
[    6.199875] PM: Cannot get wkup_m3_ipc handle
[    6.207303] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[   12.751700] PM: Cannot get wkup_m3_ipc handle
[   12.759426] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[   12.775789] PM: Cannot get wkup_m3_ipc handle
[   12.787396] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[   24.397956] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[   24.650969] loop: module loaded
[   24.753549] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null)
[   24.839461] EXT4-fs (loop1): mounted filesystem with ordered data mode. Opts: (null)
[   25.080166] Not activating Mandatory Access Control as /sbin/tomoyo-init does not exist.
[   25.569080] systemd[1]: System time before build time, advancing clock.
[   25.785848] systemd[1]: systemd 250 running in system mode (-PAM -AUDIT -SELINUX -APPARMOR -IMA -SMACK -SECCOMP -GCRYPT -GNUTLS +OPENSSL -ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN +IPTC +KMOD -LIBCRYPTSETUP -LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -BZIP2 -LZ4 +XZ +ZLIB -ZSTD -BPF_FRAMEWORK -XKBCOMMON -UTMP -SYSVINIT default-hierarchy=unified)
[   25.818231] systemd[1]: Detected architecture arm.
[   25.836876] systemd[1]: Hostname set to <combios>.
[   25.856997] systemd[1]: Initializing machine ID from random generator.
[   26.129649] systemd[1003]: /usr/lib/systemd/system-generators/systemd-gpt-auto-generator failed with exit status 1.
[   26.968207] systemd[1]: Queued start job for default target Multi-User System.
[   26.975683] systemd[1]: Unnecessary job was removed for /dev/ttyO0.
[   26.982130] systemd[1]: Unnecessary job was removed for /dev/bone/uart/0.
[   26.989078] systemd[1]: Unnecessary job was removed for /sys/devices/platform/ocp/44c00000.interconnect/44c00000.interconnect:segment@200000/44e09050.target-module/44e09000.serial/tty/ttyS0.
[   27.020195] systemd[1]: Created slice Slice /system/modprobe.
[   27.046426] systemd[1]: Created slice Slice /system/serial-getty.
[   27.073926] systemd[1]: Created slice User and Session Slice.
[   27.095831] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[   27.119637] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[   27.143732] systemd[1]: Reached target Path Units.
[   27.163191] systemd[1]: Reached target Remote File Systems.
[   27.187080] systemd[1]: Reached target Slice Units.
[   27.207154] systemd[1]: Reached target Swaps.
[   27.228990] systemd[1]: Listening on Journal Audit Socket.
[   27.252384] systemd[1]: Listening on Journal Socket (/dev/log).
[   27.276493] systemd[1]: Listening on Journal Socket.
[   27.300798] systemd[1]: Listening on Network Service Netlink Socket.
[   27.324835] systemd[1]: Listening on udev Control Socket.
[   27.348169] systemd[1]: Listening on udev Kernel Socket.
[   27.372298] systemd[1]: Huge Pages File System was skipped because of a failed condition check (ConditionPathExists=/sys/kernel/mm/hugepages).
[   27.392860] systemd[1]: Mounting POSIX Message Queue File System...
[   27.433168] systemd[1]: Mounting Kernel Debug File System...
[   27.470640] systemd[1]: Mounting Kernel Trace File System...
[   27.508838] systemd[1]: Mounting Temporary Directory /tmp...
[   27.548301] systemd[1]: Starting Create List of Static Device Nodes...
[   27.588343] systemd[1]: Starting Load Kernel Module configfs...
[   27.627986] systemd[1]: Starting Load Kernel Module drm...
[   27.664169] systemd[1]: Starting Load Kernel Module fuse...
[   27.691943] systemd[1]: File System Check on Root Device was skipped because of a failed condition check (ConditionPathIsReadWrite=!/).
[   27.719894] systemd[1]: Starting Journal Service...
[   27.745197] systemd[1]: Load Kernel Modules was skipped because all trigger condition checks failed.
[   27.783791] systemd[1]: Starting Generate network units from Kernel command line...
[   27.844186] systemd[1]: Starting Remount Root and Kernel File Systems...
[   27.912355] systemd[1]: Starting Apply Kernel Variables...
[   27.976163] systemd[1]: Starting Coldplug All udev Devices...
[   28.153517] systemd[1]: Mounted POSIX Message Queue File System.
[   28.204649] systemd[1]: Mounted Kernel Debug File System.
[   28.244988] systemd[1]: Mounted Kernel Trace File System.
[   28.280529] systemd[1]: Mounted Temporary Directory /tmp.
[   28.314025] systemd[1]: Finished Create List of Static Device Nodes.
[   28.358261] systemd[1]: modprobe@configfs.service: Deactivated successfully.
[   28.391697] systemd[1]: Finished Load Kernel Module configfs.
[   28.430090] systemd[1]: modprobe@drm.service: Deactivated successfully.
[   28.459478] systemd[1]: Finished Load Kernel Module drm.
[   28.502180] systemd[1]: modprobe@fuse.service: Deactivated successfully.
[   28.531374] systemd[1]: Finished Load Kernel Module fuse.
[   28.574451] systemd[1]: Finished Generate network units from Kernel command line.
[   28.618227] systemd[1]: Finished Remount Root and Kernel File Systems.
[   28.662344] systemd[1]: Finished Apply Kernel Variables.
[   28.701119] systemd[1]: Reached target Preparation for Network.
[   28.759539] systemd[1]: Mounting FUSE Control File System...
[   28.840456] systemd[1]: Mounting Kernel Configuration File System...
[   28.891570] systemd[1]: Platform Persistent Storage Archival was skipped because of a failed condition check (ConditionDirectoryNotEmpty=/sys/fs/pstore).
[   28.915048] systemd[1]: Starting Create Static Device Nodes in /dev...
[   28.965665] systemd[1]: Started Journal Service.
[   29.239736] systemd-journald[1018]: Received client request to flush runtime journal.
[   29.351598] audit: type=1334 audit(1657711848.780:2): prog-id=6 op=LOAD
[   29.372852] audit: type=1334 audit(1657711848.788:3): prog-id=7 op=LOAD
[   29.438963] audit: type=1334 audit(1657711848.788:4): prog-id=8 op=LOAD
[   30.180733] audit: type=1334 audit(1657711849.608:5): prog-id=9 op=LOAD
[   30.297192] audit: type=1334 audit(1657711849.724:6): prog-id=10 op=LOAD
[   32.001394] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   32.049552] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[   32.359511] audit: type=1334 audit(1657711851.788:7): prog-id=11 op=LOAD
[   32.425157] cpsw 4a100000.ethernet: initializing cpsw version 1.12 (0)
[   32.536742] SMSC LAN8710/LAN8720 4a101000.mdio:00: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[   33.074908] EXT4-fs (mmcblk0p1): re-mounted. Opts: (null)
[   33.091733] audit: type=1334 audit(1657711852.520:8): prog-id=12 op=LOAD
[   33.114221] audit: type=1334 audit(1657711852.528:9): prog-id=13 op=LOAD
[   33.151778] audit: type=1334 audit(1657711852.528:10): prog-id=14 op=LOAD
[   33.297761] audit: type=1334 audit(1657711852.724:11): prog-id=15 op=LOAD
[   34.970019] audit: type=1334 audit(1657711854.396:12): prog-id=16 op=LOAD
[   35.683717] cpsw 4a100000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
[   35.729762] audit: type=1325 audit(1657711855.156:13): table=filter family=2 entries=0 op=xt_register pid=1064 subj=unconfined comm="modprobe"
[   35.755761] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   36.031165] audit: type=1325 audit(1657711855.460:14): table=filter family=2 entries=4 op=xt_replace pid=1061 subj=unconfined comm="iptables-restor"
[   45.615832] PM: Cannot get wkup_m3_ipc handle
[   45.627446] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
[   45.663600] PM: Cannot get wkup_m3_ipc handle
[   45.687534] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle

I have tried to search for an answer and this forum post seems to be related: AM3358: Linux GPIO driver failing to bring up gpio0 on first pass; incorrect gpiochip order - Processors forum - Processors - TI E2E support forums

But the answer in that post is a bit old and says that the 5.10 kernel is not supported. So should I compile a version 4.19 kernel or is there a simple fix for my problem?

I’ll let RCN comment on whether or not they’ve deprecated the entire /sys interface.

Otherwise, here’s my “workaround” to determine proper mapping.

// [summary]
// Produce the map of which gpiochip[0,1,2,3] is attached to what gpio[0,1,2,3] port.  This function has shown its necessity due to version 5.1x.x kernel managing to scramble the port-abstraction arrangement relative to v4.19.xx kernel
//  [end of summary]
// parameter: unsigned int *chipnum_by_portnum[4 ]
// return value: The map through the 4 element array of integers, -1 means no "gpiochip" abstraction for that port, otherwise nothing.</returns>
void gpio_portmap(int* chipnum_by_portnum)
{
    //doing these four commands will also give, this info...in human readable form.
    // to get gpio3[]'s chip do this command:
    //"ls `find /sys/devices/platform/ocp -name 481ae000.gpio` | grep gpiochip"
    // to get gpio2[]'s chip do this command:
    //"ls `find /sys/devices/platform/ocp -name 481ac000.gpio` | grep gpiochip"
    // to get gpio1[]'s chip do this command:
    //"ls `find /sys/devices/platform/ocp -name 4804c000.gpio` | grep gpiochip"
    // to get gpio0[]'s chip do this command:
    //"ls `find /sys/devices/platform/ocp -name 44e07000.gpio` | grep gpiochip"

    // This function does kind of skip the elegance of using the ftw(3) function
    // and direct search for the reuse of user oriented tools already present
    // as mentioned above.
    const char* gpiofind_cmds[4] =
    {
        // On TI's AM3358, gpio port 0 has its register base address at 0x44E07000
        "ls `find /sys/devices/platform/ocp -name 44e07000.gpio` | grep gpiochip", 
        // On TI's AM3358, gpio port 1 has its register base address at 0x4804C000
        "ls `find /sys/devices/platform/ocp -name 4804c000.gpio` | grep gpiochip",
        // On TI's AM3358, gpio port 2 has its register base address at 0x481AC000
        "ls `find /sys/devices/platform/ocp -name 481ac000.gpio` | grep gpiochip",
        // On TI's AM3358, gpio port 3 has its register base address at 0x481AE000
        "ls `find /sys/devices/platform/ocp -name 481ae000.gpio` | grep gpiochip"
    };
    int portnum;
    for (portnum=0;portnum<4;portnum++)
    {
        FILE* rv;
        char rstring[256];
        int chipval;
        rv = popen(gpiofind_cmds[portnum], "r");
        fread(rstring, sizeof(char), 255, rv);
        //At this point rstring will have a value of "gpiochipx\n"
        if (sscanf((rstring+8), "%d", &chipval) == 1)
        {
            *(chipnum_by_portnum + portnum) = chipval;
            //debugware: printf("gpio%d will be accessed through /dev/gpiochip%d\n", portnum, chipval);
        }
        else
        {
            *(chipnum_by_portnum + portnum) = -1;
            //debugware: printf("gpio%d ain't nowhere. rstring was \"%s\"\n", portnum,rstring);
        }
        pclose(rv);
    }
}
1 Like

Thanks for your reply. A workaround solution is probably the best solution for the 5.10 kernel. I tried to compile v5.4.209-bone65 and for some reason that version does not have the gpio ordering “bug”.

Not really a bug, over the last few years every subsystem in linux has been moving from a synchronous to asynchronous to boot faster.

a fix would probably create an aliases for gpio, just like everyone else.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/am33xx.dtsi?h=v6.2-rc6#n20

but only /sys/class/gpio really cares about this, where-as the developers want you to use libgpiod… So i don’t think mainline would touch this…

Regards,

I also ran into this issue today after upgrading to a newer Debian (12/13). Some things that I’ve learned that might be useful to document here:

  • The sysfs interface is deprecated, kernel developers really want to get rid of it at some point. Even while it is still there, you cannot rely on the GPIO numbering to have any stability at all.
  • The gpiod interface (which has one /dev/gpiochipx device per gpiochip and then uses pin offsets within the chip) also suffers from the reordering issue, since the /dev/gpiochipx devices can change.
  • However, the aliases approach suggested above is not the way forward. This was already discussed in 2016 here: Re: [PATCH] gpio: document how to order GPIO controllers — Linux Device Tree More generally, users should not rely on the numbering - the kernel should be free to reorder things. Instead, users should rely on labels for gpiochips or individual pins (or maybe udev could have a role in renaming or symlinking the gpiochips like done for ethernet devices too).
  • The gpiochip labels on the beagleboards (anything that uses the gpio-omap driver) are meaningless, since they still rely on initialization order. I’ve brought this up at the linux-gpio list: Setting gpiochip labels from devicetree
  • Best bet for now is to use pin/line names, as shown in gpioinfo, for example: gpioset 'P9_26 [uart1_rxd]'=1

gpiofind exists for exactly this purpose…

But yes, as Robert already mentioned, you really should be using libgpiod.