Linksys RE6500 need help recompiling for bigger flash chip

Hi i have recently got a linksys re6500 router and have installed openwrt onto it and is working fine but it has only got 8mb of flash and after installing luci there is only 2.2mb left for other packages so i upgraded the flash chip to a 16mb one and copied all the contents over using a ch341a chip programmer and everything worked but i quickly found that the available size hadn't changed i tried to re flash openwrt and it didn't work so i had a look on here and found this post about how he upgraded the flash on his router

so going off what that post said i downloaded the imagebuilder for the mt7621 https://downloads.openwrt.org/releases/21.02.2/targets/ramips/mt7621/openwrt-imagebuilder-21.02.2-ramips-mt7621.Linux-x86_64.tar.xz
and unzipped the file and edited the dts file for the router mt7621_linksys_re6500.dts
and changed the section partition@50000 from reg = <0x50000 0x7b0000>; to reg = <0x50000 0xf60000>; then i changed in the file mt7621.mk under device linksys_re6500 from this IMAGE_SIZE := 7872k to this IMAGE_SIZE := 15744k
after doing this i also added luci and luci-ssl as default packages in target.mk in the folder mt7621 after doing all this i did make image PROFILE="linksys_re6500" and it built the .sysupgrade image after this i went to build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/tmp and used openwrt-21.02.2-ramips-mt7621-linksys_re6500-squashfs-sysupgrade.bin to flash my router and well nothing changed it still said 2.2mb free have i done something wrong or not edited something that needed to be edited i know this post is lengthy but i thought it would be best if i went through step by step of what i did if anyone can help me and tell me what i need to do it would be very appreciated

edit: the original flash chip is a 8mb mxic 25l6433f and the one i upgraded it with is a 16mb winbond w25q128fv

thanks nathan

ok i tried re-downloading everything and editing the files again and i added an output directory so i don't have to go searching for it in the folder build_dir and still nothing im obviously missing something or doing it completely wrong any help would be great

No. Imagebuilder skip all compiling stages (kernel, dts-file, appending dtb-file into kerne, packing kernel and makeing so called kernel.bin). It start from making rootfs (usually squashfs file) and append this rootfs to kernel.bin to make ready firmware image.
You have to reproduce all steps to remake kernel.bin file by hand.
If you are familiar with openwrt buildroot system you can do it without problem. At least all needed files/tools already exist in imagebuilder.
Steps in short:

  1. Correct dtb-file for your device (already exist in build_dir/target*/linux-ramips_mt7621):
  • decompile it with dtc (dtc -I dtb -O dts dtb-file -o dts-file)
  • correct flash size in dts-file and compile back to dtb-file (dtc dts-file -o dtb-file)
  1. Append dtb-file to kernel (vmlinux exist the same path as dtb-file):
    cat vmlinux dtb-file >you-device-kernel
  2. Pack your-device-kernel with lzma tool:
    lzma e -lc1 -lp2 -pb2 your-device-kernel your-device-kernel.lzma
  3. Make kernel.bin with mkimage tool:
    mkimage -A MIPS -O linux -T kernel -C lzma -a 80001000 -e 80001000 -n "Openwrt patched" -d your-device-kernell.zma your-device-kernel.bin
    That's all. You remake kernel.bin for you device :slight_smile:
    After these steps imagebuilder will use your corrected kernel.bin.
1 Like

im getting these warnings while compiling the dts file into the dtb file and after completing the rest of the steps and flashing the router with the .sysupgrade it just bootloops and from the serial output it trys to boot but does nothing it doesn't even say its loading anything like there's no image there

