How to use WILC3000 on SAM development boards
This page describes how WILC3000 devices could be used on SAM development boards.
The following table specifies the boards were WILC3000 is soldered and the boards were WILC3000 could be soldered.
|
|
Board Name |
Socket |
Present |
SAM9X60-EK |
U24 |
N* |
SAMA5D27-WLSOM1-EK1 |
U4 |
Y |
SAMA5D2-ICP |
U32 |
N* |
|
|
|
*) WILC3000 could be soldered on the corresponding socket
The driver that is used to control the WILC3000 devices is WILC1000 driver. The compatible strings available for these devices are:
"microchip,wilc1000"
"microchip,wilc3000
For boards where WILC3000 module is already soldered on the there is no need to follow instruction on this chapter.
For boards where WILC3000 module is soldered by the used the proper device tree overlay should be loaded from U-Boot. To check the available WILC device tree overlays check the files
*_wilc.dtso
in
dt-overlay-at91 repository.
To load WILC overlay follow the next steps:
1. Enter U-Boot prompt by hitting enter when
Hit any key to stop autoboot
message appears on console:
U-Boot 2019.04-linux4sam_6.2 (Oct 25 2019 - 03:10:23 +0000)
CPU: SAM9X60
Crystal frequency: 24 MHz
CPU clock : 600 MHz
Master clock : 200 MHz
DRAM: 256 MiB
MMC: sdhci-host@80000000: 0
Loading Environment from FAT... OK
In: serial
Out: serial
Err: serial
Net: eth0: ethernet@f802c000
Hit any key to stop autoboot: 3
2. Edit
bootcmd
U-Boot environment variable and add
#wilc
string at the end:
U-Boot> edit bootcmd
edit: fatload mmc 0:1 0x24000000 sam9x60ek.itb; bootm 0x24000000#kernel_dtb#wilc
3. Enter
boot
command. The Linux kernel would be loaded using the WILC device tree overlay:
U-Boot> boot
4508836 bytes read in 225 ms (19.1 MiB/s)
## Loading kernel from FIT Image at 24000000 ...
Using 'kernel_dtb' configuration
Trying 'kernel' kernel subimage
Description: Linux4SAM Linux kernel
Type: Kernel Image
Compression: uncompressed
Data Start: 0x240000d8
Data Size: 4447104 Bytes = 4.2 MiB
Architecture: ARM
OS: Linux
Load Address: 0x22000000
Entry Point: 0x22000000
Hash algo: crc32
Hash value: 2c706949
Hash algo: sha1
Hash value: d8d72f7fb8603a35a39a6803d9b418abebbca9a5
Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 24000000 ...
Using 'kernel_dtb' configuration
Trying 'base_fdt' fdt subimage
Description: SAM9X60-EK Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x2443dd90
Data Size: 28407 Bytes = 27.7 KiB
Architecture: ARM
Load Address: 0x23000000
Hash algo: crc32
Hash value: b8c3d3b7
Hash algo: sha1
Hash value: b538fc9f410be576b6bba6e18add7010e68f6f7b
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading fdt from 0x2443dd90 to 0x23000000
## Loading fdt from FIT Image at 24000000 ...
Using 'wilc' configuration
Trying 'fdt_wilc' fdt subimage
Description: Device Tree blob WILC3000 overlay
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x2444b168
Data Size: 1572 Bytes = 1.5 KiB
Architecture: ARM
Load Address: 0x23180000
Hash algo: crc32
Hash value: e8fbf3b2
Hash algo: sha1
Hash value: e36920209c1e758e6e67207b4a1646896b3a8784
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading fdt from 0x2444b168 to 0x23180000
Booting using the fdt blob at 0x23000000
Loading Kernel Image ... OK
Loading Device Tree to 2feeb000, end 2fef51c8 ... OK
Starting kernel ...
Kernel module
To be able to use the WILC devices the following kernel needs to be inserted after kernel boots:
cfg80211.ko
pwrseq_wilc.ko
wilc-sdio.ko
Check the above modules are inserted by running
lsmod
command:
root@sama5d27-wlsom1-ek-sd:~# lsmod
Module Size Used by
cfg80211 237568 0
usb_f_acm 12288 1
u_serial 16384 1 usb_f_acm
g_serial 12288 0
libcomposite 32768 2 g_serial,usb_f_acm
pwrseq_wilc 12288 1
atmel_usba_udc 24576 0
If one of the above modules is missing try inserting them using
insmod
or
modprobe
command. In the above example wilc-sdio.ko module is missing. To insert it:
root@sama5d27-wlsom1-ek-sd:~# insmod /lib/modules/$(uname -r)/kernel/drivers/staging/wilc1000/wilc-sdio.ko
wilc_sdio: module is from the staging directory, the quality is unknown, you have been warned.
wifi_pm : 0
wifi_pm : 1
wilc_sdio mmc1:0001:1: Driver Initializing success
In case the other modules are missing try insert them using
insmod
or
modprobe
commands:
insmod /lib/modules/$(uname -r)/kernel/net/wireless/cfg80211.ko
insmod /lib/modules/$(uname -r)/kernel/drivers/mmc/core/pwrseq_wilc.ko
insmod /lib/modules/$(uname -r)/kernel/drivers/staging/wilc1000/wilc-sdio.ko
After all kernel modules are installed the
wlan0
interface should apear in
ifconfig
:
root@sama5d27-wlsom1-ek-sd:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 54:10:ec:ff:fa:16
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:30 Base address:0x8000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:140 (140.0 B) TX bytes:140 (140.0 B)
p2p0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
sit0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
From here on the WILC device could be used in either WiFi client mode, Access Point mode or BT.
Client mode
In this mode WILC device would behave as an WiFi client by connecting to an Access Point device and requesting from it IP addresses, DNS etc.
Step by step configuration
To work in this mode create or edit*
/etc/wpa_supplicant.conf
file. The content of file should be as follows:
ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
ssid="access-point-name"
psk="access-point-passwork"
}
Where SSID and PSK variables keeps the Access Point name and password the WILC device will be connected to.
Save the file.
Start the WPA supplicant service using the following command:
wpa_supplicant -B -iwlan0 -Dnl80211 -c /etc/wpa_supplicant.conf &
Initiate a DHCP request so that a proper IP address and DNS settings to be installed for WILC device:
udhcpc -i wlan0 &
At this point an IP address should be assigned to wlan0 interface and IP connectivity should be alive.
Pre-defined script
Starting with Linux4SAM-2020.04 release for boards where WILC device is soldered, Buildroot root file system provides a demo script that allows configuring WILC device in STA mode by running just one command. To do this run the following script:
/root/Start_STA.sh
Provisioning mode
Starting with Linux4SAM-2020.04 release for boards where WILC device is soldered, Buildroot root file system provides a provisioning mechanism which allows the configuration of WILC devices in STA mode.
To start provisioning execute the script
/root/Start_Provision.sh
:
/root/Start_Provision.sh
This will reboot the board. After reboot the WILC device will enter in SoftAP mode with name
wilc_SoftAP
and IP
192.168.0.1
. This allow connecting to the WILC device using any Wi-Fi device for provisioning. Connecting to
192.168.0.1
will allow the configuration for Access Point to connect to. The meaning of fields in the opened web page are as follows:
Network Name: The Access Point name that WILC in STA mode should connect
Pass phrase: The Access Point password
Device Name: The name of the WILC device
After filling in the above fields and pressing
Connect
button the board will reboot and WILC device will start in STA mode and connect to the configured Access Point.
Access Point mode
WILC device could work in Access Point mode in different configurations depending on the level of security. This could be Open, WEP, WPA.
Open Access Point configuration
For this mode create or edit*
/etc/wilc_hostapd_open.conf
file as follows:
interface=wlan0
driver=nl80211
ctrl_interface=/var/run/hostapd
ssid=wilc_OpenAP
dtim_period=2
beacon_int=100
channel=7
hw_mode=g
max_num_sta=8
ap_max_inactivity=300
Where the Access Point name would be
wilc_OpenAP
.
WEP Access Point configuration
For this mode create or edit*
/etc/wilc_hostapd_wep.conf
file as follows:
interface=wlan0
driver=nl80211
ctrl_interface=/var/run/hostapd
ssid=wilc_WepAP
dtim_period=2
beacon_int=100
channel=7
hw_mode=g
max_num_sta=8
ap_max_inactivity=300
ieee80211n=1
auth_algs=1
######### WEP ###########
wep_default_key=0
wep_key0=1234567890
wep_key1="vwxyz"
wep_key2=0102030405060708090a0b0c0d
wep_key3=".2.4.6.8.0.23"
wep_key_len_broadcast=5
wep_key_len_unicast=5
wep_rekey_period=300
Where the Access Point name would be
wilc_WepAP
and password would be
1234567890
.
Note: Default build support for WEP Authentication was removed from the hostapd 2.10 version, so this test will
fail by default. (CONFIG_WEP=y can be used to enable it if needed).
WPA Access Point configuration
For this mode create or edit*
/etc/wilc_hostapd_wpa.conf
file as follows:
interface=wlan0
driver=nl80211
ctrl_interface=/var/run/hostapd
ssid=wilc_WpaAP
dtim_period=2
beacon_int=100
channel=7
hw_mode=g
max_num_sta=8
ap_max_inactivity=300
ieee80211n=1
auth_algs=1
######### WPA/WPA2 ###########
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
Where the Access Point name would be
wilc_WpaAP
and password would be
12345678
.
DHCP server configuration
To enable offering IPs to WiFi clients DHCP server service have to be enabled.
Create or edit*
/etc/dhcp/dhcpd.conf
with the following content(if the image is based on Buildroot):
option domain-name "tecmint.lan";
option domain-name-servers ns1.tecmint.lan, ns2.tecmint.lan;
default-lease-time 3600;
max-lease-time 7200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-search "tecmint.lan";
option domain-name-servers 192.168.1.1;
range 192.168.1.10 192.168.1.100;
range 192.168.1.110 192.168.1.200;
}
If the image is based on the Yocto Project,
Create or edit* /etc/kea/kea-dhcp4.conf with the contents below:
{
"Dhcp4": {
"interfaces-config": {
"interfaces": ["wlan0"]
},
"subnet4": [
{
"subnet": "192.168.1.0/24",
"pools": [
{ "pool": "192.168.1.100 - 192.168.1.200" }
],
"option-data": [
{ "code": 3, "data": "192.168.1.1" },
{ "code": 6, "data": "192.168.1.1, 8.8.8.8" }
]
}
]
}
}
Start Access Point
To start WILC working in Access Point:
1. Start
hostapd
service with file configured above:
hostapd -B <configuration file>
Where configuration file could be one of the following:
/etc/wilc_hostapd_open.conf
/etc/wilc_hostapd_wep.conf
/etc/wilc_hostapd_wpa.conf
2. Configure an IP address to wlan0 interface:
ifconfig wlan0 192.168.1.1 netmask 255.255.255.0 up
3. Start DHCP server:
For Buildroot:
dhcpd -cf /etc/dhcp/dhcpd.conf
For Yocto Project:
keactrl start
Pre-defined script
Starting with Linux4SAM-2020.04 release for boards where WILC device is soldered, Buildroot root file system provides a demo script that allows configuring WILC device in Access Point mode by running just one command. To do this run the following script:
/root/Start_AP.sh
This will start WILC device in Open Access Point mode.
4. Connect from an WiFi client to newly created access point and try a ping.
Bluetooth mode
To be able to use WILC device in Bluetooth mode on devices were WILC device is not soldered on the board, user has to wire WILC BT serial with one of serial supported by
SoC. The table below specifies what serial, pins could be used on SAM boards. On boards were WILC device is soldered on the board there is no need for extra wires and the table specifies NA in connector and connector pins columns.
|
|
Board Name |
Serial |
Connector |
Connector Pins |
SAM9X60-EK |
ttyS1 |
J14 |
TX, RX |
SAMA5D2-ICP |
ttyS3 |
J22 |
TX, RX |
SAMA5D2-Xplained |
ttyS1 |
J17 |
27, 28 |
SAMA5D4-Xplained |
ttyS5 |
J17 |
9, 10 |
SAMA5D27-SOM1-EK |
ttyS1 |
J25 |
3, 4 |
SAMA5D27-WLSOM1-EK1 |
ttyS1 |
J19 |
TX, RX |
SAMA5D3-Xplained |
ttyS1 |
NA |
NA |
SAMA5D2-PTC-EK |
ttyS1 |
J15 |
3, 4 |
|
|
|
Step-by-step configuration
Insert the next commands to configure WILC device in Bluetooth mode:
echo BT_SDIO_INIT > /dev/wilc_bt
echo BT_POWER_UP > /dev/wilc_bt
echo BT_FW_CHIP_WAKEUP > /dev/wilc_bt
echo BT_DOWNLOAD_FW > /dev/wilc_bt
echo BT_FW_CHIP_ALLOW_SLEEP > /dev/wilc_bt
hciattach <bluetooth-serial> any 115200 noflow # see table at the beginning of this chapter
hciconfig hci0 up
ln -svf /usr/libexec/bluetooth/bluetoothd /usr/sbin
bluetoothd -p time -n &
If the last command returns a D-Bus error check if
bluetoothd
daemon is already started. If yes, kill it and retry the last command:
kill bluetoothd
bluetoothd -p time -n &
Check bluetooth interface status:
hciconfig -a
Enable LE activity:
hciconfig hci0 leadv
Try to scan and connect to a device:
bluetoothctl
scan on
connect <identifier-listed-by-scan>
If scan fails run the following command:
power on
Pre-defined script
Starting with Linux4SAM-2020.04 release for boards where WILC device is soldered, Buildroot root file system provides a demo script that allows configuring WILC device in Bluethoot mode by running just one command. To do this run the following script:
/root/Start_BT.sh
This will start WILC device in Bluetooth mode.
* Starting with Linux4SAM-2020.04 predefined wpa_supplicant and hostapd configuration files are installed on Yocto and Buildroot images.
The above documentation is inspired from documentation already present on
Microchip WILC3000 webpage, more precisely the
ATWILC1000/ATWILC 3000 Wi-Fi Link Controller Linux User Guide.