Heinrich Schuchardt | a22f59a | 2024-05-12 06:25:24 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Milk-V Mars CM |
| 4 | ============== |
| 5 | |
| 6 | U-Boot for the Milk-V Mars CM uses the same U-Boot binaries as the VisionFive 2 |
| 7 | board. In U-Boot SPL the actual board is detected and the device-tree patched |
| 8 | accordingly. |
| 9 | |
| 10 | The Milk-V Mars CM Lite comes without eMMC and needs a different pin muxing |
| 11 | than the Milk-V Mars CM. The availability and size of the eMMC shows up in the |
| 12 | serial number displayed by the *mac* command, e.g. |
| 13 | MARC-V10-2340-D002E016-00000304. The number after the E is the MMC size. U-Boot |
| 14 | takes a value of E000 as an indicator for the Lite version. Unfortunately the |
| 15 | vendor has not set this value correctly on some Lite boards. |
| 16 | |
| 17 | Please, use CONFIG_STARFIVE_NO_EMMC=y if EEPROM data indicates eMMC is present |
| 18 | on the Milk-V Mars CM Lite. Otherwise you will not be able to read from the |
| 19 | SD-card. |
| 20 | |
| 21 | The serial number can be corrected using the *mac* command: |
| 22 | |
| 23 | .. code-block:: |
| 24 | |
| 25 | mac read_eeprom |
| 26 | mac product_id MARC-V10-2340-D002E000-00000304 |
| 27 | mac write_eeprom |
| 28 | |
| 29 | .. note:: |
| 30 | |
| 31 | The *mac initialize* command overwrites the vendor string and the MAC |
| 32 | addresses. This is why it is avoided here. |
| 33 | |
| 34 | By default the EEPROM is write protected. The write protection may be overcome |
| 35 | by connecting the "GND" and "EN" test pads on top of the module. |
| 36 | |
| 37 | Building |
| 38 | ~~~~~~~~ |
| 39 | |
| 40 | 1. Add the RISC-V toolchain to your PATH. |
| 41 | 2. Setup ARCH & cross compilation environment variable: |
| 42 | |
| 43 | .. code-block:: none |
| 44 | |
| 45 | export CROSS_COMPILE=<riscv64 toolchain prefix> |
| 46 | |
| 47 | The M-mode software OpenSBI provides the supervisor binary interface (SBI) and |
| 48 | is responsible for the switch to S-Mode. It is a prerequisite to build U-Boot. |
| 49 | Support for the JH7110 was introduced in OpenSBI 1.2. It is recommended to use |
| 50 | a current release. |
| 51 | |
| 52 | .. code-block:: console |
| 53 | |
| 54 | git clone https://github.com/riscv/opensbi.git |
| 55 | cd opensbi |
| 56 | make PLATFORM=generic FW_TEXT_START=0x40000000 |
| 57 | |
| 58 | (*FW_TEXT_START* is not needed anymore after OpenSBI patch d4d2582eef7a |
| 59 | "firmware: remove FW_TEXT_START" which should appear in OpenSBI 1.5.) |
| 60 | |
| 61 | Now build the U-Boot SPL and U-Boot proper. |
| 62 | |
| 63 | .. code-block:: console |
| 64 | |
| 65 | cd <U-Boot-dir> |
| 66 | make starfive_visionfive2_defconfig |
| 67 | make OPENSBI=$(opensbi_dir)/build/platform/generic/firmware/fw_dynamic.bin |
| 68 | |
| 69 | This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well |
| 70 | as the FIT image (u-boot.itb) with OpenSBI and U-Boot. |
| 71 | |
| 72 | Device-tree selection |
| 73 | ~~~~~~~~~~~~~~~~~~~~~ |
| 74 | |
| 75 | Depending on the board version U-Boot sets variable $fdtfile to either |
| 76 | starfive/jh7110-milkv-mars-cm.dtb (with eMMC storage) or |
| 77 | starfive/jh7110-milkv-mars-cm-lite.dtb (without eMMC storage). |
| 78 | |
| 79 | To overrule this selection the variable can be set manually and saved in the |
| 80 | environment |
| 81 | |
| 82 | :: |
| 83 | |
| 84 | env set fdtfile my_device-tree.dtb |
| 85 | env save |
| 86 | |
| 87 | or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to |
| 88 | provide a default value. |
| 89 | |
| 90 | The variable *$fdtfile* is used in the boot process to automatically load |
| 91 | a device-tree provided by the operating system. For details of the boot |
Simon Glass | 16047dc | 2024-07-17 09:30:52 +0100 | [diff] [blame] | 92 | process refer to the :doc:`/develop/bootstd/index` |
Heinrich Schuchardt | a22f59a | 2024-05-12 06:25:24 +0200 | [diff] [blame] | 93 | description. |
| 94 | |
| 95 | Boot source selection |
| 96 | ~~~~~~~~~~~~~~~~~~~~~ |
| 97 | |
| 98 | The low speed connector nRPIBOOT line is used to switch the boot source. |
| 99 | |
| 100 | * If nRPIBOOT is connected to ground, the board boots from UART. |
| 101 | * If nRPIBOOT is not connected, the board boots from SPI flash. |
| 102 | |
| 103 | Compute module boards typically have a switch or jumper for this line. |
| 104 | |
| 105 | Flashing a new U-Boot version |
| 106 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 107 | |
| 108 | U-Boot SPL is provided as file spl/u-boot-spl.bin.normal.out. Main U-Boot is |
| 109 | in file u-boot.itb. |
| 110 | |
| 111 | Assuming your new U-Boot version is on partition 1 of an SD-card you could |
| 112 | install it to the SPI flash with: |
| 113 | |
| 114 | :: |
| 115 | |
| 116 | sf probe |
| 117 | load mmc 0:1 $kernel_addr_r u-boot-spl.bin.normal.out |
| 118 | sf update $kernel_addr_r 0 $filesize |
| 119 | load mmc 0:1 $kernel_addr_r u-boot.itb |
| 120 | sf update $kernel_addr_r 0x100000 $filesize |
| 121 | |
| 122 | For loading the files from a TFTP server refer to the dhcp and tftpboot |
| 123 | commands. |
| 124 | |
| 125 | After updating U-Boot you may want to reboot and reset the environment to the |
| 126 | default. |
| 127 | |
| 128 | :: |
| 129 | |
| 130 | env default -f -a |
| 131 | env save |
| 132 | |
| 133 | Booting from UART |
| 134 | ~~~~~~~~~~~~~~~~~ |
| 135 | |
| 136 | For booting via UART U-Boot must be built with CONFIG_SPL_YMODEM_SUPPORT=y. |
| 137 | |
| 138 | With nRPIBOOT connected to ground for UART boot, power the board and upload |
| 139 | u-boot-spl.bin.normal.out via XMODEM. Then upload u-boot.itb via YMODEM. |
| 140 | |
| 141 | The XMODEM implementation in the boot ROM is not fully specification compliant. |
| 142 | It sends too many NAKs in a row. Tio is a terminal emulation that tolerates |
| 143 | these faults. |
| 144 | |
| 145 | :: |
| 146 | |
| 147 | $ tio -b 115200 --databits 8 --flow none --stopbits 1 /dev/ttyUSB0 |
| 148 | [08:14:54.700] tio v2.7 |
| 149 | [08:14:54.700] Press ctrl-t q to quit |
| 150 | [08:14:54.701] Connected |
| 151 | |
| 152 | (C)StarFive |
| 153 | CCC |
| 154 | (C)StarFive |
| 155 | CCCCCCCC |
| 156 | |
| 157 | Press *ctrl-t x* to initiate XMODEM-1K transfer. |
| 158 | |
| 159 | :: |
| 160 | |
| 161 | [08:15:14.778] Send file with XMODEM |
| 162 | [08:15:22.459] Sending file 'u-boot-spl.bin.normal.out' |
| 163 | [08:15:22.459] Press any key to abort transfer |
| 164 | ........................................................................ |
| 165 | .......................................................................| |
| 166 | [08:15:22.459] Done |
| 167 | |
| 168 | U-Boot SPL 2024.07-rc1-00075-gd6a4ab20097 (Apr 25 2024 - 16:32:10 +0200) |
| 169 | DDR version: dc2e84f0. |
| 170 | Trying to boot from UART |
| 171 | CC |
| 172 | |
| 173 | Press *ctrl-t y* to initiate YMODEM transfer. |
| 174 | |
| 175 | :: |
| 176 | |
| 177 | [08:15:50.331] Send file with YMODEM |
| 178 | [08:15:53.540] Sending file 'u-boot.itb' |
| 179 | [08:15:53.540] Press any key to abort transfer |
| 180 | ........................................................................ |
| 181 | … |
| 182 | ...............| |
| 183 | [08:15:53.540] Done |
| 184 | Loaded 1040599 bytes |
| 185 | |
| 186 | |
| 187 | U-Boot 2024.07-rc1-00075-gd6a4ab20097 (Apr 25 2024 - 16:32:10 +0200) |
| 188 | |
| 189 | Booting from SPI flash |
| 190 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 191 | |
| 192 | With nRPIBOOT disconnected from ground for SPI boot, power up the board. You |
| 193 | should see the U-Boot prompt on the serial console. |