Flexcan Bring up on boot up service with Android 11

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

Flexcan Bring up on boot up service with Android 11

1,724 Views
Adi99
Contributor I

Hello,

I am working on I.MX 8M Plus with Android 11.

I want to bring the Flexcan with I.MX 8m Plus.

In current state Flexcan driver is loaded and I am able to see the can0 node by hitting ifconfig -a.

But to up and run I need to hit "ip link set can0 up type can bitrate 1000000 sample-point 0.75 dbitrate 2000000 dsample-point 0.8 fd on" 

To up and run i created below script init.cancfg.sh

#! /vendor/bin/sh

ip link set can0 up type can bitrate 1000000 sample-point 0.75 dbitrate 2000000 dsample-point 0.8 fd on

 I am able to copy the .sh in to vendor bin with the help of below command in evk_8mp.mk

PRODUCT_COPY_FILES +=\
device/nxp/common/init/init.cancfg.sh:vendor/bin/init.cancfg.sh

I added below sepolicy in init-cancfg-sh.te

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;

This sepolicy i added in file_contexts

/vendor/bin/init\.cancfg\.sh u:object_r:init-cancfg-sh_exec:s0

And below is my service init.cancfg.rc :

service init-cancfg-sh /vendor/bin/init.cancfg.sh

class late_start
user root
group root system
oneshot

on property:sys.boot_completed=1
start init-cancfg-sh

My Shell script if working while i am running manually with below logs:

 evk_8mp:/ # sh vendor/bin/init.cancfg.sh
[10196.361149][ T1748] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready

 

When it is running from service init-cancfg-sh :

[102.612966][ T1] init: starting service 'init-cancfg-sh'...
[102.622699][ T1] init: Control message: Processed ctl.start for 'init-cancfg-sh' from pid: 1750 (start init-cancfg-sh)
evk_8mp:/ # [102.661876][ T1] init: Service 'init-cancfg-sh' (pid 1751) exited with status 0 oneshot service took 0.041000 seconds in background
[102.674131][ T1] init: Sending signal 9 to service 'init-cancfg-sh' (pid 1751) process group...
[102.683363][ T1] libprocessgroup: Successfully killed process cgroup uid 0 pid 1751 in 0ms

 

And can0 is not up and Run

 

Can anyone suggest to bring flexcan on boot up service?

 

Thanks

0 Kudos
Reply
2 Replies

1,616 Views
Adi99
Contributor I

HI @brian14 Thank you for your reply.

I resolved this issue its similar as your solution. 

can you help to me in another questions regarding ethernet eqos : https://community.nxp.com/t5/i-MX-Processors/Bring-up-Ethernet-1-eqos-in-imx8mp-evaluation-kit/m-p/1...

0 Kudos
Reply

1,630 Views
brian14
NXP TechSupport
NXP TechSupport

Hi @Adi99

Please accept my apologies for the delayed reply.

My colleague in our internal team, try to replicate your issue and had the following result:

He is using an android_11.0.0_2.4 image.
It seems that you are missing one line.

service init-cancfg-sh /vendor/bin/init.cancfg.sh
classlate_startuser root
group root
oneshot
disabled
seclabel u:r:init:s0
on property:sys.boot_completed=1&&property:ro.build.type=userdebug
start init-cancfg-sh

It is working the CAN0 is enabled after the boot process.

Brian_Ibarra_0-1675887104223.png

If you have any questions or concerns, don’t hesitate to let me know.

0 Kudos
Reply