1 1
matrzh

How to setup an environment to build custom kernel modules

Recommended Posts

This may be a somewhat stupid question, but I just cannot find anything about it.

  • I have custom-compiled the kernel for Allwinner A20/cubietruck as described here on a Virtual Box Ubuntu 18.04
  • Once done, I took the *.deb files out of output/debs, copied it to the machine and installed them.  Everything worked fine and so far so good B).   But the "build" directory on the host with the compile.sh script is surprisingly empty.
  • However, if I want to cross compile an additional kernel module on the virtual machine, how do I set this up?  Is it enough to "make" with CROSS-COMPILE=arm-linux-gnueabihf-?  or do I also need to somehow consider the linaro stuff in cache/toolchains?   (the arm-linux-gnueabihf files are all in the /usr/bin of the host machine)
  • I also want to reference some header-files (*.h) from the drivers sources, etc. can I copy the directory /usr/src/linux-headers-4.14....-sunxi? What happens if I extract the linux-source-next-sunxi_5.66_all.deb file to the virtual host machine?
  • Also as a side note: if I want to recompile to enable an additional module, what do I do to use the old kernel configuration as a base?  When I run "compile.sh" again, I get the choice to choose "cubietruck" again, but it starts from zero and does not consider any options I had previously disabled or changed.

 

The reason, I am doing this, is that I am upgrading from a legacy kernel and I have some custom modules to control peripherals here and here, that I want to adapt to the new kernel.

Share this post


Link to post
Share on other sites

No. But I am still at the stage to set up a decent IDE, so that I can include header files for other kernel drivers etc.  I do not believe that the modules will just compile, the gpio is handled differently in the new kernel and I would actually like to explore the code a bit (without changing it).  The *.h files will probably suffice to see what definitions exist.

Actually, I would just have to know where the sources are, after compile.sh is being run.

Share this post


Link to post
Share on other sites

O.k.  I just had to include the path /usr/src/linux-headers-4.14...sunxi/include and the code sense works.

Guess I can take it from here. The normal "cross compile" seems to work, too.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
1 1