Message ID | 1473179935-29811-1-git-send-email-tharvey@gateworks.com |
---|---|
State | Changes Requested |
Headers | show |
On 2016-09-06 18:38, Tim Harvey wrote: > The 4.4 kernel is not easily sized down to below the 1.5MB limit imposed by > the SPI flash MTD partition mapping. Increase this to 2MB where it is for > NOR flash devices. Additionally add a check that ensures the kernel fits > within the 2MB limit. How about using mtdsplit to make this dynamic? - Felix
On Tue, Sep 6, 2016 at 1:17 PM, Felix Fietkau <nbd@nbd.name> wrote: > On 2016-09-06 18:38, Tim Harvey wrote: >> The 4.4 kernel is not easily sized down to below the 1.5MB limit imposed by >> the SPI flash MTD partition mapping. Increase this to 2MB where it is for >> NOR flash devices. Additionally add a check that ensures the kernel fits >> within the 2MB limit. > How about using mtdsplit to make this dynamic? Felix, If this just affects image creation and doesn't require users to change their bootloader bootscript or flashing method that would be fine. Can you point me to an example target that uses this in what you would call a proper way? Thanks, Tim
On 2016-09-06 22:55, Tim Harvey wrote: > On Tue, Sep 6, 2016 at 1:17 PM, Felix Fietkau <nbd@nbd.name> wrote: >> On 2016-09-06 18:38, Tim Harvey wrote: >>> The 4.4 kernel is not easily sized down to below the 1.5MB limit imposed by >>> the SPI flash MTD partition mapping. Increase this to 2MB where it is for >>> NOR flash devices. Additionally add a check that ensures the kernel fits >>> within the 2MB limit. >> How about using mtdsplit to make this dynamic? > > Felix, > > If this just affects image creation and doesn't require users to > change their bootloader bootscript or flashing method that would be > fine. Can you point me to an example target that uses this in what you > would call a proper way? Several targets use this, including ar71xx, ath25, lantiq, etc. What you do is you call the combined partition 'firmware' and make it cover both the kernel and the rootfs area. When generating images, you append the rootfs directly after the kernel and use pad-rootfs on the result. When booting, the kernel will parse the uImage length and then search for a rootfs afterwards and create the partitions dynamically. This should work without any boot loader script changes, since the kernel offset and format remains the same. - Felix
diff --git a/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c b/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c index 667a8e5..f1a0696 100644 --- a/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c +++ b/target/linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c @@ -168,12 +168,12 @@ static struct mtd_partition laguna_spi_partitions[] = { .offset = SZ_256K, }, { .name = "kernel", - .size = SZ_1M + SZ_512K, + .size = SZ_2M, .offset = SZ_512K, }, { .name = "rootfs", - .size = SZ_16M - SZ_2M, - .offset = SZ_2M, + .size = SZ_16M - SZ_2M - SZ_512K, + .offset = SZ_2M + SZ_512K, }, }; @@ -973,19 +973,19 @@ static int __init laguna_model_setup(void) if (laguna_info.config2_bitmap & (SPI_FLASH_LOAD)) { switch (laguna_info.spi_flash_size) { case 1: - laguna_spi_partitions[3].size = SZ_4M - SZ_2M; + laguna_spi_partitions[3].size = SZ_4M - SZ_2M - SZ_512K; break; case 2: - laguna_spi_partitions[3].size = SZ_8M - SZ_2M; + laguna_spi_partitions[3].size = SZ_8M - SZ_2M - SZ_512K; break; case 3: - laguna_spi_partitions[3].size = SZ_16M - SZ_2M; + laguna_spi_partitions[3].size = SZ_16M - SZ_2M - SZ_512K; break; case 4: - laguna_spi_partitions[3].size = SZ_32M - SZ_2M; + laguna_spi_partitions[3].size = SZ_32M - SZ_2M - SZ_512K; break; case 5: - laguna_spi_partitions[3].size = SZ_64M - SZ_2M; + laguna_spi_partitions[3].size = SZ_64M - SZ_2M - SZ_512K; break; } spi_register_board_info(ARRAY_AND_SIZE(laguna_spi_devices)); diff --git a/target/linux/cns3xxx/image/Makefile b/target/linux/cns3xxx/image/Makefile index 8f29c6c..d71a860 100644 --- a/target/linux/cns3xxx/image/Makefile +++ b/target/linux/cns3xxx/image/Makefile @@ -9,6 +9,10 @@ include $(INCLUDE_DIR)/image.mk define Image/Prepare mkimage -A arm -O linux -T kernel -C none -a 0x20008000 -e 0x20008000 -n 'OpenWrt Linux-$(LINUX_VERSION)' -d $(KDIR)/zImage $(KDIR)/uImage + @if [ `stat -c%s "$(KDIR)/uImage"` -gt `expr 2048 \* 1024` ]; then \ + echo "Error: Kernel is too big" >&2; \ + exit 1; \ + fi endef # Build sysupgrade image @@ -39,7 +43,7 @@ define Image/Build/squashfs dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \ ) > $(BIN_DIR)/$(IMG_PREFIX)-$(1)_laguna_nor.bin ( \ - dd if=$(KDIR)/uImage bs=1536k conv=sync; \ + dd if=$(KDIR)/uImage bs=2048k conv=sync; \ dd if=$(KDIR)/root.$(1) bs=256k conv=sync; \ ) > $(BIN_DIR)/$(IMG_PREFIX)-$(1)_laguna_spi.bin endef
The 4.4 kernel is not easily sized down to below the 1.5MB limit imposed by the SPI flash MTD partition mapping. Increase this to 2MB where it is for NOR flash devices. Additionally add a check that ensures the kernel fits within the 2MB limit. This resolves boot issues on SPI based boards such as the GW2380/82. Signed-off-by: Tim Harvey <tharvey@gateworks.com> --- .../linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c | 16 ++++++++-------- target/linux/cns3xxx/image/Makefile | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-)