diff mbox

[OpenWrt-Devel] ar71xx: add tools/kernel2minor package for Mikrotik NOR flash devices.

Message ID 1460973907-20270-1-git-send-email-adron@yapic.net
State Changes Requested
Headers show

Commit Message

adron@yapic.net April 18, 2016, 10:05 a.m. UTC
From: Sergey Sergeev <adron@yapic.net>

kernel2minor tool is used for packing openwrt kernel into modified yaffs2 file system image.
This is necessary to boot via Routerboot on new Mikrotik NOR flash devices.
---
 config/Config-images.in                |  7 +++++++
 target/linux/ar71xx/image/Makefile     |  3 +++
 target/linux/ar71xx/mikrotik/target.mk |  2 +-
 tools/Makefile                         |  1 +
 tools/kernel2minor/Makefile            | 35 ++++++++++++++++++++++++++++++++++
 5 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 tools/kernel2minor/Makefile

Comments

John Crispin April 25, 2016, 3:04 p.m. UTC | #1
Hi,

comments inline

On 18/04/2016 12:05, adron@yapic.net wrote:
> From: Sergey Sergeev <adron@yapic.net>
> 
> kernel2minor tool is used for packing openwrt kernel into modified yaffs2 file system image.
> This is necessary to boot via Routerboot on new Mikrotik NOR flash devices.
> ---
>  config/Config-images.in                |  7 +++++++
>  target/linux/ar71xx/image/Makefile     |  3 +++
>  target/linux/ar71xx/mikrotik/target.mk |  2 +-
>  tools/Makefile                         |  1 +
>  tools/kernel2minor/Makefile            | 35 ++++++++++++++++++++++++++++++++++
>  5 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 tools/kernel2minor/Makefile
> 
> diff --git a/config/Config-images.in b/config/Config-images.in
> index a60dd50..339a5fd 100644
> --- a/config/Config-images.in
> +++ b/config/Config-images.in
> @@ -6,6 +6,13 @@
>  
>  menu "Target Images"
>  
> +	config TARGET_KERNEL_MINOR_YAFFS2
> +		bool "kernel.minor-yaffs2"
> +		default n
> +		depends on TARGET_ar71xx_mikrotik
> +		help
> +		  Build a Mikrotik Nor Yaffs2 kernel filesystem for RouterBoot
> +

can you change this to be like

        config TARGET_ROOTFS_YAFFS2
                bool "yaffs2"
                default y if USES_YAFFS2
                help
                  Build a YAFFS2 root filesystem.

then patch scripts/metadata.pl to handle USES_YAFFS2
and finally patch target/linux/ar71xx/mikrotik/target.mk and add yaffs2
to the FEATURES list

	John



>  	menuconfig TARGET_ROOTFS_INITRAMFS
>  		bool "ramdisk"
>  		default y if USES_INITRAMFS
> diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
> index e4e2fcf..64bec18 100644
> --- a/target/linux/ar71xx/image/Makefile
> +++ b/target/linux/ar71xx/image/Makefile
> @@ -1658,6 +1658,9 @@ define Image/BuildKernel
>  	$(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(UIMAGE)-gzip.bin)
>  	$(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(UIMAGE)-lzma.bin)
>  	cp $(KDIR)/loader-generic.elf $(VMLINUX)-lzma.elf
> +        ifeq ($(CONFIG_TARGET_KERNEL_MINOR_YAFFS2),y)
> +		$(STAGING_DIR_HOST)/bin/kernel2minor -k $(KDIR)/loader-generic.elf -r $(VMLINUX)-lzma.minor-yaffs2 -e
> +        endif
>  	-mkdir -p $(KDIR_TMP)
>  	$(call Image/Build/Profile/$(IMAGE_PROFILE),buildkernel)
>  endef
> diff --git a/target/linux/ar71xx/mikrotik/target.mk b/target/linux/ar71xx/mikrotik/target.mk
> index b2fb0df..250252e 100644
> --- a/target/linux/ar71xx/mikrotik/target.mk
> +++ b/target/linux/ar71xx/mikrotik/target.mk
> @@ -1,4 +1,4 @@
> -BOARDNAME:=Mikrotik devices with NAND flash
> +BOARDNAME:=Mikrotik devices with NAND/NOR flash
>  FEATURES += targz ramdisk
>  
>  define Target/Description
> diff --git a/tools/Makefile b/tools/Makefile
> index 187655e..2ea66c40 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -38,6 +38,7 @@ tools-$(CONFIG_TARGET_x86) += qemu
>  tools-$(CONFIG_TARGET_mxs) += elftosb sdimage
>  tools-$(CONFIG_TARGET_brcm2708)$(CONFIG_TARGET_sunxi)$(CONFIG_TARGET_mxs) += mtools dosfstools
>  tools-$(CONFIG_TARGET_ar71xx) += lzma-old squashfs
> +tools-$(CONFIG_TARGET_ar71xx_mikrotik) += kernel2minor
>  tools-y += lzma squashfs4
>  tools-$(BUILD_B43_TOOLS) += b43-tools
>  tools-$(BUILD_PPL_CLOOG) += ppl cloog
> diff --git a/tools/kernel2minor/Makefile b/tools/kernel2minor/Makefile
> new file mode 100644
> index 0000000..abf4d90
> --- /dev/null
> +++ b/tools/kernel2minor/Makefile
> @@ -0,0 +1,35 @@
> +#
> +# Copyright (C) 2016 adron@yapic.net
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=kernel2minor
> +PKG_VERSION:=0.01
> +PKG_RELEASE:=1
> +
> +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
> +PKG_SOURCE_URL:=https://github.com/adron-s/kernel2minor.git
> +PKG_SOURCE_PROTO:=git
> +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
> +PKG_SOURCE_VERSION:=8d59a129acb5663e130a002e47ba2e05d7e29c57
> +
> +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION)
> +
> +include $(INCLUDE_DIR)/host-build.mk
> +
> +define Host/Compile
> +	$(MAKE) -C $(HOST_BUILD_DIR)
> +endef
> +
> +define Host/Install
> +	$(INSTALL_BIN) $(HOST_BUILD_DIR)/kernel2minor $(STAGING_DIR_HOST)/bin/
> +endef
> +
> +define Host/Clean
> +	rm -f $(STAGING_DIR_HOST)/bin/kernel2minor
> +endef
> +
> +$(eval $(call HostBuild))
>
diff mbox

