blob: 52d4e5e9098232ee116e6e82185d0051b375a2b6 [file] [log] [blame]
Heinrich Schuchardta22f59a2024-05-12 06:25:24 +02001.. SPDX-License-Identifier: GPL-2.0+
2
3Milk-V Mars CM
4==============
5
6U-Boot for the Milk-V Mars CM uses the same U-Boot binaries as the VisionFive 2
7board. In U-Boot SPL the actual board is detected and the device-tree patched
8accordingly.
9
10The Milk-V Mars CM Lite comes without eMMC and needs a different pin muxing
11than the Milk-V Mars CM. The availability and size of the eMMC shows up in the
12serial number displayed by the *mac* command, e.g.
13MARC-V10-2340-D002E016-00000304. The number after the E is the MMC size. U-Boot
14takes a value of E000 as an indicator for the Lite version. Unfortunately the
15vendor has not set this value correctly on some Lite boards.
16
17Please, use CONFIG_STARFIVE_NO_EMMC=y if EEPROM data indicates eMMC is present
18on the Milk-V Mars CM Lite. Otherwise you will not be able to read from the
19SD-card.
20
21The 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
34By default the EEPROM is write protected. The write protection may be overcome
35by connecting the "GND" and "EN" test pads on top of the module.
36
37Building
38~~~~~~~~
39
401. Add the RISC-V toolchain to your PATH.
412. Setup ARCH & cross compilation environment variable:
42
43.. code-block:: none
44
45 export CROSS_COMPILE=<riscv64 toolchain prefix>
46
47The M-mode software OpenSBI provides the supervisor binary interface (SBI) and
48is responsible for the switch to S-Mode. It is a prerequisite to build U-Boot.
49Support for the JH7110 was introduced in OpenSBI 1.2. It is recommended to use
50a 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
61Now 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
69This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well
70as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
71
72Device-tree selection
73~~~~~~~~~~~~~~~~~~~~~
74
75Depending on the board version U-Boot sets variable $fdtfile to either
76starfive/jh7110-milkv-mars-cm.dtb (with eMMC storage) or
77starfive/jh7110-milkv-mars-cm-lite.dtb (without eMMC storage).
78
79To overrule this selection the variable can be set manually and saved in the
80environment
81
82::
83
84 env set fdtfile my_device-tree.dtb
85 env save
86
87or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to
88provide a default value.
89
90The variable *$fdtfile* is used in the boot process to automatically load
91a device-tree provided by the operating system. For details of the boot
Simon Glass16047dc2024-07-17 09:30:52 +010092process refer to the :doc:`/develop/bootstd/index`
Heinrich Schuchardta22f59a2024-05-12 06:25:24 +020093description.
94
95Boot source selection
96~~~~~~~~~~~~~~~~~~~~~
97
98The 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
103Compute module boards typically have a switch or jumper for this line.
104
105Flashing a new U-Boot version
106~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107
108U-Boot SPL is provided as file spl/u-boot-spl.bin.normal.out. Main U-Boot is
109in file u-boot.itb.
110
111Assuming your new U-Boot version is on partition 1 of an SD-card you could
112install 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
122For loading the files from a TFTP server refer to the dhcp and tftpboot
123commands.
124
125After updating U-Boot you may want to reboot and reset the environment to the
126default.
127
128::
129
130 env default -f -a
131 env save
132
133Booting from UART
134~~~~~~~~~~~~~~~~~
135
136For booting via UART U-Boot must be built with CONFIG_SPL_YMODEM_SUPPORT=y.
137
138With nRPIBOOT connected to ground for UART boot, power the board and upload
139u-boot-spl.bin.normal.out via XMODEM. Then upload u-boot.itb via YMODEM.
140
141The XMODEM implementation in the boot ROM is not fully specification compliant.
142It sends too many NAKs in a row. Tio is a terminal emulation that tolerates
143these 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
157Press *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
173Press *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
189Booting from SPI flash
190~~~~~~~~~~~~~~~~~~~~~~
191
192With nRPIBOOT disconnected from ground for SPI boot, power up the board. You
193should see the U-Boot prompt on the serial console.