{"id":23280517,"url":"https://github.com/alwint3r/crosscompile-raspberrypi-kernel-docker","last_synced_at":"2026-04-18T07:32:25.867Z","repository":{"id":76136016,"uuid":"212865129","full_name":"alwint3r/crosscompile-raspberrypi-kernel-docker","owner":"alwint3r","description":"Cross-compile Raspberry Pi kernel on a docker container.","archived":false,"fork":false,"pushed_at":"2019-10-08T14:57:00.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-07T01:34:06.315Z","etag":null,"topics":["docker","linux-kernel","raspberry-pi"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alwint3r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-04T17:07:20.000Z","updated_at":"2025-02-07T12:24:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd74ddef-0222-4b39-829b-4c80f1727d21","html_url":"https://github.com/alwint3r/crosscompile-raspberrypi-kernel-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alwint3r/crosscompile-raspberrypi-kernel-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwint3r%2Fcrosscompile-raspberrypi-kernel-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwint3r%2Fcrosscompile-raspberrypi-kernel-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwint3r%2Fcrosscompile-raspberrypi-kernel-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwint3r%2Fcrosscompile-raspberrypi-kernel-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alwint3r","download_url":"https://codeload.github.com/alwint3r/crosscompile-raspberrypi-kernel-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alwint3r%2Fcrosscompile-raspberrypi-kernel-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","linux-kernel","raspberry-pi"],"created_at":"2024-12-19T23:36:23.304Z","updated_at":"2026-04-18T07:32:25.851Z","avatar_url":"https://github.com/alwint3r.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"Cross-compiling Raspberry Pi Kernel on a Docker Container\n=========================================================\n\nAn Ubuntu 16.04-based environment for cross-compiling Raspberry Pi kernel.\n\n## Why?\n\nIsolation. I need it so bad because I screwed up my host environment.\n\n## Pros \u0026 Cons\n\n**Pros**\n\n* Faster build time, assuming your machine is far more powerful than a Raspberry Pi.\n\n\n**Cons**\n\n* Installing a newly built kernel isn't that simple, especially if you're targetting a Raspberry Pi Compute Module board.\n\n\nIt's a lot simpler if you build the kernel on the Pi itself, but the whole process can take hours to finish.\n\n## Starting the Container\n\nClone the repository\n\n```sh\ngit clone https://github.com/alwint3r/raspberrypi-kernel-crosscompile\n```\n\nMove to the cloned repository, then build the docker image.\n```sh\ndocker build -t rpi-cross-compile:latest .\n```\n\nDon't forget to set up a directory to store the compilation result on your host machine. Mount that directory as one of the volumes of the container using `/root/raspberrypi` as the mount point. For example, I'm going to use the `raspberrypi-linux` directory in my home directory.\n\n```sh\ndocker run --name rpi-cross-compile-kernel -it \\\n -v $HOME/raspberrypi-linux:/root/raspberrypi \\\n rpi-cross-compile:latest \\\n /bin/bash\n```\n\nA new container named `rpi-cross-compile-kernel` will be created and a new bash session will be opened.\n\n## Getting the Kernel Source Code\n\nYou can get the source code by cloning the whole repository at `https://github.com/raspberrypi/linux`.\n```sh\ngit clone https://github.com/raspberrypi/linux\n```\n\nIf you prefer to get the source code at a specific branch only, then run the following command:\n\n```sh\ngit clone --depth=1 --branch rpi-4.18.y https://github.com/raspberrypi/linux\n```\n\nIn the example above, the branch that we'll get is rpi-4.18.y which means we will get the source code for kernel version 4.18. If you prefer another version, then just change the branch name to match your preferred kernel version.\n\n## Building the Kernel\n\nYou can follow the guide on the [official documentation](https://www.raspberrypi.org/documentation/linux/kernel/building.md).\n\nThe steps are pretty much the same as the guide on the official documentation.\n\nHere's what I did\n\n1. Configuring kernel for target, in this case, I'm targetting a Compute Module 3\n\n```sh\nmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig\n```\n\n2. Run `menuconfig` to configure the kernel, you can skip this step if you think it's not necessary. It is necessary for me because I need to enable a staging driver.\n\n```sh\nmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig\n```\n\n3. Start building the kernel image, modules, and device trees\n\n```sh\nmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs\n```\n\nYes, you can use `j N` flagh with N is the number of jobs that will be run at the same time.\n\n4. As for installing the modules, I need to copy the entire kernel source code to my Raspberry Pi and then run the installation of the modules there. It is a lot easier than copying the pre-installed modules on your container to the Raspberry Pi. Trust me, you don't want to deal with symlinks.\n\nIn the Raspberry Pi terminal, inside the linux kernel directory\n```sh\nsudo make install_modules\n```\n\n5. If you need to compile a driver source code based on the kernel that you just compiled yourself, see [this guide](https://forum.loverpi.com/discussion/555/how-to-fix-dkms-error-bin-sh-1-scripts-basic-fixdep-exec-format-error). We need to compile the scripts in the Raspberry Pi instead of in our host machine.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwint3r%2Fcrosscompile-raspberrypi-kernel-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falwint3r%2Fcrosscompile-raspberrypi-kernel-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwint3r%2Fcrosscompile-raspberrypi-kernel-docker/lists"}