Is there a demo source code for peripheral sharing between Linux and FreeRTOS ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a demo source code for peripheral sharing between Linux and FreeRTOS ?

2,841 Views
harish_g
Contributor III

I want to share a I2C device between the 2 cores( A7 and M4 ) in imx7. I am aware of the RDC permissions , which must be given to peripherals before using that peripheral . The current permissions are set with the below code in the FreeRTOS side.  

RDC_SetPdapAccess(RDC, BOARD_I2C_RDC_PDAP, ( 3 << (BOARD_DOMAIN_ID * 2) | 3 ) , true , false);‍‍

Since i have chosen to enforce the use of RDC_SEMAPHORE for peripheral sharing , Everytime i access I2C in either of the cores, i should obtain the semaphore of the particular peripheral , like this in FreeRTOS , inorder to maintain exclusive access to that particular peripheral.

RDC_SEMAPHORE_Lock(BOARD_I2C_RDC_PDAP);

These things were mentioned beautifully in an example program in the FreeRTOS BSP.

Similarly ,to use these kinds of exclusive access, is there any demo driver available to perform the same kind of operation in Linux side ? I see that there is absolutely no APIs for RDC access in linux side. I know that these are all the things that i should be taking care of in the A7 side. But is there any potential pitfalls that i should be taking care of in linux side drivers ?

If i choose to use semaphores for sharing resources, will it affect the boot of linux in anyway ? ( Will it hang the linux boot ? ). 

Labels (4)
5 Replies

2,327 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi harish,

it is definitely possible to share peripherals but we don't have such example. I will look for an example of a semaphore in linux to share it with you. However, may I ask what is the purpose of sharing I2C with bot cores?

Regards,

Carlos

2,327 Views
harish_g
Contributor III

Hi Carlos,

                  Thanks for the reply! The purpose is somewhat vague. It is for a demo with our product which showcases its Heterogenous multiprocessing capabilities. We thought making a peripheral like I2C work in both the cores will be a nice proof of concept. It is definitely useful as we can have 2 sensors in the same I2C bus, like a temperature sensor which is used from the A7 side and an IMU, which can be controlled from the M4 side.

On a side note, I already realise that i can access the RDC_SEMAPHOREs by directly accessing the memory, as a standalone application. But the point is, It will work for our cause if those things can be done by a driver. But to my eye, it looks like we may have to change the driver from the root in order to achieve this.

Thanks,

G.Harish

0 Kudos

2,327 Views
mtx512
Contributor V

From our experience sharing the peripheral between running cores require a fair amount of development effort. For example for I2C you would need to get the A9 to do the initialization and then inform the M4 is complete even these two steps requires some detailed modifications to the FreeRTOS BSP and Linux Kernel. Most likely you will need to develop a custom kernel driver to handle shared I2C access from the A9 side as the standard implementation has no support. From a practical point of view I don't see much benefit in sharing the I2C bus unless the devices on their have a low data rate which wouldn't apply to an IMU.  

2,327 Views
harish_g
Contributor III

Hi Jas Math,

                      Thanks for the reply. From a preliminary exploration of the kernel drivers i understood that it will take a fair amount of time to modify for a mature driver/device like an I2C . But our only doubt was , Why would NXP sell its processor as a HMP with peripheral sharing , without having any kind of support in the main kernel ? Isnt that one of the selling points of this product ( iMX7 )? Thats why i asked if they have any mods which i have missed .  I agree with your point about sharing an I2C with an IMU, But since the resources are limited we cant afford ( in most cases ) to outsource an entire peripheral to the M4 side for performing a single task with it. Disabling an entire peripheral is kind of offputting and slightly offsets the benefits provided by a HMP.

Regards,

G.Harish

0 Kudos

2,327 Views
mtx512
Contributor V

I can't speak for NXP however the main benefits of HMP are covered nicely here and I don't think sharing of peripherals was the intention as peripherals should be assigned to a core so that they can be 'firewall protected' to ensure the other core isn't unintentionally accessing them (see point 3).