`dtc mt7621_linksys_re6500.dts -o image-mt7621_linksys_re6500.dtb

mt7621_linksys_re6500.dts:499.11-545.7: Warning (unit_address_vs_reg): /ethernet@1e100000/mdio-bus/switch@1f/ports: node has a reg or ranges property, but no unit name
mt7621_linksys_re6500.dts:91.4-20: Warning (clocks_property): /palmbus@1E000000/i2c@900:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:104.4-20: Warning (clocks_property): /palmbus@1E000000/i2s@a00:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:181.4-25: Warning (clocks_property): /palmbus@1E000000/spi@b00:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:397.3-19: Warning (clocks_property): /xhci@1E1C0000:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:425.4-25: Warning (clocks_property): /interrupt-controller@1fbc0000/timer:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:441.3-19: Warning (clocks_property): /nand@1e003000:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:455.3-19: Warning (clocks_property): /ethernet@1e100000:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:572.3-44: Warning (clocks_property): /pcie@1e140000:clocks: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:572.3-44: Warning (clocks_property): /pcie@1e140000:clocks: cell 2 is not a phandle reference
mt7621_linksys_re6500.dts:572.3-44: Warning (clocks_property): /pcie@1e140000:clocks: cell 4 is not a phandle reference
mt7621_linksys_re6500.dts:111.4-33: Warning (dmas_property): /palmbus@1E000000/i2s@a00:dmas: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:111.4-33: Warning (dmas_property): /palmbus@1E000000/i2s@a00:dmas: cell 2 is not a phandle reference
mt7621_linksys_re6500.dts:574.3-32: Warning (phys_property): /pcie@1e140000:phys: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:574.3-32: Warning (phys_property): /pcie@1e140000:phys: cell 2 is not a phandle reference
mt7621_linksys_re6500.dts:92.4-25: Warning (resets_property): /palmbus@1E000000/i2c@900:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:105.4-25: Warning (resets_property): /palmbus@1E000000/i2s@a00:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:119.4-25: Warning (resets_property): /palmbus@1E000000/systick@500:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:182.4-25: Warning (resets_property): /palmbus@1E000000/spi@b00:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:230.4-25: Warning (resets_property): /palmbus@1E000000/gdma@2800:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:244.4-25: Warning (resets_property): /palmbus@1E000000/hsdma@7000:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:459.3-34: Warning (resets_property): /ethernet@1e100000:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:459.3-34: Warning (resets_property): /ethernet@1e100000:resets: cell 2 is not a phandle reference
mt7621_linksys_re6500.dts:496.5-26: Warning (resets_property): /ethernet@1e100000/mdio-bus/switch@1f:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:570.3-44: Warning (resets_property): /pcie@1e140000:resets: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:570.3-44: Warning (resets_property): /pcie@1e140000:resets: cell 2 is not a phandle reference
mt7621_linksys_re6500.dts:570.3-44: Warning (resets_property): /pcie@1e140000:resets: cell 4 is not a phandle reference
mt7621_linksys_re6500.dts:576.3-34: Warning (gpios_property): /pcie@1e140000:reset-gpios: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:634.4-29: Warning (gpios_property): /leds/wifi:gpios: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:639.4-29: Warning (gpios_property): /leds/power:gpios: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:648.4-29: Warning (gpios_property): /keys/wps:gpios: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:654.4-29: Warning (gpios_property): /keys/reset:gpios: cell 0 is not a phandle reference
mt7621_linksys_re6500.dts:76.12-86.5: Warning (interrupt_provider): /palmbus@1E000000/gpio@600: Missing #address-cells in interrupt provider
mt7621_linksys_re6500.dts:414.32-427.4: Warning (interrupt_provider): /interrupt-controller@1fbc0000: Missing #address-cells in interrupt provider`

Reread point 1 carefully.
Firstly you must decompile dtb-file which already exist.
For compiling original dts-file (mt7621_linksys_re6500.dts) imagebuilder don't contain some files from kernel source tree.
Something like:
dtc -I dtb -O dts mt7621_linksys_re6500.dtb -o image-mt7621_linksys_re6500.dts
Then correct image-mt7621_linksys_re6500.dts and compile again:
dtc image-mt7621_linksys_re6500.dts -o image-mt7621_linksys_re6500.dtb

i did i followed every step you said this is what i did and any errors/output to the terminal

and after doing that i took the .sysupgrade that was created and flashed it to the router and it just bootloops

Very strange command:
lzma -e --lzma1=lc=1,lp=2,pb=2 linksys_re6500-kernel.bin linksys_re6500-kernel.lzma
Pls use lzma and dtc from imagebuilder. Not system ones.

ok got it working and booting after using the correct lzma but now i got a differant problem its saying theres 29mb free so i just need to change it to the correct value in the dts file thanks sooo much for helping me do this i would of been lost otherwise

fixed the problem where it says 29 mb free i changed 0xf6000 to 0xffffff and now it reports the correct value of 10.4mb free

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

yea but wont that delete the post after a few days i thought i would leave it up so if other people want to upgrade their routers (not just the re6500 router i have) they can because i couldnt find anything on how to do this until 123serge123 told me how i know that more advanced people could find how to do this but im a bit of a noob when it comes to openwrt and googling how to do this i couldnt find anything probably because i didnt search for the right things but if this stays up then other people can just google how to upgrade flash chip openwrt and they will find this

this is solved but if it can stay up for other openwrt noobs to follow like me that would be great

