mirror of
https://github.com/archr-linux/Arch-R.git
synced 2026-03-31 14:41:55 -07:00
Merge pull request #2010 from stolen/rk3326-fix-update-from-legacy-uboot
rk3326: fix update from legacy u-boot
This commit is contained in:
@@ -7,6 +7,14 @@
|
||||
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash"
|
||||
[ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '})
|
||||
|
||||
# mount $BOOT_ROOT rw
|
||||
mount -o remount,rw $BOOT_ROOT
|
||||
|
||||
# Setup logging
|
||||
echo -n > $BOOT_ROOT/update.log
|
||||
log() { echo $*; echo $* >> $BOOT_ROOT/update.log; }
|
||||
log "Starting bootloader update"
|
||||
|
||||
# identify the boot device
|
||||
if [ -z "$BOOT_DISK" ]; then
|
||||
case $BOOT_PART in
|
||||
@@ -14,55 +22,42 @@ if [ -z "$BOOT_DISK" ]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
# mount $BOOT_ROOT rw
|
||||
mount -o remount,rw $BOOT_ROOT
|
||||
|
||||
DT_SOC=$($SYSTEM_ROOT/usr/bin/dtsoc | cut -f2 -d,)
|
||||
DT_ID=$($SYSTEM_ROOT/usr/bin/dtname)
|
||||
if [ -n "$DT_ID" ]; then
|
||||
case $DT_ID in
|
||||
powkiddy,x55) SUBDEVICE="Powkiddy_x55";;
|
||||
*) SUBDEVICE="Generic";;
|
||||
esac
|
||||
fi
|
||||
|
||||
### Migrate device trees to subfolder (except RK326) - remove in the future
|
||||
if [ "$DT_SOC" = "rk3326" ]; then
|
||||
if [ -d "$BOOT_ROOT/device_trees" ]; then
|
||||
mv $BOOT_ROOT/device_trees/*.dtb $BOOT_ROOT
|
||||
rm -rf $BOOT_ROOT/device_trees
|
||||
fi
|
||||
if [ -f "$BOOT_ROOT/boot.ini" ]; then
|
||||
grep -q "device_trees" $BOOT_ROOT/boot.ini &&
|
||||
sed -i 's/${dtb_loadaddr} device_trees\//${dtb_loadaddr} /g' $BOOT_ROOT/boot.ini
|
||||
fi
|
||||
SUBDEVICE=$(sed -n 's|^.* uboot.hwid_adc=\([^, ]\),.*$|\1|p' /proc/cmdline)
|
||||
if [ -n "$SUBDEVICE" ]; then
|
||||
log "Subdevice from cmdline: $SUBDEVICE"
|
||||
elif [ -f $BOOT_ROOT/boot.scr ]; then
|
||||
grep -q "rk3326-anbernic-rg351m.dtb" $BOOT_ROOT/boot.scr && SUBDEVICE=a || SUBDEVICE=b
|
||||
log "Subdevice from boot.scr: $SUBDEVICE"
|
||||
elif [ -f $BOOT_ROOT/boot.ini ]; then
|
||||
grep -q "rk3326-anbernic-rg351m.dtb" $BOOT_ROOT/boot.ini && SUBDEVICE=a || SUBDEVICE=b
|
||||
log "Subdevice from boot.ini: $SUBDEVICE"
|
||||
else
|
||||
if [ ! -d "$BOOT_ROOT/device_trees" ]; then
|
||||
mkdir $BOOT_ROOT/device_trees
|
||||
mv $BOOT_ROOT/*.dtb $BOOT_ROOT/device_trees
|
||||
if [ -f "$BOOT_ROOT/extlinux/extlinux.conf" ]; then
|
||||
if ! grep -q "device_trees" $BOOT_ROOT/extlinux/extlinux.conf; then
|
||||
sed -i 's/FDT /FDT \/device_trees/g' $BOOT_ROOT/extlinux/extlinux.conf
|
||||
sed -i 's/FDTDIR \//FDTDIR \/device_trees/g' $BOOT_ROOT/extlinux/extlinux.conf
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
SUBDEVICE=a
|
||||
log "Subdevice fallback: $SUBDEVICE"
|
||||
fi
|
||||
###
|
||||
|
||||
echo "Updating device trees..."
|
||||
[ "$DT_SOC" = "rk3326" ] && DT_LOC=$BOOT_ROOT || DT_LOC=$BOOT_ROOT/device_trees
|
||||
cp -f $SYSTEM_ROOT/usr/share/bootloader/device_trees/* $DT_LOC
|
||||
log "Updating device trees..."
|
||||
if [ -d "$BOOT_ROOT/device_trees" ]; then
|
||||
mv $BOOT_ROOT/device_trees/*.dtb $BOOT_ROOT
|
||||
rm -rf $BOOT_ROOT/device_trees
|
||||
fi
|
||||
cp -f $SYSTEM_ROOT/usr/share/bootloader/device_trees/* $BOOT_ROOT
|
||||
|
||||
if [ -d $SYSTEM_ROOT/usr/share/bootloader/overlays ]; then
|
||||
echo "Updating device tree overlays..."
|
||||
log "Updating device tree overlays..."
|
||||
mkdir -p $BOOT_ROOT/overlays
|
||||
cp -f $SYSTEM_ROOT/usr/share/bootloader/overlays/* $BOOT_ROOT/overlays
|
||||
fi
|
||||
|
||||
for BOOT_IMAGE in ${SUBDEVICE}_uboot.bin uboot.bin; do
|
||||
if [ ! -f $BOOT_ROOT/extlinux/extlinux.conf ]; then
|
||||
log "Creating extlinux.conf..."
|
||||
mkdir -p $BOOT_ROOT/extlinux
|
||||
cp -f $SYSTEM_ROOT/usr/share/bootloader/extlinux/* $BOOT_ROOT/extlinux/
|
||||
fi
|
||||
|
||||
for BOOT_IMAGE in uboot.bin; do
|
||||
if [ -f "$SYSTEM_ROOT/usr/share/bootloader/$BOOT_IMAGE" ]; then
|
||||
echo "Updating $BOOT_IMAGE on $BOOT_DISK..."
|
||||
log "Updating $BOOT_IMAGE on $BOOT_DISK..."
|
||||
# instead of using small bs, read the missing part from target and do a perfectly aligned write
|
||||
{
|
||||
dd if=$BOOT_DISK bs=32K count=1
|
||||
@@ -72,8 +67,13 @@ for BOOT_IMAGE in ${SUBDEVICE}_uboot.bin uboot.bin; do
|
||||
fi
|
||||
done
|
||||
|
||||
log "Updating boot.scr from ${SUBDEVICE}_boot.scr..."
|
||||
cp -f $SYSTEM_ROOT/usr/share/bootloader/${SUBDEVICE}_boot.scr $BOOT_ROOT/boot.scr
|
||||
|
||||
log "Finishing bootloader update..."
|
||||
# mount $BOOT_ROOT ro
|
||||
sync
|
||||
mount -o remount,ro $BOOT_ROOT
|
||||
|
||||
echo "UPDATE" > /storage/.boot.hint
|
||||
log "DONE"
|
||||
|
||||
@@ -23,28 +23,33 @@ else
|
||||
fi
|
||||
|
||||
# Just in case this script is executed by (patched?) hardkernel u-boot, recover adc value from hwrev
|
||||
if test -n "${hwid_adc}"; then echo "ADC ${hwid_adc}" # mainline u-boot, just use real value
|
||||
elif test ${hwrev} = 'v10'; then setenv hwid_adc 856 # OGA
|
||||
elif test ${hwrev} = 'v11'; then setenv hwid_adc 677 # OGABE
|
||||
elif test ${hwrev} = 'v10-go3';then setenv hwid_adc 85 # OGS
|
||||
elif test ${hwrev} = 'rg351v'; then setenv hwid_adc 515
|
||||
elif test ${hwrev} = 'r33s'; then setenv hwid_adc 165
|
||||
elif test ${hwrev} = 'xu10'; then setenv hwid_adc 1025
|
||||
elif test ${hwrev} = 'chi'; then setenv hwid_adc 475
|
||||
else setenv hwid_adc 65000
|
||||
if test -n "${hwid_adc}"; then setenv adc ${hwid_adc}; echo "ADC ${hwid_adc}" # mainline u-boot, just use real value
|
||||
elif test ${hwrev} = 'v10'; then setenv adc 856 # OGA
|
||||
elif test ${hwrev} = 'v11'; then setenv adc 677 # OGABE
|
||||
elif test ${hwrev} = 'v10-go3';then setenv adc 85 # OGS
|
||||
elif test ${hwrev} = 'rg351v'; then setenv adc 515
|
||||
elif test ${hwrev} = 'r33s'; then setenv adc 165
|
||||
elif test ${hwrev} = 'xu10'; then setenv adc 1025
|
||||
elif test ${hwrev} = 'chi'; then setenv adc 475
|
||||
else setenv adc 65000
|
||||
fi
|
||||
|
||||
# this will be passed to cmdline so that userspace can analyze boot criteria
|
||||
if test -n "${hwid_adc}"; then setenv hwid_adc a,${hwid_adc};
|
||||
else setenv hwid_adc a,${hwrev}
|
||||
fi
|
||||
|
||||
# Depending on ADC value select a proper DTB
|
||||
if itest.w ${hwid_adc} > 59 && itest.w ${hwid_adc} < 111; then
|
||||
if itest.w ${adc} > 59 && itest.w ${adc} < 111; then
|
||||
setenv fdtfile "rk3326-odroid-go3.dtb"
|
||||
elif itest.w ${hwid_adc} > 139 && itest.w ${hwid_adc} < 191; then
|
||||
elif itest.w ${adc} > 139 && itest.w ${adc} < 191; then
|
||||
# setenv fdtfile "rk3326-powkiddy-rgb20s.dtb"
|
||||
setenv fdtfile "rk3326-gameconsole-r33s.dtb"
|
||||
elif itest.w ${hwid_adc} > 449 && itest.w ${hwid_adc} < 496; then
|
||||
elif itest.w ${adc} > 449 && itest.w ${adc} < 496; then
|
||||
setenv fdtfile "rk3326-gameforce-chi.dtb"
|
||||
elif itest.w ${hwid_adc} < 541; then
|
||||
elif itest.w ${adc} < 541; then
|
||||
setenv fdtfile "rk3326-anbernic-rg351v.dtb"
|
||||
elif itest.w ${hwid_adc} > 651 && itest.w ${hwid_adc} < 703; then
|
||||
elif itest.w ${adc} > 651 && itest.w ${adc} < 703; then
|
||||
if gpio input c22; then
|
||||
if gpio input d9; then
|
||||
setenv fdtfile "rk3326-powkiddy-rgb10.dtb"
|
||||
@@ -54,12 +59,12 @@ elif itest.w ${hwid_adc} > 651 && itest.w ${hwid_adc} < 703; then
|
||||
else
|
||||
setenv fdtfile "rk3326-anbernic-rg351m.dtb"
|
||||
fi
|
||||
elif itest.w ${hwid_adc} > 830 && itest.w ${hwid_adc} < 882; then
|
||||
elif itest.w ${adc} > 830 && itest.w ${adc} < 882; then
|
||||
setenv fdtfile "rk3326-odroid-go2.dtb"
|
||||
elif itest.w ${hwid_adc} > 999 && itest.w ${hwid_adc} < 1051; then
|
||||
elif itest.w ${adc} > 999 && itest.w ${adc} < 1051; then
|
||||
setenv fdtfile "rk3326-magicx-xu10.dtb"
|
||||
else
|
||||
echo "Unexpected ADC value ${hwid_adc}, falling back to OGA dtb"
|
||||
echo "Unexpected ADC value ${adc}, falling back to OGA dtb"
|
||||
setenv fdtfile "rk3326-odroid-go2.dtb"
|
||||
fi
|
||||
|
||||
|
||||
@@ -23,26 +23,31 @@ else
|
||||
fi
|
||||
|
||||
# Just in case this script is executed by (patched?) hardkernel u-boot, recover adc value from hwrev
|
||||
if test -n "${hwid_adc}"; then echo "ADC ${hwid_adc}" # mainline u-boot, just use real value
|
||||
elif test ${hwrev} = 'v10'; then setenv hwid_adc 856 # OGA
|
||||
elif test ${hwrev} = 'v11'; then setenv hwid_adc 677 # OGABE
|
||||
elif test ${hwrev} = 'v10-go3';then setenv hwid_adc 85 # OGS
|
||||
elif test ${hwrev} = 'rg351v'; then setenv hwid_adc 515
|
||||
elif test ${hwrev} = 'r33s'; then setenv hwid_adc 165
|
||||
elif test ${hwrev} = 'xu10'; then setenv hwid_adc 1025
|
||||
elif test ${hwrev} = 'chi'; then setenv hwid_adc 475
|
||||
else setenv hwid_adc 65000
|
||||
if test -n "${hwid_adc}"; then setenv adc ${hwid_adc}; echo "ADC ${hwid_adc}" # mainline u-boot, just use real value
|
||||
elif test ${hwrev} = 'v10'; then setenv adc 856 # OGA
|
||||
elif test ${hwrev} = 'v11'; then setenv adc 677 # OGABE
|
||||
elif test ${hwrev} = 'v10-go3';then setenv adc 85 # OGS
|
||||
elif test ${hwrev} = 'rg351v'; then setenv adc 515
|
||||
elif test ${hwrev} = 'r33s'; then setenv adc 165
|
||||
elif test ${hwrev} = 'xu10'; then setenv adc 1025
|
||||
elif test ${hwrev} = 'chi'; then setenv adc 475
|
||||
else setenv adc 65000
|
||||
fi
|
||||
|
||||
# this will be passed to cmdline so that userspace can analyze boot criteria
|
||||
if test -n "${hwid_adc}"; then setenv hwid_adc b,${hwid_adc};
|
||||
else setenv hwid_adc b,${hwrev}
|
||||
fi
|
||||
|
||||
# Depending on ADC value select a proper DTB
|
||||
if itest.w ${hwid_adc} > 139 && itest.w ${hwid_adc} < 191; then
|
||||
if itest.w ${adc} > 139 && itest.w ${adc} < 191; then
|
||||
setenv fdtfile "rk3326-powkiddy-rgb10x.dtb"
|
||||
elif itest.w ${hwid_adc} > 999 && itest.w ${hwid_adc} < 1051; then
|
||||
elif itest.w ${adc} > 999 && itest.w ${adc} < 1051; then
|
||||
setenv fdtfile "rk3326-magicx-xu-mini-m.dtb"
|
||||
elif itest.w ${hwid_adc} > 489 && itest.w ${hwid_adc} < 541; then
|
||||
elif itest.w ${adc} > 489 && itest.w ${adc} < 541; then
|
||||
setenv fdtfile "rk3326-gameconsole-eeclone.dtb"
|
||||
else
|
||||
echo "Unexpected ADC value ${hwid_adc}, falling back to OGA dtb"
|
||||
echo "Unexpected ADC value ${adc}, falling back to OGA dtb"
|
||||
setenv fdtfile "rk3326-odroid-go2.dtb"
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@ LABEL ROCKNIX
|
||||
FDTDIR /
|
||||
# FDT /your-custom-devicetree.dtb ## don't forget the leading slash
|
||||
FDTOVERLAYS /overlays/mipi-panel.dtbo
|
||||
APPEND boot=${partition_boot} disk=${partition_storage} @EXTRA_CMDLINE@ uboot.hwid_adc=${hwid_adc}"
|
||||
APPEND boot=${partition_boot} disk=${partition_storage} @EXTRA_CMDLINE@ uboot.hwid_adc=${hwid_adc}
|
||||
|
||||
@@ -279,7 +279,7 @@ new file mode 100644
|
||||
+ color = <LED_COLOR_ID_RED>;
|
||||
+ default-state = "off";
|
||||
+ function = LED_FUNCTION_CHARGING;
|
||||
+ linux,default-trigger = "battery-charging-blink-full-solid";
|
||||
+ linux,default-trigger = "none";
|
||||
+ gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
cat <<EOF >/storage/.config/profile.d/001-device_config
|
||||
# Device Features
|
||||
DEVICE_PLAYBACK_PATH_SPK="HP"
|
||||
DEVICE_PLAYBACK_PATH_HP="SPK"
|
||||
DEVICE_PLAYBACK_PATH_SPK="SPK"
|
||||
DEVICE_PLAYBACK_PATH_HP="HP"
|
||||
DEVICE_BATTERY_LED_STATUS="true"
|
||||
DEVICE_TEMP_SENSOR="/sys/devices/virtual/thermal/thermal_zone0/temp"
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user