Post by xtr4nge on Mar 4, 2017 11:43:45 GMT
Raspberry Pi Zero W
www.raspberrypi.org/magpi/pi-zero-w/
Raspbian Jessie Lite
Version:March 2017
Release date:2017-03-02
downloads.raspberrypi.org/raspbian_lite_latest
Ethernet Gadget
learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget
CDC Ethernet (USB Armory)
github.com/inversepath/usbarmory/wiki/Host-communication
Stopping SD Card Corruption on Raspberry Pi’s Raspbian
ideaheap.com/2013/07/stopping-sd-card-corruption-on-a-raspberry-pi/
Install FruityWiFi
github.com/xtr4nge/FruityWifi/wiki/Install
[ Ethernet Gadget ]
These steps are not required, but is handy to have access to the RPi-Zero using this method.
=> Edit config.txt & cmdline.txt
After burning the SD card, do not eject it from your computer. Use a text editor to open up the config.txt (boot) file that is in the SD card.
Go to the bottom and add dtoverlay=dwc2as the last line:
Save the config.txt file as plain text. Open up cmdline.txt and after rootwait (the last word on the first line) add a space and then modules-load=dwc2,g_ether
=> Boot your RPi-Zero-W
[ RPi Setup ]
=> Setting Static IP
Edit /etc/network/interfaces
Note: I removed (commented) the setup for wlan0 and wlan1, and I added a static setup for usb0 (Ethernet Gadget)
=> Reducing SD Card Corruption
I like to reduce writing on the SD card (logs, run). The following two lines should be added to /etc/fstab:
Change the values to whatever is better for you.
Changing the /var/log folder to none, could give you some headaches, as some programas and scripts will not find their logs folder, but you can solve it like this:
Edit /etc/rc.local
Note: I added some lines to create sub-folderts in /var/log but also to kill dnsmasq and to restart ssh. You should take notes of your /var/log structure before to add this code, and amend it as needed.
[ Linux Host <=> USB Ethernet <=> RPi ]
- Connect the RPi-Zero to your Linux Host using USB (not the power!).
- The Linux Host creates a new interface named usb0.
- Assign the IP 10.0.0.2 to usb0 (Linux Host)
- Enable forwarding and outgoing connections
Note: -o needs to be the interface providing internet access (eth0/wlan0/or_whatever..)
- You can now access the RPi-Zero
[ FruityWiFi ]
The previous part of the tutorial, it was to setup the RPi. (Not related at all with FruityWiFi)
Lets install FruityWiFi in the RPi-Zero-W, this is very easy! (Of course you need to have internet access on your RPi first)
=> Install FruityWiFi
Done.
Go to http://localhost:8000 (for http)
Go to https://localhost:8443 (for https)
user: admin
pass: admin
=> Install Modules
You need to install 3 modules from FruityWiFi/menu/modules
- API
- AP
- Automaton
=> Setup Automaton Module
The last thing to do to get FruityWiFi [AP] running as soon as you Boot Up your RPi is to setup Automaton.
Template: ap-start.conf
Template: ap-start-secure.conf (does not exists, you need to create this template)
In the Options tab you need to change OnBoot option to the one that you want to use: ap-start.conf or ap-start-secure.conf and then enable (start) OnBoot
Note: Be sure that you are not using the same IP for usb0 and wlan0 on the RPi-Zero
Thats it, you can now use FruityWiFi on your RPi-Zero-W using the inbuilt wireless card.
Note: Not all the modules will work with the inbuilt wireless card. You need to use a second card such as Ralink RT5370 for more advanced features and modules.
There are a few things that I will explain in another tutorial, or as an extension of this one:
- FruityWiFi logs can be configured to to point to /var/log reducing writing on the SD card.
- How to add and configure a second wireless card such as Ralink RT5370
www.raspberrypi.org/magpi/pi-zero-w/
Raspbian Jessie Lite
Version:March 2017
Release date:2017-03-02
downloads.raspberrypi.org/raspbian_lite_latest
Ethernet Gadget
learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget
CDC Ethernet (USB Armory)
github.com/inversepath/usbarmory/wiki/Host-communication
Stopping SD Card Corruption on Raspberry Pi’s Raspbian
ideaheap.com/2013/07/stopping-sd-card-corruption-on-a-raspberry-pi/
Install FruityWiFi
github.com/xtr4nge/FruityWifi/wiki/Install
[ Ethernet Gadget ]
These steps are not required, but is handy to have access to the RPi-Zero using this method.
=> Edit config.txt & cmdline.txt
After burning the SD card, do not eject it from your computer. Use a text editor to open up the config.txt (boot) file that is in the SD card.
Go to the bottom and add dtoverlay=dwc2as the last line:
..
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=dwc2
Save the config.txt file as plain text. Open up cmdline.txt and after rootwait (the last word on the first line) add a space and then modules-load=dwc2,g_ether
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether
=> Boot your RPi-Zero-W
[ RPi Setup ]
=> Setting Static IP
Edit /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet manual
#allow-hotplug wlan0
#iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#allow-hotplug wlan1
#iface wlan1 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug usb0
iface usb0 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.2
dns-nameserver 8.8.8.8
dns-nameserver 8.8.4.4
Note: I removed (commented) the setup for wlan0 and wlan1, and I added a static setup for usb0 (Ethernet Gadget)
=> Reducing SD Card Corruption
I like to reduce writing on the SD card (logs, run). The following two lines should be added to /etc/fstab:
none /var/run tmpfs size=1M,noatime 00
none /var/log tmpfs size=10M,noatime 00
Change the values to whatever is better for you.
Changing the /var/log folder to none, could give you some headaches, as some programas and scripts will not find their logs folder, but you can solve it like this:
Edit /etc/rc.local
# ADD CODE BEFORE exit0
killall dnsmasq
sleep 1
/etc/init.d/ssh restart
sleep 1
# SET LOG FOLDERS
mkdir /var/log/apt
mkdir /var/log/fsck
mkdir /var/log/nginx
mkdir /var/log/ntpstats
mkdir /var/log/samba
exit 0
Note: I added some lines to create sub-folderts in /var/log but also to kill dnsmasq and to restart ssh. You should take notes of your /var/log structure before to add this code, and amend it as needed.
[ Linux Host <=> USB Ethernet <=> RPi ]
- Connect the RPi-Zero to your Linux Host using USB (not the power!).
- The Linux Host creates a new interface named usb0.
- Assign the IP 10.0.0.2 to usb0 (Linux Host)
ifconfig usb0 10.0.0.2
- Enable forwarding and outgoing connections
# enable masquerading for outgoing connections
iptables -t nat -A POSTROUTING -s 10.0.0.1/32 -o eth0 -j MASQUERADE
# enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
Note: -o needs to be the interface providing internet access (eth0/wlan0/or_whatever..)
- You can now access the RPi-Zero
ssh pi@10.0.0.1
[ FruityWiFi ]
The previous part of the tutorial, it was to setup the RPi. (Not related at all with FruityWiFi)
Lets install FruityWiFi in the RPi-Zero-W, this is very easy! (Of course you need to have internet access on your RPi first)
=> Install FruityWiFi
# AS ROOT!
wget https://github.com/xtr4nge/FruityWifi/archive/master.zip
unzip master.zip
cd FruityWifi-master
./install-FruityWiFi.sh
Done.
Go to http://localhost:8000 (for http)
Go to https://localhost:8443 (for https)
user: admin
pass: admin
=> Install Modules
You need to install 3 modules from FruityWiFi/menu/modules
- API
- AP
- Automaton
=> Setup Automaton Module
The last thing to do to get FruityWiFi [AP] running as soon as you Boot Up your RPi is to setup Automaton.
Template: ap-start.conf
SET /config/core/ap_mode/1
SET /config/core/io_in_iface/wlan0
SET /config/core/io_in_ip/192.168.0.1
SET /config/core/io_out_iface/usb0
SET /config/core/hostapd_secure/0
SET /config/core/hostapd_ssid/WiFi
SET /config/core/dnsmasq_domain/WiFi
SLEEP 1
START ap
Template: ap-start-secure.conf (does not exists, you need to create this template)
SET /config/core/ap_mode/1
SET /config/core/io_in_iface/wlan0
SET /config/core/io_in_ip/192.168.0.1
SET /config/core/io_out_iface/usb0
SET /config/core/hostapd_secure/1
SET /config/core/hostapd_ssid/WiFi
SET /config/core/dnsmasq_domain/WiFi
SET /config/core/hostapd_wpa_passphrase/SuperPassword
SLEEP 1
START ap
In the Options tab you need to change OnBoot option to the one that you want to use: ap-start.conf or ap-start-secure.conf and then enable (start) OnBoot
Note: Be sure that you are not using the same IP for usb0 and wlan0 on the RPi-Zero
Thats it, you can now use FruityWiFi on your RPi-Zero-W using the inbuilt wireless card.
Note: Not all the modules will work with the inbuilt wireless card. You need to use a second card such as Ralink RT5370 for more advanced features and modules.
There are a few things that I will explain in another tutorial, or as an extension of this one:
- FruityWiFi logs can be configured to to point to /var/log reducing writing on the SD card.
- How to add and configure a second wireless card such as Ralink RT5370