I have a UART-based device, ESP8266EX, and I need to write to its driver for Linux. Since I am new to writing kernel drivers is there any example or method for accessing uart reading and writing through kernel driver. How is it different from user space uart code?
I have a small iot board with mu device connected to /dev/ttymxc1 port so the uart port will remain fixed for this device and also the device will work at fixed 115200 baud rate. I should be able to read and write to uart from kernel.
Asked
Active
Viewed 1,176 times
1
-
*UART based device* is slave of master? From context it sounds like a slave. Thus, what is that device? Since for most devices you don't need to have a kernel driver (there is a user space available API for that, called TERMIOS). – 0andriy May 02 '17 at 13:10
-
The device is wifi module(AT command based) – prattom May 02 '17 at 13:19
-
Any datasheet or link to it? – 0andriy May 02 '17 at 13:21
-
https://espressif.com/en/products/hardware/esp8266ex/overview it's ep8266 module – prattom May 02 '17 at 13:28
-
1I see. You perhaps just can use SDIO variant https://raspberrypi.stackexchange.com/questions/39344/installing-esp8266-sdio-driver-make-command-gives-kernel-build-tree-not-foun – 0andriy May 02 '17 at 13:39
-
Due to some reason I can't use sdio variant currently in my board and thus I thought of writing drivers for uart. Can we use user space Uart code to read and write to Uart from kernel? – prattom May 02 '17 at 13:45
-
Yes, you can do it in user space. – 0andriy May 02 '17 at 13:47
-
Thanks for the reply.Can you provide some tutorial or link how to read and write to UART code? – prattom May 02 '17 at 13:49
-
There's also serdev which is a new serial device bus being phased into kernel v4.11. The advantage is that it provides nice abstractions, so e.g. even if the UART device is connected via USB-serial converter (e.g. ttyUSB0) or whatever happens to be underlying communication mechanism, that will be abstracted away from driver code. – bytefire May 02 '17 at 14:50
-
2*"Can you provide some tutorial or link how to read and write to UART code?"* -- UARTs in Linux are typically implemented as serial terminals, and the API is termios. See [Serial Programming Guide for POSIX Operating Systems](http://www.cmrr.umn.edu/~strupp/serial.html). For sample code see http://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c/38318768#38318768 – sawdust May 02 '17 at 17:50