I noticed that when I set up the wifi device (by console commands) it goes down misteriously. I ping my e-book reader and it only works just after setting up wlan0 device, when changing between screens, when I open the browser and when the USB cable is plugged...
After getting crazy at least twice :P I found what is happening and how to avoid the problem: the infamous "system_manager". That odious process tries to enter the system in power saving mode continuously if the USB cable is not connected or if the system load is under about 10%, but I discovered how, it is something like:
echo mem > /sys/power/state
well, not with "echo" command, it does it with "open" and "write" calls, but the effect is the same. So, how to avoid "system_manager" doing that? This is my approach:
mkdir --parents /tmp/.real/sys/power
mkdir --parents /tmp/.fake/sys/power
mount -o bind /sys/power /tmp/.real/sys/power
cd /tmp/.fake/sys/power
ln -s /tmp/.real/sys/power/led led
ln -s /tmp/.real/sys/power/pm_async pm_async
echo -n mem > state
mount -o bind /tmp/.fake/sys/power /sys/power
With "mount -o bind" you can mount an existing directory onto another. So I recreate a fake "/sys/power" directory and mount it to make both system_manager and me happy