apm821xx: build squashfs-rootfs images for the MBL

This patch adds support for squashfs as the root filesystem.

advantages:
 - migrate from a existing -ext4 installation and back
   with the sysupgrade utility
 - existing partition layout will not be lost during switch
 - slightly smaller image size as compared to the -ext4 image.

disadvantages:
 - needs f2fs + tools. This is because fstools rootdisk.c decides based
   on the partition size (currently root partitions > 100 MiB) f2fs is
   used as the rootfs_data filesystem.
 - rootfs_data is placed into the rootfs partition after the squashfs.
   This makes it difficult for tools that expect a /dev/sda${X} device.
   It also makes it difficult for data recovery tools as they might not
   expect to find a embedded partition or will be slightly confused.
   ... or will not support f2fs.

For people with existing build configurations: make sure to include mkf2fs
and f2fsck packages into the image. Otherwise the new -squashfs image will
only boot from the ram-overlay.

Note:
All overlay data (configurations/all installed packages/...) will be
placed in inside the rootfs partition (i.e. /dev/sda2) just after the
squashfs image.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
master
Christian Lamparter 7 years ago committed by John Crispin
parent 7516a96011
commit aed4799d6d
  1. 5
      target/linux/apm821xx/image/Makefile
  2. 2
      target/linux/apm821xx/image/mbl_boot.scr
  3. 8
      target/linux/apm821xx/image/mbl_gen_hdd_img.sh
  4. 6
      target/linux/apm821xx/sata/config-default
  5. 4
      target/linux/apm821xx/sata/target.mk

@ -211,7 +211,7 @@ define Build/boot-img
endef
define Build/hdd-img
./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS)
./mbl_gen_hdd_img.sh $@ $@.boot $(IMAGE_ROOTFS) $(BOOT_SIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE)
endef
define Device/wd_mybooklive
@ -219,7 +219,6 @@ define Device/wd_mybooklive
DEVICE_PACKAGES := kmod-usb-dwc2 kmod-usb-ledtrig-usbport kmod-usb-storage kmod-fs-vfat wpad-mini
DEVICE_DTS := wd-mybooklive
SUPPORTED_DEVICES += mbl wd_mybooklive-duo
IMAGE_SIZE := 48m
BLOCKSIZE := 1k
DTB_SIZE := 16384
KERNEL := kernel-bin | dtb | gzip | uImage gzip
@ -227,7 +226,7 @@ define Device/wd_mybooklive
BOOT_SIZE := 8
IMAGES := rootfs.img.gz kernel.dtb
DEVICE_DTB := apollo3g.dtb
FILESYSTEMS := ext4
FILESYSTEMS := ext4 squashfs
IMAGE/kernel.dtb := export-dtb
IMAGE/rootfs.img.gz := boot-script | boot-img | hdd-img | gzip | append-metadata
endef

@ -1,4 +1,4 @@
setenv boot_args 'setenv bootargs root=/dev/sda2 rw rootfstype=ext4'
setenv boot_args 'setenv bootargs root=/dev/sda2 rw rootfstype=squashfs,ext4'
setenv load_part1 'sata init; ext2load sata 1:1 ${kernel_addr_r} /boot/uImage; ext2load sata 1:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv load_part2 'sata init; ext2load sata 0:1 ${kernel_addr_r} /boot/uImage; ext2load sata 0:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv load_sata 'if run load_part1; then echo Loaded part 1; elif run load_part2; then echo Loaded part 2; fi'

@ -1,16 +1,16 @@
#!/usr/bin/env bash
set -x
[ $# -eq 3 ] || {
echo "SYNTAX: $0 <file> <bootfs image> <rootfs image>"
[ $# -eq 5 ] || {
echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
exit 1
}
OUTPUT="$1"
BOOTFS="$2"
ROOTFS="$3"
let "BOOTFSSIZE=(`stat -c%s "$2"` + 1048575) / 1048576"
let "ROOTFSSIZE=(`stat -c%s "$3"` + 1048575) / 1048576"
BOOTFSSIZE="$4"
ROOTFSSIZE="$5"
head=4
sect=63

@ -16,6 +16,11 @@ CONFIG_GENERIC_PHY=y
CONFIG_SATA_DWC=y
# CONFIG_SATA_DWC_DEBUG is not set
CONFIG_EXT4_FS=y
# CONFIG_F2FS_CHECK_FS is not set
CONFIG_F2FS_FS=y
# CONFIG_F2FS_FS_SECURITY is not set
CONFIG_F2FS_FS_XATTR=y
CONFIG_F2FS_STAT_FS=y
CONFIG_SCSI=y
CONFIG_BLK_DEV_SD=y
CONFIG_GPIOLIB=y
@ -23,6 +28,7 @@ CONFIG_GPIO_GENERIC=y
CONFIG_GPIO_GENERIC_PLATFORM=y
CONFIG_GPIO_74XX_MMIO=y
CONFIG_LEDS_TRIGGER_DISK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_DM=y
CONFIG_BLK_DEV_DM_BUILTIN=y
CONFIG_BLK_DEV_MD=y

@ -1,7 +1,7 @@
BOARDNAME := Devices which boot from SATA (NAS)
FEATURES += ext4 usb ramdisk
FEATURES += ext4 usb ramdisk squashfs
DEFAULT_PACKAGES += badblocks block-mount e2fsprogs \
kmod-dm kmod-md-mod partx-utils
kmod-dm kmod-md-mod partx-utils mkf2fs f2fsck
define Target/Description
Build firmware images for APM82181 boards that boot from SATA.

Loading…
Cancel
Save