You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extras/cross-compile/README.md
+25-16Lines changed: 25 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
# Raspberry Pi Linux Cross-compilation Environment
2
2
3
-
> **NOTE**: The old Vagrant and VirtualBox-based build environment is now stored in the [`legacy-vagrant`](legacy-vagrant/) directory.
4
-
5
3
This environment can be used to [cross-compile the Raspberry Pi OS kernel](https://www.raspberrypi.org/documentation/linux/kernel/building.md) from a Linux, Windows, or Mac workstation using Docker.
6
4
7
-
This build configuration has only been tested with the Raspberry Pi 4, CM4, and Pi 400, and run on macOS.
5
+
You can also skip the 'Bringing up the build environment' section and just compile the kernel directly on the Pi itself.
6
+
7
+
This build configuration currently targets Raspberry Pi 5, CM5, and Pi 500/500+, and on macOS using Docker Desktop, using the Pi OS 64-bit build.
8
8
9
9
## Bringing up the build environment
10
10
11
11
1. Install Docker (and Docker Compose if not using Docker Desktop).
12
12
1. Bring up the cross-compile environment:
13
13
14
14
```
15
-
docker-compose up -d
15
+
dockercompose up -d
16
16
```
17
17
18
18
1. Log into the running container:
@@ -27,17 +27,19 @@ You will be dropped into a shell inside the container's `/build` directory. From
27
27
28
28
## Compiling the Kernel
29
29
30
+
If compiling on the Raspberry Pi directly, omit the `ARCH` and `CROSS_COMPILE` options.
31
+
30
32
1. Clone the linux repo (or clone a fork or a different branch):
1. Run the following commands to make the .config file:
38
+
1. Run the following commands to make the .config file (change the `bcm2712` to `bcm2711` if compiling for Pi 4/400/CM4):
37
39
38
40
```
39
41
cd linux
40
-
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
42
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2712_defconfig
41
43
```
42
44
43
45
1. (Optionally) Either edit the .config file by hand or use menuconfig:
@@ -49,12 +51,23 @@ You will be dropped into a shell inside the container's `/build` directory. From
49
51
1. Compile the Kernel:
50
52
51
53
```
52
-
make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs
54
+
make -j6 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs
53
55
```
54
56
55
-
> For 32-bit Pi OS, use `ARCH=arm`, `CROSS_COMPILE=arm-linux-gnueabihf-`, and `zImage` instead of `Image`.
57
+
> I set the jobs argument (`-j6`) conservatively. If you have more processor cores, you may be able to speed up compilation with a higher number, like `-j8` or `-j10`.
56
58
57
-
> I set the jobs argument (`-j8`) based on a bit of benchmarking on my Mac's processor. For different types of processors you may want to use more (or fewer) jobs depending on architecture and how many cores you have.
59
+
**If you're cross-compiling the kernel**: proceed to the next sections.
60
+
61
+
**If you're compiling the kernel on a Raspberry Pi**: install the new kernel and kernel modules directly, then reboot the Pi:
> For 32-bit Pi OS, use `ARCH=arm`, `CROSS_COMPILE=arm-linux-gnueabihf-`, `zImage` instead of `Image`, `kernel7l` instead of `kernel8`, and `arm` instead of `arm64`.
139
-
140
151
### Hard Reset on the CM4 IO Board
141
152
142
153
If you get a fatal kernel panic that doesn't get caught cleanly (which I do, quite often, when debugging PCI Express devices), you can quickly reset the CM4 IO Board by jumping pins 12 and 14 on J2 (`GLOBAL_EN` to `GND`).
0 commit comments