#!/bin/bash # vim:sw=8:noet MEDIATABLE=msdos ROOTPART_NUM=1 START_SECTOR=16 # MiB [ -n "$SYSCON" ] || SYSCON=ttyS2,1500000n8 soc_write_bootloader() { [ -n "$TMPROOT" ] || mount_partition # Write U-Boot set_path_to_uboot local IDBSPL IDBLOADER FIT FIT_SEEK_FILE FIT_SEEK UBOOT="$UBOOT/u-boot-rockchip.bin" UBOOT_ZST="$UBOOT.zst" IDBSPL="$UBOOT/idbspl.img" IDBLOADER="$UBOOT/idbloader.img" FIT="$UBOOT/u-boot.itb" FIT_SEEK_FILE="$UBOOT/u-boot.itb.seek" FIT_SEEK=16384 if [ -f "$UBOOT_ZST" ]; then UBOOT="$UBOOT_ZST" CAT="unzstd -c" else CAT=cat fi if [ -f "$UBOOT" ]; then print_message "Writing u-boot-rockchip.bin..." $CAT "$UBOOT" | dd of="$MEDIA" seek=64 || fatal_error "Error: Failed to write u-boot-rockchip.bin!!!" sync print_done else print_message "Warning: $UBOOT is missing. Try find idbspl.img..." if [ -f "$IDBSPL" ]; then print_message "Writing idbspl.img..." dd if="$IDBSPL" of="$MEDIA" seek=64 || fatal_error "Error: Failed to write idbspl.img" sync print_done else print_message "Warning: idbspl.img is missing. Try find idbloader.img..." if [ -f "$IDBLOADER" ]; then print_message "Writing idbloader.img..." dd if="$IDBLOADER" of="$MEDIA" seek=64 || fatal_error "Error: Failed to write idbloader.img" sync print_done else print_message "Warning: idbloader.img is missing. Try find and write u-boot.itb without first loader..." fi fi [ -f "$FIT" ] || fatal_error "Error: u-boot.itb not found!!!" print_message "Writing U-Boot FIT image..." if [ -f "$FIT_SEEK_FILE" ]; then FIT_SEEK="$(cat FIT_SEEK_FILE | head -n1)" fi dd if="$FIT" of="$MEDIA" seek="$FIT_SEEK" || fatal_error "Error: failed to write u-boot.itb!!!" sync print_done fi }