Skip to content

Commit

Permalink
Adding eMMC boot
Browse files Browse the repository at this point in the history
  • Loading branch information
rbray89 committed Aug 19, 2018
1 parent 170ed2d commit e986490
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
2 changes: 2 additions & 0 deletions buildroot-external/board/odroidc2/boot-env.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


# Custom modeline!
# To use custom modeline you need to disable all the below resolutions
# and setup your own!
Expand Down
2 changes: 1 addition & 1 deletion buildroot-external/board/odroidc2/info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel Odroid-C2"
CHASSIS=embedded
BOOTLOADER=uboot
KERNEL_FILE=Image
BOOT_ENV=/mnt/boot/uboot.env
BOOT_ENV=/dev/disk/by-partuuid/0d3e0000-09
BOOT_ENV_OFF=0x0000
BOOT_ENV_SIZE=0x2000
PART_BOOT=/dev/disk/by-partuuid/0d3e0000-01
Expand Down
34 changes: 20 additions & 14 deletions buildroot-external/board/odroidc2/uboot-boot.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@

###########################################

part start mmc ${devnum} 9 mmc_env
mmc dev ${devnum}
setenv loadbootstate "\
echo 'loading env...';\
mmc read ${ramdisk_addr_r} ${mmc_env} 0x10;\
env import -c ${ramdisk_addr_r} 0x2000;"

setenv storebootstate "\
echo 'storing env...';\
env export -c -s 0x2000 ${ramdisk_addr_r};\
mmc write ${ramdisk_addr_r} ${mmc_env} 0x10;"

run loadbootstate
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B"
test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3
test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3

if load mmc 0:1 ${ramdisk_addr_r} uboot-settings.txt; then
if load mmc ${devnum}:1 ${ramdisk_addr_r} uboot-settings.txt; then
env import -t ${ramdisk_addr_r} ${filesize};
fi

Expand All @@ -17,20 +30,14 @@ setenv bootargs_odroidc2 "${condev} no_console_suspend hdmimode=${m} ${cmode} m_
setenv bootargs_hassos "zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor cgroup_enable=memory"

# HassOS system A/B
#setenv bootargs_a "root=PARTUUID=0d3e0000-06 rootfstype=squashfs ro"
#setenv bootargs_b "root=PARTUUID=0d3e0000-08 rootfstype=squashfs ro"

#setenv bootargs_a "root=/dev/mmcblk1p6 rootfstype=squashfs ro rootwait"
#setenv bootargs_b "root=/dev/mmcblk1p8 rootfstype=squashfs ro rootwait"

setenv bootargs_a "root=PARTUUID=0d3e0000-06 rootfstype=squashfs ro rootwait"
setenv bootargs_b "root=PARTUUID=0d3e0000-08 rootfstype=squashfs ro rootwait"

usb start

# Load extraargs
fileenv mmc 0:1 ${ramdisk_addr_r} cmdline.txt cmdline
fatload mmc 0:1 ${fdt_addr_r} meson-gxbb-odroidc2.dtb
fileenv mmc ${devnum}:1 ${ramdisk_addr_r} cmdline.txt cmdline
fatload mmc ${devnum}:1 ${fdt_addr_r} meson-gxbb-odroidc2.dtb
#fdt addr ${fdt_addr_r}

# logical volumes get numbered after physical ones.
Expand All @@ -51,27 +58,26 @@ for BOOT_SLOT in "${BOOT_ORDER}"; do
if test ${BOOT_A_LEFT} -gt 0; then
setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining"
setenv load_kernel "ext4load mmc 0:5 ${kernel_addr_r} Image"
setenv load_kernel "ext4load mmc ${devnum}:5 ${kernel_addr_r} Image"
setenv bootargs "${bootargs_hassos} ${bootargs_odroidc2} ${bootargs_a} rauc.slot=A ${cmdline}"
fi
elif test "x${BOOT_SLOT}" = "xB"; then
if test ${BOOT_B_LEFT} -gt 0; then
setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining"
setenv load_kernel "ext4load mmc 0:7 ${kernel_addr_r} Image"
setenv load_kernel "ext4load mmc ${devnum}:7 ${kernel_addr_r} Image"
setenv bootargs "${bootargs_hassos} ${bootargs_odroidc2} ${bootargs_b} rauc.slot=B ${cmdline}"
fi
fi
done

setenv fdt_addr
if test -n "${bootargs}"; then
saveenv
run storebootstate
else
echo "No valid slot found, resetting tries to 3"
setenv BOOT_A_LEFT 3
setenv BOOT_B_LEFT 3
saveenv
run storebootstate
reset
fi

Expand Down
9 changes: 5 additions & 4 deletions buildroot-external/board/odroidc2/uboot.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# CONFIG_USB_STORAGE is not set
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_ENV_FAT_FILE="uboot.env"
# CONFIG_ENV_IS_IN_FAT is not set
# CONFIG_ENV_FAT_INTERFACE is not set
# CONFIG_ENV_FAT_DEVICE_AND_PART is not set
# CONFIG_ENV_FAT_FILE is not set
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_DISTRO_DEFAULTS=y
# CONFIG_EXPERT is not set
Expand All @@ -16,5 +16,6 @@ CONFIG_FS_EXT4=y
CONFIG_CONSOLE_SCROLL_LINES=10
CONFIG_CMD_SETEXPR=y
CONFIG_USB=y
CONFIG_CMD_USB=y
CONFIG_DM_USB=y
CONFIG_CMD_FILEENV=y

0 comments on commit e986490

Please sign in to comment.