Serial (UART) not working on GPIO 14 and GPIO 15

Hi, something seems to be stopping the UART on GPIO14 and 15 from working.

I can get the UART working with a vanilla 2019-09-26-raspbian-buster-lite image so the hardware and configuration is working. But I cannot seem to get it going under the pwnagotchi-raspbian-lite-v1.2.1 image.

I cannot see anything obvious in the builder/ configuration that would cause things not to work. My /boot/config.txt has the needed enable_uart=1 and the /boot/cmdline.txt has no reference to /dev/ttyS0.

Thanks

What display are you using? Maybe the display is messing with those pins?

I have a waveshare v1 display and a RTC hooked up. I have an SD card with vanilla raspbian and another SD card with the pwnagotchi image and can swap between the two. With the same hardware plugged in the UART works on the one but not the other.

It doesn’t look like the display is using those pins. I am still busy debugging. I’ll try and enable the RTC, display and USB gadget on the vanilla image and see if the UART breaks at any point. This is the last thing I need get working to hook up my little serial GPS :slight_smile:

Hi, if the github.com/repaper/gratis/ repos are used for the waveshare display then I think you correct. Rather that the display driver might be messing with those pins not the hardware.

The #defines in https://github.com/repaper/gratis/blob/master/PlatformWithOS/RaspberryPi/epd_io.h I think are referencing pin numbers, which means that pins 8 and 10 (GPIO 14 and 15) are being used by the driver? I’ll maybe try and change those defines and try and recompile the driver?

you can try, but i have no idea what happens if you do :smiley:

OK, so this is what I think is going on and the solution that seems to have worked for me.

The rpi image build script (in pwnagotchi.yml) uses the EPD_IO=‘epd_io.h’ flag which uses the physical pins listed in this header file:

https://github.com/repaper/gratis/blob/master/PlatformWithOS/RaspberryPi/epd_io.h

The header file specifies pins 8 and 10 (GPIO 14 and 15) which are also the serial UART pins. I don’t think the Waveshare displays actually uses these signals.

The “epd_io_free_uart.h” header in the same directory has the same pins but moves two defines away from the UART pins to (so far, unused) pins 13 and 15.

https://github.com/repaper/gratis/blob/master/PlatformWithOS/RaspberryPi/epd_io_free_uart.h

And the solution:

The waveshare display driver needs to be recompiled to use the alternative header. You can SSH into your pwnagotchi and do the following:

cd /usr/local/src/gratis/
sudo make rpi-remove PANEL_VERSION=‘V231_G2’
sudo make rpi-clean PANEL_VERSION=‘V231_G2’
sudo make rpi PANEL_VERSION=‘V231_G2’ EPD_IO=‘epd_io_free_uart.h’
sudo make rpi-install PANEL_VERSION=‘V231_G2’ EPD_IO=‘epd_io_free_uart.h’

Then reboot the rpi. The screen should still work and you should be able to use the UART pins (remember to configure these with raspi-config). The above removes the old driver and cleans the build then recompiles and installs the driver.

This, so far, seems to have worked for me, please let me know if I got anything wrong.

4 Likes

wow man you hacked this thing bad … good job :smiley:

1 Like

Another, maybe simpler solution… Using a GPS module via the UART now and BT Tether via miniuart

append to /boot/config.txt

enable_uart=1
dtoverlay=miniuart-bt
force_turbo=1

and on each boot, setting the pin mode via /etc/systemd/system/uart_gps.service

[Unit]
Description=UART GPS
Wants=network.target
After=bettercap.service pwnagotchi.service

[Service]
Type=oneshot
ExecStart=/usr/bin/raspi-gpio set 15 a0

[Install]
WantedBy=multi-user.target

3 Likes

Wow, thanks! This actually solved my issues with a GPS module.