H Bell | ad2ee4e | 2024-05-22 19:12:51 +0000 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Pine64 Star64 |
| 4 | ============= |
| 5 | |
| 6 | U-Boot for the Star64 uses the same U-Boot binaries as the VisionFive 2 board. |
| 7 | In U-Boot SPL the actual board is detected and the device-tree patched |
| 8 | accordingly. |
| 9 | |
| 10 | Building |
| 11 | ~~~~~~~~ |
| 12 | |
| 13 | 1. Add the RISC-V toolchain to your PATH. |
| 14 | 2. Setup ARCH & cross compilation environment variable: |
| 15 | |
| 16 | .. code-block:: none |
| 17 | |
| 18 | export CROSS_COMPILE=<riscv64 toolchain prefix> |
| 19 | |
| 20 | The M-mode software OpenSBI provides the supervisor binary interface (SBI) and |
| 21 | is responsible for the switch to S-Mode. It is a prerequisite to build U-Boot. |
| 22 | Support for the JH7110 was introduced in OpenSBI 1.2. It is recommended to use |
| 23 | a current release. |
| 24 | |
| 25 | .. code-block:: console |
| 26 | |
| 27 | git clone https://github.com/riscv/opensbi.git |
| 28 | cd opensbi |
| 29 | make PLATFORM=generic FW_TEXT_START=0x40000000 |
| 30 | |
| 31 | Now build the U-Boot SPL and U-Boot proper. |
| 32 | |
| 33 | .. code-block:: console |
| 34 | |
| 35 | cd <U-Boot-dir> |
| 36 | make starfive_visionfive2_defconfig |
| 37 | make OPENSBI=$(opensbi_dir)/build/platform/generic/firmware/fw_dynamic.bin |
| 38 | |
| 39 | This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well |
| 40 | as the FIT image (u-boot.itb) with OpenSBI and U-Boot. |
| 41 | |
| 42 | Device-tree selection |
| 43 | ~~~~~~~~~~~~~~~~~~~~~ |
| 44 | |
| 45 | U-Boot will set variable $fdtfile to starfive/jh7110-pine64-star64.dtb. |
| 46 | |
| 47 | To overrule this selection the variable can be set manually and saved in the |
| 48 | environment |
| 49 | |
| 50 | :: |
| 51 | |
| 52 | env set fdtfile my_device-tree.dtb |
| 53 | env save |
| 54 | |
| 55 | or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to |
| 56 | provide a default value. |
| 57 | |
| 58 | Boot source selection |
| 59 | ~~~~~~~~~~~~~~~~~~~~~ |
| 60 | |
| 61 | Boot mode is selected by an MSEL-DIP marked S1804 and GPIO_0 position adjacent |
| 62 | to the 40pin GPIO header. ON/ONKE and number markings of the MSEL-DIP are |
| 63 | misleading; Instead refer to the ``L`` (0) and ``H`` (1) silkscreen for |
| 64 | accurate selection. |
| 65 | |
| 66 | + (QSPI) Flash: 00 |
| 67 | + SD: 01 |
| 68 | + EMMC: 10 |
| 69 | + UART: 11 |
| 70 | |
| 71 | Preparing the SD-Card |
| 72 | ~~~~~~~~~~~~~~~~~~~~~ |
| 73 | |
| 74 | The device firmware loads U-Boot SPL (u-boot-spl.bin.normal.out) from the |
| 75 | partition with type GUID 2E54B353-1271-4842-806F-E436D6AF6985. You are free |
| 76 | to choose any partition number. |
| 77 | |
| 78 | With the default configuration U-Boot SPL loads the U-Boot FIT image |
| 79 | (u-boot.itb) from partition 2 (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2). |
| 80 | When formatting it is recommended to use GUID |
| 81 | BC13C2FF-59E6-4262-A352-B275FD6F7172 for this partition. |
| 82 | |
| 83 | The FIT image (u-boot.itb) is a combination of OpenSBI's fw_dynamic.bin, |
| 84 | u-boot-nodtb.bin and the device tree blob. |
| 85 | |
| 86 | Format the SD card (make sure the disk has GPT, otherwise use gdisk to switch) |
| 87 | |
| 88 | .. code-block:: bash |
| 89 | |
| 90 | sudo sgdisk --clear \ |
| 91 | --set-alignment=2 \ |
| 92 | --new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985\ |
| 93 | --new=2:8192:16383 --change-name=2:uboot --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172 \ |
| 94 | --new=3:16384:1654784 --change-name=3:system --typecode=3:EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \ |
| 95 | /dev/sdb |
| 96 | |
| 97 | Copy U-Boot to the SD card |
| 98 | |
| 99 | .. code-block:: bash |
| 100 | |
| 101 | sudo dd if=u-boot-spl.bin.normal.out of=/dev/sdb1 |
| 102 | sudo dd if=u-boot.itb of=/dev/sdb2 |
| 103 | |
| 104 | sudo mount /dev/sdb3 /mnt/ |
| 105 | sudo cp u-boot-spl.bin.normal.out /mnt/ |
| 106 | sudo cp u-boot.itb /mnt/ |
| 107 | sudo cp Image.gz /mnt/ |
| 108 | sudo cp initramfs.cpio.gz /mnt/ |
| 109 | sudo cp jh7110-starfive-visionfive-2.dtb /mnt/ |
| 110 | sudo umount /mnt |
| 111 | |
| 112 | Booting |
| 113 | ~~~~~~~ |
| 114 | |
| 115 | Once you plugin the sdcard and power up, you should see the U-Boot prompt. |
| 116 | |
| 117 | Serial Number and MAC address issues |
| 118 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 119 | |
| 120 | U-Boot requires valid EEPROM data to determine which board-specific fix-up to |
| 121 | apply at runtime. This affects the size of memory initialized, network mac |
| 122 | address numbering, and tuning of the network PHYs. |
| 123 | |
| 124 | The Star64 does not currently ship with unique serial numbers per-device. |
| 125 | Devices follow a pattern where the last mac address bytes are a sum of 0x7558 |
| 126 | and the serial number (lower port mac0), or a sum of 0x7559 and the serial |
| 127 | number (upper port mac1). |
| 128 | |
| 129 | As tested there are several 4gb model units where the serial number and network |
| 130 | mac addresses collide with other devices (serial |
| 131 | ``STAR64V1-2310-D004E000-00000005``, MACs ``6c:cf:39:00:75:61``, |
| 132 | ``6c:cf:39:00:75:62``) |
| 133 | |
| 134 | Some early Star64 boards shipped with an uninitialized EEPROM and no write |
| 135 | protect pull-up resistor in place. Later units of all 4gb and 8gb models |
| 136 | sharing the same serial number in EEPROM data will have this problem that the |
| 137 | network mac addresses are alike between different models and this may be |
| 138 | corrected by defeating the write protect resistor to write new values. As an |
| 139 | alternative to this, it may be worked around by overriding the mac addresses |
| 140 | via U-Boot environment variables. |
| 141 | |
| 142 | It is required for any unit having uninitialized EEPROM and recommended for |
| 143 | all later Star64 4gb model units (not properly serialized) to have decided on a |
| 144 | new 6-byte serial number. This serial number should be high enough to |
| 145 | avoid collision with other JH7110 boards and low enough not to overflow i.e. |
| 146 | between ``cafe00`` and ``f00d00``. |
| 147 | |
| 148 | Update EEPROM values |
| 149 | ^^^^^^^^^^^^^^^^^^^^ |
| 150 | |
| 151 | 1. Prepare EEPROM data in memory |
| 152 | |
| 153 | :: |
| 154 | |
| 155 | ## When there is no error to load existing data: |
| 156 | mac read_eeprom |
| 157 | |
| 158 | ## When there is an error to load non-existing data: |
| 159 | # "DRAM: Not a StarFive EEPROM data format - magic error" |
| 160 | mac initialize |
| 161 | |
| 162 | 2. Set Star64 values |
| 163 | |
| 164 | :: |
| 165 | |
| 166 | ## Common values |
| 167 | mac vendor PINE64 |
| 168 | mac pcb_revision c1 |
| 169 | mac bom_revision A |
| 170 | |
| 171 | ## Device-specific values |
| 172 | # Year 2023 week 10 production date, 8GB DRAM, optional eMMC, serial cdef01 |
| 173 | mac product_id STAR64V1-2310-D008E000-00cdef01 |
| 174 | |
| 175 | # Last three bytes mac0: 0x7558 + serial number 0xcdef01 |
| 176 | mac mac0_address 6c:cf:39:ce:64:59 |
| 177 | |
| 178 | # Last three bytes mac1: 0x7559 + serial number 0xcdef01 |
| 179 | mac mac1_address 6c:cf:39:ce:64:5a |
| 180 | |
| 181 | 3. Defeat write-protect pull-up resistor (if installed) and write to EEPROM |
| 182 | |
| 183 | :: |
| 184 | |
| 185 | mac write_eeprom |
| 186 | |
| 187 | Set Variables in U-Boot |
| 188 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 189 | |
| 190 | .. note:: Changing just the serial number will not alter your MAC address |
| 191 | |
| 192 | The MAC addresses may be "set" as follows by writing as a custom config to SPI |
| 193 | (Change the last 3 bytes of MAC addreses as appropriate): |
| 194 | |
| 195 | :: |
| 196 | |
| 197 | env set serial# STAR64V1-2310-D008E000-00cdef01 |
| 198 | env set ethaddr 6c:cf:39:ce:64:59 |
| 199 | env set eth1addr 6c:cf:39:ce:64:5a |
| 200 | env save |
| 201 | reset |