Ref.
1. https://rtime.felk.cvut.cz/can/lin-bus/
for Uart to linbus
2. https://github.com/linux-can/can-utils
for slcan_attach modify
3. https://github.com/karelzak/util-linux
for ldattach
4. https://github.com/shemminger/iproute2
for ip link set up in C code
///// Linux Kernel /////
1. Copy sllin.c to kernel_imx/drivers/net/can
2. gedit kernel_imx/include/uapi/linux/tty.h
//add
#define N_SLLIN 25
3. Modify Makefile in kernel_imx/drivers/net/can
obj-$(CONFIG_CAN_SLLIN) += sllin.o
4. Add in Kconfig
gedit kernel_imx/drivers/net/can/Kconfig
### begin: issue #3727 ###
config CAN_SLLIN
tristate "Serial / UART serial CAN Adaptors (sllin)"
---help---
slLIN is TTY line discipline implemented for Linux operating
system that handles the interchange of LIN messages between
the underlying UART driver and the CAN bus subsystem.
### end: issue #3727 ###
5. Add in Default Config
gedit kernel_imx/arch/arm/configs/mx6dq_matrix_android_defconfig
### begin: issue #3727 ###
CONFIG_CAN_SLLIN=y
### end: issue #3727 ###
6.
gedit ~/myandroid/external/sepolicy/app.te
//add
neverallow { appdomain -bluetooth -shell -system_app } self:capability *;
7.
gedit /mnt/projects/marsh_200/myandroid/device/fsl/matrix_io/sepolicy/shell.te
//add
allow shell self:capability net_admin;
allow shell self:netlink_route_socket nlmsg_write;
8.
gedit ~/myandroid/device/fsl/matrix_io/sepolicy/system_app.te
//add
allow system_app self:capability net_admin;
allow system_app self:netlink_route_socket nlmsg_write;
/////////////////////////////////////////
///// Android UserSpace /////
1. Copy external/canutils/slcan_attach.c to external/canutils/sllin_attach.c
2. gedit external/canutils/sllin_attach.c
//int ldisc = N_SLCAN;
to
int ldisc = N_SLLIN;
3. gedit bionic/libc/kernel/uapi/linux/tty.h
//add
#define N_SLLIN 25
4. gedit device.mk
//add
### begin: issue #3727 ###
PRODUCT_PACKAGES += \
candump \
cangen \
sllin_attach \
ldattach
### end: issue #3727 ###
5. in Target console A
su
sllin_attach -w /dev/ttymxc2
6. in Local terminal B
adb shell
su
cangen sllin0 -R -I1 -n1 -L0
7. in Local terminal C
adb shell
su
candump sllin0
////////////////////another way from step 5
5. in Target console A
su
ldattach SLLIN /dev/ttymxc2
ip link set sllin0 up
cangen sllin0 -R -I1 -n1 -L0
6. in Target terminal B
adb shell
su
candump sllin0
source download:
http://www.mediafire.com/file/8drkcbu54pvbfwv/sllin_linbus.tar.gz
沒有留言:
張貼留言