Heinrich Schuchardt | b59ac9b | 2024-04-02 10:49:12 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Milk-V Mars |
| 4 | =========== |
| 5 | |
| 6 | U-Boot for the Milk-V Mars 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 | 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 FW_OPTIONS=0 |
| 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 | Depending on the board version U-Boot set variable $fdtfile to either |
| 46 | starfive/jh7110-starfive-visionfive-2-v1.2a.dtb or |
| 47 | starfive/jh7110-starfive-visionfive-2-v1.3b.dtb. |
| 48 | |
| 49 | To overrule this selection the variable can be set manually and saved in the |
| 50 | environment |
| 51 | |
| 52 | :: |
| 53 | |
| 54 | setenv fdtfile my_device-tree.dtb |
| 55 | env save |
| 56 | |
| 57 | or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to |
| 58 | provide a default value. |
| 59 | |
| 60 | Boot source selection |
| 61 | ~~~~~~~~~~~~~~~~~~~~~ |
| 62 | |
| 63 | The board provides the DIP switches MSEL[1:0] to select the boot device out of |
| 64 | SPI flash, eMMC, SD-card, UART. To select booting from SD-card set the DIP |
| 65 | switches MSEL[1:0] to 10. |
| 66 | |
| 67 | Preparing the SD-Card |
| 68 | ~~~~~~~~~~~~~~~~~~~~~ |
| 69 | |
| 70 | The device firmware loads U-Boot SPL (u-boot-spl.bin.normal.out) from the |
| 71 | partition with type GUID 2E54B353-1271-4842-806F-E436D6AF6985. You are free |
| 72 | to choose any partition number. |
| 73 | |
| 74 | With the default configuration U-Boot SPL loads the U-Boot FIT image |
| 75 | (u-boot.itb) from partition 2 (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2). |
| 76 | When formatting it is recommended to use GUID |
| 77 | BC13C2FF-59E6-4262-A352-B275FD6F7172 for this partition. |
| 78 | |
| 79 | The FIT image (u-boot.itb) is a combination of OpenSBI's fw_dynamic.bin, |
| 80 | u-boot-nodtb.bin and the device tree blob. |
| 81 | |
| 82 | Format the SD card (make sure the disk has GPT, otherwise use gdisk to switch) |
| 83 | |
| 84 | .. code-block:: bash |
| 85 | |
| 86 | sudo sgdisk --clear \ |
| 87 | --set-alignment=2 \ |
| 88 | --new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985\ |
| 89 | --new=2:8192:16383 --change-name=2:uboot --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172 \ |
| 90 | --new=3:16384:1654784 --change-name=3:system --typecode=3:EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \ |
| 91 | /dev/sdb |
| 92 | |
| 93 | Copy U-Boot to the SD card |
| 94 | |
| 95 | .. code-block:: bash |
| 96 | |
| 97 | sudo dd if=u-boot-spl.bin.normal.out of=/dev/sdb1 |
| 98 | sudo dd if=u-boot.itb of=/dev/sdb2 |
| 99 | |
| 100 | sudo mount /dev/sdb3 /mnt/ |
| 101 | sudo cp u-boot-spl.bin.normal.out /mnt/ |
| 102 | sudo cp u-boot.itb /mnt/ |
| 103 | sudo cp Image.gz /mnt/ |
| 104 | sudo cp initramfs.cpio.gz /mnt/ |
| 105 | sudo cp jh7110-starfive-visionfive-2.dtb /mnt/ |
| 106 | sudo umount /mnt |
| 107 | |
| 108 | Booting |
| 109 | ~~~~~~~ |
| 110 | |
| 111 | Once you plugin the sdcard and power up, you should see the U-Boot prompt. |