Electronic – Porting Linux drivers specifically I2C

armcortex-m3driverfreertosi2c

I am developing an I2C driver for an accelerometer.

My objectives (actually it's the restriction I have as per the project guidelines given in my institute):

  1. use Linux flavour of operating systems – (software)
  2. use ARM core based ISA (ARM CORTEX- A or M series) – (hardware)

Any help in this regard would be great.

One of the solution offered to me was to go for FreeRTOS on NXP's LPC1769 which is ARM cortex-M3 based SoC. (using LPCXpresso developmental board)

But my question is: Why go for RTOS when my requirement is driver implementation? Why can't I take up normal vanilla flavour of Linux kernel or so?

And also any help regarding the developmental boards supporting the above configuration?

Any suggestions or thought process on this?

Best Answer

I am not sure what you are asking about but,

There is something interesting with your assignment:

  • You have to use a Linux kernel
  • It would be an ARM A or M.

First of all, porting a linux kernel is not an easy task !

You have two choices. Either the platform you choose is supported already and you can use it or it is not. And when I say platform I mean the whole board, not just the model of MCU. Each board may have different RAM chip & FLASH chip, use different IO assignments, clock tree, etc. All these things are pretty low level in the kernel (or in the bootloader) and would require a lot of effort to port (and to test). When I say a lot, I mean months if you are familiar with this, or maybe years if not...

I am not aware of standard Linux kernel port for Cortex-M. IFAIK the lack of MMU in Cortex-M devices is a NO-GO for a std linux kernel. You may use uClinux instead. But is it still Linux ? You would have to answer this.

This is also why you can't use a common linux distribution: Your platform won't be a PC. The RAM you will have might reach 512MB, not 4GB. Thing about a Raspberry Pi board. No standard Linux for it, but some custom distribution made specifically for it. In fact a Raspberry Pi might be OK for you here. All the system is ready, and you could focus on writing an I2C driver for your accelerometer.

Then you are talking about RTOS. First, Linux is not a real-time OS. Real-time may be added to the standard kernel (Xenomai for instance) but I am not sure why you are talking about real-time OSs here.

You also said that one option was to go with FreeRTOS. But this would violate your requirement to use a Linux kernel. And if the goal of the whole project is to learn device driver development. Using FreeRTOS or Linux is completely different in term of driver coding.

Anyway, using FreeFTOS seems a sound idea here. It comes with a lot of supported platforms including examples. It is quite easy to use (at least an order of magnitude (or maybe two) easier than porting a Linux kernel). It is real-time, this might be a requirement, depending what you plan to do with your accelerometer data. Last but not least, you may not need external RAM or FLASH. It is lightweight enough to fit into the internal memory of your MCU. A Cortex-M is fine here.

* EDIT *

I read in the history of your question that you initially said that it is supposed to be a 1 month project.

Thus you don't have the choice anymore and have basically two options:

  1. Go for a well known embedded Linux platform that is alread up and running, such as the Raspberry Pi. And dive into Linux kernel diver development right away.

  2. Go for a platform already supported with an I2C example of FreeRTOS. You may download FreeRTOS and look into the example folder. Find a board that has an I2C example attached to it and use that board.

I am not aware of your cost requirement for your project, but a sound dev-board might cost hundreds of dollars and may require a programmer or a development environment that may or may not be free, when a Pi is ~50$ and requires nothing.