Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
updated uboot-env to read the kernel from squashfs instead of the boo…
Browse files Browse the repository at this point in the history
…t partition

the boot partition is now empty and used as a dummy
  • Loading branch information
Tidone committed Feb 2, 2023
1 parent a8eeb6c commit 687bb49
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 77 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ follows:
releases, and Linux kernel updates. They're also made to fix bugs and add
features to the build infrastructure.

## v1.22.1
## v1.22.0-1

- Changes
- Corrected led assignments in linux device tree
- Updated the u-boot environment to read the Linux Kernel and all relevant
device-tree overlays from the root partition. The Boot partition mmcblk0p1
is now empty and used as a dummy to avoid having to adapt all partition
assignments.

- Updated dependencies
- Linux 6.1.9
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.1
1.22.0-1
2 changes: 1 addition & 1 deletion fwup-revert.conf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ define(NERVES_FW_AUTHOR, "The Nerves Team")

# The U-Boot environment is written directly to the SDCard/eMMC. It is not
# in any partition
define(UBOOT_ENV_OFFSET, 2048)
define(UBOOT_ENV_OFFSET, 24576)
define(UBOOT_ENV_COUNT, 256) # 128 KB

# Firmware archive metadata
Expand Down
31 changes: 6 additions & 25 deletions fwup.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ define(ROOTFS, "${NERVES_SYSTEM}/images/rootfs.squashfs")
# | (formatted as uboot env) |
# +----------------------------+
# | p0: Boot partition (FAT32) |
# | Device tree overlays |
# | vars.txt |
# | Image.gz.a |
# | Image.gz.b |
# | Dummy partition |
# | All boot files are loaded |
# | from the rootfs partition |
# +----------------------------+
# | p1: Rootfs A (squashfs) |
# +----------------------------+
Expand All @@ -59,13 +58,13 @@ define(UBOOT_ENV_COUNT, 256) # 128 KB
define(LOADER_PART_OFFSET, 64) # 32 KB
define(LOADER_PART_COUNT, 23552) # 11.5 MB

# The boot partition contains the dtb files, vars.txt, and Kernel-Images
# Dummy boot partition to avoid having having to adapt all references to the partition numbers
define(BOOT_PART_OFFSET, 36864) # 18 MB
define(BOOT_PART_COUNT, 131072) # 65 MB
define(BOOT_PART_COUNT, 2048) # 1 MB

