12-11-2008, 05:13 PM | #1 |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Safe(r) experimenting with alternative start scripts
Hi All,
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 post, but it's really quite simple. Read along... 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': Code:
#!/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] 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: Code:
#!/bin/sh date >>$MYLOG echo "############################" >>$MYLOG /usr/local/bin/sd_present aaa 2>>$MYLOG echo "===== pwd =======================" >>$MYLOG pwd >>$MYLOG echo "===== mount =======================" >>$MYLOG mount >>$MYLOG echo "====== ps -edalf ======================" >>$MYLOG ps -edalf >>$MYLOG echo "====== /usr/local ======================" >>$MYLOG ls -l /usr/local >>$MYLOG echo "====== /mnt/free ======================" >>$MYLOG ls -l /mnt/free >>$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] Code:
// 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; } } Code:
arm-linux-gcc sd_present.c -o sd_present Happy hacking, Hansel Edit: attached binary that runs on Iliad Last edited by hansel; 12-11-2008 at 05:37 PM. Reason: attach sd_present |
12-11-2008, 07:57 PM | #2 |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
Can't I test if sd is inserted by using shell script: "if [ -e /media/card/specific_file_onsd ]"?
Added: I seem to understand your idea. It's really a good idea for customizing boot. With your idea, we can add customized boot script in SD for testing. If failed, just remove SD and reboot, and everything goes back to normal. Last edited by ericshliao; 12-11-2008 at 09:03 PM. |
Advert | |
|
12-11-2008, 09:52 PM | #3 |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
I would like to suggest a small modification:
just replace the line in /home/root/.start.sh: Code:
/usr/bin/displayMgr -p & Code:
if [-f /media/card/mybootscript.sh ]; then . /media/card/mybootscript.sh else /usr/bin/displayMgr -p & fi Last edited by ericshliao; 12-11-2008 at 10:17 PM. |
12-12-2008, 01:10 AM | #4 |
Evangelist
Posts: 423
Karma: 1517132
Join Date: Jun 2006
Location: Madrid, Spain
Device: quaderno, remarkable2, yotaphone2, prs950, iliad, onhandpc, newton
|
|
12-12-2008, 02:15 AM | #5 | |
JSR FFD2
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Quote:
= The Idea it to only make a small change to start.sh, and then leave it alone. Personally I'm experimenting with contentLister. If you change it often for different things, you'll end up by making a 'fatal' mistake as I did earlier yesterday = The -f test will not work. The removable devices are not yet mounted at that stage. The hotplug stuff is at the *end* of start.sh. That's why I put those start scripts in the main file system... |
|
Advert | |
|
12-12-2008, 02:21 AM | #6 | |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
Quote:
What if I move the following lines: Code:
modprobe phci modprobe usb-storage /etc/init.d/hotplug start modprobe mscd Last edited by ericshliao; 12-12-2008 at 02:24 AM. |
|
12-12-2008, 02:36 AM | #7 |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
Ah...
I have another idea. put xepdmgr and mybootscript.sh in /home/root. And use the following code in .start.sh: Code:
if [ -f /home/root/mybootscript.sh ]; then chmod 777 /home/root/mybootscript.sh chmod 777 /home/root/xepdmgr . /home/root/mybootscript.sh mv /home/root/mybootscript.sh /home/root/_mybootscript.sh else /usr/bin/displayMgr -p & fi If xepdmgr failed, there still a chance it will back to normal in the next boot. Last edited by ericshliao; 12-12-2008 at 02:45 AM. |
12-12-2008, 03:48 AM | #8 | |
Evangelist
Posts: 423
Karma: 1517132
Join Date: Jun 2006
Location: Madrid, Spain
Device: quaderno, remarkable2, yotaphone2, prs950, iliad, onhandpc, newton
|
Quote:
AFAICT Hansel's code is safe. |
|
12-12-2008, 04:04 AM | #9 |
Guru
Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
Yes, it's fatal if anything wrong with mybootscript.sh and that mv line might never be executed. But I don't understand your words. How to do it?
Added: Ah... I understand your words now. Yes, I should do the mv action before do source action. Currently, there is only one line in mybootscript.sh: Code:
/home/root/xepdmgr & I can replace displayMgr with xepdmgr with my mod now. Last edited by ericshliao; 12-12-2008 at 04:10 AM. |
12-12-2008, 12:28 PM | #10 |
Developer
Posts: 345
Karma: 3473
Join Date: Apr 2007
Location: Brooklyn, NY, USA
Device: iRex iLiad v1, Blackberry Tour, Kindle DX, iPad.
|
Hi, all!
Nice work. I did something similar a while ago; I posted it in this thread. It's pretty much the same idea, but the implementation is a little different. Basically it's a start.sh that calls the original start.sh by default. However, if it finds a lockfile, it first deletes the lockfile and then calls testing.sh instead of the default start.sh. This way, you can just create the lockfile (I use the command 'touch lockfile') and reboot. The iLiad will delete the lockfile and use the experimental start script. If the script fails, simply reboot and you're back to the original start script. I like your idea of checking for an SD card, because then all your work can be done on the SD card. No need to use ssh to login or to manually create a lockfile, it's all just automatic. Nice work! |
Tags |
development, iliad, software |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Easier EPUB Experimenting and Updating in iBooks | tomsem | Apple Devices | 0 | 09-03-2010 05:09 PM |
is it safe to.... | Pushka | Calibre | 4 | 02-15-2010 07:52 AM |
PRS-600 Experimenting with LEDs on Sony Cover/light [PRSA-CL1] | Dr. Drib | Sony Reader | 6 | 02-05-2010 06:19 PM |
Unutterably Silly The alternative alternative Friday Question 21 August 2009 | Wetdogeared | Lounge | 13 | 08-26-2009 09:47 AM |
Sourcebooks Experimenting with DRM-Free e-Books | joedevon | News | 2 | 07-11-2009 07:23 PM |