crownroyal avatar image
crownroyal asked

RPi 3B with Waveshare LTE HAT: How to reset GPIO states (before reboot)?


This is my first post after browsing many threads and following great community ideas. I'm very glad this community exists and the effort that Victron puts into maintaining and supporting this is just awesome!

Okay, now my issue :-)

I'm running a Raps 3B combined with the Waveshare LTE HAT (SIM7600) with 2.65/2.70 (tried both). It's working out of the box after I adjusted the APN manually. The HAT is getting initialized and recognized properly upon a fresh boot. Since the Waveshare HAT needs some GPIO PINs pulled down or up to get powered up, it looks like VenusOS is taking care of this - which is great.

The problem I face is upon reboot. It looks like when the GPIO UART states remain (HAT keeps blinking) the Raspi gets stuck at the rainbow screen. I can circumvent this by unplugging the USB data cable before rebooting or doing a hard reset by cutting off the power. I also tried messing around with the UART Pins, pulling them up/down when entering reboot init stage, but that does only work sometimes. With a power cycle this never happens.

So, question is. Is there any script which can reset the GPIO UART states to the default before rebooting? Or maybe where can I find the UART settings which are performed upon boot? Any ideas?

Thank you very much.

Raspberry Pi4g
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Warwick Bruce Chapman avatar image Warwick Bruce Chapman commented ·

Interested to know this HAT works! I had one and never tried - assumed it would not. Very interested in this.

0 Likes 0 ·
crownroyal avatar image crownroyal Warwick Bruce Chapman commented ·

The HAT works out of the box. I tested it with RPI2 and RPI3. The only issue I have is the reboot behavior. But you definitely need a reliable PSU.

If I recall correctly, Victron does use the SIM7600 similarly in their products

0 Likes 0 ·
3 Answers
crownroyal avatar image
crownroyal answered ·

A dirty fix I played with is to unexport the GPIO pins the HAT is using upon shutdown/reboot and wait until the HAT stops blinking. But I haven't validated whether it is a reliable workaround.

4 - Flight Mode
6 - Power from RasPI
14,15 - TX,RX

echo 4 > /sys/class/gpio/unexport

sleep 1

echo 6 > /sys/class/gpio/unexport

sleep 1

echo 14 > /sys/class/gpio/unexport

sleep 1

echo 15 > /sys/class/gpio/unexport

sleep 15

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Kevin Windrem avatar image
Kevin Windrem answered ·

While Venus does set some GPIO pin states it does NOT set pin directions. I looked into this when I noticed some Venus digital inputs were active and some were inactive with nothing connected. It was necessary to add an overlay to set pin directions. This overlay is applied early in the boot process, but I don't know if it is early enough to reset pins for you.

The overlay I applied is part of my GPIO mods package. As-is it probably won't help you but it may provide you with some guidance in making your own.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

crownroyal avatar image crownroyal commented ·

Thanks, Kevin. Perhaps it is not early enough as the RPi gets stuck right at the rainbow screen after reboot, which is before the SD card is even accessed. Unfortunately I don't know any debugging options at this early stage.

I guess the only option is not reset the states upon reboot/init 6, but this may only apply for a soft reboot. Probably this wouldn't apply for a watchdog reset.

0 Likes 0 ·
trygvelu avatar image
trygvelu answered ·

I've played around with this Waveshare HAT a bit - but with the newer version of the hardware, so there may be some differences in behaviour. I'm a little confused: Are you using the internal RPi UART for communicating with the LTE module?

There is a UART jumper header, which lets you control the function of the UART pins, and by default the connection is made between RPi UART and SIM7600X UART (option B). But dbus-modem uses the USB interface, in my case at least. I need to make the connection to the USB port, and then it works fine. So in order to avoid the hangup on reboot I just switched the jumpers to option A - which connects the RPi uart to the UART-USB bridge on the SIM7600X board. This also provides a convenient USB terminal to the RPi on the USB TO UART port. Option C gives you external access to the SIM7600X UART - which might be useful, I dunno.

I think the "freeze" with rainbow screen is just u-boot halting boot, after receiving chars on the terminal tty.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.