Need to add custom script as service in init.rc for Android 9

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

Need to add custom script as service in init.rc for Android 9

Jump to solution
6,872 Views
vinothkumars
Senior Contributor IV

Dear NXP,

I am working on i.MX 6Quad SABRE-SD with Android 9. I am planning to add USB Re-flash (custom script) service in Android 9.

I done the below configuration to start the service. But, the service is not started. Please let me know if I miss anything.

Below are the configuration,

1. Copy this script (usb-update.sh) to the following location
            /device/fsl/imx6dq/sabresd_6dq

2. Add the following command
            /device/fsl/imx6dq/sabresd_6dq/usb-update.sh: system/bin/usb-update.sh
            To Copy command to copy usb-update.sh to /system/bin location in the following file sabresd_6dqr.mk under following section PRODUCT_COPY_FILES

3. Add USB-UPDATE into the PRODUCT_PACKAGE section of sabresd_6dqr.mk file

4. Define the service in file init.rc
            service usb-update /system/bin/ usb-update.sh
                     class main

                     user root

                     group root system
                     oneshot
                     seclabel u:r: usb-update:s0

5. Add a new Domain “usb-update

      a. Create the file in the following location,
               /device/fsl/imx6dq/sabresd_6dq/sepolicy/usb-update.te
              And add the following content,
                # USB-UPDATE service
               type usb-update, domain;
               type usb-update_exec, exec_type, file_type;

      

               init_deamon_domain(foo)

b. Add the Label “/system/bin/usb-update.sh” to device/fsl/imx6dq/sepolicy/ file_contexts
            /system/bin/usb-update     u:object_r: usb-update_exec:s0

Thanks & Regards,

VinothS.

Regards,
Vinothkumar Sekar
Labels (2)
0 Kudos
1 Solution
5,484 Views
vinothkumars
Senior Contributor IV

This is the problem with order. obd process is depends upon the usb-update process. So, I needs to defined usb-update first followed by obd process.

Regards,

VinothS

Regards,
Vinothkumar Sekar

View solution in original post

0 Kudos
6 Replies
5,485 Views
vinothkumars
Senior Contributor IV

This is the problem with order. obd process is depends upon the usb-update process. So, I needs to defined usb-update first followed by obd process.

Regards,

VinothS

Regards,
Vinothkumar Sekar
0 Kudos
5,484 Views
vinothkumars
Senior Contributor IV

I done the following configuration and It's working fine. 

1. Add the script to the following location
         /device/fsl/imx6dq/sabresd_6dq/usb-update.sh
2. Add the following command in the sabresd_6dqr.mk file under PRODUCT_COPY_FILES section,
         /device/fsl/imx6dq/sabresd_6dq/usb-update.sh: system/bin/usb-update.sh
3. Add USB-UPDATE into the PRODUCT_PACKAGE section of sabresd_6dqr.mk file
4. Modify PRODUCT_FULL_TREBLE_OVERRIDE := false in sabresd_6dqr.mk file
5. Define the service in init.rc file
         service usb-update /system/bin/ usb-update.sh
               class main
               user root
               oneshot
               seclabel u:r: usb-update:s0

6. Add a new Domain named as usb-update
   a. Create the file in the following location,
            /device/fsl/imx6dq/sabresd_6dq/sepolicy/usb-update.te
   And add the following content,
            # USB-UPDATE service
            type usb-update, domain;
            type usb-update_exec, exec_type, file_type;
            init_deamon_domain(foo)
            domain_auto_trans(init, shell_exec, usb-update)

   b. Add the Label “/system/bin/usb-update.sh” to device/fsl/imx6dq/sepolicy/ file_contexts
         /system/bin/usb-update seclabel u:r: usb-update:s0

Note:

   This configuration is working in boot level. But, when enter into the user space this service is not running.

Regards,

VinothS.

Regards,
Vinothkumar Sekar
0 Kudos
5,484 Views
vinothkumars
Senior Contributor IV

Dear NXP,

I got some problem when integrate the same configuration for OBD,

SELinux:  Context u:object_r:obd_exec:s0 is not valid (left unmapped).

If anyone experience in this, please response.

Configuration,

1. Define the service in init.rc file
         service obd /system/bin/obd
               class main
               user root
               oneshot
               seclabel u:r: obd:s0

2. Add a new Domain named as obd
   a. Create the file in the following location,
            /device/fsl/imx6dq/sabresd_6dq/sepolicy/obd.te
   And add the following content,
            # obd service
            type obd, domain;
            type obd_exec, exec_type, file_type;
            init_deamon_domain(obd)
            domain_auto_trans(init, shell_exec, obd)

   b. Add the Label “/system/bin/obd” to device/fsl/imx6dq/sepolicy/ file_contexts
         /system/bin/obd        seclabel u:r:obd_exec:s0

Thanks & Regards,

VinothS.

Regards,
Vinothkumar Sekar
0 Kudos
5,484 Views
vinothkumars
Senior Contributor IV

Dear NXP,

 

I got some problem when integrate the same configuration for OBD,

 

SELinux:  Context u:object_r:obd_exec:s0 is not valid (left unmapped).

 

If anyone experience in this, please response.

Thanks & Regards,

VinothS

Regards,
Vinothkumar Sekar
0 Kudos
5,484 Views
b36401
NXP Employee
NXP Employee

Please make sure that your script has right permissions and you have proper interpterer in the OS.

0 Kudos
5,484 Views
vinothkumars
Senior Contributor IV

Thank you Victor.

Regards,
Vinothkumar Sekar
0 Kudos