Increasing flash size without build my own firmware

I have TL-WDR4300 Tplink router, it has 8 MB flash chip
I soldered a 16MB flash and bootloader have been updated to pepe2k bootloader that support 16MB flash
I need to repartition flash or create new mtd after art partition
building my own firmware is not an option because of kernel module mismatch with openwrt hosted modules and building all modules to my firmware statically is not an option.
I need help to use extra 8MB free size available in flash.

I don't think there's any other way than building your own fw...

If you check out and compile the 19.07.7 from github, you should be able to use the public package repository.

4 Likes

You can extract the kernel dtb and modify partition size.

That's how I did on my WRT1200AC with 512MB flash instead of 128MB.

3 Likes

thanks very good solution
can you explain where is kernel dtb?
I dig into firmware with binwalk but didn't find it

it's at the end of kernel image, you can verify if it exist in your device by searching the pattern D0 0D FE ED.


Then use dtc (device tree compiler) to decompile the dtb into dts, and modify partitions:

2 Likes

@Hamid19 , here is a useful utility to extract such dtb files, from kernel after extracting with binwalk (if you dont want to search for the pattern yourself)

2 Likes

Thank you very much I will do it asap.

I modified dts and build back to dtb
is it enough to replace binary in kernel and no crc or checksum change neaded?
and then how can I make compressed kernel with header?
thanks for your help

Actually you need to fix the header, since uboot will check crc.

I've a small script fix_header.sh to do it easily :

#!/bin/bash

# Extract kernel name
NAME=$(xxd -l 32 -s 32 $1 | xxd -r | tr -d '\0')
# Remove first 64 bytes (header)
dd if=$1 of=$1.tmp bs=64 skip=1
# Generate header
mkimage -C none -A arm -O linux -a 0x8000 -e 0x8000 -n "$NAME" -d $1.tmp $1.uImage

rm $1.tmp

For example:

# Generate dtb from dts
dtc -I dts -O dtb dtbdump_1.dts -o dtbdump_1.dtb
# Combine kernel & dtb
cat kernel dtbdump_1.dtb > kernel_21.02
# Fix header
./fixheader.sh kernel_21.02

mkimage is in package u-boot-tools

1 Like

I think my image format is diffrent from yours.
my Kernel Image has lzma compression and header format is different from what mkimage command make
can you take a look to wdr4300 openwrt image format if it's possible ?

Indeed wdr4300 format is very different...

Maybe it's easier to use the imagebuilder to generate firmware.
Here is the tuto : https://openwrt.org/docs/guide-user/additional-software/imagebuilder

Inside build_dir\target-mips_24kc_musl\linux-ath79_generic I saw kernel and dtb files, It should be ok to replace the dtb with your modified one.

PS: take a USB-Serial cable in case of something goes wrong.

1 Like

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