# Let the rootfs have room to grow up to 140 MiB and align it to the nearest 1
# MB boundary
define(ROOTFS_A_PART_OFFSET, 196608)
define(ROOTFS_A_PART_OFFSET, 40960) # 20 MB
define(ROOTFS_A_PART_COUNT, 286720) # 140 MB
define-eval(ROOTFS_B_PART_OFFSET, "${ROOTFS_A_PART_OFFSET} + ${ROOTFS_A_PART_COUNT}")
define(ROOTFS_B_PART_COUNT, ${ROOTFS_A_PART_COUNT})
Expand Down Expand Up @@ -96,15 +95,6 @@ file-resource uboot-env.bin {
host-path = "${NERVES_SYSTEM}/images/uboot-env.bin"
assert-size-lte = ${UBOOT_ENV_COUNT}
}
file-resource vars.txt {
host-path = "${NERVES_SYSTEM}/images/vars.txt"
}
file-resource rk3566-radxa-cm3-spa.dtb {
host-path = "${NERVES_SYSTEM}/images/rockchip/rk3566-radxa-cm3-spa.dtb"
}
file-resource Image.gz {
host-path = "${NERVES_SYSTEM}/images/Image.gz"
}
file-resource rootfs.img {
host-path = ${ROOTFS}

Expand Down Expand Up @@ -154,13 +144,9 @@ task complete {

fat_mkfs(${BOOT_PART_OFFSET}, ${BOOT_PART_COUNT})
fat_setlabel(${BOOT_PART_OFFSET}, "BOOT")
fat_mkdir(${BOOT_PART_OFFSET}, "rockchip")
fat_mkdir(${BOOT_PART_OFFSET}, "rockchip/overlays")
}

on-resource u-boot-rockchip.bin { raw_write(${LOADER_PART_OFFSET}) }

on-resource Image.gz { fat_write(${BOOT_PART_OFFSET}, "Image.gz.a") }

on-resource uboot-env.bin {
# Boot to the A partition first and don't fail back.
Expand All @@ -187,9 +173,6 @@ task complete {
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
}

on-resource vars.txt { fat_write(${BOOT_PART_OFFSET}, "vars.txt") }
on-resource rk3566-radxa-cm3-spa.dtb { fat_write(${BOOT_PART_OFFSET}, "rockchip/rk3566-radxa-cm3-spa.dtb") }

on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
Expand Down Expand Up @@ -239,7 +222,6 @@ task upgrade.a {
# Write the new firmware and Linux images, but don't
# commit them. That way if the user aborts midway, we
# still are using the original firmware.
on-resource Image.gz { fat_write(${BOOT_PART_OFFSET}, "Image.gz.a") }
on-resource rootfs.img {
delta-source-raw-offset=${ROOTFS_B_PART_OFFSET}
delta-source-raw-count=${ROOTFS_B_PART_COUNT}
Expand Down Expand Up @@ -294,7 +276,6 @@ task upgrade.b {
trim(${ROOTFS_B_PART_OFFSET}, ${ROOTFS_B_PART_COUNT})
}

on-resource Image.gz { fat_write(${BOOT_PART_OFFSET}, "Image.gz.b") }
on-resource rootfs.img {
delta-source-raw-offset=${ROOTFS_A_PART_OFFSET}
delta-source-raw-count=${ROOTFS_A_PART_COUNT}
Expand Down
31 changes: 22 additions & 9 deletions linux/rk3566-radxa-cm3-spa.dts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,29 @@
#clock-cells = <0>;
};

leds {
gpio_leds: gpio-leds {
compatible = "gpio-leds";
status = "okay";

user-led {
gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "none";
default-state = "off";
pinctrl-0 = <&user_led_set>;
};

led-act {
pi-led-green {
gpios = <&gpio4 4 GPIO_ACTIVE_LOW>;
linux,default-trigger = "timer";
led-pattern = <2000 2000>;
default-state = "on";
gpios = <&gpio4 RK_PA4 GPIO_ACTIVE_LOW>;
linux,default-trigger = "disk-activity";
pinctrl-0 = <&act_led>;
pinctrl-0 = <&pi_led>;
};

led-pwr {
pwr-led-red {
gpios = <&gpio4 15 GPIO_ACTIVE_LOW>;
linux,default-trigger = "none";
default-state = "on";
gpios = <&gpio4 RK_PB7 GPIO_ACTIVE_LOW>;
linux,default-trigger = "default-on";
pinctrl-0 = <&pwr_led>;
};
};
Expand Down Expand Up @@ -410,7 +419,11 @@
};

leds {
act_led: act-led {
user_led_set: user-led {
rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
};

pi_led: pi-led {
rockchip,pins = <4 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
};

Expand Down
6 changes: 1 addition & 5 deletions post-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ $HOST_DIR/usr/bin/fwup -c -f $NERVES_DEFCONFIG_DIR/fwup-revert.conf -o $TARGET_D
# Copy the fwup includes to the images dir
cp -rf $NERVES_DEFCONFIG_DIR/fwup_include $BINARIES_DIR

# Since U-Boot's squashfs support is so slow (sadly), store the Linux
# kernel in the FAT filesystem instead of /boot. See the fwup.conf for how the Image
# is put in the FAT filesystem.
# Remove everything in /boot because all relevant files are copied to the boot partition anyways.
rm -f $TARGET_DIR/boot/*
cp -a $NERVES_DEFCONFIG_DIR/uboot/vars.txt $TARGET_DIR/boot/
9 changes: 0 additions & 9 deletions post-createfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,3 @@ if grep -iq "Some images are invalid" $NERVES_DEFCONFIG_DIR/build.log; then
echo "Uboot created an invalid image. Is the path to BL31 correct?"
exit 1
fi

# Copy all dtb files to the respective output folder (fwup will ignore most of these and only include the ones specified in fwup.conf in the final image)
linuxDir=`find $BINARIES_DIR/../build -name 'vmlinux' -type f | xargs dirname`
cp -a $NERVES_DEFCONFIG_DIR/uboot/vars.txt $BINARIES_DIR/
mkdir -p $BINARIES_DIR/rockchip/overlays
if [ -d ${linuxDir}/arch/arm64/boot/dts/rockchip/overlay ]; then
cp -a ${linuxDir}/arch/arm64/boot/dts/rockchip/overlay/*.dtbo $BINARIES_DIR/rockchip/overlays
fi
cp -a $BINARIES_DIR/*.dtb $BINARIES_DIR/rockchip
15 changes: 8 additions & 7 deletions uboot/boot.env
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ nerves_init=\
fi;\
saveenv;\
fi;\
setenv bootfile Image.gz.${nerves_fw_active};\
setenv bootfile Image.gz;\
if test ${nerves_fw_active} = "a"; then\
echo "Booting Partition A";\
setenv uenv_root /dev/mmcblk0p2;\
Expand All @@ -93,28 +93,29 @@ nerves_init=\
setenv bootpart 0:3;\
fi

# Since U-Boot now has better support for squahsfs and read speeds are getting better (>23MB/s)
# we can load all relevant bootfiles (vars.txt, all dtbs, Image.gz) directly from the root partition
uname_boot=echo "loading boot vars";\
setenv load_addr $ramdisk_addr_r;\
setenv devnum 0;\
load mmc ${devnum} ${load_addr} vars.txt;\
load mmc ${bootpart} ${load_addr} /boot/vars.txt;\
env import -t ${load_addr} ${filesize};\
echo "setting boot args";\
setenv bootargs root=${uenv_root} switolb=1 coherent_pool=1m rootwait ${extra_bootargs};\
fatload mmc ${devnum}:${distro_bootpart} ${fdt_addr_r} ${fdtfile};\
fatload mmc ${devnum}:${distro_bootpart} ${kernel_addr_r} ${bootfile};\
load mmc ${bootpart} ${fdt_addr_r} /boot/${fdtfile};\
load mmc ${bootpart} ${kernel_addr_r} /boot/${bootfile};\
setenv overlay_error "false";\
fdt addr ${fdt_addr_r};\
fdt resize 65536;\
for overlay_file in ${overlays}; do\
echo "loading overlay ${overlay_file}";\
if fatload mmc ${devnum}:${distro_bootpart} ${load_addr} rockchip/overlays/${overlay_file}.dtbo; then\
if load mmc ${bootpart} ${load_addr} /boot/${overlay_file}.dtbo; then\
echo "Applying kernel provided DT overlay ${overlay_file}.dtbo";\
fdt apply ${load_addr} || setenv overlay_error "true";\
fi;\
done;\
if test "${overlay_error}" = "true"; then\
echo "Error applying DT overlays, restoring original DT";\
fatload mmc ${devnum}:${distro_bootpart} ${fdt_addr_r} ${fdtfile};\
load mmc ${bootpart} ${fdt_addr_r} /boot/${fdtfile};\
fi;\
echo booting linux ...;\
echo debug: [${bootargs}] ... ;\
Expand Down
43 changes: 25 additions & 18 deletions uboot/rk3566-quartz64-a_spa.dts
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,29 @@
};
};

leds {
gpio_leds: gpio-leds {
compatible = "gpio-leds";
status = "okay";

led-work {
label = "work-led";
user-led {
gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "none";
default-state = "off";
gpios = <&gpio0 RK_PD3 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&work_led_enable_h>;
retain-state-suspended;
pinctrl-0 = <&user_led_set>;
};

led-diy {
label = "diy-led";
pi-led-green {
gpios = <&gpio4 4 GPIO_ACTIVE_LOW>;
linux,default-trigger = "timer";
default-state = "on";
gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
pinctrl-names = "default";
pinctrl-0 = <&diy_led_enable_h>;
retain-state-suspended;
pinctrl-0 = <&pi_led>;
};

pwr-led-red {
gpios = <&gpio4 15 GPIO_ACTIVE_LOW>;
linux,default-trigger = "none";
default-state = "on";
pinctrl-0 = <&pwr_led>;
};
};

Expand Down Expand Up @@ -722,12 +725,16 @@
};

leds {
work_led_enable_h: work-led-enable-h {
rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
user_led_set: user-led {
rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
};

pi_led: pi-led {
rockchip,pins = <4 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
};

diy_led_enable_h: diy-led-enable-h {
rockchip,pins = <0 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
pwr_led: pwr-led {
rockchip,pins = <4 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>;
};
};

Expand Down
1 change: 1 addition & 0 deletions uboot/uboot.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
CONFIG_CMD_SQUASHFS=y
# CONFIG_SPL_DOS_PARTITION is not set
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_LIVE=y
Expand Down
2 changes: 1 addition & 1 deletion uboot/vars.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
overlays=
fdtfile=rockchip/rk3566-radxa-cm3-spa.dtb
fdtfile=rk3566-radxa-cm3-spa.dtb
extra_bootargs="quiet"

0 comments on commit 687bb49

Please sign in to comment.