Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: paulfxh on January 22, 2009, 06:06:36 AM
-
Just got TC frugal working very well on my EeePC 901.
However, still one or two small problems.
In particular, although I'm using the "tce=hdXY" and "restore=hdXY" boot codes, I still have to go through a bit of a rigmarole to get my wireless connection after boot.
This involves two steps:
1. Using AppBrowser to load both wireless_tools.tcel and wpa-supplicant.tce which remain saved to /home/tc (as does the wireless driver)
2. Run this script to launch the wireless connection
#!/bin/sh
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
To streamline this procedure, I would like to add the extension loading to the script but I can't figure out how. Using "tar -zxvf" seems to only partly achieve this.
Any clues?
Assuming this is possible, the next step would be to autostart the script so that the connection is available immediately after boot. Does TC handle autostarting?
-
Here's what I use for a similar task:
#!/bin/sh -e
#
tce-load /mnt/sda1/source/buildtc/08_09_05/b43_firmware.tce
tce-load /mnt/sda1/extensions/wireless_tools.tcel
#
tce-load /mnt/sda1/extensions/wireless-2.6.26.tcem
tce-load /mnt/sda1/extensions/misc-2.6.26.tcem
tce-load /mnt/sda1/extensions/hwmon-cpufreq-2.6.26.tcem
#
sudo modprobe b43
#
sleep 5
sudo iwconfig wlan0 essid "ssid"
sudo iwconfig wlan0 key restricted 7D:3A:7C:72:F7:9A:6F:91:DF:CF:C9:AD:CE
#
sudo udhcpc -b -i wlan0
#
# EOF
If you call your script from bootlocal.sh, it will start on boot
-
1. Using AppBrowser to load both wireless_tools.tcel and wpa-supplicant.tce which remain saved to /home/tc (as does the wireless driver)[/quote
Move your extensions to your tce directory as specified by the tce boot code.
They will auto load. Saving you from having to use appbrowser to manually load them.
Storing extensions in home dir only slows down the backup.
Factorization of static vs dynamic content is a principle of TC.
Extensions, code, is static. You should not have to be saving code eveytime.
Your boot time script to configure wireless can be stored in /opt/bootlocal.sh or could be made into a personal .tce.
-
Thank you for the replies.
Moving both wireless_tools.tcel and wpa-supplicant.tce from /home/tc/ to /mnt/hdd7/tce nicely eliminated the need to load these two extensions after booting.
However, I had less success in getting the wireless configuration script to complete during the boot.
As suggested I added my script to /opt/bootlocal.sh which now looks like this:
#!/bin/sh
# put other system startup command here
/opt/ra0.sh &
/opt/ra00.sh &
sudo su
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
However, running the script (as root) after the boot works just as well as before.
Two possible reasons for this failure is that network configuration commands (like iwconfig) only run as root. I tried to include a "sudo su" line in the script but this didn't work.
Another possibility is that the script runs before the wireless_tools have had a chance to load in which case iwconfig will not be available.
Any clues?
-
bootlocal already runs as root, the sudo su is not needed.
Perhaps this is a timing problem, try inserting "sleep 5" as the first command after #!/bin/sh to wait 5 secs.
-
Unfortunately, putting in the "sleep 5" line in the bootlocal.sh script didn't get me any further.
Indeed, I tried sleep 10, sleep 60 and sleep 300 but none of them worked. What was noticeable, however, was that there was no indication at all that the boot was being prolongued by the time included in the "sleep" line.
In fact, for "sleep 300", the script didn't seem to run at all as typing "iwconfig" after boot did not show the ra0 interface.
Other things I tried were:
1. Load both wireless_tools and wpa-supplicant as part of the bootlocal.sh script using the commands shown in Juanito's post to make sure that wireless_tools were indeed loaded before needing to use iwconfig in the script
2. Include my script as part of ra0.sh which itself is part of the bootlocal.sh script.
However, neither of these caused any improvement.
This is very puzzling as I've already used very similar scripts to autostart wireless connections in some other OSes on this EeePC 901.
Perhaps somebody else can see what might be wrong here?
-
That's because bootlocal.sh is backgrounded. If you put "sleep 300" in it, you would have to wait 5 min after boot for the rest of the script to be executed.
Also, note that tce-load will not run as root.
What's in the /opt/ra0.sh and ra00.sh?
-
/opt /ra0.sh now looks like this
#!/bin/sh
pkill udhcpc
ifconfig ra0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
#cd /home/tc
#cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
#depmod -a
#modprobe rt2860sta
#ifconfig ra0 up
#iwconfig ra0 key open
#iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
#iwconfig ra0 essid "xxxxxxxxxxxxxxx"
The commented-out stuff is what I had added in one of my "experiments".
Here below is /opt/ra00.sh
#!/bin/sh
pkill udhcpc
ifconfig ra00 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
-
1. Load both wireless_tools and wpa-supplicant as part of the bootlocal.sh script using the commands shown in Juanito's post to make sure that wireless_tools were indeed loaded before needing to use iwconfig in the script
In case it wasn't clear, I don't call the script via bootlocal.sh and I run the script as user tc - since I'm using tc in development/testing mode 95% of the time, I don't have a backup.
If you did want to load an extension via bootlocal.sh, I guess you could use "su tc tce-load /path/extension"
-
@Juanito
Thanks for those comments.
I don't call the script via bootlocal.sh and I run the script as user tc
Do you, therefore, run the script during the boot but not as root?
If so, how do you do that?
I'm fairly convinced now that my problem is that I can't get wireless_tools loaded before my script runs with the result that the three "iwconfig" commands don't function.
As bootlocal.sh runs as root, and "tce-load" cannot be run as root, I've got a problem.
I did, of course, try your suggestion
If you did want to load an extension via bootlocal.sh, I guess you could use "su tc tce-load /path/extension"
but this didn't work for me.
Indeed, If I run the script (after boot) in a root terminal, the two "tce-load" lines give me this error:
sh: can't open tce-load
So, in summary I believe what I need are either a) a means to allow the wireless_tools and wpa-supplement tce's to be loaded from bootlocal.sh or b) some way to get a script to be run during, or immediately after (but automatically), the boot other than through bootlocal.sh
-
Do you, therefore, run the script during the boot but not as root?
Sorry, no - I run it after boot
"su dsl mydsl-load /path/extension" works in dsl from bootlocal.sh, but (as you say) "su tc tce-load /path/extension" does not work in tc.
Looking at mydsl-load and tce-load, the tests for user are different - perhaps roberts would consider changing the test in tce-load to allow loading extensions from bootlocal.sh with "su tc tce-load /path/extension"?
-
TC uses a different default shell than DSL. However, I don't understand why one would want to manually maintain and load extensions from bootlocal.sh when there are already the options of autoloading at boot or manually loading from optional directory. All extensions load before /opt/bootlocal.sh is started. In fact as I pointed out in the opera/flash thread that order of tces before tczs are important. So what would be the benefit of delaying extension loading? It would seem to me to have more of a 'timing' issue? Perhaps not backgrounding /opt/bootlocal.sh would be better? I have no issue with my wireless extensions in tce directory and configuration in /opt/bootlocal.sh Given the fact that autoloading the wireless extensions from tce directory then manually running your script is successful would suggest no need to move extension loading.
-
#!/bin/sh
# put other system startup command here
/opt/ra0.sh &
/opt/ra00.sh &
sudo su
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
I think the part where this fails is that there is no ra0 interface when the ra0 and ra00 scripts are run, and that the sleep should be inserted after the modprobe. I don't think the backgrounding has anything to do with this. paulfxh, try this as bootlocal.sh:#!/bin/sh
# put other system startup command here
PATH=$PATH:/usr/local/sbin
pkill udhcpc
cp /home/tc/rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
sleep 10
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
Since the script is backgrounded, you will need to wait that 10s before checking if your wireless is up.
-
Hopefully this is it. I can reproduce the issue.
iwconfig was/is not being found in running of /opt/bootlocal.sh
The solution is to use full path to iwconfig. /usr/local/sbin/iwconfig
It is best to use full pathing on everything in /opt/bootlocal.sh
To help troubleshoot boot time processes, use the pause boot option.
-
Yeah, that's it!!! :D
Everything working fine now.
This is my bootlocal.sh and startwifi (my script slightly munged) if anybody else wants to do something similar:
bootlocal.sh
#!/bin/sh
# put other system startup command here
/opt/ra0.sh &
/opt/ra00.sh &
/home/tc/startwifi &
startwifi
#!/bin/sh
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
sleep 15
ifconfig ra0 up
/usr/local/sbin/iwconfig ra0 key open
/usr/local/sbin/iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
/usr/local/sbin/iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
Perhaps I should move my script to /opt and I'll try to reduce the sleep time to a minimum.
Thanks to everybody for the suggestions. :)
-
Glad to hear it works.
Note that you could just use one script, ie startwifi, by just moving/replacing the statements over.
-
OK, I've got it down to one script and here it is:
#!/bin/sh
ifconfig ra0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
/usr/local/sbin/iwconfig ra0 key open
/usr/local/sbin/iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
/usr/local/sbin/iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
Note that the sleep command wasn't needed at all.
However, it's not clear to me why some duplication (e.g the route command) is necessary but the script doesn't seem to work without it.
Something else I don't understand is that if I put my script into /opt (from ~/) it doesn't survive a reboot. Along the same lines is the fact that the Ralink driver needs to be copied to /lib/modules/2.6.26-tinycore/kernel/drivers/net/ on every boot.
Incidentally, because I was essentially "barking up the wrong tree", the title of this thread is quite misleading. Perhaps it would be more useful to others in the future if its title was more appropriate. However, I'm not sure of your policy in this regard.
-
See curaga's post for a possible explanation. This may be better:
#!/bin/sh
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
/usr/local/sbin/iwconfig ra0 key open
/usr/local/sbin/iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
/usr/local/sbin/iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
Something else I don't understand is that if I put my script into /opt (from ~/) it doesn't survive a reboot.
See backup/restore, ie /opt/.filetool.lst, "Getting Started" doc
Along the same lines is the fact that the Ralink driver needs to be copied to /lib/modules/2.6.26-tinycore/kernel/drivers/net/ on every boot.
You could use the generated extension instead (posted something on this in this thread iirc) which is recommended, or one of the other options to have it persistent.
Incidentally, because I was essentially "barking up the wrong tree", the title of this thread is quite misleading. Perhaps it would be more useful to others in the future if its title was more appropriate.
You can change the title if you wish, but it will not change the titles of the replies.
-
Thanks for the suggestions.
I tried your suggested script but this didn't work. It seems you need to run the extended "ifconfig ra0 up" before running the "iwconfig ra0" commands which seems reasonable.
This one works fine for me:
#!/bin/sh
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
/usr/local/sbin/iwconfig ra0 key open
/usr/local/sbin/iwconfig ra0 key a784947226d4aedbfadce86783
/usr/local/sbin/iwconfig ra0 essid "eircom6523 7524"
route add default gw 192.168.1.254
-
You could tar up your /lib/modules/2.6.26-tinycore/kernel/drivers/net/rt2860sta.ko.gz and name it rt2860sta.tcem then copy it to your tce directory
tces are basically tarballs with optional menu and icon items.
The ending 'm' signals that the extension has module(s) and thus depmod is automactic.
By doing so, you can then drop these lines
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
This also saves you from backing up and restoring the static content of rt2860sta.ko.gz
Something that TC encourages, factorization of static from dynamic content via making your own personal extensions.
-
You could tar up your /lib/modules/2.6.26-tinycore/kernel/drivers/net/rt2860sta.ko.gz and name it rt2860sta.tcem then copy it to your tce directory
tces are basically tarballs with optional menu and icon items.
The ending 'm' signals that the extension has module(s) and thus depmod is automactic.
By doing so, you can then drop these lines
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
This also saves you from backing up and restoring the static content of rt2860sta.ko.gz
Something that TC encourages, factorization of static from dynamic content via making your own personal extensions.
I very much would like to do this but I'm running into a problem (essentially due to inexperience :D).
I have read the creating extensions guide (http://www.tinycorelinux.com/wiki/tiki-index.php?page=Creating+Extensions) but note that this refers to packages rather than to single files such as this driver.
In any event, what I did was to copy the "/lib/modules/2.6.26-tinycore/kernel/drivers/net/rt2860stta.ko.gz" file to "rt2860sta.filelist" and ran this command:
sudo tar -cvzpf rt2860sta.tcem rt2860sta.filelist
I was unable to use the --numeric-owner switch as it caused the command to fail.
I then placed the resulting rt2860sta.tcem in /mnt/hdd7/tce and commented out the three lines you referred to in your post from my script (startwifi).
However, during the next reboot, not only was wireless not started but the ra0 interface wasn't created either.
Obviously, I've slipped up somewhere. :-[
-
I was just thinking of tar command like this, after you have copied the module:
tar -C / -czvf ra2860.tcem lib/modules/2.6.26-tinycore/kernel/drivers/net/rt2860sta.ko.gz
Then move the ra2860.tcem to your tce directory.
-
Well, that wasn't too difficult and it works fine.
My wireless autostart script is down to just eight lines now:
#!/bin/sh
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
modprobe rt2860sta
ifconfig ra0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
/usr/local/sbin/iwconfig ra0 key open
/usr/local/sbin/iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
/usr/local/sbin/iwconfig ra0 essid "xxxxxxxxxxxxxxx"
route add default gw 192.168.1.254
Thanks for the advice.
-
I was just thinking of tar command like this, after you have copied the module:
tar -C / -czvf ra2860.tcem lib/modules/2.6.26-tinycore/kernel/drivers/net/rt2860sta.ko.gz
Then move the ra2860.tcem to your tce directory.
I just tried modprobing bcm43.xx.ko and got an invalid module format error for some reason.
edit: after a little research, I can see broadcom requires a bit more......think I'll stick with my simple
ath0 cards....