in target/linux/ar71xx/image/legacy.mk . Just be careful not to nuke the ART partition. Make a backup of it to begin with. Maybe make rootfs smaller to make space for a larger kernel?
Maybe poke around the device definition and try to find where the kernel image limit is set.
Might be a waste of time if the problem is the bootloader cannot handle a larger kernel than what's defined already... but can't hurt trying (as long as you have an ART backup and u-boot has some recovery mechanism to recover the brick).
Why can't I throw away unnecessary hardware from kernel to shrink the size? I could not find something specific about kernel_menuconfig, whatever I did, lzma image still the same size.
The image has gotten, but not tested yet: ap147_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14328k(rootfs),1672k(kernel),64k(art)ro,16000k@0x50000(firmware)
I subtracted 200Kb from rootfs and added that to kernel partition. Still don't know correctly is... I think it can cause problems with rootfs_data partition at least... but maybe u-boot will not find kernel.
Seeing that there is a u-boot-env partition, would it be an option to change the entry-point after the bootloader? If you can make it boot from 0x50000 instead of 0xe8000, you wouldn't have to care as much about not running into the art partition and you could just use a dynamic firmware partition split.
My guess is that the bootargs from u-boot are patched out in the OpenWrt kernel. To be sure, you can check /proc/cmdline in OpenWrt to see what bootargs were actually used.
I don't really understand how ar71xx/legacy.mk works, but maybe changing the partition layout to the following will be sufficient to generate an image with kernel:rootfs instead of rootfs:kernel: ap147_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro
If you can then permanently modify u-boot to boot from the start of the firmware partition, you don't have to worry about the kernel size any more.
So, I turned back to my previous idea and got a positive result!
It took times to calculate "magic number" to boot kernel. I opened old sysupgrade image in hex editor, then found the address where kernel starts, then did the same for new image and then subtracted it from old address, then the result subtracted from old magic number.
Thus:
It seems that the build system uses rootfs or firmware partition size and always appends a uImage with the kernel. In that case, my suggestion by itself wont be enough and you have to find a way to place the uImage before the rootfs.
That 'magic' number is the address where the flash is mapped to. Address 0x9f000000 refers to the first byte of the flash. 0x9fe80000 is just the address of the kernel image then (0xe80000 = 256kiB+64kiB+14528kiB).
If you change the partition sizes, note that it might be best to stick to multiples of 64k.
I don't know if you've tried running with a modified firmware layout yet, but e.g. the mtd splitter that dynamically creates the rootfs-data overlay rounds partition sizes to an erase block. If the end of your rootfs partition doesn't align with an EB, then your kernel may or may not get corrupted.
Wow! I have never calculated hex before: (1024*256=262144=0x40000) + (1024*64=65536=0x10000) + (1024*14528=14876672=0xE30000) = 15204352 or 0xE80000
Just leave it here to come back if I'll forget again
Even I am facing the same issue with 19.07 branch for ap147-10, being a newbie to Openwrt platform, can you please tell the final fix to generate squashfs.bin image.
There is no final fix, I've just done it for myself.
Ok, I'll tell you the algorithm what I did:
get git repository
Edit file target/linux/ar71xx/image/legacy.mk and replace ap147_mtdlayout with ap147_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14328k(rootfs),1672k(kernel),64k(art)ro,16000k@0x50000(firmware)
make menuconfig and choose the platform.
make
you need to connect to your device via UART and use any terminal emulator (for example putty)
upload image with uboot menu and tftp (you can upload it via web or sysupgrade, but the device will not boot), I recommend to learn to use tftp if something went wrong and you'll want to get back an old image: tftpboot 0x80060000 openwrt-19.07.3-ar71xx-generic-ap147-010-squashfs-sysupgrade.bin && erase 0x9f050000 +${filesize} && cp.b $fileaddr 0x9f050000 $filesize
change magic number to new address: setenv bootcmd bootm 0x9FE4E000 saveenv
I could help you to build the image, but you anyway need to get in to uboot menu and change magic number. ( item 7).
Hi thanks, I tried this workaround, but still could not get the openwrt-19.07-ar71xx-generic-ap147-010-squashfs-sysupgrade.bin image, Is there any more files to modified
Hmmm... As I understand, you need to update u-boot-env partition as well, but it is in read-only more, I did not think about it.
The second way is to shrink the kernel size by cut out unneeded options. This what I tried to do at first, but fail.