0011-brcm2708-Implement-sysupgrade.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Fri, 17 Jul 2015 20:51:23 +0200
  3. Subject: brcm2708: Implement sysupgrade
  4. Implement sysupgrade for Raspberry Pi, similar to the way it is done on x86:
  5. The config files are saved in the boot partition and moved to where they are
  6. normally expected in preinit.
  7. Also add optional gzip compression for the SD card image, since this can save
  8. a lot of space (76M vs 6M), also similar to x86.
  9. Signed-off-by: Bruno Randolf <br1@einfach.org>
  10. diff --git a/target/linux/brcm2708/Makefile b/target/linux/brcm2708/Makefile
  11. index 30f6e1d..015aa9c 100644
  12. --- a/target/linux/brcm2708/Makefile
  13. +++ b/target/linux/brcm2708/Makefile
  14. @@ -19,7 +19,7 @@ SUBTARGETS:=bcm2708 bcm2709
  15. KERNEL_PATCHVER:=3.18
  16. include $(INCLUDE_DIR)/target.mk
  17. -DEFAULT_PACKAGES += brcm2708-gpu-fw kmod-usb-hid kmod-sound-core kmod-sound-arm-bcm2835
  18. +DEFAULT_PACKAGES += brcm2708-gpu-fw kmod-usb-hid kmod-sound-core kmod-sound-arm-bcm2835 kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1
  19. define Target/Description
  20. Build firmware image for Broadcom BCM2708/BCM2709 SoC devices.
  21. diff --git a/target/linux/brcm2708/base-files/lib/preinit/79_move_config b/target/linux/brcm2708/base-files/lib/preinit/79_move_config
  22. new file mode 100644
  23. index 0000000..7bcea7b
  24. --- /dev/null
  25. +++ b/target/linux/brcm2708/base-files/lib/preinit/79_move_config
  26. @@ -0,0 +1,18 @@
  27. +#!/bin/sh
  28. +# Copyright (C) 2015 OpenWrt.org
  29. +
  30. +BOOTPART=/dev/mmcblk0p1
  31. +
  32. +move_config() {
  33. + if [ -b $BOOTPART ]; then
  34. + insmod nls_cp437
  35. + insmod nls_iso8859-1
  36. + insmod fat
  37. + insmod vfat
  38. + mount -t vfat -o rw,noatime $BOOTPART /mnt
  39. + [ -f /mnt/sysupgrade.tgz ] && mv -f /mnt/sysupgrade.tgz /
  40. + umount /mnt
  41. + fi
  42. +}
  43. +
  44. +boot_hook_add preinit_mount_root move_config
  45. diff --git a/target/linux/brcm2708/base-files/lib/upgrade/platform.sh b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
  46. new file mode 100644
  47. index 0000000..3e1ee00
  48. --- /dev/null
  49. +++ b/target/linux/brcm2708/base-files/lib/upgrade/platform.sh
  50. @@ -0,0 +1,17 @@
  51. +platform_check_image() {
  52. + # i know no way to verify the image
  53. + return 0;
  54. +}
  55. +
  56. +platform_do_upgrade() {
  57. + sync
  58. + get_image "$1" | dd of=/dev/mmcblk0 bs=2M conv=fsync
  59. + sleep 1
  60. +}
  61. +
  62. +platform_copy_config() {
  63. + mount -t vfat -o rw,noatime /dev/mmcblk0p1 /mnt
  64. + cp -af "$CONF_TAR" /mnt/
  65. + sync
  66. + umount /mnt
  67. +}
  68. diff --git a/target/linux/brcm2708/image/Makefile b/target/linux/brcm2708/image/Makefile
  69. index e70bdd0..2c18baf 100644
  70. --- a/target/linux/brcm2708/image/Makefile
  71. +++ b/target/linux/brcm2708/image/Makefile
  72. @@ -28,6 +28,9 @@ define Image/Build/RaspberryPi
  73. mcopy -i $(KDIR)/boot.img $(KDIR)/Image ::kernel.img # Copy OpenWrt built kernel
  74. ./gen_rpi_sdcard_img.sh $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img $(KDIR)/boot.img $(KDIR)/root.$(1) \
  75. $(CONFIG_BRCM2708_SD_BOOT_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
  76. + ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
  77. + gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-sdcard-vfat-$(1).img
  78. + endif
  79. endef
  80. define Image/Build