No.
Marking a topic solved and then deleting it after some days would be crazy.
Please read How to mark a topic as [Solved] to get a better understanding what this does and why it is a useful thing to do.

If you want to be really helpful, you could post a summary of the actions that lead to a working status, and then mark your posting as the solution.

ok ill do that then

ok if anyone wants to upgrade the flash on their router this guide will show you how this guide is only for routers that have spi flash not nand flash

step 1: you need to copy the contents of the old flash to the new to do this you can get a cheap programmer here's one from amazon
https://www.amazon.co.uk/KeeYees-SOIC8-EEPROM-CH341A-Programmer/dp/B07SNTL5V6/ref=sr_1_3?crid=1AEV8F9Y8EKGB&keywords=ch341a&qid=1649267693&sprefix=ch341a%2Caps%2C207&sr=8-3 it comes with a clip so you don't have to solder it but don't use it to read the chip as 
it will power the router and not read the flash correctly if you use the clip make sure pin 1 of the chip goes to the red wire on the clip but if you want you can solder the chip to one of the included boards 
with this programmer you will need to do a mod on it as it outputs 5v logic levels and most flash chips are 3.3v sometimes you can get away with it a few times but
it will damage the chip here is a link to a video on how to do the mod https://www.youtube.com/watch?v=HwnzzF645hA

step 2: you also need programming software i use asprogrammer https://github.com/nofeletru/UsbAsp-flash/releases download asprogrammer_version.zip unzip the file and open the program click hardware and select ch341a
then connect your chip make sure to put the chip clip in the right way or the soldered board then click read id and select the chip you have then you want to dump the chip i do this twice just to be sure save these in a safe place 

step 3: after dumping the chip you might need to adjust the image a bit before flashing the new chip i use the hex editor called HxD https://mh-nexus.de/en/downloads.php?product=HxD20

step 4: open the dumped firmware image in HxD and scroll all the way down to the bottom and if there is code at the bottom it should look like random letters and numbers if its just f's
you don't need to do steps 5-9 so go straight to step 10  

step 5: if there is code at the bottom of the flash that will need to be moved select from the bottom of the file to just before you start seeing a lot of f's cut it so it removes it and copy's it then create a new file in HxD and copy it there

step 6: now you need to make the dumped image bigger i usually make a new text doc and type a load of f's into it then copy those f's into the dumped image until the image is the correct size

step 7: look at the left side of the program and you should see offset and under that letters and numbers ascending up if you are upgrading from 4mb to 8mb you need this to end at 007ffff0 if your upgrading from 8mb to 16mb it needs to end at 00fffff0 

step 8: now go back to the new file you created in HxD and copy the code you put there and paste it at the bottom of the dumped image it will make it bigger than the size you need so go to above the code and remove some of the f's until the file ends at the correct offset

step 9: now do save as and name it something different like firmware edited don't overwrite your original firmware dump as if something goes wrong you will need to revert back to this

step 10: now you need to flash the new chip click read id on asprogrammer and select the correct chip then flash the edited image if you had to do steps 5-9 or the unedited image to the new flash chip by clicking the little down arrow on the program ic button and click unprotect-erase-program-verify after it completes solder the chip back onto the router and make sure it boots but if you had to do steps 5-9 wifi wont work but if you didn't wifi should be fine  

step 11: you need a Linux pc for this or if you have windows use a virtual machine program such as virtual box https://www.virtualbox.org/wiki/Downloads if you use this download the one called windows hosts and download manjaro Linux as
its pretty easy to use https://manjaro.org/downloads/official/kde/ if you use this one you don't even need to install it and you can try it out but it wont save anything you do as it is a live image and when you reboot everything will reset so if you want to keep everything you do install it 

step 12: download latest image builder for the device you need at https://downloads.openwrt.org/releases/ click on the latest release and then click targets then the one that corresponds with your router then click either generic
or the cpu in your router then go all the way down to the bottom and download the file ending in imagebuilder to the Linux pc

step 13: go to the menu and find konsole

step 14: install dependencies command for manjaro: sudo pacman -S --needed base-devel autoconf automake bash binutils bison bzip2 fakeroot file findutils flex gawk gcc gettext git grep groff gzip libelf libtool libxslt m4 make ncurses openssl patch pkgconf python rsync sed texinfo time unzip util-linux wget which zlib

step 15: create a new folder and call it openwrt copy the imagebuilder.tar file into it and close and open terminals/konsoles then go into the openwrt folder and right click anywhere in it if your using manjaro it should say open in terminal

