As indicated by Tim Harvey:

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.

https://github.com/Gateworks/openwrt/commit/17b860f32fe5739042445eb852109682d6ff7d99

Signed-off-by: Koen Vandeputte <koen.vandepu...@ncentric.com>
---
 .../linux/cns3xxx/files/arch/arm/mach-cns3xxx/laguna.c   | 16 ++++++++--------
 target/linux/cns3xxx/image/Makefile                      |  6 +++++-
 2 files changed, 13 insertions(+), 9 deletions(-)

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 fb519d2..3c21404 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,
        },
 };
 
@@ -988,19 +988,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
-- 
2.7.4


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to