diff --git a/config/Config-images.in b/config/Config-images.in index fcc5fa52cb..9a49d7f1e8 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -356,4 +356,18 @@ menu "Target Images" across reboots. When enabled, /var/run will still be linked to /tmp/run. + config TARGET_PSTORE_BLK_ENABLE + bool "Enable creating a PSTORE partition" + depends on GRUB_IMAGES || GRUB_EFI_IMAGES + help + Create a partition for usage with the pstore-blk kernel module. + + config TARGET_PSTORE_BLK_PARTSIZE + int "pstore partition size (in MB)" + depends on TARGET_PSTORE_BLK_ENABLE + + config TARGET_PSTORE_BLK_PARTNAME + string "pstore partition on target device" + depends on TARGET_PSTORE_BLK_ENABLE + endmenu diff --git a/package/kernel/linux/modules/fs.mk b/package/kernel/linux/modules/fs.mk index 85c9a5e9cb..de33b88a1c 100644 --- a/package/kernel/linux/modules/fs.mk +++ b/package/kernel/linux/modules/fs.mk @@ -700,7 +700,6 @@ define KernelPackage/pstore CONFIG_PSTORE \ CONFIG_PSTORE_COMPRESS=y FILES:= $(LINUX_DIR)/fs/pstore/pstore.ko - AUTOLOAD:=$(call AutoLoad,30,pstore,1) DEPENDS:=+kmod-lib-zlib-deflate +kmod-lib-zlib-inflate endef diff --git a/package/kernel/linux/modules/other.mk b/package/kernel/linux/modules/other.mk index 1b9a287253..4b7a0dbeae 100644 --- a/package/kernel/linux/modules/other.mk +++ b/package/kernel/linux/modules/other.mk @@ -544,6 +544,45 @@ endef $(eval $(call KernelPackage,ramoops)) +define KernelPackage/pstore-blk + SUBMENU:=$(OTHER_MENU) + TITLE:=Pstore block device (pstore_blk) + DEFAULT:=m if ALL_KMODS + KCONFIG:=CONFIG_PSTORE_BLK \ + CONFIG_PSTORE_CONSOLE=y \ + CONFIG_PSTORE_BLK_BLKDEV="" \ + CONFIG_PSTORE_BLK_CONSOLE_SIZE=1024 \ + CONFIG_PSTORE_BLK_KMSG_SIZE=1024 \ + CONFIG_PSTORE_BLK_MAX_REASON=2 + DEPENDS:=+kmod-pstore +kmod-pstore-zone + FILES:= $(LINUX_DIR)/fs/pstore/pstore_blk.ko + AUTOLOAD:=$(call AutoLoad,90,pstore_blk) + MODPARAMS.pstore_blk:=best_effort=y blkdev=/dev/vda2 +endef + +define KernelPackage/pstore-blk/description + Kernel module for pstore-blk crash log storage on block devices +endef + +$(eval $(call KernelPackage,pstore-blk)) + + +define KernelPackage/pstore-zone + SUBMENU:=$(OTHER_MENU) + TITLE:=Ramoops (pstore-zone) + DEFAULT:=m if ALL_KMODS + KCONFIG:=CONFIG_PSTORE_ZONE + DEPENDS:=+kmod-pstore + FILES:= $(LINUX_DIR)/fs/pstore/pstore_zone.ko +endef + +define KernelPackage/pstore-zone/description + Kernel module for pstore-zone crash log storage +endef + +$(eval $(call KernelPackage,pstore-zone)) + + define KernelPackage/reed-solomon SUBMENU:=$(OTHER_MENU) TITLE:=Reed-Solomon error correction diff --git a/scripts/gen_image_generic.sh b/scripts/gen_image_generic.sh index 11e40f3886..269323f847 100755 --- a/scripts/gen_image_generic.sh +++ b/scripts/gen_image_generic.sh @@ -15,18 +15,30 @@ ROOTFSIMAGE="$5" ROOTFSPARTTYPE=${ROOTFSPARTTYPE:-83} ALIGN="$6" +PSTORESIZE="16" +PSTOREPARTTYPE=${PSTOREPARTTYPE:-83} + rm -f "$OUTPUT" head=16 sect=63 # create partition table -set $(ptgen -o "$OUTPUT" -h $head -s $sect ${GUID:+-g} -t "${KERNELPARTTYPE}" -p "${KERNELSIZE}m${PARTOFFSET:+@$PARTOFFSET}" -t "${ROOTFSPARTTYPE}" -p "${ROOTFSSIZE}m" ${ALIGN:+-l $ALIGN} ${SIGNATURE:+-S 0x$SIGNATURE} ${GUID:+-G $GUID}) - -KERNELOFFSET="$(($1 / 512))" -KERNELSIZE="$2" -ROOTFSOFFSET="$(($3 / 512))" -ROOTFSSIZE="$(($4 / 512))" +if [ -n "$PSTORE_ENABLE" ]; then + set $(ptgen -o "$OUTPUT" -h $head -s $sect ${GUID:+-g} -t "${KERNELPARTTYPE}" -p "${KERNELSIZE}m${PARTOFFSET:+@$PARTOFFSET}" -t "${PSTOREPARTTYPE}" -p "${PSTORESIZE}m" -t "${ROOTFSPARTTYPE}" -p "${ROOTFSSIZE}m" ${ALIGN:+-l $ALIGN} ${SIGNATURE:+-S 0x$SIGNATURE} ${GUID:+-G $GUID}) + KERNELOFFSET="$(($1 / 512))" + KERNELSIZE="$2" + PSTOREOFFSET="$(($3 / 512))" + PSTORESIZE="$(($4 / 512))" + ROOTFSOFFSET="$(($5 / 512))" + ROOTFSSIZE="$(($6 / 512))" +else + set $(ptgen -o "$OUTPUT" -h $head -s $sect ${GUID:+-g} -t "${KERNELPARTTYPE}" -p "${KERNELSIZE}m${PARTOFFSET:+@$PARTOFFSET}" -t "${ROOTFSPARTTYPE}" -p "${ROOTFSSIZE}m" ${ALIGN:+-l $ALIGN} ${SIGNATURE:+-S 0x$SIGNATURE} ${GUID:+-G $GUID}) + KERNELOFFSET="$(($1 / 512))" + KERNELSIZE="$2" + ROOTFSOFFSET="$(($3 / 512))" + ROOTFSSIZE="$(($4 / 512))" +fi # Using mcopy -s ... is using READDIR(3) to iterate through the directory # entries, hence they end up in the FAT filesystem in traversal order which diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile index 29bebeb748..aedfa67169 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -25,9 +25,16 @@ GRUB_TERMINALS += serial GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS) ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME)) -ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02) GPT_ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME)) -GPT_ROOTPART:=$(if $(GPT_ROOTPART),$(GPT_ROOTPART),PARTUUID=$(shell echo $(IMG_PART_DISKGUID) | sed 's/00$$/02/')) + +ifneq ($(CONFIG_PACKAGE_kmod-pstore-blk),) + PSTORE_BLK_ENABLE:="1" + ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-03) + GPT_ROOTPART:=$(if $(GPT_ROOTPART),$(GPT_ROOTPART),PARTUUID=$(shell echo $(IMG_PART_DISKGUID) | sed 's/00$$/03/')) +else + ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02) + GPT_ROOTPART:=$(if $(GPT_ROOTPART),$(GPT_ROOTPART),PARTUUID=$(shell echo $(IMG_PART_DISKGUID) | sed 's/00$$/02/')) +endif GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT)) GRUB_TITLE:=$(call qstrip,$(CONFIG_GRUB_TITLE)) @@ -44,7 +51,7 @@ define Build/combined $(INSTALL_DIR) $@.boot/efi/boot $(CP) $(STAGING_DIR_IMAGE)/grub2/boot$(if $(CONFIG_x86_64),x64,ia32).efi $@.boot/efi/boot/ ) - PADDING="1" SIGNATURE="$(IMG_PART_SIGNATURE)" \ + PADDING="1" PSTORE_ENABLE="$(PSTORE_BLK_ENABLE)" SIGNATURE="$(IMG_PART_SIGNATURE)" \ $(if $(filter $(1),efi),GUID="$(IMG_PART_DISKGUID)") $(SCRIPT_DIR)/gen_image_generic.sh \ $@ \ $(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \