diff mbox

[OpenWrt-Devel,1/2] include/image.mk: Introduce option to wrap kernel into JFFS2

Message ID 1446492831-20768-2-git-send-email-benjamin@sipsolutions.net
State Changes Requested
Headers show

Commit Message

Benjamin Berg Nov. 2, 2015, 7:33 p.m. UTC
Some devices like the NBG6616 and NBG6617 expect the kernel to be
in a JFFS2 partition. This macro allows wrapping the kernel so that
a normal squashfs+jffs partition can be used for the rest of the
firmware.

Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
---
 include/image.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Felix Fietkau Nov. 2, 2015, 7:49 p.m. UTC | #1
On 2015-11-02 20:33, Benjamin Berg wrote:
> Some devices like the NBG6616 and NBG6617 expect the kernel to be
> in a JFFS2 partition. This macro allows wrapping the kernel so that
> a normal squashfs+jffs partition can be used for the rest of the
> firmware.
Does that board run u-boot? If it does, you may want to use the padjffs2
utility to force it to stop scanning after the end of the filesystem image.

In case the boot loader scans the whole filesystem, this will also
prevent it from parsing data from OpenWrt's jffs2 overlay.

- Felix
Benjamin Berg Nov. 2, 2015, 11:53 p.m. UTC | #2
On Mo, 2015-11-02 at 20:49 +0100, Felix Fietkau wrote:
> On 2015-11-02 20:33, Benjamin Berg wrote:
> > Some devices like the NBG6616 and NBG6617 expect the kernel to be
> > in a JFFS2 partition. This macro allows wrapping the kernel so that
> > a normal squashfs+jffs partition can be used for the rest of the
> > firmware.
> Does that board run u-boot? If it does, you may want to use the padjffs2
> utility to force it to stop scanning after the end of the filesystem image.
> 
> In case the boot loader scans the whole filesystem, this will also
> prevent it from parsing data from OpenWrt's jffs2 overlay.

Sounds good. I was simply looking at the ZyXELNAND target, which does
not do that currently. Only realized now that mkubntkernelimage is
pretty much identical and does the padding already.

So, the new plan would be to merge mkubntkernelimage with what I stared
with the jffs2 definition. That way both models can use the same
definition and the ubnt-uap-pro KERNEL line changes from
  KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | mkubntkernelimage
to
  KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | jffs2 kernel0

Benjamin
diff mbox

Patch

diff --git a/include/image.mk b/include/image.mk
index 43980bc..8a23800 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -347,6 +347,21 @@  define Build/gzip
 	@mv $@.new $@
 endef
 
+define Build/jffs2
+	mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1))
+	cp $@ $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$(1)
+
+	$(STAGING_DIR_HOST)/bin/mkfs.jffs2 --pad=$$(($(subst k,* 1024,$(subst m, * 1024k,$(KERNEL_SIZE))))) \
+		$(if $(CONFIG_BIG_ENDIAN),--big-endian,--little-endian) \
+		--squash-uids -v -e $(patsubst %k,%KiB,$(BLOCKSIZE)) \
+		-o $@.new \
+		-d $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 \
+		2>&1 1>/dev/null | awk '/^.+$$$$/'
+
+	@rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/
+	@mv $@.new $@
+endef
+
 define Build/kernel-bin
 	rm -f $@
 	cp $^ $@