Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostap update for Orange Pi #106

Merged
merged 13 commits into from
Oct 29, 2017
Merged
1 change: 1 addition & 0 deletions scripts/hostapd/dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.127,255.255.255.0,12h
bind-interfaces
27 changes: 19 additions & 8 deletions scripts/hostapd/install
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ set -e

BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Install hostapd and dnsmasq to run IEEE 802.11 Access Point
if ! [ "$(which hostapd)" ] || ! [ "$(which dnsmasq)" ]; then
sudo apt-get install hostapd dnsmasq radvd -y
fi
# Install packages to run IEEE 802.11 Access Point
sudo apt-get install hostapd radvd dnsmasq iptables -y

# Configure wlan0 interface
sudo cp /etc/network/interfaces /etc/network/interfaces.backup
Expand All @@ -16,6 +14,7 @@ if [ ! -z $START ]; then
END=$(expr $START + 3)
sudo sed -i "${START},${END}d" /etc/network/interfaces
fi

echo "" | sudo tee --append /etc/network/interfaces > /dev/null
echo "allow-hotplug wlan0" | sudo tee --append /etc/network/interfaces > /dev/null
echo "iface wlan0 inet static" | sudo tee --append /etc/network/interfaces > /dev/null
Expand All @@ -26,6 +25,8 @@ echo " broadcast 10.0.0.255" | sudo tee --append /etc/network/interfaces > /d
echo "iface wlan0 inet6 static" | sudo tee --append /etc/network/interfaces > /dev/null
echo " address fdfc::2" | sudo tee --append /etc/network/interfaces > /dev/null
echo " netmask 64" | sudo tee --append /etc/network/interfaces > /dev/null
echo "allow-hotplug eth0" | sudo tee --append /etc/network/interfaces > /dev/null
echo "iface eth0 inet dhcp" | sudo tee --append /etc/network/interfaces > /dev/null

# Enable packet forwarding
sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
Expand Down Expand Up @@ -73,16 +74,26 @@ else
fi

# Configure DHCP with dnsmasq
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
if [ -f /etc/dnsmasq.conf ]; then
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup
fi
sudo cp "$BASE_DIR/dnsmasq.conf" /etc/dnsmasq.conf
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.backup
sudo echo "" | sudo tee --append /etc/dhcpcd.conf > /dev/null
sudo echo "denyinterfaces wlan0" | sudo tee --append /etc/dhcpcd.conf > /dev/null

if [ -f /etc/dhcpcd.conf ]; then
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.backup
sudo echo "" | sudo tee --append /etc/dhcpcd.conf > /dev/null
sudo echo "denyinterfaces wlan0" | sudo tee --append /etc/dhcpcd.conf > /dev/null
fi

# Configure IPv6 router advertisement with radvd
sudo cp "$BASE_DIR/radvd.conf" /etc/radvd.conf

# Enable hostapd service
if [ -f /etc/default/hostapd ]; then
sed '\?^DAEMON_CONF?d' /etc/default/hostapd | sudo tee /etc/default/hostapd > /dev/null
sudo echo DAEMON_CONF="/etc/hostapd.conf" | sudo tee --append /etc/default/hostapd > /dev/null
fi

sudo cp "$BASE_DIR/hostapd.service" /etc/systemd/system/hostapd.service
sudo systemctl daemon-reload
sudo systemctl enable hostapd.service
Expand Down
22 changes: 18 additions & 4 deletions scripts/install2
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ BOARD_REVISION="?"
CJDNS_BUILD_CMD="sudo Seccomp_NO=1 NO_NEON=1 ./do"
BOARD_HARDWARE=$(cat /proc/cpuinfo | grep Hardware | awk '{print $3}' | head -n 1)

# Flag to identify if board can support onboard AP
SUPPORT_HOSTAP=false

# Possibly use /sys/firmware/devicetree/base/model
if [[ "$BOARD_HARDWARE" == 'Allwinner' || "$BOARD_HARDWARE" == 'Generic' ]]; then
if [[ "$BOARD_HARDWARE" == 'Allwinner' || "$BOARD_HARDWARE" == 'Generic' ]]; then
BOARD_FAMILY="Orange Pi"
BOARD_NAME=$(grep BOARD_NAME /etc/armbian-image-release | awk -F \= '{print $2}' | tr -d \" | sed 's/Orange Pi //g')
BOARD_REVISION="experimental"
if [[ '$BOARD_NAME' == 'Zero' ]]; then
if [[ "$BOARD_NAME" == "Zero" ]]; then
CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -fomit-frame-pointer -marm\" ./do"
# If board already support xradio, let it install hostapd
if [ "$(lsmod | grep xradio_wlan)" ]; then
SUPPORT_HOSTAP=true
fi
else
CJDNS_BUILD_CMD="sudo Seccomp_NO=1 CFLAGS=\"-s -static -Wall -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fomit-frame-pointer -marm\" ./do"
fi
Expand All @@ -41,6 +48,8 @@ else
elif [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]]; then
BOARD_NAME="3"
CJDNS_BUILD_CMD="sudo NO_TEST=1 CFLAGS=\"-march=armv8-a+crc -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard\" ./do"
# PI3 Has onboard wifi that can be used as an AP
SUPPORT_HOSTAP=true
fi
fi

Expand All @@ -61,6 +70,11 @@ if [[ $BOARD_FAMILY == "Orange Pi" ]]; then
wget http://apt.armbian.com/pool/main/l/linux-4.10.0-sun8i/linux-image-dev-sun8i_5.26_armhf.deb
sudo dpkg -i linux-image-dev-sun8i_5.26_armhf.deb
rm -rf linux-image-dev-sun8i_5.26_armhf.deb
# Downgrading kernel, allow hostapd
SUPPORT_HOSTAP=true
else
# Zero is not downgraded from broken kernel, don't allow hostap
SUPPORT_HOSTAP=false
fi
fi
fi
Expand All @@ -78,7 +92,7 @@ if [ -z "$WITH_MESH_POINT" -o "$WITH_MESH_POINT" != "true" -a "$WITH_MESH_POINT"
WITH_MESH_POINT=true
fi
fi
if [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]] && [ -z "$WITH_WIFI_AP" -o "$WITH_WIFI_AP" != "true" -a "$WITH_WIFI_AP" != "false" ]; then
if [[ "$SUPPORT_HOSTAP" == "true" ]] && [ -z "$WITH_WIFI_AP" -o "$WITH_WIFI_AP" != "true" -a "$WITH_WIFI_AP" != "false" ]; then
read -p "Configure WiFi Access Point (Y/n)? " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Nn]$ ]]; then
Expand Down Expand Up @@ -246,7 +260,7 @@ if [ ! -z "$WITH_MESH_POINT" -a "$WITH_MESH_POINT" == "true" ]; then
fi

# WiFi Access Point on RPi3
if [[ $BOARD_REVISION == *"a02082"* || $BOARD_REVISION == *"a22082"* ]] && [ ! -z "$WITH_WIFI_AP" -a "$WITH_WIFI_AP" == "true" ]; then
if [[ "$SUPPORT_HOSTAP" == "true" ]] && [ ! -z "$WITH_WIFI_AP" -a "$WITH_WIFI_AP" == "true" ]; then
source hostapd/install
fi

Expand Down