Skip to content

Commit

Permalink
fix wpa_ap service
Browse files Browse the repository at this point in the history
  • Loading branch information
Rock Qu committed Jun 13, 2019
1 parent 6489648 commit 1ce7412
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 21 deletions.
9 changes: 3 additions & 6 deletions Ultra96/packages/wilc3000/pre.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash

set -e
set -x
#! /bin/bash

target=$1
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

sudo cp $script_dir/wpa_ap.service $target/lib/systemd/system
sudo cp -r $script_dir/wpa_ap $target/usr/local/share/
sudo mkdir $target/wilc_bld
sudo mkdir -p $target/lib/firmware/mchp
sudo mkdir -p $target/lib/modules/4.14.0-xilinx-v2018.3/extra
sudo cp $script_dir/wilc-sdio.ko $target/lib/modules/4.14.0-xilinx-v2018.3/extra/
sudo cp $script_dir/ap_v2.sh $target/usr/local/share/wpa_ap/

44 changes: 32 additions & 12 deletions Ultra96/packages/wilc3000/qemu.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
#! /bin/bash
#!/bin/bash

set -x
set -e

cd /wilc_bld
set -x

# Install firmware files on root filesystem
cd /wilc_bld
git clone https://github.com/linux4wilc/firmware
cd firmware
git checkout tags/wilc_linux_15_2
cp /wilc_bld/firmware/wilc3000_wifi_firmware.bin /lib/firmware/mchp/
cp /wilc_bld/firmware/wilc3000_ble_firmware.bin /lib/firmware/mchp/

cd /
rm -rf wilc_bld

# Register wifi driver (depmod doesn't work here)
# depmod -a

# Start module on bootup
echo "wilc-sdio" >> /etc/modules

# Wilc cannot do wlan1 only wlan0 and p2p0, so fix that for host ap
echo "INTERFACES=\"usb0 p2p0\"" > /etc/default/isc-dhcp-server
cp /usr/local/share/wpa_ap/ap.sh /usr/local/share/wpa_ap/ap_v1.sh
cp /usr/local/share/wpa_ap/ap_v2.sh /usr/local/share/wpa_ap/ap.sh
chmod a+x /usr/local/share/wpa_ap/ap.sh

if [ -f /etc/default/isc-dhcp-server ] && \
grep -q "INTERFACES=" /etc/default/isc-dhcp-server; then
if ! grep -q "p2p0" /etc/default/isc-dhcp-server; then
sed -i 's/\(INTERFACES=\)"\(.*\)"/\1"\2 p2p0"/g' \
/etc/default/isc-dhcp-server
fi
else
echo 'INTERFACES="p2p0"' > /etc/default/isc-dhcp-server
fi

cat - >> /etc/dhcp/dhcpd.conf <<EOT
subnet 192.168.2.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.2.0;
range 192.168.2.2 192.168.2.100;
}
EOT

cat - > /etc/network/interfaces.d/wlan0 <<EOT
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
EOT

# Uncomment the following line to enable wireless access point by default
# systemctl enable wpa_ap.service
11 changes: 11 additions & 0 deletions Ultra96/packages/wilc3000/wpa_ap.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Wifi Access Point for U96-V2
Before=network-online.service isc-dhcp-server.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/share/wpa_ap/ap.sh

[Install]
WantedBy=basic.target
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ done
cd /usr/local/share/wpa_ap

# Create a new managed mode interface wlan1 to run AP
iw phy phy0 interface add wlan1 type managed
iw phy phy0 interface add p2p0 type managed

hid=$(ifconfig p2p0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | sed "s/:/_/g")
ip=192.168.2.1
Expand All @@ -24,7 +24,7 @@ sed "s/pynq/pynq_$hid/g" wpa_ap.conf > wpa_ap_actual.conf

ifconfig p2p0 down
sleep 2
wpa_supplicant -c ./wpa_ap_actual.conf --ip2p0 &
wpa_supplicant -c ./wpa_ap_actual.conf -ip2p0 &

ifconfig p2p0 $ip

10 changes: 10 additions & 0 deletions Ultra96/packages/wilc3000/wpa_ap/wpa_ap.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1

network={
ssid="pynq"
mode=2
key_mgmt=NONE
frequency=2437
}
3 changes: 2 additions & 1 deletion Ultra96/specs/Ultra96_v2.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARCH_Ultra96 := aarch64
BSP_Ultra96 := sensors96b_v2.bsp

STAGE4_PACKAGES_Ultra96 := pynq mraa upm usbgadget wpa_ap usb-eth0 sensorconf wilc3000
STAGE4_PACKAGES_Ultra96 := pynq mraa upm usbgadget usb-eth0 sensorconf
STAGE4_PACKAGES_Ultra96 += wilc3000

0 comments on commit 1ce7412

Please sign in to comment.