When experimenting with essential Iliad programs, a small mistake can be fatal: unbootable device, re-flash required.
I solved this with the following set-up:
This is a long article, but it's really quite simple
When experimenting you can just modify 'my_start.sh', and let this do whatever you want. If the iliad doesn't start properly: remove the sd-card (it works even with the dummy plastic one), reboot, and try again. :)
Here is the modification at the start of the official 'start.sh':
#!/bin/sh #HANSEL: Alternative start export MYLOG=/home/root/start.log /usr/local/bin/sd_present aaa 2>>$MYLOG if /usr/local/bin/sd_present then . /home/root/my_start.sh exit 0 fi #HANSEL: original start follows... . /usr/bin/do_updates.sh #/usr/bin/erregInit #/sbin/syslogd -s 500 -b 0 -O /var/log/messages export DISPLAY=:0 [snip]
Be careful when moving the original start.sh around. It must be present, correct an executable (chmod +x) before rebooting! The big advantage is that you have to modify it only once.
It's a good idea to start my_start.sh (/home/root/my_script.sh) as a copy of start.sh, and modify it in small steps. The following script is my first experiment:
#!/bin/sh echo "############################" >>$MYLOG date >>$MYLOG /usr/local/bin/sd_present aaa 2>>$MYLOG echo "====== Running processes ======================" >>$MYLOG ps -edalf >>$MYLOG echo "============================" >>$MYLOG . /usr/bin/do_updates.sh #/usr/bin/erregInit #/sbin/syslogd -s 500 -b 0 -O /var/log/messages export DISPLAY=:0 export LD_LIBRARY_PATH=/usr/lib/mozilla-minimo [snip: relevant parts of original script]
The program to check the presence of the sd-card is quite simple:
// This progam return 0 (= success) when sd-card is present // free-ware without purpose, hansel<AT>hpelbers<DOT>org, 12-12-2008 // To test: run it with any parameter: it will print if the card is inserted or not #include <stdio.h> #include <fcntl.h> #include <sys/ioctl.h> #define BUTTON_IOCTL_BASE 'b' #define BUTTON_IOCTL_GET_STATUS _IOR( BUTTON_IOCTL_BASE,7,unsigned int) int main(int argc, char *argv[]) { int stat; int dev; if ((dev = open("/dev/buttons", O_RDWR)) < 0) { fprintf(stderr,"ERROR opening failed\n"); return 10; // error } else if (ioctl(dev, BUTTON_IOCTL_GET_STATUS, &stat)) { fprintf(stderr, "ERROR: BUTTON_IOCTL_GET_STATUS failed\n"); return 11; // error } else { if(argc>1) fprintf(stderr, "OK: sd_present=%d\n", (stat&0x800) != 0); return (stat&0x800) ? 0 : 1; } }
It can be compiled with the cross-compiler as:
arm-linux-gcc sd_present.c -o sd_present
As you can see in the start.sh, I have installed it in /usr/local/bin. The experimental start script is installed as /home/root/my_start.sh
Attached: binary that runs on Iliad
Note: I published and discussed this article on mobileread.com