Software UART on open GPIOs - VIM3L


There is 2 UART on GPIOs one(18,19) for Linux logs, and one(pin 15,16) is mux with SPI, I need SPI and now there is no UART left for general propose, Now to access other GPIOs as UART, I found some drivers but thats for Raspb Pi kernel and its a bit difficult for me to bring up.

As per I know, there is no UART in M.2. slot as well. So only thing left is to bring software UART on GPIOs, Can someone guide me for the right drivers, or if there is what changes I should make.

I am trying this one

Please let me know if someone have done this already.

Thank you.

1 Like

@Chirag I will add it to my plan, and I don’t know it’s the same thing, but I can’t guarantee that I can do it

Hay @Frank , Thank You very much. Please let me know what you will get !!!

Hay @Frank ,

Just let you know that, I have managed to communicate over uart with unknown speed or boudrate, I can transmit message from khadas to serial but cant manage the boudrate. I explaind below.

Change GPIO number in module.c file to

static int gpio_tx = 475;
module_param(gpio_tx, int, 0);

static int gpio_rx = 474;
module_param(gpio_rx, int, 0);

In my case I have disabled I2C3, You can use whichever GPIO is free.

Now only error I get is in raspberry_soft_uart.c file,
line 187

hrtimer_start(&timer_rx, ktime_set(0, period /2 ), HRTIMER_MODE_REL);

error: I can not devide or use period / 2.

So, I changed ktime_set(0, 104166.666) its 1000000000/9600 and I also tried 1000000000/4800. Both code run without error, At terminal I can acknowledge that some text is received but the boudrate seems unknown or maybe the pulse width.

So far I have managed to this, I guess it just require some minor changes.

There is also another code in which I also get error, but you can refer,

Let me know whenever you get something.

Thank You.

@Chirag I have successfully implemented it, and the code will be released next week


Can you try with my code ? It work for me now.

Hay @Frank

Thank you for the code. And it works for me as well :grinning:

There was some problem initially, but I guess it was the problem of minicom
to everyone - Make sure to install minicom first

I successfully transmitted the message from khadas to serial. I am trying to read from serial, But I am not getting anything.

cat /dev/ttySOFT0
cat -v /dev/ttySOFT0
cat /dev/ttySOFT0 | hexdump -C

I tried these command. Is it correct or should I try something else!!!

Thank You.

@Chirag My test method is connect the uart3 of the board that simulates the serial port with DuPont cable for testing. Did you close i2c, from the overlay?

Yes I2C3 is disabled and I have confirmed that by using this pins as GPIO as well.

And I will be able to use hardware SPI of khadas right ??

Ok So it works now, I was using Arduino serial console, but from putty it works, sometimes I get an error in string(mostly when you receive long message). but overall it works.

Thank You