0

I have recently been working on a bare metal project on a raspberry pi. I have been using a uart to usb cable to for logging, which has been able to send messages to my computer. Recently however, it has stopped working.

I tested the cable using an Arduino and it works.

I installed a fresh version of raspbian on an sd card and tried to use uart from that. When I booted with the cable plugged in, or plugged the cable in, it would either not power on or immediately power off. To further debug, I plugged in an led to the gpio pins and turned in on and off. The pins 14 and 15 (UART TX and RX), however did not work with the led.

At this point, my conclusion is that the UART pins are fried. Is this a valid conclusion and if not, how should I further debug?

2
  • it is a valid conclusion ... it may be incorrect ... test by connecting two GPIO data pins together ... set both to input mode before connecting ... switch one to output mode ... etc. ..... i think that you get the idea
    – jsotola
    Oct 24, 2021 at 18:42
  • 1
    You're using "it" way too much: "Recently however, it has stopped working. I tested the cable using an Arduino and it works... plugged the cable in, it would either not power on or immediately power off" - are you talking about the Pi, the Arduino or the cable? How can a cable "power off"? And what is a "cable" - a simple USB cable or a USB->UART adapter? You can't connect a USB cable to UART pins, and you typically don't use USB->UART adapters with Arduinos. Oct 25, 2021 at 8:25

2 Answers 2

1

The fist thing I do with UARTs is a loopback test: connect TX to RX, send something to the serial device and see if you're receiving the same characters back. This should work regardless of baudrate settings, and you can't get stuff like voltage levels wrong.

0

Run my GPIO test. It needs the pigpio daemon to be running (sudo pigpiod).

See https://elinux.org/R-Pi_Troubleshooting#Testing

gpiotest

#!/bin/bash

skipped=""
tested=""
failed=""

usage()
{
   cat <<EOF
This program checks the Pi's (user) gpios.

The program reads and writes all the gpios.  Make sure NOTHING
is connected to the gpios during this test.

The program uses the pigpio daemon which must be running.

To start the daemon use the command sudo pigpiod.

Press the ENTER key to continue or ctrl-C to abort...
EOF

   read a
}

restore_mode()
{
   # $1 gpio
   # $2 mode

   case "$2" in
        0) m="r" ;;
        1) m="w" ;;
        2) m="5" ;;
        3) m="4" ;;
        4) m="0" ;;
        5) m="1" ;;
        6) m="2" ;;
        7) m="3" ;;
        *)
           echo "invalid mode $2 for gpio $1"
           exit 1
   esac

   $(pigs m $1 $m)
}

check_gpio()
{
   # $1 gpio
   # $2 i2c

   m=$(pigs mg $1) # save mode
   L=$(pigs r $1)  # save level

   s=$(pigs m $1 w)

   if [[ $s  = "" ]]
   then
      f=0
      tested+="$1 "

      # write mode tests
      $(pigs w $1 0)
      r=$(pigs r $1)
      if [[ $r -ne 0 ]]; then f=1; echo "Write 0 to gpio $1 failed."; fi

      $(pigs w $1 1)
      r=$(pigs r $1)
      if [[ $r -ne 1 ]]; then f=1; echo "Write 1 to gpio $1 failed."; fi

      # read mode tests using pull-ups and pull-downs
      $(pigs m $1 r)

      if [[ $2 -eq 0 ]]
      then
         $(pigs pud $1 d)
         r=$(pigs r $1)
         if [[ $r -ne 0 ]]; then f=1; echo "Pull down on gpio $1 failed."; fi
      fi

      $(pigs pud $1 u)
      r=$(pigs r $1)
      if [[ $r -ne 1 ]]; then f=1; echo "Pull up on gpio $1 failed."; fi

      $(pigs pud $1 o)   # switch pull-ups/downs off
      $(pigs w $1 $L)    # restore original level
      restore_mode $1 $m # restore original mode

      if [[ $f -ne 0 ]]; then failed+="$1 "; fi
   else
      skipped+="$1 "
   fi
}  2>/dev/null

usage

v=$(pigs hwver)

if [[ $v < 0 ]]
then
   echo "The pigpio daemon wasn't found.  Did you sudo pigpiod?"
   exit
fi

echo "Testing..."

for ((i=0;  i<4;  i++)) do check_gpio $i 1; done
for ((i=4;  i<16; i++)) do check_gpio $i 0; done

if [[ $v -ge 16 ]];
then
   check_gpio 16 0
else
   skipped+="16 "
fi

for ((i=17;  i<28; i++)) do check_gpio $i 0; done
for ((i=28; i<30; i++)) do check_gpio $i 1; done
for ((i=30; i<32; i++)) do check_gpio $i 0; done

if [[ $failed = "" ]]; then failed="None"; fi

echo "Skipped non-user gpios: $skipped"
echo "Tested user gpios: $tested"
echo "Failed user gpios: $failed"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.