PeterPawn / YourFritz

dynamic package management for AVM routers
GNU General Public License v2.0
219 stars 63 forks source link

Changes of eva_to_memory #61

Closed vaxinf closed 9 months ago

vaxinf commented 9 months ago

I have identified a problem with the eva_to_memory script: for the Fritzbox 7581 the upload parameters are set incorrectly, so that the firmware upload fails: In the original script the memory size is 0x80000000, but the fritzbox in question only has 0x20000000.

After inserting three lines into the code, the parameters were set correctly again, just as the original recovery program from AVM sets.

[ "$limit_memory" = "1" ] && memsize=$(( 1024 1024 128 )) && echo "Memory size limited to 128 MB"

new

                if [ $((startaddress)) -gt $((memsize)) ]; then
                    startaddress=$(( 0 ))
                fi

end new

echo "Image size is $(printf "0x%06x" $filesize) $(printf "(%u MB)" $(( filesize / 1024 / 1024 )))"

PeterPawn commented 9 months ago

In the original script the memory size is 0x80000000

That's wrong - the value of startaddress (don't mix it up with startaddr (https://github.com/PeterPawn/YourFritz/blob/f0b0942846ffcc9ff8a5e8c038350fbd2f63e215/eva_tools/eva_to_memory#L125), that's the computed start address of image in memory) is the "base address" for all other addresses and has a special meaning for the MIPS architecture (it says: unmapped, cacheable memory in kernel mode -> look for "kseg0 mips memory map" in your favored search engine) and this value will (up to nowadays) always be larger than the installed memory size.

I don't know any (MIPS-based) device by AVM with more than 1 GB RAM yet - and in (basic) "kseg0 mode" the accessible memory range is limited to 512 MB, too.

The script was developed for MIPS architecture only - and your 7581 device uses another platform (ARM), so it's not eligible to be flashed with this script anyway. But you may adapt it to your needs and set startaddress in this line: https://github.com/PeterPawn/YourFritz/blob/f0b0942846ffcc9ff8a5e8c038350fbd2f63e215/eva_tools/eva_to_memory#L34C16-L34C24 to 0 (or implement an additional parameter or whatever you want).

Nevertheless the suggested changes are wrong for other (MIPS-based) devices (at least the description of the problem and its solution) - so I'll close this issue.