Hello,
My aim is to configure the CAN interface at boot up on a iMX8M device running the Android 10 release. I know that this is normally defined in /etc/network/interfaces for Linux devices and I couldn't find a similar interface file in the Android build. I've attempted to create a service in my init.imx8mq_rc file and wrote a script that executes the CAN interface through the command line.
In my init.imx8mq.rc I have
on property:sys.boot_completed=1
start init-cancfg-sh
service init-cancfg-sh /vendor/bin/init.cancfg.sh
class main
user root
group root system.
oneshot
My script init.cancfg.sh contains
#!/system/bin/sh
ip link set can0 up type can bitrate 250000
Note: I have also set SELinux at boot up time in permissive mode.
The service isn't started and I'm not sure what I'm missing with this approach. I am relatively new to customizing AOSP ROMs and any input would be much appreciated.
Thanks and best regards,
Tony
Solved! Go to Solution.
I solved this issue.
In addition to the setup I had in my description, I had to do the following to get my script to work:
- In device/myvendor/mydevice/sepolicy/file_contexts I added:
/vendor/bin/init\.cancfg\.sh u:object_r:init-cancfg-sh_exec:s0
- In device/myvendor/mydevice/sepolicy/init-cancfg-sh.te I added a new domain:
type init-cancfg-sh, domain;
type init-cancfg-sh_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(init-cancfg-sh)
allow init-cancfg-sh vendor_shell_exec:file rx_file_perms;
allow init-cancfg-sh vendor_toolbox_exec:file rx_file_perms;
- Copy the script in the device.mk file:
PRODUCT_COPY_FILES += \
$(IMX_DEVICE_PATH)/init.cancfg.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.cancfg.sh
Hello tony,
I have refer your post and I tried the same script with below content.
#!/system/bin/sh
ip link set can0 up type can bitrate 100000
if i run same command with adb (ip link set can0 up type can bitrate 100000) it works.
But not work inside the script and init.cancfg.sh throw the error as below.
bitrate not found.
why the same command working on debugg terminal not working inside the sh file.
I solved this issue.
In addition to the setup I had in my description, I had to do the following to get my script to work:
- In device/myvendor/mydevice/sepolicy/file_contexts I added:
/vendor/bin/init\.cancfg\.sh u:object_r:init-cancfg-sh_exec:s0
- In device/myvendor/mydevice/sepolicy/init-cancfg-sh.te I added a new domain:
type init-cancfg-sh, domain;
type init-cancfg-sh_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(init-cancfg-sh)
allow init-cancfg-sh vendor_shell_exec:file rx_file_perms;
allow init-cancfg-sh vendor_toolbox_exec:file rx_file_perms;
- Copy the script in the device.mk file:
PRODUCT_COPY_FILES += \
$(IMX_DEVICE_PATH)/init.cancfg.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.cancfg.sh