Andre Przywara | a868598 | 2016-07-08 15:25:23 +0100 | [diff] [blame] | 1 | Pine64 board README |
| 2 | ==================== |
| 3 | |
| 4 | The Pine64(+) is a single board computer equipped with an AArch64 capable ARMv8 |
| 5 | compliant Allwinner A64 SoC. |
| 6 | This chip has ARM Cortex A-53 cores and thus can run both in AArch32 |
| 7 | (compatible to 32-bit ARMv7) and AArch64 modes. Upon reset the SoC starts |
| 8 | in AArch32 mode and executes 32-bit code from the Boot ROM (BROM). |
| 9 | This has some implications on U-Boot. |
| 10 | |
| 11 | Quick start |
| 12 | ============ |
| 13 | - Get hold of a boot0.img file (see below for more details). |
| 14 | - Get the boot0img tool source from the tools directory in [1] and compile |
| 15 | that on your host. |
| 16 | - Build U-Boot: |
| 17 | $ export CROSS_COMPILE=aarch64-linux-gnu- |
| 18 | $ make pine64_plus_defconfig |
| 19 | $ make |
| 20 | - You also need a compiled ARM Trusted Firmware (ATF) binary. Checkout the |
| 21 | "allwinner" branch from the github repository [2] and build it: |
| 22 | $ export CROSS_COMPILE=aarch64-linux-gnu- |
| 23 | $ make PLAT=sun50iw1p1 DEBUG=1 bl31 |
| 24 | The resulting binary is build/sun50iw1p1/debug/bl31.bin. |
| 25 | |
| 26 | Now put an empty (or disposable) micro SD card in your card reader and learn |
| 27 | its device file name, replacing /dev/sd<x> below with the result (that could |
| 28 | be /dev/mmcblk<x> as well): |
| 29 | |
| 30 | $ ./boot0img --device /dev/sd<x> -e -u u-boot.bin -B boot0.img \ |
| 31 | -d trampoline64:0x44000 -s bl31.bin -a 0x44008 -p 100 |
| 32 | (either copying the respective files to the working directory or specifying |
| 33 | the paths directly) |
| 34 | |
| 35 | This will create a new partition table (with a 100 MB FAT boot partition), |
| 36 | copies boot0.img, ATF and U-Boot to the proper locations on the SD card and |
| 37 | will fill in the magic Allwinner header to be recognized by boot0. |
| 38 | Prefix the above call with "sudo" if you don't have write access to the |
| 39 | uSD card. You can also use "-o output.img" instead of "--device /dev/sd<x>" |
| 40 | to create an image file and "dd" that to the uSD card. |
| 41 | Omitting the "-p" option will skip the partition table. |
| 42 | |
| 43 | Now put this uSD card in the board and power it on. You should be greeted by |
| 44 | the U-Boot prompt. |
| 45 | |
| 46 | |
| 47 | Main U-Boot |
| 48 | ============ |
| 49 | The main U-Boot proper is a real 64-bit ARMv8 port and runs entirely in the |
| 50 | 64-bit AArch64 mode. It can load any AArch64 code, EFI applications or arm64 |
| 51 | Linux kernel images (often named "Image") using the booti command. |
| 52 | Launching 32-bit code and kernels is technically possible, though not without |
| 53 | drawbacks (or hacks to avoid them) and currently not implemented. |
| 54 | |
| 55 | SPL support |
| 56 | ============ |
| 57 | The main task of the SPL support is to bring up the DRAM controller and make |
| 58 | DRAM actually accessible. At the moment there is no documentation or source |
| 59 | code available which would do this. |
| 60 | There are currently two ways to overcome this situation: using a tainted 32-bit |
| 61 | SPL (involving some hacks and resulting in a non-redistributable binary, thus |
| 62 | not described here) or using the Allwinner boot0 blob. |
| 63 | |
| 64 | boot0 method |
| 65 | ------------- |
| 66 | boot0 is Allwiner's secondary program loader and it can be used as some kind |
| 67 | of SPL replacement to get U-Boot up and running. |
| 68 | The binary is a 32 KByte blob and contained on every Pine64 image distributed |
| 69 | so far. It can be easily extracted from a micro SD card or an image file: |
| 70 | # dd if=/dev/sd<x> of=boot0.bin bs=8k skip=1 count=4 |
| 71 | where /dev/sd<x> is the device name of the uSD card or the name of the image |
| 72 | file. Apparently Allwinner allows re-distribution of this proprietary code |
| 73 | as-is. |
| 74 | For the time being this boot0 blob is the only redistributable way of making |
| 75 | U-Boot work on the Pine64. Beside loading the various parts of the (original) |
| 76 | firmware it also switches the core into AArch64 mode. |
| 77 | The original boot0 code looks for U-Boot at a certain place on an uSD card |
| 78 | (at 19096 KB), also it expects a header with magic bytes and a checksum. |
| 79 | There is a tool called boot0img[1] which takes a boot0.bin image and a compiled |
| 80 | U-Boot binary (plus other binaries) and will populate that header accordingly. |
| 81 | To make space for the magic header, the pine64_plus_defconfig will make sure |
| 82 | there is sufficient space at the beginning of the U-Boot binary. |
| 83 | boot0img will also take care of putting the different binaries at the right |
| 84 | places on the uSD card and works around unused, but mandatory parts by using |
| 85 | trampoline code. See the output of "boot0img -h" for more information. |
| 86 | boot0img can also patch boot0 to avoid loading U-Boot from 19MB, instead |
| 87 | fetching it from just behind the boot0 binary (-B option). |
| 88 | |
| 89 | FEL boot |
| 90 | ========= |
| 91 | FEL is the name of the Allwinner defined USB boot protocol built-in the |
| 92 | mask ROM of most Allwinner SoCs. It allows to bootstrap a board solely |
| 93 | by using the USB-OTG interface and a host port on another computer. |
| 94 | Since FEL boot does not work with boot0, it requires the libdram hack, which |
| 95 | is not described here. |
| 96 | |
| 97 | [1] https://github.com/apritzel/pine64/ |
| 98 | [2] https://github.com/apritzel/arm-trusted-firmware.git |