Patch

diff --git a/config/Config-images.in b/config/Config-images.in
index a60dd50..339a5fd 100644
--- a/config/Config-images.in
+++ b/config/Config-images.in
@@ -6,6 +6,13 @@ 
 
 menu "Target Images"
 
+	config TARGET_KERNEL_MINOR_YAFFS2
+		bool "kernel.minor-yaffs2"
+		default n
+		depends on TARGET_ar71xx_mikrotik
+		help
+		  Build a Mikrotik Nor Yaffs2 kernel filesystem for RouterBoot
+
 	menuconfig TARGET_ROOTFS_INITRAMFS
 		bool "ramdisk"
 		default y if USES_INITRAMFS
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index e4e2fcf..64bec18 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -1658,6 +1658,9 @@  define Image/BuildKernel
 	$(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(UIMAGE)-gzip.bin)
 	$(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(UIMAGE)-lzma.bin)
 	cp $(KDIR)/loader-generic.elf $(VMLINUX)-lzma.elf
+        ifeq ($(CONFIG_TARGET_KERNEL_MINOR_YAFFS2),y)
+		$(STAGING_DIR_HOST)/bin/kernel2minor -k $(KDIR)/loader-generic.elf -r $(VMLINUX)-lzma.minor-yaffs2 -e
+        endif
 	-mkdir -p $(KDIR_TMP)
 	$(call Image/Build/Profile/$(IMAGE_PROFILE),buildkernel)
 endef
diff --git a/target/linux/ar71xx/mikrotik/target.mk b/target/linux/ar71xx/mikrotik/target.mk
index b2fb0df..250252e 100644
--- a/target/linux/ar71xx/mikrotik/target.mk
+++ b/target/linux/ar71xx/mikrotik/target.mk
@@ -1,4 +1,4 @@ 
-BOARDNAME:=Mikrotik devices with NAND flash
+BOARDNAME:=Mikrotik devices with NAND/NOR flash
 FEATURES += targz ramdisk
 
 define Target/Description
diff --git a/tools/Makefile b/tools/Makefile
index 187655e..2ea66c40 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -38,6 +38,7 @@  tools-$(CONFIG_TARGET_x86) += qemu
 tools-$(CONFIG_TARGET_mxs) += elftosb sdimage
 tools-$(CONFIG_TARGET_brcm2708)$(CONFIG_TARGET_sunxi)$(CONFIG_TARGET_mxs) += mtools dosfstools
 tools-$(CONFIG_TARGET_ar71xx) += lzma-old squashfs
+tools-$(CONFIG_TARGET_ar71xx_mikrotik) += kernel2minor
 tools-y += lzma squashfs4
 tools-$(BUILD_B43_TOOLS) += b43-tools
 tools-$(BUILD_PPL_CLOOG) += ppl cloog
diff --git a/tools/kernel2minor/Makefile b/tools/kernel2minor/Makefile
new file mode 100644
index 0000000..abf4d90
--- /dev/null
+++ b/tools/kernel2minor/Makefile
@@ -0,0 +1,35 @@ 
+#
+# Copyright (C) 2016 adron@yapic.net
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=kernel2minor
+PKG_VERSION:=0.01
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://github.com/adron-s/kernel2minor.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=8d59a129acb5663e130a002e47ba2e05d7e29c57
+
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/host-build.mk
+
+define Host/Compile
+	$(MAKE) -C $(HOST_BUILD_DIR)
+endef
+
+define Host/Install
+	$(INSTALL_BIN) $(HOST_BUILD_DIR)/kernel2minor $(STAGING_DIR_HOST)/bin/
+endef
+
+define Host/Clean
+	rm -f $(STAGING_DIR_HOST)/bin/kernel2minor
+endef
+
+$(eval $(call HostBuild))