sartura / replica

Replica.one is an easy to use build system designed to deliver both secure and flexible firmware images.
MIT License
26 stars 12 forks source link

how to add new drivers #11

Closed Sheng2216 closed 3 years ago

Sheng2216 commented 3 years ago

We learned that replica downloads kernel source code from raspberry pi’s website, if we want to add a new driver, how to do it? Our current approach is to do cross-compile and generate a driver module for later usages, are there any other ways to do this? Is there a patch-like method to change the kernel’s source code?

jpetrina commented 3 years ago

New drivers can be added either by: (1) pre-compiling out-of-tree kernel modules for the target kernel version and simply adding them as kernel shared objects (.ko files) to the overlay mechanism, or by (2) forking the upstream Linux repository and changing the target repository in Replica to build the specific fork.

Although Portage supports patching, one of our design goals has been to avoid introducing patch files for the kernel in the repository tree; we prefer having upstreamed all patches before building production images. However, for development efforts we maintain a fork of the Linux kernel repository which we use to build development images and as a staging area for the upstreaming process.

jsmolic commented 3 years ago

@Sheng-IoT This is now documented in the wiki pages, let me know if you have any additional questions regarding adding kernel drivers. Thanks!

Sheng2216 commented 3 years ago

Thank you for the detailed documentation, is it possible for you to further explain how replica.one's overlay mechanism works? Do I just simply copy the driver's .ko file and drop it into the overlay folder? Or, I should create a directory just like rpi4/etc/systemd/network for the driver's .ko file?

jsmolic commented 3 years ago

You can simply create a directory in the overlay/rpi4 where kernel drivers are usually located, i.e. /lib/modules/$(uname -r) and put your module there