Topic: How much free memory needed for Sysupgrade?

http://wiki.openwrt.org/doc/howto/generic.sysupgrade says I need to have "as much free RAM as the image is in size plus an some additional MiB of free memory".

Now I am a bit uncler about this, free gives me this:

  Mem:        13388        12636          752            0         1292
 Swap:            0            0            0
Total:        13388        12636          752

Which is obviously not enough.

However, df gives this:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2304      2304         0 100% /rom
tmpfs                     6696        60      6636   1% /tmp
tmpfs                      512         0       512   0% /dev
/dev/mtdblock3             576       288       288  50% /overlay
mini_fo:/overlay          2304      2304         0 100% /

It says I have 6MB free in tmpfs. Now my image is roughly 3MB in size. Could I make tmpfs smaller and free the three MB that I do not need to store the firmware image? Wiki is a bit unclear about this:-/.

I tried upgrading, but it always failed (the router rebooted itself unupgraded) - I am not sure whether this was the cause.

Re: How much free memory needed for Sysupgrade?

Looks like you don't have enought memory rather than tmp space.

Re: How much free memory needed for Sysupgrade?

johan666 wrote:

Looks like you don't have enought memory rather than tmp space.

Yes, I figured just that. What I am basically asking is whether (and how) I could make the tmp space smaller and give it to free memory.

Re: How much free memory needed for Sysupgrade?

Have you in fact tried to update? Afaik. you need only a little bit more RAM than the image is. Tmpfs is actually located in RAM, and if you don't use all the tmp space, the rest is free RAM. The only thing space is needed for in RAM is the image itself and for the sysupgrade program to run.

What I normally do is the following:
# cd /tmp
# mkdir firmware
# cd firmware
# wget <http://download.openwrt.org/somedir/imagefile.img>
# sysupgrade -v <imagefile.img>

As your image is 3 MB, and you have over 6 MB of RAM free (all the space in /tmp) you should be fine.

Re: How much free memory needed for Sysupgrade?

avbohemen wrote:

Have you in fact tried to update? Afaik. you need only a little bit more RAM than the image is. Tmpfs is actually located in RAM, and if you don't use all the tmp space, the rest is free RAM. The only thing space is needed for in RAM is the image itself and for the sysupgrade program to run.

What I normally do is the following:
# cd /tmp
# mkdir firmware
# cd firmware
# wget <http://download.openwrt.org/somedir/imagefile.img>
# sysupgrade -v <imagefile.img>

As your image is 3 MB, and you have over 6 MB of RAM free (all the space in /tmp) you should be fine.

Yes, I tried, several times. That is why I am asking:-). It always froze somewhere in the middle and rebooted itself. I have an Asus wl-500g, so I uses ASUS's reflash utility and it worked fine.

6 (edited by avbohemen 2012-05-07 12:42:47)

Re: How much free memory needed for Sysupgrade?

How big is your image exactly? According to your df, you have 2880 kB of flash available for Openwrt. I assume every image requires an /overlay partition (for custom configuration files), probably at least 64 kB, so that leaves 2816 kB for the image. Does yours fit in that? Otherwise you probably have bad luck... try to leave out some packages to make it fit I guess...

Re: How much free memory needed for Sysupgrade?

avbohemen wrote:

How big is your image exactly? According to your df, you have 2880 kB of flash available for Openwrt. I assume every image requires an /overlay partition (for custom configuration files), probably at least 64 kB, so that leaves 2816 kB for the image. Does yours fit in that? Otherwise you probably have bad luck... try to leave out some packages to make it fit I guess...

I have 4MB flash and the images were between 2.6 to 3.6MB. df is confusing, see https://forum.openwrt.org/viewtopic.php?id=36657 for explanation.

Re: How much free memory needed for Sysupgrade?

‹free› is not really reliable because includes file system cache and buffers. The actually free memory will be larger.

root@winder:~# free
             total         used         free       shared      buffers
Mem:         61984        57832         4152            0         3408
-/+ buffers:              54424         7560
Swap:       131068         2532       128536
root@winder:~# echo 3 > /proc/sys/vm/drop_caches
root@winder:~# free
             total         used         free       shared      buffers
Mem:         61984        47924        14060            0          456
-/+ buffers:              47468        14516
Swap:       131068         2532       128536

Re: How much free memory needed for Sysupgrade?

sup wrote:

It says I have 6MB free in tmpfs. Now my image is roughly 3MB in size. Could I make tmpfs smaller and free the three MB that I do not need to store the firmware image? Wiki is a bit unclear about this:-/.

"Free space" on tmpfs is just an accounting gimmick. All the data placed on tmpfs is kept in RAM anyway. To make sure some amount of RAM is available for "normal use" tmpfs size can not grow beyond 1/2 of RAM, but if you put something on tmpfs it's removed from "free ram" immediately and you remove something from tmpfs is's available for other uses immediately.

Re: How much free memory needed for Sysupgrade?

try to use the -n flag with sysupgrade. this will reset your configurations to default but will also allow you to flash when there are memory constraints. ( also use the "echo 3 > /proc/sys/vm/drop_cachesW thing to clear some ram ). You can also do a "ps" to see the running processes and kill some, like ssh crond dhcp, dnsmasq, etc ( kill -9 process_number )

I was able to flash a WRT54G with sysupgrade -n -v flashimage.trx from trunk to backfire whereas without the -n it would reboot without flashing anything.

hope this helps

11

Re: How much free memory needed for Sysupgrade?

finas wrote:

try to use the -n flag with sysupgrade. this will reset your configurations to default but will also allow you to flash when there are memory constraints. ( also use the "echo 3 > /proc/sys/vm/drop_cachesW thing to clear some ram ). You can also do a "ps" to see the running processes and kill some, like ssh crond dhcp, dnsmasq, etc ( kill -9 process_number )

I was able to flash a WRT54G with sysupgrade -n -v flashimage.trx from trunk to backfire whereas without the -n it would reboot without flashing anything.

hope this helps

Thanks, I will try that once I will try to do that again:-).