Jump to content

best practice - adding a kernel driver as user (eg. CAN-A20 from olimex)


winfried

Recommended Posts

Hello,

 

I am not very experienced on the Armbian development and want to add a kernel driver to the legacy kernel using the compile.sh development tool, but did not grasp the best practice to add the kernel source reading some forum posts and docs.

 

As a start lets add the sunxi-can driver for the Olimex CAN-A20  interface  for legacy kernel for Olimex lime2 A20 board like described in the Wiki at Olimex:

 

 https://www.olimex.com/wiki/A20-CAN

 

I did:

 

a)  http://docs.armbian.com/Developer-Guide_Build-Preparationon an virtual box on my machine

and can successfully build kernel packages and apply user-patches

 

B) enable some patches like the

 copy /patch/kernel/sun7i-default/0015-sunxi-codec_LL.patch.disabled to user-patches/...

 

and build new kernel packages for my board and tested it.

 

To add the driver

 

a)  cloned the driver source:

 git clone https://github.com/btolfa/sunxi-can-driver.git

 

So the first questions for best practice:

 

 1) where to place the source so it is not removed on updates ?

 

 2) How to change

  linux-sunxi/drivers/net/can/Kconfig and linux-sunxi/drivers/net/can/Makefile ?

 

 3) How to change the linux config without everytime run the menuconfig and being able to

  update new versions of config file if new kernel arrives ?

 

mfg

 winfried

Link to comment
Share on other sites

3/

copy the ".config" file with the pattern in userpatches folder

I am using

userpatches/linux-sunxi-next.config

userpatches/linux-odroidxu4-next.config

 

2/

unless better piece of advise, create a patch for the 2 files then put them in userpatches/kernel (?)

 

1/

idea 1: create a patch with all the source (???)

idea 2: use symlinks ???

Link to comment
Share on other sites

 1) where to place the source so it is not removed on updates ?

 

 2) How to change

  linux-sunxi/drivers/net/can/Kconfig and linux-sunxi/drivers/net/can/Makefile ?

This can be done with a single patch that adds new source files and adds new options to Kconfig and Makefile. Or even better - after you test and confirm that this driver works with your board, this driver can be added to default Armbian kernel since I don't see any CAN related options enabled in our sun7i-default config.

Link to comment
Share on other sites

3/

copy the ".config" file with the pattern in userpatches folder

I am using

userpatches/linux-sunxi-next.config

userpatches/linux-odroidxu4-next.config

 

2/

unless better piece of advise, create a patch for the 2 files then put them in userpatches/kernel (?)

 

1/

idea 1: create a patch with all the source (???)

idea 2: use symlinks ???

 

I thought so, but then I saw userpatches/overlay...

It is mentioned it is for the image, but I do not really understand how I can use it, is there an example ?

so I cannot put additional driver source in it.

 

This can be done with a single patch that adds new source files and adds new options to Kconfig and Makefile. Or even better - after you test and confirm that this driver works with your board, this driver can be added to default Armbian kernel since I don't see any CAN related options enabled in our sun7i-default config.

 

Ok, I will do so and test beginning next week, when I have access to a CAN bus again and post it here  ?

 

Thanks for the answers.

Link to comment
Share on other sites

You can test this precompiled kernel if you want.

Kernel module is called "sun7i_can"

Thanks again.

 

This brings me to another question before I go testing tomorrow:

 

- How to name the packages, for example linux-image ?

 

If having the same name as the distribution on update it will be overwritten easily.

I want to distribute the kernel debian packages to be installed in the nodes and updated if I update them on server.

 

Since I apply some patches I also would add this info

like

  "linux-image-sun7i-3.4.112-rt-can_5.20_armhf.deb"

or for koco modules.

  "linux-image-sun7i-koco_5.20_armhf.deb"

 

Where can I change naming and version numbers of generated debian packages  ?

Link to comment
Share on other sites

This brings me to another question before I go testing tomorrow:

 

- How to name the packages, for example linux-image ?

 

If having the same name as the distribution on update it will be overwritten easily.

I want to distribute the kernel debian packages to be installed in the nodes and updated if I update them on server.

 

Since I apply some patches I also would add this info

like

  "linux-image-sun7i-3.4.112-rt-can_5.20_armhf.deb"

or for koco modules.

  "linux-image-sun7i-koco_5.20_armhf.deb"

 

Where can I change naming and version numbers of generated debian packages  ?

These names are based on variables (i.e. $LINUXFAMILY) in build script, it's not easy to change them. Anyway, if this patch or kernel works for you, I'll just add it to default Armbian kernel, so you don't have to worry about updates or kernel package names.

Link to comment
Share on other sites

Where can I change naming and version numbers of generated debian packages  ?

 

I guess zador.blood.stain hasn't still changed the variable, I am using SUBREVISION="-GRO" it doesn't rename the debian package but still the tags is changed in dpkg/aptitude so Armbian 5.21 is renamed 5.21-GRO

Link to comment
Share on other sites

UPDATE -  CAN Bus didnt work:

  It always hung after some seconds of receiving until we found that it was a electrical problem,

  a non isolated CAN-Bus on another voltage ground.

  Unfortunately we could not finish the tests before return of the vehicle, therefore I cannot confirm the working patch until now.

 

PS: I will do another try on the CAN-Bus of my Zero E-motorcycle in spring and report.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines