Просмотр исходного кода

target: mips: Implement yaffs kernel support

Target systems may select ADK_TARGET_WITH_YAFFS_KERNEL if their boot
loader expects the kernel in a yaffs filesystem. Utilize yafut host
build to create a suitable image.

XXX: No attempt at flashing the image was successfull so far. The image
does not contain OOB data (it seems), and I have no idea how to create
the needed ECC (and maybe more?) bits during nandwrite. The respective
code in OpenWrt does not create an image with OOB either, so maybe
something is missing at least on rb493g to make the kernel create ECC
data upon nandwrite from user space.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Phil Sutter 1 неделя назад
Родитель
Сommit
7d4892bf70

+ 5 - 0
target/config/Config.in.endian

@@ -60,3 +60,8 @@ config ADK_JFFS2_OPTS
 	string
 	default "-l" if ADK_TARGET_LITTLE_ENDIAN
 	default "-b" if ADK_TARGET_BIG_ENDIAN
+
+config ADK_YAFUT_OPTS
+	string
+	default "-L" if ADK_TARGET_LITTLE_ENDIAN
+	default "-M" if ADK_TARGET_BIG_ENDIAN

+ 3 - 0
target/config/Config.in.hardware

@@ -112,3 +112,6 @@ config ADK_TARGET_WITH_SMP
 
 config ADK_TARGET_WITH_IOMMU
 	bool
+
+config ADK_TARGET_WITH_YAFFS_KERNEL
+	bool

+ 2 - 0
target/config/Config.in.rootfs

@@ -63,6 +63,7 @@ config ADK_TARGET_ROOTFS_SQUASHFS
 	bool "Compressed read-only root filesystem (squashfs)"
 	select ADK_LINUX_KERNEL_SQUASHFS
 	select ADK_HOST_NEED_SQUASHFS_TOOLS
+	select ADK_HOST_NEED_YAFUT if ADK_TARGET_WITH_YAFFS_KERNEL
 	select ADK_HOST_NEED_QEMU if ADK_TARGET_QEMU
 	select ADK_TARGET_QEMU_WITH_BLOCK if ADK_TARGET_QEMU
 	depends on ADK_TARGET_WITH_MTD \
@@ -88,6 +89,7 @@ config ADK_TARGET_ROOTFS_UBIFS
 	select ADK_LINUX_KERNEL_UBIFS_FS if ADK_TARGET_OS_LINUX
 	select ADK_HOST_NEED_MTD_UTILS
 	select ADK_HOST_NEED_KERNEL2MINOR
+	select ADK_HOST_NEED_YAFUT if ADK_TARGET_WITH_YAFFS_KERNEL
 	depends on ADK_TARGET_WITH_NAND
 	help
 	  Root filesystem on NAND flash with UBI.

+ 16 - 0
target/mips/Makefile

@@ -96,6 +96,12 @@ endif
 ifeq ($(ADK_TARGET_FS),ubifs)
 targethelp:
 	@echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
+ifneq ($(ADK_TARGET_WITH_YAFFS_KERNEL),)
+	@echo 'Use the following command to write it to flash:'
+	@echo 'nand erase /dev/mtdX && yafut -d /dev/mtdX -i /path/to/kernel -o /kernel'
+	@echo 'There is also a prepared YAFFS image: $(FW_DIR)/${TARGET_KERNEL}.yaffs2'
+	@echo 'This might be written to flash using standard utilities'
+endif
 	@echo 'The UBI image is: ${FW_DIR}/${ROOTFSUBIFS}'
 	@echo 'Use the following command to write it to flash:'
 	@echo 'ubiformat /dev/mtdX -f /path/to/ubi.img'
@@ -120,6 +126,16 @@ endif
 
 kernel-install: kernel-strip
 	$(CP) $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/${TARGET_KERNEL}
+ifneq ($(ADK_TARGET_WITH_YAFFS_KERNEL),)
+	PATH='${HOST_PATH}'; \
+	PEB_SZ='${ADK_TARGET_FLASH_PEB_SIZE}'; \
+	KNL_SZ=$$(ls -l $(FW_DIR)/${TARGET_KERNEL} | cut -d' ' -f5); \
+	IMG_PEB=$$((($$KNL_SZ + $$PEB_SZ - 1) / $$PEB_SZ + 3)); \
+	dd if=/dev/zero bs=$$PEB_SZ count=$$IMG_PEB | \
+		tr '\000' '\377' >$(FW_DIR)/${TARGET_KERNEL}.yaffs2; \
+	yafut -d $(FW_DIR)/${TARGET_KERNEL}.yaffs2 -w $(ADK_YAFUT_OPTS) \
+		-i $(FW_DIR)/${TARGET_KERNEL} -E -P -S -o /kernel
+endif
 
 # filesystem specific targets
 ifeq ($(ADK_TARGET_FS),archive)

+ 1 - 0
target/mips/systems/mikrotik-rb4xx

@@ -14,6 +14,7 @@ config ADK_TARGET_SYSTEM_MIKROTIK_RB4XX
 	select ADK_TARGET_WITH_NETDEVICE
 	select ADK_TARGET_WITH_BLOCK
 	select ADK_TARGET_KERNEL_WITH_COMPRESSION
+	select ADK_TARGET_WITH_YAFFS_KERNEL
 	help
 	  Support for Mikrotik RB411/RB433/RB493g.
 

+ 1 - 0
target/mips/systems/mikrotik-rb532

@@ -12,6 +12,7 @@ config ADK_TARGET_SYSTEM_MIKROTIK_RB532
 	select ADK_TARGET_WITH_NET
 	select ADK_TARGET_WITH_NETDEVICE
 	select ADK_TARGET_WITH_BLOCK
+	select ADK_TARGET_WITH_YAFFS_KERNEL
 	help
 	  Support for Mikrotik RB532.