Re: [LEDE-DEV] [PATCH] cns3xxx: backport upstream SPI Flash partition sizes

2016-09-22 Thread Tim Harvey
On Thu, Sep 15, 2016 at 1:24 PM, Felix Fietkau  wrote:
> On 2016-09-15 20:27, Tim Harvey wrote:
>> Felix,
>>
>> I like the 'idea' of using mtdsplit (very clean) however this break's
>> the ability to downgrade firmware. If I take an old firmware image (a
>> version of OpenWrt prior to cns3xxx moving to the 4.4 kernel which
>> became too large to fit in the hard-coded mtd partitions chosen long
>> ago) I can upgrade with the new mtdsplit sysupgrade however if I then
>> try to downgrade to a non-mtdsplit sysupgrade image from the older
>> kernel it will fail in the image check with 'Invalid image type. Image
>> check 'platform_check_image' failed.'. I suppose if we wanted to
>> support upgrade and downgrade we would need to keep logic in
>> platform.sh to deal with the old partitioning.
> You can still downgrade, just use lede-cns3xxx-squashfs_laguna_nor.bin
> or lede-cns3xxx-squashfs_laguna_spi.bin instead of the -sysupgrade.bin.
> The new sysupgrade code will accept it, and even keeping the
> configuration should work that way.

ok - that makes sense

>
> This is a bit confusing now, so some documentation will have to be
> written. I don't see any easier way though, and simply changing the
> partition sizes would also not have worked without breaking stuff.
>

right - I can handle that on our wiki site with documentation (and
will update lede docs once I find the appropriate place)

>> I suppose sysupgrade != sysdowngrade so maybe I should care about
>> downgrading without JTAG?
>>
>> Also, to create JTAG images I need the root.squashfs and the uImage so
>> we need to keep those in the BIN_DIR (although we don't need to pad
>> them... I can do that in script that creates JTAG'able images).
> The new sysupgrade.bin can be written directly to flash now. You don't
> need separate root.squashfs and uImage anymore.
>

yes, this makes sense too.

Great - thanks for the patch

Tim

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


Re: [LEDE-DEV] [PATCH] cns3xxx: backport upstream SPI Flash partition sizes

2016-09-15 Thread Felix Fietkau
On 2016-09-15 20:27, Tim Harvey wrote:
> Felix,
> 
> I like the 'idea' of using mtdsplit (very clean) however this break's
> the ability to downgrade firmware. If I take an old firmware image (a
> version of OpenWrt prior to cns3xxx moving to the 4.4 kernel which
> became too large to fit in the hard-coded mtd partitions chosen long
> ago) I can upgrade with the new mtdsplit sysupgrade however if I then
> try to downgrade to a non-mtdsplit sysupgrade image from the older
> kernel it will fail in the image check with 'Invalid image type. Image
> check 'platform_check_image' failed.'. I suppose if we wanted to
> support upgrade and downgrade we would need to keep logic in
> platform.sh to deal with the old partitioning.
You can still downgrade, just use lede-cns3xxx-squashfs_laguna_nor.bin
or lede-cns3xxx-squashfs_laguna_spi.bin instead of the -sysupgrade.bin.
The new sysupgrade code will accept it, and even keeping the
configuration should work that way.

This is a bit confusing now, so some documentation will have to be
written. I don't see any easier way though, and simply changing the
partition sizes would also not have worked without breaking stuff.

> I suppose sysupgrade != sysdowngrade so maybe I should care about
> downgrading without JTAG?
> 
> Also, to create JTAG images I need the root.squashfs and the uImage so
> we need to keep those in the BIN_DIR (although we don't need to pad
> them... I can do that in script that creates JTAG'able images).
The new sysupgrade.bin can be written directly to flash now. You don't
need separate root.squashfs and uImage anymore.

- Felix

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


Re: [LEDE-DEV] [PATCH] cns3xxx: backport upstream SPI Flash partition sizes

2016-09-15 Thread Tim Harvey
On Thu, Sep 15, 2016 at 7:36 AM, Tim Harvey  wrote:
> On Thu, Sep 15, 2016 at 4:03 AM, Felix Fietkau  wrote:
>> On 2016-09-15 12:16, Felix Fietkau wrote:
>>> On 2016-09-15 11:34, Koen Vandeputte wrote:
 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 
>>> I'm now working on the approach that I encouraged Tim to take when this
>>> issue came up last. I think simply bumping the hardcoded kernel/rootfs
>>> split partition sizes is a hack at best, my solution involves using
>>> mtdsplit to make the kernel/rootfs split dynamic, like on other platforms.
>>> From what I can tell, the old sysupgrade script is written in a way that
>>> the image format changes will not break sysupgrade from old firmware to
>>> new and vice versa.
>> It's done now and pushed to my staging tree:
>> https://git.lede-project.org/?p=lede/nbd/staging.git;a=commit;h=aa58ee42c93136a8e158ef317cad20806001c039
>>
>> Please take a look at the commit description, test it, and let me know
>> what you think.
>>
>> - Felix
>

Felix,

I like the 'idea' of using mtdsplit (very clean) however this break's
the ability to downgrade firmware. If I take an old firmware image (a
version of OpenWrt prior to cns3xxx moving to the 4.4 kernel which
became too large to fit in the hard-coded mtd partitions chosen long
ago) I can upgrade with the new mtdsplit sysupgrade however if I then
try to downgrade to a non-mtdsplit sysupgrade image from the older
kernel it will fail in the image check with 'Invalid image type. Image
check 'platform_check_image' failed.'. I suppose if we wanted to
support upgrade and downgrade we would need to keep logic in
platform.sh to deal with the old partitioning.

I suppose sysupgrade != sysdowngrade so maybe I should care about
downgrading without JTAG?

Also, to create JTAG images I need the root.squashfs and the uImage so
we need to keep those in the BIN_DIR (although we don't need to pad
them... I can do that in script that creates JTAG'able images).

Regards,

Tim

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


Re: [LEDE-DEV] [PATCH] cns3xxx: backport upstream SPI Flash partition sizes

2016-09-15 Thread Tim Harvey
On Thu, Sep 15, 2016 at 4:03 AM, Felix Fietkau  wrote:
> On 2016-09-15 12:16, Felix Fietkau wrote:
>> On 2016-09-15 11:34, Koen Vandeputte wrote:
>>> 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 
>> I'm now working on the approach that I encouraged Tim to take when this
>> issue came up last. I think simply bumping the hardcoded kernel/rootfs
>> split partition sizes is a hack at best, my solution involves using
>> mtdsplit to make the kernel/rootfs split dynamic, like on other platforms.
>> From what I can tell, the old sysupgrade script is written in a way that
>> the image format changes will not break sysupgrade from old firmware to
>> new and vice versa.
> It's done now and pushed to my staging tree:
> https://git.lede-project.org/?p=lede/nbd/staging.git;a=commit;h=aa58ee42c93136a8e158ef317cad20806001c039
>
> Please take a look at the commit description, test it, and let me know
> what you think.
>
> - Felix

Thanks Felix! I started to work on this and then got pulled away to
something else. I'll take a look and report back.

Tim

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


[LEDE-DEV] [PATCH] cns3xxx: backport upstream SPI Flash partition sizes

2016-09-15 Thread Koen Vandeputte
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 
---
 .../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