0

Firstly, I'm floundering and out of my depth, like a blind man in a dark room looking for a black cat that really isn't there. I've been going around in circles all day with this and have had to admit defeat after multiple failed solutions (aka guesses). Please try and keep help, if you'd be so kind, to be reasonably basic.

Situation: I'm running a 3D printer from an RPi 4b. All had been running perfectly for a year or so until today, when I changed an unrelated bit of printer hardwire. Somehow during this I have stuffed up GPIO14 and 15, which I was using to communicate with the printer (using Klipper/Mainsail). I found the stuff up using gpiotext. That shows me that everything works ... other than GPIO 14 & 15.

(Edit as I forgot to state): I'm now trying to use a different pair of pins for comms. I've picked GPIO8 & 9, but it needn't be that pair if there's a reason they can't be used.

What I had originally...

In my RPi /boot/config.txt I HAD the following:

   enable_uart=1
   dtoverlay=disable-bt

I've tried multiple things in the new config.txt and I think the closest I have got might be this:

   enable_uart=1
   dtoverlay=uart1
   dtoverlay=pi3-miniuart-bt
   dtoverlay=uart1,txd1_pin=8,rxd1_pin=9
   dtoverlay=disable-bt

What I think I'm doing there, line by line ...

   Enabling UART in general terms
   Setting things to use UART1
   A line that, well, just seems to need to be there but might not
   Setting the pins to be GPIO8 (TX) and GPIO9 (RX)
   Disabling Bluetooth, as that was there already

Additionally, in my printer.cfg, in Klipper/Mainsail, I have changed a line. Originally I had:

  [mcu]
  serial: /dev/ttyAMA0
  baud: 250000
  restart_method: command 

And "/dev/ttyAMA0" now reads "/dev/ttyAMA1"

I think I need to use UART 1, and I think I can use any free GPIO pins. However, I'm finding all sorts of different advice on the net, none of which are quite my situation. The only relevant hardware change I've made is to move the TX and RX cables to those new pins.

I know this can be done, and don't want to have to cheat and buy a new RPi so I have working GPIO 14 and 15, but I've tried just about everything and can't get this going.

I'm missing something, hopefully a simple something, but just can't get it.

Help please, and let me know if there's info you need I haven't supplied. I am really floundering here.

Natator
  • 3
  • 2

1 Answers1

0

Updated answer due to changes in Question.

The Pi4 has additional UART Raspberry Pi4 UART

If you want to use GPIO8/9 (which are normally used for SPI0) you should use dtoverlay=uart4

The additional UART will appear as /dev/ttyAMAn - most likely ttyAMA1 but this is expected to change to a predictable identifier with the next kernel update which I believe will allocate ttyAMA4.


The ONLY thing you have to do is put enable_uart=1 in /boot/config.txt OR better still run sudo raspi-config Select Interfacing Options / Serial then specify if you want a Serial console (probably no) then if you want the Serial Port hardware enabled (probably yes).

Remove everything else you have done (do this first).

Then use /dev/serial0 in any code which accesses the Serial Port.

If you want mode detail see How do I make serial work on the Raspberry Pi3 or later

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Firstly, thanks for the help! The "/dev/serial0" seems new(ish) and I hadn't come across it in my hunting.

    It still doesn't work with those changes, but they leave me wondering:

    Where in there is anything saying I'm using GPIO 8 & 9? With telling it nothing is it still trying to use GPIO 14 & 15?

    (sorry, can't seem to put in line breaks)

    – Natator Jul 20 '23 at 08:49
  • /dev/serial0 has been in Raspbian/Raspberry Pi OS for 7 years and is the default UART on GPIO14/15. Unless you have damaged the GPIO it should work. If you WANT to use any other pins you need to clarify your question. – Milliways Jul 20 '23 at 08:52
  • Sorry, I did put that I have damaged GPIO 14 & 15 in the question, but didn't make it clear I am trying to now use a different pair of pins, I just had it in my failed code. I'll do an edit on the question, thanks. – Natator Jul 20 '23 at 08:55
  • One thing on the second link you put, which I had found but it stumped me was this bit:

    Name: uart1 Info: Change the pin usage of uart1 Load: dtoverlay=uart1,= Params: txd1_pin GPIO pin for TXD1 (14, 32 or 40 - default ) rxd1_pin GPIO pin for RXD1 (15, 33 or 41 - default 15)


    Does that mean I con only use the pins shown there, which given 14 & 15 are damaged, and I don't have GPIO 30+, leaves me still stumped.

    – Natator Jul 20 '23 at 09:12
  • Your comment "everything works ... other than GPIO 14 & 15" doesn't imply hardware damage. The table at the end of my Pi4 link shows the possible UART on Pi4. You CAN NOT use uart1 because it can only use GPIO 14 15 (unless you have a CM) (apart from the fact that some of your other changes imply it is connected to Bluetooth). I don't know what gpiotext is. There are 4 UART you can use and the potential conflicts. I use uart2 but this needs other settings. – Milliways Jul 20 '23 at 09:46
  • You see, this is the stuff I came here to learn. There are many guides out there but some have conflicting information. I got it going in the end using UART2 (won't need those pins for anything else, and didn't even know they were GPIO0&1 until I happened upon another thread here). It was a comment of your in another thread that got past a mistake I had. You were discussing using UART2 with someone and commented that it came in as "/dev/ttyAMA1", which I expected to be "/dev/ttyAMA2". With that change it is all working, thanks, and boy have I learned a lot fumbling my way through it all! – Natator Jul 20 '23 at 10:18