better method of changing android's fstab that should survive ota.
I've tested this method using a php server to generate the new dtbo on the spot using partition_setup.sh, I've yet to test ota, but as long as ota's dont delete custom overlays on the boot partition, then this method of defining the fstab should allow for it. I'll be testing during the next day or two and can confirm this once i have time to set up android and actually use it.
obviously, i don't expect the next version soon, i can use my php server for now, but it would help if you could include the Device Tree Compiler program in the next release, i could then draft a final partition_setup.sh for you to check out if you'd like.
here is the buildroot pkg. I'm looking into compiling it myself with this included but I'm not familiar with buildroot at all
https://github.com/buildroot/buildroot/blob/2023.02.x/package/dtc/dtc.mk
android DT fstab reference: https://source.android.com/docs/core/architecture/kernel/mounting-partitions-early https://source.android.com/docs/core/architecture/dto/compile
here is my partiton setup draft so far:
EDIT: used the wrong partition var for the dts template. ($px not $partX) whoops.
#!/bin/sh
#supports_backup in PINN
set -x
if [ -z "$part1" ] || [ -z "$part2" ] || [ -z "$part3" ] || [ -z "$part4" ]; then
printf "Error: missing environment variable part1,2,3 or 4\n" 1>&2
exit 1
fi
#Adapt linux device names to Android device names
p1=`echo ${part1} | sed -e 's|dev|dev/block|g'`
p2=`echo ${part2} | sed -e 's|dev|dev/block|g'`
p3=`echo ${part3} | sed -e 's|dev|dev/block|g'`
p4=`echo ${part4} | sed -e 's|dev|dev/block|g'`
mkdir -p /tmp/1 /tmp/2 /tmp/3 /tmp/4
mount "$part1" /tmp/1
mount "$part2" /tmp/2
mount "$part3" /tmp/3
mount "$part4" /tmp/4
#17.1+ Nov2020+ uses DT, so... lets just use DT not modify ramdisk (should enable OTA as well)
for InstallMedia in sda nvme0n1 mmcblk0
do
if echo "$part1" | grep "${InstallMedia}" >/dev/null 2>&1
then
# set bootdev type for dt
echo "${InstallMedia}" | grep mmcblk0 >/dev/null 2>&1 && bootdev=sdcard
echo "${InstallMedia}" | grep nvme0n1 >/dev/null 2>&1 && bootdev=nvme
echo "${InstallMedia}" | grep sda >/dev/null 2>&1 && bootdev=usb
########################################
## WONT BE NECCESSARY WITH DTC BINARY ##
#### extract actual part numbers for PHP request
p1PartNum=`echo $p1 | sed -e "s|/dev/block/${InstallMedia}p||"`
p2PartNum=`echo $p2 | sed -e "s|/dev/block/${InstallMedia}p||"`
p3PartNum=`echo $p3 | sed -e "s|/dev/block/${InstallMedia}p||"`
p4PartNum=`echo $p4 | sed -e "s|/dev/block/${InstallMedia}p||"`
## WONT BE NECCESSARY WITH DTC BINARY ##
########################################
echo $InstallMedia
echo $bootdev
break
fi
done
########################################
## WONT BE NECCESSARY WITH DTC BINARY ##
#dtc binary not present, i'll use my webserver for now
echo p1/${p1PartNum}/p2/${p2PartNum}/p3/${p3PartNum}/p4/${p4PartNum}/bootdev/$bootdev
wget "https://pinn.dabwow.win/dtbo/p1/${p1PartNum}/p2/${p2PartNum}/p3/${p3PartNum}/p4/${p4PartNum}/bootdev/$bootdev" -O /tmp/1/overlays/android-pinnboot.dtbo
## WONT BE NECCESSARY WITH DTC BINARY ##
########################################
#dtc command if/when available
#adatpted template from https://github.com/raspberry-vanilla/android_kernel_brcm_rpi/blob/android-15.0/arch/arm/boot/dts/overlays/android-sdcard-overlay.dts
## added data partition entry, replaced devs with placeholders
cat << EOF > /tmp/1/overlays/android-pinnboot.dts
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target-path = "/";
__overlay__ {
firmware {
android {
compatible = "android,firmware";
bootdevice = ";;;replacebootdev;;;;;";
fstab {
compatible = "android,fstab";
boot {
compatible = "android,boot";
dev = "/dev/block/mmcblk0pW";
type = "vfat";
mnt_flags = "ro";
fsmgr_flags = "wait,first_stage_mount";
};
system {
compatible = "android,system";
dev = "/dev/block/mmcblk0pX";
type = "ext4";
mnt_flags = "ro,barrier=1";
fsmgr_flags = "wait,first_stage_mount";
};
vendor {
compatible = "android,vendor";
dev = "/dev/block/mmcblk0pY";
type = "ext4";
mnt_flags = "ro,barrier=1";
fsmgr_flags = "wait,first_stage_mount";
};
data {
compatible = "android,data";
dev = "/dev/block/mmcblk0pZ";
type = "ext4";
mnt_flags = "noatime,nosuid,nodev,nomblk_io_submit,errors=panic";
fsmgr_flags = "wait,check,formattable,quota";
};
};
};
};
};
};
};
EOF
sed -i -e "s|;;;replacebootdev;;;;;|$bootdev|" \
-e "s|/dev/block/mmcblk0pW|${p1}|" \
-e "s|/dev/block/mmcblk0pX|${p2}|" \
-e "s|/dev/block/mmcblk0pY|${p3}|" \
-e "s|/dev/block/mmcblk0pZ|${p4}|" \
/tmp/1/overlays/android-pinnboot.dts
###comment out dct until binary available, keep dts output for debug
# dtc -@ -I dts -O dtb /tmp/1/overlays/android-pinnboot.dts -o /tmp/1/overlays/android-pinnboot.dtbo
# tell pi to use fstab overlay, config_user.txt just to avoid possible OTA changes in config.txt (if that happens?)
echo dtoverlay=android-pinnboot >> config_user.txt
cd /tmp
for i in $(seq 4); do
umount /tmp/$i
rmdir $i
done