|
| 1 | +--- |
| 2 | +riscv_hardware: true |
| 3 | +cmake_plat: star64 |
| 4 | +xcompiler_arg: -DRISCV64=1 -DUseRiscVOpenSBI=OFF |
| 5 | +platform: Star64 |
| 6 | +arch: RV64GBC, RV64IMAC, RV32IMAFBC |
| 7 | +virtualization: "No" |
| 8 | +iommu: "No" |
| 9 | +simulation_target: false |
| 10 | +Status: "Unverified" |
| 11 | +Contrib: "Community" |
| 12 | +Maintained: "seL4 Foundation" |
| 13 | +soc: StarFive JH7110 |
| 14 | +cpu: U74-MC, E24 |
| 15 | +SPDX-License-Identifier: CC-BY-SA-4.0 |
| 16 | +SPDX-FileCopyrightText: 2020 seL4 Project a Series of LF Projects, LLC. |
| 17 | +--- |
| 18 | + |
| 19 | +# Star64 |
| 20 | + |
| 21 | +The Star64 is a RISC-V SBC by Pine64 based on the StarFive JH7110 SoC. Check |
| 22 | +[here](https://wiki.pine64.org/wiki/STAR64) for details. |
| 23 | + |
| 24 | +The StarFive JH7110 SoC is comprised of the SiFive U74-MC (four 64-bit U74 |
| 25 | +cores and one 64-bit S7 core) and one SiFive E24 32-bit core. Note that by |
| 26 | +default seL4 is setup to use the U74 cores as neither the S7 or E24 core has |
| 27 | +S-Mode, which seL4 requires. |
| 28 | + |
| 29 | +The Star64 arrives with the following boot process from the SPI flash: |
| 30 | + 1. U-Boot SPL starts |
| 31 | + 2. OpenSBI starts |
| 32 | + 3. U-Boot proper starts |
| 33 | + |
| 34 | +## Building the GCC toolchain |
| 35 | + |
| 36 | +{% include risc-v.md %} |
| 37 | + |
| 38 | +## Building seL4test |
| 39 | + |
| 40 | +{% include sel4test.md %} |
| 41 | + |
| 42 | +## Booting via microSD card |
| 43 | + |
| 44 | +``` |
| 45 | +fatload mmc 1 0x60000000 sel4test-driver-image-riscv-star64 |
| 46 | +go 0x60000000 |
| 47 | +``` |
| 48 | + |
| 49 | +## Booting via TFTP |
| 50 | + |
| 51 | +If you have setup a TFTP server, enter the following commands on the U-Boot console |
| 52 | +to load an image via the network. |
| 53 | + |
| 54 | +``` |
| 55 | +dhcp |
| 56 | +tftpboot 0x60000000 <YOUR_TFTP_SERVER_IP_ADDRESS>:sel4test-driver-image-riscv-star64 |
| 57 | +go 0x60000000 |
| 58 | +``` |
| 59 | + |
| 60 | +## Producing a SD card bootable image |
| 61 | + |
| 62 | +If you require a custom U-Boot or have other constraints, you may need to create |
| 63 | +your own bootable image. The following instructions show how to make a bootable |
| 64 | +image for a microSD card that can then be inserted into the Star64. Note that you |
| 65 | +will need to change the booting mode via the DIP switch, like so: |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +The boot process of this bootable image is the same as the SPI flash booting |
| 70 | +process. Unfortunately, at the time of writing, U-Boot does not support booting |
| 71 | +in M-Mode which means U-Boot must be loaded by an SBI in S-Mode. |
| 72 | + |
| 73 | +### Acquring sources |
| 74 | + |
| 75 | +At the time of writing, mainline U-Boot does not support the Pine64 Star64, hence |
| 76 | +if you want to built it yourself, there is a patch to apply available on a fork of |
| 77 | +U-Boot. Note that these instructions are reproduced from [here](https://github.com/Ivan-Velickovic/star64_sdcard). |
| 78 | + |
| 79 | +```sh |
| 80 | +git clone https://github.com/Fishwaldo/u-boot.git --branch star64 |
| 81 | +git clone https://github.com/riscv/opensbi.git |
| 82 | +git clone https://github.com/starfive-tech/soft_3rdpart.git |
| 83 | +``` |
| 84 | + |
| 85 | +### Compiling U-Boot and U-Boot SPL |
| 86 | + |
| 87 | +```sh |
| 88 | +CROSS_COMPILE=<RISCV_TOOLCHAIN> make -C u-boot pine64_star64_defconfig |
| 89 | +CROSS_COMPILE=<RISCV_TOOLCHAIN> make -C u-boot |
| 90 | +``` |
| 91 | + |
| 92 | +### Compiling OpenSBI |
| 93 | + |
| 94 | +Now that we have U-Boot, we can make the OpenSBI image that contains U-Boot as the |
| 95 | +payload. |
| 96 | + |
| 97 | +```sh |
| 98 | +mkdir -p opensbi_build |
| 99 | +make -C $OPENSBI PLATFORM=generic \ |
| 100 | + CROSS_COMPILE=<RISCV_TOOLCHAIN> \ |
| 101 | + FW_FDT_PATH=u-boot/arch/riscv/dts/pine64_star64.dtb \ |
| 102 | + FW_PAYLOAD_PATH=u-boot/u-boot.bin \ |
| 103 | + PLATFORM_RISCV_XLEN=64 \ |
| 104 | + PLATFORM_RISCV_ISA=rv64imafdc \ |
| 105 | + PLATFORM_RISCV_ABI=lp64d \ |
| 106 | + O=opensbi_build \ |
| 107 | + FW_TEXT_START=0x40000000 \ |
| 108 | +``` |
| 109 | + |
| 110 | +Now we need to take the payload and turn it into a Flattened uImage Tree (FIT) for U-Boot SPL |
| 111 | +to load. |
| 112 | + |
| 113 | +First we'll need an ITS file to describe the FIT: |
| 114 | +```sh |
| 115 | +/dts-v1/; |
| 116 | + |
| 117 | +/ { |
| 118 | + description = "U-boot-spl FIT image for JH7110 Pine64 Star64"; |
| 119 | + #address-cells = <2>; |
| 120 | + |
| 121 | + images { |
| 122 | + firmware { |
| 123 | + description = "u-boot"; |
| 124 | + data = /incbin/("build/opensbi/platform/generic/firmware/fw_payload.bin"); |
| 125 | + type = "firmware"; |
| 126 | + arch = "riscv"; |
| 127 | + os = "u-boot"; |
| 128 | + load = <0x0 0x40000000>; |
| 129 | + entry = <0x0 0x40000000>; |
| 130 | + compression = "none"; |
| 131 | + }; |
| 132 | + }; |
| 133 | + |
| 134 | + configurations { |
| 135 | + default = "config-1"; |
| 136 | + |
| 137 | + config-1 { |
| 138 | + description = "U-boot-spl FIT config for JH7110 Pine64 Star64"; |
| 139 | + firmware = "firmware"; |
| 140 | + }; |
| 141 | + }; |
| 142 | +}; |
| 143 | +``` |
| 144 | + |
| 145 | +Now, invoke the `mkimage` tool to generate the FIT. |
| 146 | +```sh |
| 147 | +mkimage -f <ITS_FILE> -A riscv -O u-boot -T firmware opensbi_uboot_fit.img |
| 148 | +``` |
| 149 | + |
| 150 | +### Add SPL header to U-Boot SPL binary |
| 151 | + |
| 152 | +```sh |
| 153 | +cd soft_3rdpart/spl_tool |
| 154 | +make |
| 155 | +``` |
| 156 | + |
| 157 | +Now that the SPL tool that adds the header is compiled, we can invoke it on the |
| 158 | +U-Boot SPL image: |
| 159 | +```sh |
| 160 | +spl_tool -c -f u-boot/spl/u-boot-spl.bin |
| 161 | +``` |
| 162 | + |
| 163 | +### Generate bootable image |
| 164 | + |
| 165 | +Lastly, we need to create the bootable image from all of these binaries. For this |
| 166 | +the `genimage` tool is used. |
| 167 | + |
| 168 | +First, we'll need the configuration file. Note that you will have to change the |
| 169 | +paths to match where you build each binary. |
| 170 | +``` |
| 171 | +image sdcard.img { |
| 172 | + hdimage { |
| 173 | + gpt = true |
| 174 | + } |
| 175 | +
|
| 176 | + partition spl { |
| 177 | + image = "/path/to/u-boot-spl.bin.normal.out" |
| 178 | + partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985 |
| 179 | + offset = 2M |
| 180 | + size = 2M |
| 181 | + } |
| 182 | +
|
| 183 | + partition uboot { |
| 184 | + image = "/path/to/opensbi_uboot_fit.img" |
| 185 | + partition-type-uuid = 5B193300-FC78-40CD-8002-E86C45580B47 |
| 186 | + offset = 4M |
| 187 | + size = 4M |
| 188 | + } |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +Now we can pass this configuration, a temporary directory path, and a root |
| 193 | +directory path to the genimage tool. |
| 194 | +```sh |
| 195 | +# genimage expects these directories to exist before invoking it |
| 196 | +mkdir -p temp |
| 197 | +mkdir -p root |
| 198 | +# <INPUT_PATH> represents the top dir from where the genimage tool looks for |
| 199 | +# the image paths in the configuration file |
| 200 | +genimage --config <GENIMAGE_CONFIG> --inputpath <INPUT_PATH> --tmppath temp |
| 201 | +``` |
| 202 | + |
| 203 | +The final image will be `images/sdcard.img`. You can either use the `dd` utility |
| 204 | +or the [balenaEtcher](https://www.balena.io/etcher) program to write the image to |
| 205 | +your microSD card. |
0 commit comments