step 16: unzip imagebuilder command do this in the new terminal that appears: tar -J -x -f openwrt-imagebuilder-name.tar

step 17: shorten the folder that gets created to openwrt-imagebuilder

step 18: copy these files out of the unzipped image builder folder to a new one called rebuild and then put that folder in the openwrt folder you created before: build_dir/target-name/linux-name/your router.dtb,vmlinux and delete your router-kernel.bin as you will be replacing this

step 19: cd into the rebuild folder with the files do  cd .. in the terminal then do  cd rebuild 

step 20: then do this command in terminal: dtc -I dtb -O dts your-router.dtb -o your-router.dts  name the .dts file the same as the .dtb file you copied out of the imagebuilder folder as this is the output of the decompiler you will need to edit this file

step 21: open the dts file in kate (kate is the default text editor in manjaro) that gets generated edit the part of the file called flash@0 under it should be different partitions if the last partition in the list is label = "firmware/denx,uimage/linux (if its not the last one and has one after the denx,uimage/firmware/Linux then you should of done steps 5-9 do not do the this step do step 22) then you should see under that something similar to this reg = <0x50000 0xffffff>; you want to edit the second part 0xffffff if you are upgrading from 4 to 8mb change it to 0x7fffff if you are upgrading from 8 to 16mb change it to 0xffffff

step 22: only do this step if you had to copy some stuff at the end of the dumped image (steps 3-9) because there is a partition after the denx,uimage/firmware/Linux you need to do this instead of the above step 
under the name for the last partition it should say something similar to this reg = <0x50000 0xffffff>; you need to edit the second part 0xffffff if you are upgrading from 4 to 8mb change it to 0x7fffff
if you are upgrading from 8 to 16mb change it to 0xffffff then you need to go back to the dumped firmware file you edited and increased the size of you need to find the address the code at the end starts
at so scroll all the way down to the bottom and then scroll up until you see the start of the code at the bottom look at the left of the program and you should see offset and find the address that the code starts 
at it should look something like this 007ffff0 you want to remove the first zeros at the front of the address and add this instead 0x so it should look like this 0x7ffff0 then copy that to the first part of the reg = <
now you need to edit the second part of the reg = <  under denx,uimage/firware/linux you need to change it to the start address of the code at the end of the dumped image the same address you used on the first part of the reg of the last partition but you need to change it slightly you need to add a gap 
between the two by subtracting 1 from the second position of the address after 0x and the way hex addresses count goes like this 0 1 2 3 4 5 6 7 8 9 a b c d e f  so if your end code start address is 0x64fff0 you need to remove 1 from the second position after 0x so
it becomes 0x63fff0 or 0x6ffff0 to 0x6efff0 or 0x60fff0 to 0x5ffff0 

step 23: now save the edited .dts file

step 24: do command: dtc your-router.dts -o your-router.dtb this will replace the origional dtb file with a edited one 

step 25: do command: cat vmlinux your-router.dtb  >your-router-kernel.bin this will generate a kernel file

step 26: do command: /home/username/Desktop/openwrt/openwrt-imagebuilder/staging_dir/host/bin/lzma -e -lc1 -lp2 -pb2 name-kernel.bin name-kernel.lzma  replace username with the username you set when installing manjaro

step 27: do command: /home/username/Desktop/openwrt/openwrt-imagebuilder/staging_dir/host/bin/mkimage -A MIPS -O linux -T kernel -C lzma -a 80001000 -e 80001000 -n "Openwrt patched" -d your=router-kernel.lzma name-kernel.bin

step 28: copy your-router-kernel.bin,your-router.dtb to their original locations and add any packages you want to include like luci and luci-ssl to target.mk in the openwrt-imagebuilder/target/Linux/your-router/your-router

step 29: do command: cd ..    then command:  cd openwrt

step 30: make a new folder in the openwrt-imagebuilder folder called output

step 31: do make info and find you router in the list then copy the name and replace  your-router-name with it

step 32: then do command: make image  PROFILE="your-router-name" BIN_DIR="/home/username/Desktop/openwrt/openwrt-imagebuilder/output"

step 33: after that command you should have a .sysupgrade image in the output folder which you can flash using the luci web interface or the cli over serial or ssh so there you go you successfully recompiled a Linux kernel and built your own openwrt image

step 34: to get the .sysupgrade image out of the virtual machine i just logged into my email on the virtual machine and sent it to myself in a email there are other ways but i would say this is the easiest
1 Like

if i have made an error in this guide please let me know and i will correct it

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.