Driver development

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Driver development

NANDAKUMAR S
Hi all,

  Iam working on an android aosp project, in which now i want to develop drivers for UART,I2C communication protocols. But iam new to this LINUX and Android platform.
Can anyone suggest me some resources or a procedure on how to learn this.

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/0d3aeaf1-871b-4dbf-8d5f-2734aebe47f1o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Driver development

Dave McLaughlin
UART and I2C are simple enough. The underlying Linux drivers should be part of the kernel and you simply open them from /dev in your Android App. The only issue you may have is not having user rights access to them.

What I did was give user access to GPIO, UART, I2C, and SPI from the init.rc and then wrote a JNI to access the /dev or /sys/class/gpio etc. 

This is assuming you are developing the Android OS build yourself. That certainly makes it easier to set up access rights from init.rc.

Check your /dev directory and see if the tty or i2c devices are already present in your build. If so, you just need to check the access rights and write a JNI to use them from an Android App.

Dave...


On Thursday, 25 June 2020 22:42:13 UTC+7, NANDAKUMAR S wrote:
Hi all,

  Iam working on an android aosp project, in which now i want to develop drivers for UART,I2C communication protocols. But iam new to this LINUX and Android platform.
Can anyone suggest me some resources or a procedure on how to learn this.

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/f6ab2a50-30fc-4dfe-aee1-c21c67bc5cd9o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Driver development

NANDAKUMAR S
Thanks for your reply,

I have tty in /dev directory. I'll check with permissions. 

Can i get any readily available app for testing.


On Tue, 30 Jun, 2020, 7:50 PM Dave McLaughlin, <[hidden email]> wrote:
UART and I2C are simple enough. The underlying Linux drivers should be part of the kernel and you simply open them from /dev in your Android App. The only issue you may have is not having user rights access to them.

What I did was give user access to GPIO, UART, I2C, and SPI from the init.rc and then wrote a JNI to access the /dev or /sys/class/gpio etc. 

This is assuming you are developing the Android OS build yourself. That certainly makes it easier to set up access rights from init.rc.

Check your /dev directory and see if the tty or i2c devices are already present in your build. If so, you just need to check the access rights and write a JNI to use them from an Android App.

Dave...


On Thursday, 25 June 2020 22:42:13 UTC+7, NANDAKUMAR S wrote:
Hi all,

  Iam working on an android aosp project, in which now i want to develop drivers for UART,I2C communication protocols. But iam new to this LINUX and Android platform.
Can anyone suggest me some resources or a procedure on how to learn this.

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/f6ab2a50-30fc-4dfe-aee1-c21c67bc5cd9o%40googlegroups.com.

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/CAHKTZp46ovn-qXUGxOBYXX%2B41w23bmm9n3tGfwS09m%3DkiMRxww%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Driver development

Dave McLaughlin
Not likely as Android apps tend to work with phones which don't have the need for I2C or UART comms etc.

I wrote a couple of JNI libraries to handle GPIO, I2C and UART, you can find it here. This can be added to your project.


This is just the library for I2C and UART. This is very basic code for the I2C (I omitted the required exception handling)

Open the I2C device

            fileHandle = i2c.open("/dev/i2c-0");

Read I2C

        i2c.read(fileHandle, slaveAddr, buf, 3);

Write I2C

i2c.write(fileHandle, slaveAddr, 0, buf, 1);

Close the device

i2c.close(fileHandle);

Buf is an int array. slaveAddr is the 7 bit address of the device you want to talk to.

Serial Port is pretty much similar. I used this with a Modbus library. You only need to allocate the file handle to the streams for this to work. Search for modbus4j by Serotonin. This works great with Android. 

I hope this helps?

On Tuesday, 30 June 2020 23:31:00 UTC+7, NANDAKUMAR S wrote:
Thanks for your reply,

I have tty in /dev directory. I'll check with permissions. 

Can i get any readily available app for testing.


--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/e8ee0a06-af80-430c-8700-76ce7bb1c6d4o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Driver development

Ignacio Moya
Hi, I was trying to change permissions of the i2c files in /dev/i2c-x (x: from 0 to 3) adding the lines "chmod 777 /dev/i2c-x" inside the "on early-boot"  action. But trying to run i2cdetectx from shell still throws "permission denied".

Could someone show me where should I change permissions inside the init.rc file? Or another way of doing the same but not in "init.rc"? I'm using AOSP 9.

Thanks!
El miércoles, 1 de julio de 2020 a las 12:03:54 UTC-3, [hidden email] escribió:
Not likely as Android apps tend to work with phones which don't have the need for I2C or UART comms etc.

I wrote a couple of JNI libraries to handle GPIO, I2C and UART, you can find it here. This can be added to your project.


This is just the library for I2C and UART. This is very basic code for the I2C (I omitted the required exception handling)

Open the I2C device

            fileHandle = i2c.open("/dev/i2c-0");

Read I2C

        i2c.read(fileHandle, slaveAddr, buf, 3);

Write I2C

i2c.write(fileHandle, slaveAddr, 0, buf, 1);

Close the device

i2c.close(fileHandle);

Buf is an int array. slaveAddr is the 7 bit address of the device you want to talk to.

Serial Port is pretty much similar. I used this with a Modbus library. You only need to allocate the file handle to the streams for this to work. Search for modbus4j by Serotonin. This works great with Android. 

I hope this helps?

On Tuesday, 30 June 2020 23:31:00 UTC+7, NANDAKUMAR S wrote:
Thanks for your reply,

I have tty in /dev directory. I'll check with permissions. 

Can i get any readily available app for testing.



This email and any of its attachments may contain privileged and confidential information and are intended only for the review of the party to whom it is addressed. If you are not the intended addressee of this e-mail or his representative, please be aware that any kind of review, publication, reproduction or retransmission of the content of this e-mail is prohibited and may be unlawful. Furthermore, if you have received this email in error, please notify the sender immediately by reply email and then delete this email. Normal e-mails are not protected against access by third parties and consequently their confidentiality may not be assured in certain circumstances. Should any virus enter your systems in connection with this e-mail despite our use of antivirus software, we cannot be held liable for any possible damages.

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/8d569110-437d-4686-a876-d1de567a9d59n%40googlegroups.com.