|
| 1 | +# Running Serenity on Raspberry Pi |
| 2 | + |
| 3 | +## NOTE |
| 4 | + |
| 5 | +This is for development purposes only - Serenity doesn't currently boot on Rasperry Pi! Use this guide if you want to set up a development environment. |
| 6 | + |
| 7 | +Currently only UART output is supported, no display. |
| 8 | + |
| 9 | +## Running in QEMU |
| 10 | + |
| 11 | +### Step 1: Setup Serenity |
| 12 | + |
| 13 | +Please follow [build instructions](BuildInstructions.md) to download and build Serenity. Make sure everything builds successfully for x86. |
| 14 | + |
| 15 | +### Step 2: Build Aarch64 toolchain |
| 16 | + |
| 17 | +Use following the command to build the toolchain for Aarch64: |
| 18 | + |
| 19 | +```console |
| 20 | +Meta/serenity.sh rebuild-toolchain aarch64 |
| 21 | +``` |
| 22 | + |
| 23 | +### Step 3: Build and run in emulator |
| 24 | + |
| 25 | +Use the following command to build and run the Aarch64 kernel: |
| 26 | + |
| 27 | +```console |
| 28 | +Meta/serenity.sh run aarch64 |
| 29 | +``` |
| 30 | + |
| 31 | +It should build Serenity and open a QEMU window, similar to the x86 version. You should see some messages in the terminal. |
| 32 | + |
| 33 | +## Running on real hardware using an SD Card |
| 34 | + |
| 35 | +### Step 0: Download and run Raspberry Pi OS from an SD Card |
| 36 | + |
| 37 | +This step is needed because the original firmware files need to be present on the SD Card when booting Serenity. It will also help with the UART setup. |
| 38 | + |
| 39 | +### Step 1: Connect your Raspberry Pi to your PC using a UART cable |
| 40 | + |
| 41 | +Please follow one of the existing guides (for example [here](https://scribles.net/setting-up-serial-communication-between-raspberry-pi-and-pc)) and make sure UART is working on Raspberry Pi OS before proceeding. |
| 42 | + |
| 43 | +### Step 2: Mount SD Card and modify config.txt file on Boot/ partition |
| 44 | + |
| 45 | +Add the following lines: |
| 46 | + |
| 47 | +``` |
| 48 | +enable_uart=1 |
| 49 | +arm_64bit=1 |
| 50 | +# kernel=serenity.img |
| 51 | +``` |
| 52 | + |
| 53 | +The last line is optional and specifies which kernel to use. You can either replace the default `kernel8.img` file with the Serenity kernel or use a custom file name to be able to easily switch between kernels. |
| 54 | + |
| 55 | +### Step 3: Copy Serenity kernel to SD Card |
| 56 | + |
| 57 | +`kernel8.img` build artifact can be found in `Build/aarch64/Kernel/Prekernel/` directory. Copy it to the main directory on `Boot/` partition, next to the `config.txt` file. You can either replace the original file or use another name (see above). |
| 58 | + |
| 59 | +### Step 4: Put the SD Card in the Raspberry Pi and power on |
| 60 | + |
| 61 | +You should start seeing some messages in your UART terminal window. |
| 62 | + |
| 63 | +## Running on real hardware using network (Raspberry Pi 3) |
| 64 | + |
| 65 | +### Prerequisites |
| 66 | + |
| 67 | +There are multiple ways to set up your network. The easiest way is a direct connection between the Raspberry Pi and your PC. To achieve this your PC has to have an Ethernet port. |
| 68 | + |
| 69 | +Here's the [Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#debugging-network-boot-mode) on booting from the network. |
| 70 | + |
| 71 | +### Step 1: Make sure OTP mode is enabled on the board |
| 72 | + |
| 73 | +This is enabled by default on Raspberry Pi 3+. For the previous boards please see the section [Debugging Network Boot Mode](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#debugging-network-boot-mode) of the Raspberry Pi documentation. |
| 74 | + |
| 75 | +### Step 2: Copy all files from the original SD Card to your PC |
| 76 | + |
| 77 | +This directory will serve as a TFTP server, sending files to the Raspberry Pi when requested. |
| 78 | + |
| 79 | +### Step 2: Set up network interface |
| 80 | + |
| 81 | +Switch the network interface to static mode (static IP) and disable the firewall. |
| 82 | + |
| 83 | +### Step 3: Set up network services |
| 84 | + |
| 85 | +Booting Raspberry Pi requires DHCP and TFTP servers. |
| 86 | + |
| 87 | +On Windows, you can use the [Tftpd32](https://bitbucket.org/phjounin/tftpd64/src/master/) program. |
| 88 | + |
| 89 | +Example configuration for DHCP: |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +Make sure you **disable** the `Ping address before assignment` option. |
| 94 | + |
| 95 | +Example configuration for TFTP: |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +The only option worth noting is `Base Directory` which should contain the files from the SD Card. |
| 100 | + |
| 101 | +### Step 4: Power up the Raspberry Pi |
| 102 | + |
| 103 | +Remove the SD Card, connect an Ethernet cable between the Raspberry Pi and your PC and power on the board. |
| 104 | + |
| 105 | +After 5-10 seconds you should see files being served by the TFTP server: |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +The system should boot normally as it would from the SD Card. |
| 110 | + |
| 111 | +### Step 5: Modify config.txt and copy Serenity kernel |
| 112 | + |
| 113 | +Similarly to booting from SD Card (see above), modify `config.txt` and copy the Serenity kernel to the TFTP directory. |
| 114 | + |
| 115 | +### Step 6: Reset Raspberry Pi |
| 116 | + |
| 117 | +You should start seeing some Serenity messages in your UART terminal window. |
0 commit comments