Set value of sixfab HAT's gpio pin from my raspberry pi 5 + openwrt

Hi all,

I have a rasperry pi 5 and sixfab's 5g modem kit.

It has been suggested to me (on the quectel forum) that I might be unable to connect to the internet via the physical SIM on the sixfab board because the board is set to eSIM rather than the nano SIM slot I need to use.

I see in the following link that GPIO pin 13 is used for SIM selection:

I was told I need to ask here as to how to manipulate GPIO while using openwrt.

I have looked at the wiki ( and am not entirely sure where to start. I don't know what risk, if any, might exist as to me damaging the device by misapplying voltages to gpio pins. I haven't set gpio voltages on a raspberry pi before.

I have used python enough to be able to handle a decent tutorial to do this if this is how I go about it?

Thanks in advance for any guidance

Edit - I tried the commands and the script from this page:

(As the SIM select pin is gpo13, and 'gpio base' was 512, I used 525 in place of the value of 229 in the commands portion of that tutorial, but without any luck.)

Show the output of cat /sys/kernel/debug/gpio

root@OpenWrt:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 512-543, parent: platform/107d508500.gpio, gpio-brcmstb@107d508500:
 gpio-512 (-                   )
 gpio-513 (2712_BOOT_CS_N      )
 gpio-514 (2712_BOOT_MISO      )
 gpio-515 (2712_BOOT_MOSI      )
 gpio-516 (2712_BOOT_SCLK      )
 gpio-517 (-                   )
 gpio-518 (-                   )
 gpio-519 (-                   )
 gpio-520 (-                   )
 gpio-521 (-                   )
 gpio-522 (-                   )
 gpio-523 (-                   )
 gpio-524 (-                   )
 gpio-525 (-                   |sysfs               ) out lo 
 gpio-526 (PCIE_SDA            )
 gpio-527 (PCIE_SCL            )
 gpio-528 (-                   )
 gpio-529 (-                   )
 gpio-530 (-                   )
 gpio-531 (-                   )
 gpio-532 (PWR_GPIO            )
 gpio-533 (2712_G21_FS         )
 gpio-534 (-                   )
 gpio-535 (-                   )
 gpio-536 (BT_RTS              )
 gpio-537 (BT_CTS              )
 gpio-538 (BT_TXD              )
 gpio-539 (BT_RXD              )
 gpio-540 (WL_ON               |wl_on_reg           ) out hi 
 gpio-541 (BT_ON               )
 gpio-542 (WIFI_SDIO_CLK       )
 gpio-543 (WIFI_SDIO_CMD       )

gpiochip1: GPIOs 544-547, parent: platform/107d508500.gpio, gpio-brcmstb@107d508520:
 gpio-544 (WIFI_SDIO_D0        )
 gpio-545 (WIFI_SDIO_D1        )
 gpio-546 (WIFI_SDIO_D2        )
 gpio-547 (WIFI_SDIO_D3        )

gpiochip2: GPIOs 548-564, parent: platform/107d517c00.gpio, gpio-brcmstb@107d517c00:
 gpio-548 (RP1_SDA             )
 gpio-549 (RP1_SCL             )
 gpio-550 (RP1_RUN             |RP1 RUN pin         ) out hi 
 gpio-551 (SD_IOVDD_SEL        |vdd-sd-io           ) out hi 
 gpio-552 (SD_PWR_ON           |sd_vcc_reg          ) out hi 
 gpio-553 (SD_CDET_N           |cd                  ) in  lo ACTIVE LOW
 gpio-554 (SD_FLG_N            )
 gpio-555 (-                   )
 gpio-556 (2712_WAKE           )
 gpio-557 (2712_STAT_LED       |ACT                 ) out hi ACTIVE LOW
 gpio-558 (-                   )
 gpio-559 (-                   )
 gpio-560 (PMIC_INT            )
 gpio-561 (UART_TX_FS          )
 gpio-562 (UART_RX_FS          )
 gpio-563 (-                   )
 gpio-564 (-                   )

gpiochip3: GPIOs 565-570, parent: platform/107d517c00.gpio, gpio-brcmstb@107d517c20:
 gpio-565 (HDMI0_SCL           )
 gpio-566 (HDMI0_SDA           )
 gpio-567 (HDMI1_SCL           )
 gpio-568 (HDMI1_SDA           )
 gpio-569 (PMIC_SCL            )
 gpio-570 (PMIC_SDA            )
gpiochip4: GPIOs 571-624, parent: platform/1f000d0000.gpio, pinctrl-rp1:
 gpio-571 (ID_SDA              )
 gpio-572 (ID_SCL              )
 gpio-573 (GPIO2               )
 gpio-574 (GPIO3               )
 gpio-575 (GPIO4               )
 gpio-576 (GPIO5               )
 gpio-577 (GPIO6               )
 gpio-578 (GPIO7               )
 gpio-579 (GPIO8               )
 gpio-580 (GPIO9               )
 gpio-581 (GPIO10              )
 gpio-582 (GPIO11              )
 gpio-583 (GPIO12              )
 gpio-584 (GPIO13              )
 gpio-585 (GPIO14              )
 gpio-586 (GPIO15              )
 gpio-587 (GPIO16              )
 gpio-588 (GPIO17              )
 gpio-589 (GPIO18              )
 gpio-590 (GPIO19              )
 gpio-591 (GPIO20              )
 gpio-592 (GPIO21              )
 gpio-593 (GPIO22              )
 gpio-594 (GPIO23              )
 gpio-595 (GPIO24              )
 gpio-596 (GPIO25              )
 gpio-597 (GPIO26              )
 gpio-598 (GPIO27              )
 gpio-599 (PCIE_RP1_WAKE       )
 gpio-600 (FAN_TACH            )
 gpio-601 (HOST_SDA            )
 gpio-602 (HOST_SCL            )
 gpio-603 (ETH_RST_N           |phy-reset           ) out hi ACTIVE LOW
 gpio-604 (-                   )
 gpio-605 (CD0_IO0_MICCLK      |cam0_reg            ) out lo 
 gpio-606 (CD0_IO0_MICDAT0     )
 gpio-607 (RP1_PCIE_CLKREQ_N   )
 gpio-608 (-                   )
 gpio-609 (CD0_SDA             )
 gpio-610 (CD0_SCL             )
 gpio-611 (CD1_SDA             )
 gpio-612 (CD1_SCL             )
 gpio-613 (USB_VBUS_EN         )
 gpio-614 (USB_OC_N            )
 gpio-615 (RP1_STAT_LED        |PWR                 ) out lo ACTIVE LOW
 gpio-616 (FAN_PWM             )
 gpio-617 (CD1_IO0_MICCLK      |cam1_reg            ) out lo 
 gpio-618 (2712_WAKE           )
 gpio-619 (CD1_IO1_MICDAT1     )
 gpio-620 (EN_MAX_USB_CUR      )
 gpio-621 (-                   )
 gpio-622 (-                   )
 gpio-623 (-                   )
 gpio-624 (-                   )

I see this says 525 is outputting 'lo', which I seem to recall seeing somewhere meant that the board is switched to the physical SIM slot. (I think I tried echoing first "1", then "0" to that pin when trying the tutorial above. )
However I am sure that you know more about it than me so I am not going to type more just now.

Edit - except I see this:

 gpio-584 (GPIO13              )

COuld I have to

Read the current state (should be 0):
cat /sys/class/gpio/gpio525/value

Change it:
echo 1 > /sys/class/gpio/gpio525/value

Then check if your SIM is accessible.

root@OpenWrt:~#  cat /sys/class/gpio/gpio525/value

But, after restarting the device in openwrt I get:

Error: Unknown error (NO_REGISTRATION)

I was earlier concerned about the pin so I put in a deliberately wrong PIN and got:

Error: PIN code rejected

When I deleted the PIN completely and restarted the device the error message changed back to:

Error: Unknown error (NO_REGISTRATION)

After this I wanted to make sure that the SIM PIN was what I had set. So I tried the following, which I found confusing: (I am aware that all of the following might be wrong, but) although I am basically new to AT commands, I thought the +CPIN: READY response to AT+CPIN? meant there was no PIN set on the SIM, when I was sure I had set a PIN.



+CME ERROR: SIM failure

I changed the pin first to 1234, then to 2345 (because I just wondered if 1234 being a default pin for asda mobile was causingr something I didn't expect to happen). Then finally I get 'SIM failure'.

If the value of gpio525 is correct at 1 (I just tried it again and it is still set to '1') could the SIM be corrupted somehow? It seems unlikely as the SIM connectts to the internet immediately in my phone (albeit over 4g), but I just wonder? I will return to this tomorrow but will take these results to the quectel forum!:

root@OpenWrt:~# cat /sys/class/gpio/gpio525/value

No need to lump everything into one pile. This topic is only about GPIO manipulation. You already have another topic for modem related issues.

If your SIM card becomes accessible with a certain value set (1?), then you need to add the following to /etc/rc.local before exit line:

echo 525 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio525/direction
echo 1 > /sys/class/gpio/gpio525/value

Fair enough, sorry. Got carried away.

I edited /etc/rc.local so my hope is that that has solved this issue.

Thank you, I will mark it as solved, and I really do appreciate your help.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.