# FreeRTOS+IO posix driver

**URL:** <https://forums.freertos.org/t/freertos-io-posix-driver/6154>\
**Category:** Kernel\
**Created:** [September 12, 2016, 12:39pm UTC](https://forums.freertos.org/t/freertos-io-posix-driver/6154 "2016-09-12T12:39:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 12, 2016, 12:39pm UTC](https://forums.freertos.org/t/freertos-io-posix-driver/6154/1 "2016-09-12T12:39:51Z")

</div>

**[andrewholt](https://sourceforge.net/u/andrewholt/)** wrote on [Monday, September 12, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/#b0c5):

I am using FreeRTOS V9.0.0, and I am investigating how to create a driver for (say) a uart or i2c that presents the posix/UNIX/Linux style API (I’m sure you know the one open,close, read,write, ioctl).

If somebody can direct me to a simple example I would be grateful.

Regards,  
Andrew

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [September 12, 2016, 12:51pm UTC](https://forums.freertos.org/t/freertos-io-posix-driver/6154/2 "2016-09-12T12:51:19Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, September 12, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/#b0c5/7a2f):

You could look at [http://www.freertos.org/io](http://www.freertos.org/io) - but it has some issues -  
namely it is too complex to port as it supports multiple transaction  
modes. Sticking to a single transaction mode would have been better.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [September 12, 2016, 12:55pm UTC](https://forums.freertos.org/t/freertos-io-posix-driver/6154/3 "2016-09-12T12:55:56Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Monday, September 12, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/#0fda):

For a UART, it should be THAT hard, as it is inherently a straming device, so a POSIX stream isn’t that bad of a match. The challange with open, is that you aren’t just writting an open for the serial port, but there is just a single open function that needs to handle EVERY device you want to connect to, and this goes and impacts the entire I/O file lib. You can look at an open source implementation like newlib for an example of how to do this. That implementation was designed to be somewhat extensible with hooks to let you add devices to the library.

I2C might be a bit tougher if you are actually expecting to use read/write to talk to the device, as I2C isn’t a simple streaming protocal, but is block based with device specific headers for each block. On the Raspberry Pi, I2C is hooked in via ioctl for all transactions, but since all the calls are now very much device specific, since you don’t have a ‘big’ OS getting in your way, it would be much better to just use a native I2C driver that you directly call, and not add a ioctl translation layer in the middle.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 12, 2016, 2:18pm UTC](https://forums.freertos.org/t/freertos-io-posix-driver/6154/4 "2016-09-12T14:18:27Z")

</div>

**[andrewholt](https://sourceforge.net/u/andrewholt/)** wrote on [Monday, September 12, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/#b0c5/7a2f/f5c0):

Hi thanks for the link. That shows how an application would use the driver, what I am looking for is an example of a driver implementation.

---

<div class="post-metadata">

**Author:** ![tlafleur](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tlafleur](https://forums.freertos.org/u/tlafleur)\
**Post date:** [September 12, 2016, 4:13pm UTC](https://forums.freertos.org/t/freertos-io-posix-driver/6154/5 "2016-09-12T16:13:47Z")

</div>

**[tlafleur](https://sourceforge.net/u/tlafleur/)** wrote on [Monday, September 12, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/#b0c5/7a2f/f5c0/f040):

In my many years of doing embedded real-time software, I have found that  
adding layers like Posix just get in the way of efficient and clean  
drivers. Yes on the outside it looks to be a great academic exercise with a  
clean API, but in reality it just add to much overhead, and is NOT tailored  
to the often needed bit manipulation interface that we see in real world  
real-time driver.

my two bit worth…

On Mon, Sep 12, 2016 at 7:18 AM, Andrew Holt [andrewholt@users.sf.net](mailto:andrewholt@users.sf.net)  
wrote:

> ## Hi thanks for the link. That shows how an application would use the driver, what I am looking for is an example of a driver implementation.
> 
> ## FreeRTOS+IO posix driver [https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/?limit=25#b0c5/7a2f/f5c0](https://sourceforge.net/p/freertos/discussion/382005/thread/a881b4d5/?limit=25#b0c5/7a2f/f5c0)
> 
> Sent from [sourceforge.net](http://sourceforge.net) because you indicated interest in  
> [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/p/freertos/discussion/382005/)
> 
> To unsubscribe from further messages, please visit  
> [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/auth/subscriptions/)

–

~~\_/) `_/)` \_/) ``` \_/)~~

Tom Lafleur
