mirror of
https://github.com/home-assistant/operating-system.git
synced 2026-04-17 23:54:06 +01:00
With "cgroup: Use kernel command line to disable memory cgroup" merged to RPi
kernel as 86099de [1], the device tree now contains "cgroup_disable=memory"
parameter. The parameters are parsed in the order defined in the cmdline and
with the previous order, the memory CG ends up disabled. Switching the order
fixes that and makes the order similar to what we get with standard bootloader
and parameters in cmdline.txt only.
The possible downside is that it won't be possible to override parameters from
hardcoded bootargs_hassos using cmdline.txt anymore, however, it's unlikely any
of these parameters will need to be adjusted by users.
Fixes #3765
[1] 86099deff5
75 lines
2.3 KiB
Plaintext
75 lines
2.3 KiB
Plaintext
|
|
part start ${devtype} ${devnum} 6 dev_env
|
|
${devtype} dev ${devnum}
|
|
|
|
setenv loadbootstate " \
|
|
echo 'loading env...'; \
|
|
${devtype} read ${ramdisk_addr_r} ${dev_env} 0x20; \
|
|
env import -c ${ramdisk_addr_r} 0x4000;"
|
|
|
|
setenv storebootstate " \
|
|
echo 'storing env...'; \
|
|
env export -c -s 0x4000 ${ramdisk_addr_r} BOOT_ORDER BOOT_A_LEFT BOOT_B_LEFT MACHINE_ID; \
|
|
${devtype} write ${ramdisk_addr_r} ${dev_env} 0x20;"
|
|
|
|
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
|
|
|
|
# Allows ConditionFirstBoot=
|
|
test -n "${MACHINE_ID}" || setenv BOOT_CONDITION "systemd.condition-first-boot=true"
|
|
|
|
# HassOS bootargs
|
|
setenv bootargs_hassos "zram.enabled=1 zram.num_devices=3 rootwait systemd.machine_id=${MACHINE_ID} cgroup_enable=memory fsck.repair=yes ${BOOT_CONDITION}"
|
|
|
|
# HassOS system A/B
|
|
setenv bootargs_a "root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd ro"
|
|
setenv bootargs_b "root=PARTUUID=a3ec664e-32ce-4665-95ea-7ae90ce9aa20 ro"
|
|
|
|
# Preserve origin bootargs
|
|
setenv bootargs_rpi
|
|
setenv fdt_org ${fdt_addr}
|
|
fdt addr ${fdt_org}
|
|
fdt get value bootargs_rpi /chosen bootargs
|
|
|
|
setenv bootargs
|
|
for BOOT_SLOT in "${BOOT_ORDER}"; do
|
|
if test "x${bootargs}" != "x"; then
|
|
# skip remaining slots
|
|
elif test "x${BOOT_SLOT}" = "xA"; then
|
|
if test ${BOOT_A_LEFT} -gt 0; then
|
|
setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
|
|
echo "Trying to boot slot A, ${BOOT_A_LEFT} attempts remaining. Loading kernel ..."
|
|
if load ${devtype} ${devnum}:2 ${kernel_addr_r} Image; then
|
|
setenv bootargs "${bootargs_rpi} ${bootargs_hassos} ${bootargs_a} rauc.slot=A"
|
|
fi
|
|
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 "Trying to boot slot B, ${BOOT_B_LEFT} attempts remaining. Loading kernel ..."
|
|
if load ${devtype} ${devnum}:4 ${kernel_addr_r} Image; then
|
|
setenv bootargs "${bootargs_rpi} ${bootargs_hassos} ${bootargs_b} rauc.slot=B"
|
|
fi
|
|
fi
|
|
fi
|
|
done
|
|
|
|
setenv fdt_addr
|
|
if test -n "${bootargs}"; then
|
|
run storebootstate
|
|
else
|
|
echo "No valid slot found, resetting tries to 3"
|
|
setenv BOOT_A_LEFT 3
|
|
setenv BOOT_B_LEFT 3
|
|
run storebootstate
|
|
reset
|
|
fi
|
|
|
|
echo "Starting kernel"
|
|
booti ${kernel_addr_r} - ${fdt_org}
|
|
|
|
echo "Boot failed, resetting..."
|
|
reset
|