Obtaining the u-boot source

To start we first need the source files of u-boot so we can compile the bootloader.

git clone https://source.denx.de/u-boot/u-boot.git
cd u-boot

Configuring the bootloader

To find the correct default config look in the /configs directory. For us the defconfig sipeed_maix_bitm_defconfig is important. If you found the best default config you can apply the config with the following command:

CROSS_COMPILE=riscv64-linux- make sipeed_maix_bitm_defconfig

To edit the config use:

CROSS_COMPILE=riscv64-linux- make menuconfig

Compiling the bootloader

After u-boot has been configured you can use the following to compile the bootloader:

CROSS_COMPILE=riscv64-riscv-linux- make -j$(nproc)

Uploading the bootloader to the MAIX bit

An bootloader only has a good use if it is installed. So lets upload it to the MAIX bit. To do that we will need the tool kflash.py. The tool is available for download at the kflash.py repository

To download the bootloader to the MAIX bit use the undermentioned command: (replace ../kflash.py with the path to your kflash.py file). The -p option selects the port to which the bit is connected. The -t option loads an serial terminal after uploading.

../kflash.py -B kd233 -p /dev/ttyUSB0 u-boot.bin -t 

To open the serial term (miniterm) manually use the following command:

python3 -m serial.tools.miniterm --raw --filter colorize /dev/ttyUSB0 115200