Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: DrRob on June 11, 2017, 05:11:05 PM

Title: Steps to connect a Pi Zero W to wifi
Post by: DrRob on June 11, 2017, 05:11:05 PM
In case it's of use to others, here's how to connect a Pi Zero W to wifi:

Start with piCore-9.0.1.

Copy the image to the SD card (see instructions on the wiki).

On an Internet-connected computer, download the extra files required:

for pkg in ca-certificates libiw libnl ncurses openssl readline wifi wireless-4.9.22-piCore wireless_tools wpa_supplicant firmware-rpi3-wireless; do for f in $pkg.tcz{,.dep,.info,.list,.md5.txt,.tree,.zsync}; do wget http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/9.x/armv6/tcz/$f; done; done

Mount the second partition of the SD card and copy the files into "tce/optional/".  Tricky on a Macbook - I tried fuse/ext4fuse, which was buggy and didn't work.  Instead I used an Ubuntu VM in Virtualbox for this part, using instructions from here: https://www.geekytidbits.com/mount-sd-card-virtualbox-from-mac-osx/ because simply attaching the SD card reader USB device to the VM refused to work.

Put the SD card into the Pi and boot with keyboard and monitor attached.

Expand the second partition (see the wiki), if not already done.

tce-audit builddb (so that tce-load will find the new files you've added).

tce-load -i firmware-rpi3-wireless

echo "firmware-rpi3-wireless" >> /mnt/mmcblk0p2/tce/onboot.lst

filetool.sh -b

sudo reboot

wifi.sh, select a wi-fi access point and enter details.

ifconfig should now show a wlan0 with an IP address.

echo "wifi.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst

echo "sudo wifi.sh -a" >> /opt/bootlocal.sh

filetool.sh -b

sudo reboot

All being well, a short while after each boot of the Pi Zero W it should be connected to the network.

Disclaimer: I haven't retried all these steps from scratch to double-check them because the part where I copied the extra files to the SD card was so awkward I'd reluctant to reset and do it all again this late in the day.  Maybe I'll check it tomorrow.

For Pi Zero W users, it would be very helpful to have an alternative SD image with the necessary files for wifi included...

HTH,
Rob.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Juanito on June 12, 2017, 03:22:34 AM
for pkg in ca-certificates libiw libnl ncurses openssl readline wifi wireless-4.9.22-piCore wireless_tools wpa_supplicant firmware-rpi3-wireless; do for f in $pkg.tcz{,.dep,.info,.list,.md5.txt,.tree,.zsync}; do wget http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/9.x/armv6/tcz/$f; done; done
Only *tcz, *tcz.dep, *tcz.md5.txt are required.

Quote
tce-audit builddb (so that tce-load will find the new files you've added).
This is not required, tce-load will search the contents of the current directory and the tce/optional directory for extensions


Quote
tce-load -i firmware-rpi3-wireless

echo "firmware-rpi3-wireless" >> /mnt/mmcblk0p2/tce/onboot.lst

filetool.sh -b
The filetool.sh command is not required, /mnt/mmcblk0p2 is persistant storage.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: DrRob on June 12, 2017, 05:08:46 AM
Thank you Juanito.  I'll confirm the exact minimum steps required by doing it all from scratch, and then persist the resulting steps to the wiki.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: DrRob on June 12, 2017, 07:02:47 AM
Seems I don't have permission to edit the wiki.  Here are the verified steps:

On your computer (not on the Pi):
    - Download piCore-9.0.1
    - Copy the image to the SD card (see instructions on the wiki)
    - Expand the second partition, e.g. in Ubuntu:
        $ sudo fdisk /dev/sdb
        [sudo] password for rob:

        Welcome to fdisk (util-linux 2.27.1).
        Changes will remain in memory only, until you decide to write them.
        Be careful before using the write command.


        Command (m for help): p
        Disk /dev/sdb: 14.5 GiB, 15523119104 bytes, 30318592 sectors
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disklabel type: dos
        Disk identifier: 0x0009bf4f

        Device     Boot Start    End Sectors Size Id Type
        /dev/sdb1        8192  77823   69632  34M  c W95 FAT32 (LBA)
        /dev/sdb2       77824 100351   22528  11M 83 Linux

        Command (m for help): d
        Partition number (1,2, default 2): 2

        Partition 2 has been deleted.

        Command (m for help): n
        Partition type
           p   primary (1 primary, 0 extended, 3 free)
           e   extended (container for logical partitions)
        Select (default p): p
        Partition number (2-4, default 2):
        First sector (2048-30318591, default 2048): 77824
        Last sector, +sectors or +size{K,M,G,T,P} (77824-30318591, default 30318591):

        Created a new partition 2 of type 'Linux' and of size 14.4 GiB.

        Command (m for help): w
        The partition table has been altered.
        Calling ioctl() to re-read partition table.
        Synching disks.
    - Note that 77824 is the important figure above - it's the start sector of the second partition and must be entered when recreating the partition.  Default values are ok for other inputs.
    - Resize the filesystem to fit the newly-expanded partition, e.g. in Ubuntu:
        $ sudo resize2fs /dev/sdb2
        resize2fs 1.42.13 (17-May-2015)
        Please run 'e2fsck -f /dev/sdb2' first.

        $ sudo e2fsck -f /dev/sdb2
        e2fsck 1.42.13 (17-May-2015)
        Pass 1: Checking inodes, blocks, and sizes
        Pass 2: Checking directory structure
        Pass 3: Checking directory connectivity
        Pass 4: Checking reference counts
        Pass 5: Checking group summary information
        /dev/sdb2: 55/2816 files (1.8% non-contiguous), 9660/11264 blocks
        $ sudo resize2fs /dev/sdb2
        resize2fs 1.42.13 (17-May-2015)
        Resizing the filesystem on /dev/sdb2 to 15120384 (1k) blocks.
        The filesystem on /dev/sdb2 is now 15120384 (1k) blocks long.
    - Mount the second partition:
        - e.g. on Ubuntu desktop by clicking its icon in the dock
        - there should be a "tce" directory at the top level
        - find its mount point and cd to "tce/optional" in a terminal
    - Download the extra files required:
        - (you may have to do this as root, depending on the mount permissions)
        - for pkg in ca-certificates libiw libnl ncurses openssl readline wifi wireless-4.9.22-piCore wireless_tools wpa_supplicant firmware-rpi3-wireless; do for f in $pkg.tcz{,.dep,.md5.txt}; do wget http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/9.x/armv6/tcz/$f; done; done
        - fix up file ownership and permissions:
            - $ chown 1001:staff *.tcz*
            - $ chmod 664 *.tcz*
    - Unmount the SD card
    - Transfer SD card to the Pi Zero W

On the Pi Zero W (attach a monitor and keyboard...):
    - $ tce-load -i firmware-rpi3-wireless
    - $ echo "firmware-rpi3-wireless.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst
    - $ sudo reboot
    - time passes...
    - $ tce-load -i wifi > /tmp/tce-load-wifi.log
    - $ sed "s,:.*,," /tmp/tce-load-wifi.log >> /mnt/mmcblk0p2/tce/onboot.lst
    - $ sudo wifi.sh
        - select a wifi AP and enter password
    - $ ifconfig
        - should now list wlan0 with an IP address
        - wifi.db has been created in the home dir, but this is a temporary location
    - if you reboot at this point, you'll have to redo the wifi.sh step
    - $ echo "sudo wifi.sh -a" >> /opt/bootlocal.sh
    - $ filetool.sh -b
        - to save bootlocal.sh and wifi.db into persistent storage

After this, after every reboot the Pi will connect to wifi automatically.

Rob.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Rich on June 12, 2017, 07:39:50 AM
Hi DrRob
Quote
Seems I don't have permission to edit the wiki.  Here are the verified steps:
You should be able to edit the Wiki after logging in using the same name and password you use to login to this forum.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: DrRob on June 12, 2017, 07:59:29 AM
You should be able to edit the Wiki after logging in using the same name and password you use to login to this forum.
That's what I thought, but there's only a "Show pagesource" tab at the top after I log in (along with "Read" and "Old revisions")...
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Juanito on June 12, 2017, 11:14:39 AM
$ sudo reboot
"sudo exitcheck.sh reboot"?

Quote
$ tce-load -i wifi > /tmp/tce-load-wifi.log
$ sed "s,:.*,," /tmp/tce-load-wifi.log >> /mnt/mmcblk0p2/tce/onboot.lst
Impressive sed-foo, but extension loading from onboot.lst is recursive, so only wifi.tcz is required..
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: gavinmc42 on June 25, 2017, 04:31:33 AM
Followed my old posts
http://forum.tinycorelinux.net/index.php/topic,19804.0.html

firmware-brcmfmac43430.tcz is now firmware-rpi3-wireless.tcz?
Does there need to be a Zero version?

tce-load -wi firmware-rpi3-wireless.tcz
tce-load -wi wifi.tcz
filetool.s -b
sudo reboot
sudo wifi.sh

wifi.sh -a goes into bootlocal.sh

This all works for a Pi3, but does not work on a Zero.
Oops, take that back, if I unplug the Ethernet on the PI3 I cannot ssh into the WiFi.
Some how the Lan Ethernet port is acting as a bridge to the WiFi port.

Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Paul_123 on June 25, 2017, 09:01:45 AM
Perhaps we need to pick a new name for the firmware extension.   But the firmware is the same for rpi3 and zero W.

Wifi and Ethernet does not automatically route.   You cannot unplug the Ethernet cable, and expect wifi to be the default route.

Can you hook a monitor up to see what is going on?
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: gavinmc42 on June 25, 2017, 09:22:57 AM
I use monitor and keyboard, need them for testing.
On a pi3 I can see Lan, local and wlan ip addresses,  only the local and wlan on a Zero.
I can ssh into either ip address on the Pi3 when lan cable is in, cannot ssh into wlan when cable is out.
Cannot ssh into wlan on the Zero.

Router sets up ip addresses as 10.0.0.x
I think I suspected this might have something to do with it last time I tried getting wifi working.
Raspbian Jessie Lite wifi works on Zero W, tested latest version 4.9.? so 10.0.0.x is ok on Raspbian.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Paul_123 on June 25, 2017, 10:16:24 AM
I just burned an image with 9.0.3 on a ZeroW, additionally I setup an old wifi router at 10.0.0.1 and everything works as expected.

I only loaded what you have below.........are you sure you didn't do something silly like not expanding your SD card?
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: gavinmc42 on June 25, 2017, 10:47:34 PM
Expanded SD.
I think the autologin did not get saved.
Seems to work today on a Pi3, now to test on Zero W

Interesting - sudo wifi.sh says no wifi devices found when run on a Zero W.
Tested it on my other Zero W and made sure I  didn't test it on my normal Zero's.

Any difference in config.txt, overlays etc?
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Paul_123 on June 27, 2017, 11:31:01 AM
Nope, I used the stock piCore 9.0.3 image, and just added the wifi.tcz (and it's dependencies) as well as firmware-rpi3-wireless.tcz

Rebooted and started wifi.sh. 

The Broadcom wifi chip still seems to be channel sensitive.  Can you change your channel on your router and see if that helps
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: njs on September 27, 2017, 11:10:19 PM
I cannot get this to work on Pi Zero W either...

I followed the instructions above with piCore 9.0.3 but wifi.sh says "No wifi devices found!" and when I do "iwconfig wlan0" I get the message: "wlan0   no such device"
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Misalf on September 28, 2017, 05:16:04 AM
Make sure firmware is loaded before other wifi (i.e. module) extensions.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: njs on September 28, 2017, 09:37:38 AM
Here is onboot.lst as it stands after following process above

Code: [Select]
mc.tcz
openssh.tcz
firmware-rpi3-wireless
readline.tcz
libnl.tcz
wpa_supplicant.tcz
wireless-4.9.22-piCore.tcz
libiw.tcz
wireless_tools.tcz
wifi.tcz
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Misalf on September 28, 2017, 10:24:15 AM
You forgot the file name extension (.tcz) for the firmware entry.
Also you can remove a few as they are deps of  wifi.tcz .
Code: [Select]
mc.tcz
openssh.tcz
firmware-rpi3-wireless.tcz
readline.tcz
wifi.tcz
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: njs on September 28, 2017, 10:40:29 PM
Thanks, that worked!
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: flyingchap on August 07, 2019, 05:13:34 AM
This is an excellent post and an excellent resource.   

Many thanks to you Rob and to the others who have expanded/ clarified the post.     

I'm just about to work on a PiZW and need rapid boot  ---  I'm sure you've saved me many hours.

Thanks and best regards


Title: Re: Steps to connect a Pi Zero W to wifi
Post by: flyingchap on August 17, 2019, 09:43:59 AM
Works Perfectly  (Aug 19,  Pi Zero W,  piCore 9.0.3).

MANY THANKS   DrRob for this excellent work  -  saved me hours,  no doubt.     Really appreciate people providing this class of advice. 

flyingchap
London
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: vinceASPECT on August 17, 2019, 02:49:17 PM
Hello

This would always be useful to know.....and to know that it will work across new upcoming TCL Rasp Pi versions not just Pi Core 9....

i did not see the exact minimal steps LIST .....committed to the wiki....... as the OP said he would do.....

http://wiki.tinycorelinux.net/wiki:start

It would be helpful to have the "exact correct  steps list" for connecting a Pi ZERO w to wi fi ....put into the wiki and (tested)

where is the "exact steps list" that works  (Tested)...?

thx

V

Title: Re: Steps to connect a Pi Zero W to wifi
Post by: DrRob on August 26, 2019, 04:37:29 AM
Hi,

Apologies, I've been off doing other things and forgot about putting this info in the wiki.  I'm about to reinstall piCore for a new project so will go through the steps again to check, and also see if I can figure out a method that doesn't involve mounting filesystems on another computer (I have an idea...).

I'm slightly puzzled that there doesn't seem to be a piCore section in the wiki?  Am I missing something?  Should I create one (if I can edit the wiki - last time I tried I couldn't).

Rob.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: DrRob on August 26, 2019, 06:45:01 AM
Here's the confirmed working set of steps, using the VFAT partition to transfer in the required files:
I'm not sure why tce-load -i doesn't add entries to onboot.lst automatically like it does when you have a network connection and can tce-load -wi...

Rob.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: Rich on August 26, 2019, 08:34:40 AM
Hi DrRob
... I'm slightly puzzled that there doesn't seem to be a piCore section in the wiki?  Am I missing something?  Should I create one (if I can edit the wiki - last time I tried I couldn't).
You need to first login to the Wiki using the same  Name/Password  you use to login to this forum.  If you are looking to start a piCore
specific  "how to"  section, you should probably create a link that points to that here:
http://wiki.tinycorelinux.net/
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: DrRob on August 26, 2019, 10:29:55 AM
OK, done, except I just added a section to the end of http://wiki.tinycorelinux.net/wiki:start rather than adding it to http://wiki.tinycorelinux.net/  There's not much on the latter page, so it didn't seem right to add it there.
Title: Re: Steps to connect a Pi Zero W to wifi
Post by: vinceASPECT on September 05, 2019, 06:58:05 PM
Dr Rob,

thanks for adding the Steps to the wiki.....there are indeed quite a lot of steps and i wonder if anybody may put it into a TCZ app at some point?

Just a one click affair.

thx

Vin