Skip to content

Commit

Permalink
chore: add files of U-Boot experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
koehlma committed Nov 21, 2023
1 parent f3997bb commit 258be9b
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 0 deletions.
12 changes: 12 additions & 0 deletions boot/uboot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To build `boot.scr` from `boot.sh`, run:

```sh
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Rugpi Boot Script" -d .boot.sh boot.scr
```

To build `u-boot.bin`, run:

```sh
CROSS_COMPILE=aarch64-linux-gnu- make rpi_3_rugpi_defconfig
CROSS_COMPILE=aarch64-linux-gnu- make -j$(nproc)
```
63 changes: 63 additions & 0 deletions boot/uboot/boot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
echo Rugpi Boot Script
echo =================


##############################################################################
# Load Rugpi environment files.
##############################################################################

if load mmc 0:1 ${loadaddr} default.env; then
env import -c ${loadaddr} ${filesize}
fi
if load mmc 0:1 ${loadaddr} boot_spare.env; then
env import -c ${loadaddr} ${filesize}
fi


##############################################################################
# Set `bootpart` to the active partition set (default or spare).
##############################################################################

if test ${bootpart} = ""; then
# If `bootpart` is not set, boot from the second partition.
setenv bootpart 2
fi

# If `boot_spare` is set, boot from the spare partition set.
if test ${boot_spare} = 1; then
setexpr bootpart 5 - ${bootpart}
# Next time, boot from the default partition set again.
setenv boot_spare 0
env export -c ${loadaddr} boot_spare
save mmc 0:1 ${loadaddr} default.env ${filesize}
fi


##############################################################################
# Load environment file `boot.env` from active partition set.
##############################################################################

if load mmc 0:${bootpart} ${loadaddr} boot.env; then
env import -c ${loadaddr} ${filesize}
fi


##############################################################################
# Print information and boot kernel.
##############################################################################

echo Bootpart: ${bootpart}
echo Cmdline: ${cmdline}

load mmc 0:${bootpart} ${kernel_addr_r} ${kernel_file}
setenv kernel_comp_addr_r ${loadaddr}
setenv kernel_comp_size 0x4000000
setenv bootargs ${cmdline}
# Try booting `zImage`.
booti ${kernel_addr_r} - ${fdt_addr}
# Try booting `uImage`.
bootm ${kernel_addr_r} - ${fdt_addr}

echo "Error loading kernel... Rebooting in 10 seconds."
sleep 10
reset
13 changes: 13 additions & 0 deletions boot/uboot/boot_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import binascii
import struct

cmdline = "console=serial0,115200 console=tty1 rootfstype=ext4 fsck.repair=yes rootwait panic=60 root=PARTUUID=2ddb0742-05 init=/usr/bin/rugpi-ctrl"
environ = [f"cmdline={cmdline}".encode("ascii")]

data = b"\0".join(environ) + b"\n"

crc = binascii.crc32(data)

with open("boot.env", "wb") as env_file:
env_file.write(struct.pack("<I", crc))
env_file.write(data)
12 changes: 12 additions & 0 deletions boot/uboot/boot_spare_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import binascii
import struct

environ = [b"boot_spare=1"]

data = b"\0".join(environ) + b"\n"

crc = binascii.crc32(data)

with open("boot_spare.env", "wb") as env_file:
env_file.write(struct.pack("<I", crc))
env_file.write(data)
61 changes: 61 additions & 0 deletions boot/uboot/configs/rpi_3_rugpi_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
CONFIG_ARM=y
CONFIG_ARCH_CPU_INIT=y
CONFIG_ARCH_BCM283X=y
CONFIG_TEXT_BASE=0x00080000
CONFIG_TARGET_RPI_3=y
CONFIG_NR_DRAM_BANKS=1
CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe40
CONFIG_ENV_SIZE=0x4000
CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b"
CONFIG_OF_LIBFDT_OVERLAY=y
CONFIG_SYS_LOAD_ADDR=0x1000000
CONFIG_BOOTSTD_DEFAULTS=y
CONFIG_OF_BOARD_SETUP=y
CONFIG_USE_PREBOOT=y
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_MISC_INIT_R=y
CONFIG_FDT_SIMPLEFB=y
CONFIG_SYS_PROMPT="U-Boot> "
CONFIG_SYS_PBSIZE=1049
CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
# CONFIG_OF_EMBED=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
CONFIG_TFTP_TSIZE=y
CONFIG_BCM2835_GPIO=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_BCM2835=y
CONFIG_PHYLIB=y
CONFIG_PINCTRL=y
# CONFIG_PINCTRL_GENERIC is not set
# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
CONFIG_SYSINFO=y
CONFIG_SYSINFO_SMBIOS=y
CONFIG_USB=y
CONFIG_USB_DWC2=y
CONFIG_USB_KEYBOARD=y
CONFIG_USB_HOST_ETHER=y
CONFIG_USB_ETHER_LAN78XX=y
CONFIG_USB_ETHER_SMSC95XX=y
CONFIG_VIDEO=y
# CONFIG_VIDEO_BPP8 is not set
# CONFIG_VIDEO_BPP16 is not set
CONFIG_SYS_WHITE_ON_BLACK=y
CONFIG_VIDEO_BCM2835=y
CONFIG_CONSOLE_SCROLL_LINES=10
CONFIG_PHYS_TO_BUS=y

##############################################################################
# Rugpi Customization
##############################################################################
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_BOOTI=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_USE_BOOTARGS=y
CONFIG_PREBOOT="setenv kernel_file kernel8.img"
12 changes: 12 additions & 0 deletions boot/uboot/rpi3_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dtparam=audio=on
camera_auto_detect=1
display_auto_detect=1
dtoverlay=vc4-kms-v3d
max_framebuffers=2

arm_64bit=1

disable_overscan=1

enable_uart=1
kernel=u-boot.bin

0 comments on commit 258be9b

Please sign in to comment.