|
|
View Full Version : SWAP on iLiad
tirsales 11-09-2007, 07:22 AM Hi there,
as a warning note in advance: Currently I don't own an iLiad, nor do I have access to one ATM. Thus this is a purely theoretical approach and I don't have the means needed to implement this myself (okay, I could implement this, but I couldn't test it).
My questions:
1. I have read multiple times, that enabling swap would be a nice thing. Though I know why swap sometimes is a nice thing on a normal system, I don't see the main advantage for the iLiad: CF is relatively slow, thus I can't see a big improvement through this (okay, perhaps when running multiple applications).
Same applies to SD. I don't know if the DOC is faster, problems see at the bottom, alternative 1.
With a (not too-low quality) modern CF/SD card the number of read/write cycles shouldn't be too much of a problem (a number of embedded device manufacturers actually deliever devices using CF, allowing for swap and giving a 3-year-warranty). This specifically excludes any "standard CF"-cards (like SanDisk Standard vs SanDisk Extreme, Ultra, etc) as they typically allow for only a limited number of write cycles. And even if killed after a year, cards are cheap.
2. What is the big problem?
AFAIK one can install a new kernel to the iLiad via the CF-Bootloader. Correct?
The swap-utilities themselves should be available for XScale-cpus and an ARM-architecture already. Granted, I haven't had a bigger look into this, but I know for sure that the ARM-port of debian allows for swap ...
Thus one should be (easily) able to port a swap-enabled kernel & -utility to the iLiad. For enabling swap:
Write a short shellscript that tests for a CF-card and wether partition 2 on this card (yes, CF can be partitioned) and, if present and a swap-partition, enables swapping to that partition.
Write a second shellscript that disables swapping (in case you want to extract the card).
It wouldn't even be needed to put the swap-modules into initrd, loading them sometime (when needed) is sufficient. It wouldn't even need to be a startscript but could be run when needed (thus reducing the power drain when swap is not needed).
Big drawback: Power drain. CF sucks power, swapping would be (in the worst case) a continuous writing/reading to that card and thus would kill your battery time for good.
Alternative 1: Repartition the iLiad-intern flash device, enabling an intern swap.
I wouldn't recommand this though:
CF/SD Cards are cheap, thus it is not a big problem if they scrumble after 1-3 years. ATM I don't know which DOC is used, thus I cannot say the number of write-cycles it supports (and I am too lazy to search). But ntl: Killing your DOC-chip (thus needing a new iLiad) is far more expensive than killing your CF/SD card (thus needing a new card). Not worth the (possible) gain IMO.
Alternative 2: Use a SD-card instead of CF (if they use less power). I don't even know wether SD-cards can be partitioned, but it should be possible to either use the complete card or use a swap-file.
Alternative 3: Use a swap-file on the DOC. Problems: see alternative1. Advantage: no need to repartition the DOC.
This thread is to be ignored or regarded at your own judgement ;)
regards
Tirsales
wallcraft 11-09-2007, 08:48 AM I have seen FBReader freeze on large files (e.g. 7 MB CHM) and large dictionaries are apparently a problem for MobiPocket Reader (24 MB: unable to open mobipocket dictionary (http://www.mobileread.com/forums/showthread.php?t=15908)). I assume this is due to a lack of memory, but I don't know this for sure.
On the Nokia 770, you can add 64 MB of swap space on a MMC card. See, for example, Setting Up Swap on MMC (http://internettablettalk.com/wiki/index.php?title=Setting_Up_Swap_on_MMC). There were initial questions about write cycles, but I am not aware of anyone actually wearing out a MMC card by using it as swap space. I would be concerned about adding swap on a CF card, because these don't always mount at boot time. In any case, the addition of card-based swap would need to allow for the possibility that the card was missing at boot time.
tirsales 11-09-2007, 09:11 AM I would be concerned about adding swap on a CF card, because these don't always mount at boot time.
I agree, this clearly speaks for MMC.
In any case, the addition of card-based swap would need to allow for the possibility that the card was missing at boot time.
This is why I proposed a script that tests for the existance of a swap-partition.
For MMC this could be changed to :
* Test if MMC-Card present
* Mount MMC-Card (alternativ: test if already mounted)
* Test if SWAP-File present (fairly easy)
* activate SWAP.
run at boot-time or after inserting the card - Linux is fairly easy on adding or removing swap.
--edit:
Creating the swap-file:
'dd if=/dev/zero of=[path to mmc-card]/swpfile bs=1M count=[größe des swapfiles in MB]'
'mkswap [path to mmc-card]/swpfile'
Example:
dd if=/dev/zero of=/media/mmc/swpfile bs=1M count=256
mkswap /media/mmc/swpfile
(erzeugt ein 256MB Swapfile)
Shellskript (assuming that MMC-cards are mounted at boot-time and that the command 'swapon' is available.)
#! /bin/bash
mmcFolder = [Pfad zu MMC auf iLiad]
swapActivated = 0
if ( -e $mmcFolder/swpfile ) ; then
swapon $mmcFolder/swpfile && swapActivated = 1
fi
if ( $swapActivated -gt 0 ) ; then
echo "Jipii! We have swap!"
free
else
echo "Baah, no swapping for you!"
fi
---
The last 'if' could be used for a more sofisticated error-handling, but it should do as an example.
If someone would be willing to test it, I could try to compile the swap-utils and the appropriate kernel - with absolutely NO WARRANTY that it won't brick your system as it would be completely untested.
On the other hand it should be fairly easy to implement yourself.
-- edit 2:
http://www.mobileread.com/forums/showthread.php?t=12386&highlight=swapon
mentions, that Adam B. has ported a busybox-variant with swapon / swapoff. Thus only the kernel is missing.
Or am I just being stupid and writing stuff everybody knows?
-- edit 3:
Seems I really am stupid - and much to used to kernel 2.6 .. IIRC the option to "disallow" swapping has been added to the kernel-config in kernelfamily 2.6, 2.4 doesn't have this option ... So: Swapping should already be possible. If not it is more difficult.
Anybody willing to try if swap is working? Or perhaps has already done so?
Adam B. 11-09-2007, 10:58 AM I've updated the busybox post to include an ipkg installer for busybox.
Then I did the following.
root@ereader:/media/cf# ipkg install busybox_1.7.2_ereader.ipk
Upgrading busybox on root from 1.01-r2 to 1.7.2...
Configuring busybox
/bin/busybox --install -s
busybox --help
BusyBox v1.7.2 (2007-10-30 12:45:14 EDT) multi-call binary
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
Licensed under GPLv2. See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: [function] [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
awk, basename, bunzip2, bzcat, cal, cat, catv, chattr, chgrp,
chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum,
clear, cmp, comm, cp, crond, crontab, cryptpw, cut, date,
dc, dd, deallocvt, delgroup, deluser, df, dhcprelay, diff,
dirname, dmesg, dnsd, dos2unix, dpkg, du, dumpkmap, dumpleases,
echo, ed, egrep, eject, env, envdir, envuidgid, ether-wake,
expand, expr, fakeidentd, false, fbset, fdflush, fdformat,
fdisk, fgrep, find, fold, free, freeramdisk, fsck, fsck.minix,
ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip,
halt, hdparm, head, hexdump, hostid, hostname, httpd, hwclock,
id, ifconfig, ifdown, ifup, inetd, init, insmod, install,
ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule,
iptunnel, kill, killall, killall5, klogd, last, length, less,
linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,
login, logname, logread, losetup, ls, lsattr, lsmod, lzmacat,
makedevs, md5sum, mdev, mesg, mkdir, mkfifo, mkfs.minix,
mknod, mkswap, mktemp, modprobe, more, mount, mountpoint,
mt, mv, nameif, nc, netstat, nice, nmeter, nohup, nslookup,
od, openvt, passwd, patch, pidof, ping, ping6, pipe_progress,
pivot_root, poweroff, printenv, printf, ps, pscan, pwd, raidautorun,
rdate, readlink, readprofile, realpath, reboot, renice, reset,
resize, rm, rmdir, rmmod, route, run-parts, runlevel, runsv,
runsvdir, rx, sed, seq, setarch, setconsole, setkeycodes,
setlogcons, setsid, setuidgid, sh, sha1sum, slattach, sleep,
softlimit, sort, split, start-stop-daemon, stat, strings,
stty, su, sulogin, sum, sv, svlogd, swapoff, swapon, switch_root,
sync, sysctl, syslogd, tail, tar, tcpsvd, tee, telnet, telnetd,
test, tftp, time, top, touch, tr, traceroute, true, tty,
ttysize, udhcpc, udhcpd, udpsvd, umount, uname, uncompress,
unexpand, uniq, unix2dos, unlzma, unzip, uptime, usleep,
uudecode, uuencode, vconfig, vi, vlock, watch, watchdog,
wc, wget, which, who, whoami, xargs, yes, zcat, zcip
dd if=/dev/zero of=/media/cf/swpfile bs=1M count=64
root@ereader:/media/cf# ls -lah swpfile
-rwxr-xr-x 1 root root 64.0M Nov 9 12:53 swpfile
root@ereader:/media/cf# mkswap /media/cf/swpfile
Setting up swapspace version 1, size = 67104769 bytes
root@ereader:/media/cf# swapon /media/cf/swpfile
root@ereader:/proc# cat meminfo
total: used: free: shared: buffers: cached:
Mem: 64901120 63266816 1634304 0 1155072 37359616
Swap: 67100672 0 67100672
MemTotal: 63380 kB
MemFree: 1596 kB
MemShared: 0 kB
Buffers: 1128 kB
Cached: 36484 kB
SwapCached: 0 kB
Active: 10052 kB
Inactive: 39232 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 63380 kB
LowFree: 1596 kB
SwapTotal: 65528 kB
SwapFree: 65528 kB
tirsales 11-09-2007, 11:13 AM Well, this means theorie 2: Writing stuff everybody knows already :oops2:
Should have read that busybox-list more thoroughfully ... :o
Adam B. 11-09-2007, 11:18 AM Nah, not stuff everybody knows. There probably aren't more than a few people who know you can add swap to the iLiad. Now, they have scripts, instructions, and binaries. :D
I think this can be a useful thread for researchers. :thumbsup:
jharker 11-09-2007, 02:13 PM Sweet, Adam, thanks a lot!
tirsales 11-09-2007, 03:12 PM Added a wiki-entry http://wiki.mobileread.com/wiki/Swap_on_iLiad .
1st rewrite done.
nkelle 11-09-2007, 03:51 PM Jep, i can confirm swapfile works nice (with new busybox)
ericshliao 01-28-2008, 10:58 PM Under what condition will swap memory does affect, improve or facilitate iLiad's function? Please share your experience.
ajnorth 01-31-2008, 01:31 AM Am pretty sure if you put swap onto your CF card you'll cause your wireless conncetion to drop every time the swapping accesses the CF card, due to a bug IRex say they're looking into (not related to swap in particular, but to any sort of access of the CF card while the wireless connection is up).
I haven't actually tested this but I have tested manual access of the CF card with the wireless up and it does cause it to drop the connection - I'm assuming access for swap purposes would cause the same problem.
So that's a big impairment of function for me at the moment.
mvoosten 04-17-2008, 06:16 AM So.. I just found this thread about being able to set (and use) a swapfile on the iLiad. Since this is just using your CF/SD card as a form of extended memory, does this also mean developers could start using this feature to implement a suspend mode????
Propably will get comments about the CPU not being able to power down completely etc.. However, when using iDS scheduled download it is able to turn on and off by itself, meaning that a software close down should be possible. Now only if the other keys like the flipbar could resume the device we should have enough to go forward right??
Adam B. 04-17-2008, 07:36 AM Swap and suspend are 2 completely different animals... Getting swap working does absolutely nothing for suspend/sleep.
axel77 04-17-2008, 10:03 AM I think this can be a useful thread for researchers. :thumbsup:
Hmm, research what?
M@rcel 09-01-2008, 02:28 PM I have enabled swap on MMC :)
Why:
I have a few HUGE pdf's consisting of images of scanned bookpages. Opening these files made the iLiad's LED blink forever (well many hours at least) and sometimes caused even a lockup (reset required). Because the same file showed different symptoms on different attempts, I wondered if the kernel ran out of memory and perhaps an application that doesn't check returns from malloc()-calls properly :smack:.
Adding (swap-) memory seemed a valid attempt to me to try to fix this.
I have a permanently mounted 1 GByte MMC for non-iRex software and things, so I decided to put the swapfile there. I chose a size of 128MByte (2 * RAM).
Result:
The documents now open correctly.
"cat /proc/swaps" and "cat /proc/meminfo" show that the swapspace is being used.
I am happy :2thumbsup.
Remarks:
The wiki page ( http://wiki.mobileread.com/wiki/Swap_on_iLiad ) shows an invalid dd commandline. Am I allowed to fix this myself?
I changed the swapfile's name into _swpfile to hide it from the contentlister
The performance seems not to suffer from this modification
wallcraft 09-01-2008, 02:56 PM The wiki page ( http://wiki.mobileread.com/wiki/Swap_on_iLiad ) shows an invalid dd commandline. Am I allowed to fix this myself? Yes. The Wiki is editable by anyone, and edits are encouraged if they improve the page.
M@rcel 09-01-2008, 03:20 PM Yes. The Wiki is editable by anyone, and edits are encouraged if they improve the page.Done :)
|