BBB UART does not work anymore: Set pin mode failed


I have a BBB that was running my application perfectly for several years. Stupid me, after I was done with my application latest version (to distribute on uSD card) I did some apt-get upgrade/update. Now my UART stopped working. Error code: Set pin mode failed for UART channel. I tried a fresh installation with Debian 2019-08-03 but that gives the same error. Something must have changed,but what? Please help me get things going again.
Running Python3 and Adafruit lib.
Thanks a lot.
Kind regards,

What pins/uart are you trying to use? (what command did you previously use to configure them.)…

Please run, sudo /opt/scripts/tools/ to help debugging…


Hello Robert,

The info:

debian@beaglebone:/opt/scripts/tools$ sudo /opt/scripts/tools/
dogtag:[ Debian Image 2019-08-03]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-gbb4af0f50f]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.03-00002-gd12b1519b4]:[location: dd MBR]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev gpio pwm eqep remoteproc admin spi tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 rng_core.default_quality=100 quiet]
dmesg | grep remote
[    1.199208] remoteproc remoteproc0: wkup_m3 is available
[    1.276700] remoteproc remoteproc0: powering up wkup_m3
[    1.276819] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    1.280880] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
dmesg | grep pinctrl-single
[    0.873753] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    0.874965] gpio-of-helper ocp:cape-universal: ready
Bus 001 Device 002: ID 1ea7:0066
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Since years I use:
import serial
import Adafruit_BBIO.UART as UART
UART.setup(“UART2”) # or 4, I need both

Hope you can help me out.

I don’t think the Adafruit library is maintained any more and has issues with newer kernels.

If the UART is configured correctly by an overlay, you won’t need to use the Adafruit library, just use the Python serial library directly.

If you have something like minicom installed on the BB you can try opening the serial ports directly using that, just to verify that they are working.

Hello Benedict,

I am not quite sure what you mean.
…~$config-pin -q p9.22 gives: pinmux file not found

p9.22 is uart.
Please advise.


If you use the correct overlay it will configure the correct pin muxing for you
you don’t need to use config-pin.

How do I know???

ok so you mentioned UART2.

P9.21 & P9.22

It looks like there are 2 overlays that configure UART2.


Both basically the same, written by 2 different groups.

if you edit /boot/uEnv.txt and scroll down to the section that starts

###Additional custom capes

In the above change the first two overlays to read


After reboot.

That should enable UARTS 2 and 4 and configure the correct pin muxing for those ports. P9.21 & P9.22 for UART2 and P9.13 & P9.11 for UART4

They should then be accessible to anything the can read/write the correct dev port.

Of course also check the user/group permissions of the /dev file to make sure whichever user you are running as, belongs to the same group.

(edit by rcn-ee, removed /lib/firmware/*)

Thank you for your time.
I did as advised but no change at all. uEnv.txt is correctly changed.
How to proceed?

Ok so just tested this in my BBB.

The version I am running is Debian Buster IoT Image 2020-04-06

Kernel is 4.19.94-ti-r42

Loaded the above overlays and rebooted.

Connected a TTL serial interface to P9.21 & P9.22 and can transmit and receive perfectly ok using minicom to my laptop.

Can you hook up a serial cable to the console output and check to see if uboot is actually loading the overlays ?

Also check to make sure uboot overlays are enabled. I think they are by default.

###Master Enable

The version of u-boot installed in your eMMC, will not support u-boot overlays. If you don’t use the eMMC, just erase it with dd…

Our version of Debian 9.x (Stretch), didn’t have a u-boot package to easily didn’t have a way to upgrade. (I didn’t create that package till Debian 10.x (Buster)).

So, unless you are attached to an ancient image, just upgrade to Debian 10.x or Debian 11.x first…


I do not understand. Everything worked fine for years and a couple of days ago: no serial IO anymore. I tried: sudo config-pin -q p9.22. A correctly configured pin should give something like UART? I get: P9_22 pinmux file not found. Can not read pinmux file. I use an attached (grafics) and usb keyboard, like always. I can connect something to the UARTs but it does not make sense at this point. What to do?

bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-gbb4af0f50f]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.03-00002-gd12b1519b4]:[location: dd MBR]

What did you do a couple days ago? That version 2017.03-00002 of u-boot didn’t magically install it self…

If you aren’t using the eMMC, just run:

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=100


I’m afraid I did: sudo apt-get upgrade/update…
Flashing Debian 10…

Flashing to a uSD card. Do not use eMMC anymore

Debian 9.x (Stretch) archive has been closed for a year, apt update/upgrade should not have installed anything… (We also don’t auto install u-boot thru apt, so the files in MBR would not have been upgraded)…


Since you are using the uSD, make sure you also erase the eMMC. Such that u-boot in the eMMC doesn’t cause endless issues…


Have nothing against eMMc but it was too small???

That’s perfectly fine…

The issue, boot rom scans for u-boot in this order:

  1. eMMC
  2. microSD

So just run:


sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=100

So that only the microSD’s version of u-boot is used on bootup, so overlays work…


OK Debian 10 is up and running. Try the dd command but the "size"operand is not recognized.