Added a note about building a cross-compiler from source, with a link

This commit is contained in:
Adam Greenwood-Byrne 2021-05-13 12:07:17 +01:00
parent 53659fa2d1
commit e62142f516

View file

@ -6,7 +6,7 @@ Building on the RPi4 itself
It's possible (but not super-simple) to follow this tutorial on the Raspberry Pi without need for an additional build device. It's possible (but not super-simple) to follow this tutorial on the Raspberry Pi without need for an additional build device.
It will require you firstly to re-image your Pi to use the 64-bit Raspberry Pi OS (Beta): Perhaps the easiest route is to firstly re-image your Pi to use the 64-bit Raspberry Pi OS (Beta), and then use a pre-built cross-compiler:
* Download a zipped _.img_ image file from the [64-bit image list](https://downloads.raspberrypi.org/raspios_arm64/images/), picking the newest update * Download a zipped _.img_ image file from the [64-bit image list](https://downloads.raspberrypi.org/raspios_arm64/images/), picking the newest update
* Unzip it and use the [Raspberry Pi Imager](https://www.raspberrypi.org/software/) to write it to your SD card, selecting "Use custom" from the options and pointing it at your downloaded _.img_ file * Unzip it and use the [Raspberry Pi Imager](https://www.raspberrypi.org/software/) to write it to your SD card, selecting "Use custom" from the options and pointing it at your downloaded _.img_ file
@ -19,12 +19,14 @@ What you're looking for is the current [AArch64 ELF bare-metal target (aarch64-n
Then unpack the archive using `tar -xf <filename>`. You'll end up with a _gcc_ directory (albeit with a slightly longer name), which itself contains a _bin_ subdirectory, wherein you'll find the _gcc_ executable (again - with a longer name!). Remember this path. Then unpack the archive using `tar -xf <filename>`. You'll end up with a _gcc_ directory (albeit with a slightly longer name), which itself contains a _bin_ subdirectory, wherein you'll find the _gcc_ executable (again - with a longer name!). Remember this path.
Note: if you don't want to re-image, you can [build a cross-compiler yourself](https://wiki.osdev.org/GCC_Cross-Compiler).
Now let's build something: Now let's build something:
* Use `git` to clone this repo: `git clone https://github.com/isometimes/rpi4-osdev.git` * Use `git` to clone this repo: `git clone https://github.com/isometimes/rpi4-osdev.git`
* Decide which part you want to build - I like testing with _part5-framebuffer_ (it's visual, so you'll know when it works!) * Decide which part you want to build - I like testing with _part5-framebuffer_ (it's visual, so you'll know when it works!)
* Copy the _Makefile.gcc_ to _Makefile_ * Copy the _Makefile.gcc_ to _Makefile_
* Edit the _Makefile_ and ensure the `GCCPATH` variable points to the _bin_ subdirectory that you just unpacked * Edit the _Makefile_ and ensure the `GCCPATH` variable points to the _bin_ subdirectory where your cross-compiler is to be found
* Type `make` at the command line and it should build without errors * Type `make` at the command line and it should build without errors
If you want to then boot with this, you'll need to copy the _kernel8.img_ file to a prepped SD card as the tutorial discusses. For the purposes of testing this process, I did the following (NOTE: it will trash your OS install unless you backup the old files so you can move them back later): If you want to then boot with this, you'll need to copy the _kernel8.img_ file to a prepped SD card as the tutorial discusses. For the purposes of testing this process, I did the following (NOTE: it will trash your OS install unless you backup the old files so you can move them back later):