FreeRTOS+IO posix driver

andrewholt wrote on Monday, September 12, 2016:

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

rtel wrote on Monday, September 12, 2016:

You could look at 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.

richard_damon wrote on Monday, September 12, 2016:

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.

andrewholt wrote on Monday, September 12, 2016:

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.

tlafleur wrote on Monday, September 12, 2016:

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
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

Sent from sourceforge.net because you indicated interest in
SourceForge.net: Log In to SourceForge.net

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net

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

Tom Lafleur