Message ID | 559D611C.5000701@einfach.org |
---|---|
State | Superseded |
Headers | show |
On 08/07/2015 19:42, Bruno Randolf wrote: > Hi! > > I have the below change to add rudimentary support for sysupgrade on the > Raspberry Pi. I looked at the way platform_copy_config() is implemented > for x86 and tried to do the same, but I get the following error on mount: > > mount: mounting /dev/mmcblk0p2 on /mnt failed: Device or resource busy in that case its either still flushing the cache or has not been properly unmounted i think. you could try adding the "partprobe" tool to force a rescan of the table but i am not sure this is the problem here > > I believe I'd need some way to re-read the partition table after the dd > command. How does it work on x86? Any ideas? partprobe and i think fdisk had a feature for that aswell > > Also would it be OK to gzip the sdcard image to save space? It > compresses from 76M to 11M. > ok, as there is not sysupgrade supported yet this change wont break running installations > Below is the diff, but this is not a properly formatted patch, yet. > > bruno > > diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh > b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh > new file mode 100644 > index 0000000..95ade38 > --- /dev/null > +++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh > @@ -0,0 +1,19 @@ > +platform_check_image() { > + # i know no way to verify the image > + return 0; > +} > + > +platform_do_upgrade() { > + sync > + get_image "$1" | dd of=/dev/mmcblk0 bs=2M conv=fsync > + sleep 1 > +} > + > +## mount does not work. I think I'd need to re-read the partition table! > +#platform_copy_config() { > +# echo "*** platform_copy_config called" > /dev/console > +# mount -t ext4 -o rw,noatime /dev/mmcblk0p2 /mnt > +# cp -af "$CONF_TAR" /mnt/ > +# umount /mnt > +# echo "*** platform_copy_config done" > /dev/console > +#} > diff --git a/target/linux/brcm2708/image/Makefile > b/target/linux/brcm2708/image/Makefile > index e70bdd0..095cf0d 100644 > --- a/target/linux/brcm2708/image/Makefile > +++ b/target/linux/brcm2708/image/Makefile > @@ -28,6 +28,7 @@ define Image/Build/RaspberryPi > mcopy -i $(KDIR)/boot.img $(KDIR)/Image ::kernel.img # Copy > OpenWrt built kernel > ./gen_rpi_sdcard_img.sh > $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img $(KDIR)/boot.img > $(KDIR)/root.$(1) \ > $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) > $(CONFIG_TARGET_ROOTFS_PARTSIZE) > + gzip -k -f $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img > endef > > define Image/Build > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel >
On 07/09/2015 06:44 AM, John Crispin wrote: >> I have the below change to add rudimentary support for sysupgrade on the >> Raspberry Pi. I looked at the way platform_copy_config() is implemented >> for x86 and tried to do the same, but I get the following error on mount: >> >> mount: mounting /dev/mmcblk0p2 on /mnt failed: Device or resource busy > > in that case its either still flushing the cache or has not been > properly unmounted i think. you could try adding the "partprobe" tool to > force a rescan of the table but i am not sure this is the problem here You are right. I tried 'partprobe -s /dev/mmcblk0' and it shows the partitions correctly but mount still fails. I also tried 'sync' before trying to mount to flush the cache with no effect. So the suspect is that it has not been properly unmounted. So I tried to 'unmount -f /dev/mmcblk0p2' but that fails with "umount: can't forcibly umount /dev/mmcblk0p2: Invalid argument" Here are the mounts at that time: rootfs on / type rootfs (rw) proc on /proc type proc (rw,noatime) sysfs on /sys type sysfs (rw,noatime) tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime) tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=755) devpts on /dev/pts type devpts (rw,relatime,mode=600) debugfs on /sys/kernel/debug type debugfs (rw,noatime) tmpfs on / type tmpfs (rw,nosuid,nodev,noatime) "rootfs on / type rootfs (rw)" should be the RAM rootfs, no? How and were to unmount / correctly? bruno
On 07/08/2015 07:42 PM, Bruno Randolf wrote: > Hi! > > I have the below change to add rudimentary support for sysupgrade on the > Raspberry Pi. I looked at the way platform_copy_config() is implemented > for x86 and tried to do the same, but I get the following error on mount: > > mount: mounting /dev/mmcblk0p2 on /mnt failed: Device or resource busy > > I believe I'd need some way to re-read the partition table after the dd > command. How does it work on x86? Any ideas? > > Also would it be OK to gzip the sdcard image to save space? It > compresses from 76M to 11M. I think it would be nice to put the gzip command into an ifneq ($(CONFIG_TARGET_IMAGES_GZIP),) check. CONFIG_TARGET_IMAGES_GZIP defaults to y, but is currently only respected on x86... I guess it would make sense to handle it on other targets with ext4 images as well. Matthias > > Below is the diff, but this is not a properly formatted patch, yet. > > bruno > > diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh > b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh > new file mode 100644 > index 0000000..95ade38 > --- /dev/null > +++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh > @@ -0,0 +1,19 @@ > +platform_check_image() { > + # i know no way to verify the image > + return 0; > +} > + > +platform_do_upgrade() { > + sync > + get_image "$1" | dd of=/dev/mmcblk0 bs=2M conv=fsync > + sleep 1 > +} > + > +## mount does not work. I think I'd need to re-read the partition table! > +#platform_copy_config() { > +# echo "*** platform_copy_config called" > /dev/console > +# mount -t ext4 -o rw,noatime /dev/mmcblk0p2 /mnt > +# cp -af "$CONF_TAR" /mnt/ > +# umount /mnt > +# echo "*** platform_copy_config done" > /dev/console > +#} > diff --git a/target/linux/brcm2708/image/Makefile > b/target/linux/brcm2708/image/Makefile > index e70bdd0..095cf0d 100644 > --- a/target/linux/brcm2708/image/Makefile > +++ b/target/linux/brcm2708/image/Makefile > @@ -28,6 +28,7 @@ define Image/Build/RaspberryPi > mcopy -i $(KDIR)/boot.img $(KDIR)/Image ::kernel.img # Copy > OpenWrt built kernel > ./gen_rpi_sdcard_img.sh > $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img $(KDIR)/boot.img > $(KDIR)/root.$(1) \ > $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) > $(CONFIG_TARGET_ROOTFS_PARTSIZE) > + gzip -k -f $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img > endef > > define Image/Build > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel >
diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh new file mode 100644 index 0000000..95ade38 --- /dev/null +++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh @@ -0,0 +1,19 @@ +platform_check_image() { + # i know no way to verify the image + return 0; +} + +platform_do_upgrade() { + sync + get_image "$1" | dd of=/dev/mmcblk0 bs=2M conv=fsync + sleep 1 +} + +## mount does not work. I think I'd need to re-read the partition table! +#platform_copy_config() { +# echo "*** platform_copy_config called" > /dev/console +# mount -t ext4 -o rw,noatime /dev/mmcblk0p2 /mnt +# cp -af "$CONF_TAR" /mnt/ +# umount /mnt +# echo "*** platform_copy_config done" > /dev/console +#} diff --git a/target/linux/brcm2708/image/Makefile b/target/linux/brcm2708/image/Makefile index e70bdd0..095cf0d 100644 --- a/target/linux/brcm2708/image/Makefile +++ b/target/linux/brcm2708/image/Makefile @@ -28,6 +28,7 @@ define Image/Build/RaspberryPi mcopy -i $(KDIR)/boot.img $(KDIR)/Image ::kernel.img # Copy OpenWrt built kernel ./gen_rpi_sdcard_img.sh $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img $(KDIR)/boot.img $(KDIR)/root.$(1) \ $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)