increasing flash size for target hw

Hi,

I wanted to ask if it is as straight forward as the diff below to increase
the flash size of a given target hardware?

Example given: in the below case from 4MB to 16MB?

Is there anything else to be aware of or that needs to be adapted? Any quirks/caveats to look out for?

Is it possible in general to just increase that size to for example
128MByte although you only have 16MByte available at the time. Does it
always adjust to the size availabe or could this damage the device?

Thanks in advance,
Mischa

# git diff mt7620n_vonets_var11n-300.dts
diff --git a/target/linux/ramips/dts/mt7620n_vonets_var11n-300.dts b/target/linux/ramips/dts/mt7620n_vonets_var11n-300.dts
index cf4b7c54..272ba249 100644
--- a/target/linux/ramips/dts/mt7620n_vonets_var11n-300.dts
+++ b/target/linux/ramips/dts/mt7620n_vonets_var11n-300.dts
@@ -75,7 +75,7 @@
                        partition@50000 {
                                compatible = "denx,uimage";
                                label = "firmware";
-                               reg = <0x50000 0x3b0000>;
+                               reg = <0x50000 0xf60000>;
                        };
                };
        };
1 Like

You diff is not the only needed change to the device support source code...

The DTS is fine because it's the last mtd partition.

You need to change also the image size in the makefile.
Take a look here:


This is needed to allow building images that are bigger than this defined size.

1 Like

Hi juppin,

thanks a lot for your fast reply and the hint. So I was looking through the file you mentioned and found that for the mt7620n SoC there are different sizes used around 16MByte. I don't quite understand why that is the case and what I have to watch out for to find the right size for my case? What are the indicators on the chosen sizes? Should I try to go with the same calculation as for the 4MB case for vonets which seems 0x3b0000/1024 = 3776k would it be 0xf60000/1024 = 15744k?

Thanks a lot,
Mischa

# grep -E1 7620n /Users/mischa/git/network/openwrt/openwrt/target/linux/ramips/image/mt7620.mk |  grep IMA | sort -n -k 3 | uniq -c  | tail -n 4
   1   IMAGE_SIZE := 14272k
   2   IMAGE_SIZE := 15744k
   4   IMAGE_SIZE := 16064k
   2   IMAGE_SIZE := 16256k
1 Like

You need to understand the areas reserved for various other partitions in the OEM firmware. There may be some calibration data (like "art"), some extra IDs or boot variables (e.g. u-boot env), some special storage area (like "Netgear"), whatever... The reserved area vary by manufacturer and router, independent of the underlying technical chipset.

If you change the memory chip, you need to not only change the size definition, but take care of copying the contents of the possibly moved partitions on flash.

E.g. "art" in the old Atheros chipsets is typically at the end of the flash. So, If you had 4 MB (boot stuff 1 MB + firmware 2,9 MB + art 0,1 MB), and you switch the chip 4 MB --> 16 MB, you need to take care to also copy that "0,1 MB art" to a safe place on the chip, so that you do not overwrite it on the previous place. Otherwise your new 14,9 MB firmware area would overwrite the contents of art at the 3,9 MB on flash.

The OEM stuff ends at 3b0000, so the 3b0000-3fffff is reserved for OEM stuff. You should likely copy those contents to fb0000 and then mark fb0000-ffffff reserved in your new partition definition. (I have not looked what the contents there are, but that is the principle.)

1 Like

This should be correct if it matches the firmware partition.

Because the firmware partition is the last partition in your flash layout you can easily increase the size without thinking about the other partitions.

But always keep a full backup of your flash to be on the safe side.

1 Like

This should be correct if it matches the firmware partition.

Yes it should: I used this change in the dts file:

--- a/target/linux/ramips/dts/mt7620n_vonets_var11n-300.dts
+++ b/target/linux/ramips/dts/mt7620n_vonets_var11n-300.dts
@@ -74,7 +74,7 @@
                        partition@50000 {
                                compatible = "denx,uimage";
                                label = "firmware";
-                               reg = <0x50000 0x3b0000>;
+                               reg = <0x50000 0xf60000>;
                        };
                };
        };

Although im not sure what exactly this reg entry means. I thought it gives the exact start and size of a given partition (in this case firmware).

Because the firmware partition is the last partition in your flash layout you can easily increase the size without thinking about the other partitions.

But what I don't understand is that with the default vonets image config (reg = <0x50000 0x3b0000>;) I actually already have access to 12MB Flash instead of what I suggested less then 4MByte which is the value configred in with reg.

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    29.5M     60.0K     29.4M   0% /tmp
/dev/mtdblock6           12.0M    500.0K     11.5M   4% /overlay
                         ^^^^^
overlayfs:/overlay       12.0M    500.0K     11.5M   4% /
tmpfs                   512.0K         0    512.0K   0% /dev

Could someone give me hint how that is achieved? Is this dynamically adapted by the Kernel or how is that actually achieved. Does that mean I won't have to change anything at all since the extra flash is already detected or could this change in the future and then cause any problems?

Thanks 1000x,
Mischa

1 Like

You are right.

That part is also not known by me, probably there is a implemented behavior to extend it to the full flash size if it's the last defined partition.

As long as the built images does not exceed the limit defined in the makefile, you won't have any limitations by that behavior.

1 Like

Hi
I did the various files changes for a WT3020 which is a mt7620 based device. The compilation went well. I perfomed the change of the flash chip (8M to 16M) including the copy of the original u-boot, art and nvram (shifted toward the end of the chip). Then i try to install the modified software.
But during the u-boot start it look like the WT3020 u-boot is checking the flash chip type. Looking at the uboot assembly code one can read different flash chip references. Most probably only those ones allowed.
I suspect that u-boot need to be modified so that to include the new chip reference . Any guidance to do that? Including u-boot update in flash?
THx
PS I did the same kind change (moving from 8 to 16M) on another unit based on ath79 where the uboot is more simple (no flash type check) and it works well.