WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Steps to connect a Pi Zero W to wifi  (Read 22907 times)

Offline DrRob

  • Jr. Member
  • **
  • Posts: 61
Steps to connect a Pi Zero W to wifi
« 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.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14849
Re: Steps to connect a Pi Zero W to wifi
« Reply #1 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.

Offline DrRob

  • Jr. Member
  • **
  • Posts: 61
Re: Steps to connect a Pi Zero W to wifi
« Reply #2 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.

Offline DrRob

  • Jr. Member
  • **
  • Posts: 61
Re: Steps to connect a Pi Zero W to wifi
« Reply #3 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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Steps to connect a Pi Zero W to wifi
« Reply #4 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.

Offline DrRob

  • Jr. Member
  • **
  • Posts: 61
Re: Steps to connect a Pi Zero W to wifi
« Reply #5 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")...

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14849
Re: Steps to connect a Pi Zero W to wifi
« Reply #6 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..

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Steps to connect a Pi Zero W to wifi
« Reply #7 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.


Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1267
Re: Steps to connect a Pi Zero W to wifi
« Reply #8 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?

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Steps to connect a Pi Zero W to wifi
« Reply #9 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.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1267
Re: Steps to connect a Pi Zero W to wifi
« Reply #10 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?

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Steps to connect a Pi Zero W to wifi
« Reply #11 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?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1267
Re: Steps to connect a Pi Zero W to wifi
« Reply #12 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

Offline njs

  • Newbie
  • *
  • Posts: 25
Re: Steps to connect a Pi Zero W to wifi
« Reply #13 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"

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Steps to connect a Pi Zero W to wifi
« Reply #14 on: September 28, 2017, 05:16:04 AM »
Make sure firmware is loaded before other wifi (i.e. module) extensions.
Download a copy and keep it handy: Core book ;)