Difference between revisions of "U-Boot"

From PINE64
Jump to navigation Jump to search
Line 17: Line 17:
==Compilation==
==Compilation==


{{hint| This guide is written with the Pinephone in mind. On other devices you will need to set a different platform variable and use different uboot sources.}}
{{hint| This guide is written with the Pinephone in mind. On other devices you will need to set a different platform variable and likely use a different uboot source with patches oriented towards your device.}}
 
Note by default these instructions utilize all of your computers cores to compile thanks to the <code>-j</code> and <code>$(nproc)</code> parameters. If you wish to only use one core to compile, or change the number of cores used for example to only two cores, then you can either completely remove the <code>-j$(nproc)</code> parameter from the make commands, or just take off <code>$(nproc)</code> and add the number of threads you want used in it's place: <code>-j4</code>


First, You need to compile ATF (Arm Trusted Firmware):
First, You need to compile ATF (Arm Trusted Firmware):
Line 26: Line 28:
  export CROSS_COMPILE
  export CROSS_COMPILE
  export ARCH=arm64
  export ARCH=arm64
  make PLAT=sun50i_a64 bl31
  make PLAT=sun50i_a64 -j$(nproc) bl31
  cd ..
  cd ..
</pre>
</pre>
Line 38: Line 40:
</pre>
</pre>


Note that you can append <code>-j#</code> to the end of <code>make all</code> in the proceeding instructions. Replacing the hashtag with the number of threads in your computer's CPU which you want to use for compiling, will make it go faster and use more of your processor.
<pre>
git clone https://github.com/crust-firmware/crust
cd crust
export CROSS_COMPILE=or1k-linux-musl-
make pinephone_defconfig
make -j$(nproc) scp
cp /build/scp/scp.bin ../u-boot/
</pre>


{{note| If you do not wish to have crust in your uboot build, then you can skip exporting SCP}}
{{note| If you do not wish to have crust in your uboot build, then you can skip exporting SCP}}
Line 49: Line 58:
  export BL31=bl31.bin
  export BL31=bl31.bin
  export ARCH=arm64
  export ARCH=arm64
  export SCP=/src/crust/build/scp/scp.bin
  export SCP=scp.bin
  make distclean
  make distclean
  make pinephone_defconfig
  make pinephone_defconfig
  make all
  make all -j$(nproc)
</pre>
</pre>



Revision as of 02:35, 15 February 2021

This page is incomplete, you're welcome to improve it.
It is helpful to have a debugging serial cable for this.
Warning: This is purely U-boot build instructions at this time! You will not have crust for your Pinephone should you follow this guide.

Building uboot manually

Prerequisites

These instructions are written with a host Arch Linux desktop system in mind.

This guide will be especially useful if you are looking to overclock the ram on your Pinephone following the information found here.

You must have these packages installed: dtc swig bc aarch64-linux-gnu-gcc

If you are using a different system such as Ubuntu, there are plenty of cross compilation instructions available online with which you can grab the needed package names from, and then proceed to follow these instructions.

Compilation

This guide is written with the Pinephone in mind. On other devices you will need to set a different platform variable and likely use a different uboot source with patches oriented towards your device.

Note by default these instructions utilize all of your computers cores to compile thanks to the -j and $(nproc) parameters. If you wish to only use one core to compile, or change the number of cores used for example to only two cores, then you can either completely remove the -j$(nproc) parameter from the make commands, or just take off $(nproc) and add the number of threads you want used in it's place: -j4

First, You need to compile ATF (Arm Trusted Firmware):

 git clone https://github.com/crust-firmware/arm-trusted-firmware/
 cd arm-trusted-firmware
 CROSS_COMPILE=aarch64-linux-gnu-
 export CROSS_COMPILE
 export ARCH=arm64
 make PLAT=sun50i_a64 -j$(nproc) bl31
 cd ..

After ATF is compiled clone u-boot and copy the bl31.bin file into the u-boot directly.

git clone https://gitlab.com/pine64-org/u-boot.git
cd arm-trusted-firmware
cp build/sun50i_a64/release/bl31.bin ../u-boot/
cd ..
git clone https://github.com/crust-firmware/crust
cd crust
export CROSS_COMPILE=or1k-linux-musl-
make pinephone_defconfig
make -j$(nproc) scp
cp /build/scp/scp.bin ../u-boot/
If you do not wish to have crust in your uboot build, then you can skip exporting SCP
 cd u-boot/
 git checkout crust
 CROSS_COMPILE=aarch64-linux-gnu-
 export CROSS_COMPILE
 export BL31=bl31.bin
 export ARCH=arm64
 export SCP=scp.bin
 make distclean
 make pinephone_defconfig
 make all -j$(nproc)

Uboot installation

Once successfully compiled you can proceed to flash the device

Warning: Replace [CHANGE THIS] with the location of your SD card

sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/[CHANGE THIS] bs=1024 seek=8

If you are compiling uboot in order to overclock your DRAM you can check if it was successful by reading the values of /sys/kernel/debug/clk/clk_summary

Pboot multi-bootloader

One of the smallest and fastest pinephone bootloaders, it was developed by Ondrej Jirman with the ability of booting multiple distros on the pinephone in mind.

More information can be found here

External Links

Sunxi Uboot Wiki

Uboot build instructions