8. Wifi

The PX30-uQ7 module features an on-board Wifi module. This chapter shows how to connect to an existing Wifi network and how to flash the wifi firmware, should the need arise.

8.1. Antenna

The development kit includes an antenna compatible with the Wifi module. Other antennas can be used. The connector on the antenna must be one of:

  • W.FL Series connector from Hirose

  • MHF III connector from I-PEX

  • AMMC connector from Amphenol

8.2. Connecting to a Wifi network

You can show the available wifi networks using:

nmcli dev wifi

Connect to a network using the following command (replace the network name and password as appropriate):

nmcli dev wifi connect "Theobroma Example Wifi" password "hello-px30"

You should get a message like:

Device 'wlan0' successfully activated with '79ef39fc-8f49-4719-a8d9-4d6d789bb815'.

You should have connectivity over Wifi now. You can check the IP address you received using:

ip addr show dev wlan0

Note

By default, nmcli is not available in our Yocto core-image-minimal image. However, it is available in our Yocto theobroma-extended-image image.

8.3. Flashing the wifi firmware

You need to have esptool.py installed on the module.

The wifi firmware consists of three files:

  • bootloader.bin

  • partition-table.bin

  • eagle.bin

Save all three to the /tmp directory on the module.

Then flash the wifi module as shown below:

GPIO_BOOT=1 #GPIO0_A1
GPIO_EN=72 #GPIO2_B0

echo ff380000.mmc > /sys/bus/platform/drivers/dwmmc_rockchip/unbind
echo sdio-pwrseq > /sys/bus/platform/drivers/pwrseq_simple/unbind

if [ ! -d /sys/class/gpio/gpio$GPIO_BOOT ]; then 
	echo $GPIO_BOOT > /sys/class/gpio/export
fi

if [ ! -d /sys/class/gpio/gpio$GPIO_EN ]; then 
	echo $GPIO_EN > /sys/class/gpio/export
fi

echo out > /sys/class/gpio/gpio$GPIO_BOOT/direction
echo out > /sys/class/gpio/gpio$GPIO_EN/direction

echo 0 > /sys/class/gpio/gpio$GPIO_BOOT/value
echo 0 > /sys/class/gpio/gpio$GPIO_EN/value
sleep 1
echo 1 > /sys/class/gpio/gpio$GPIO_EN/value
sleep 1

ESPTOOL=$(PATH=/root/.local/bin/:$PATH which esptool.py)
 
$ESPTOOL -p /dev/ttyS3 -b 460800 --before default_reset --after hard_reset \
  --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m \
  0x1000 /tmp/bootloader.bin \
  0x8000 /tmp/partition-table.bin \
  0x10000 /tmp/eagle.bin

sleep 1
echo 1 > /sys/class/gpio/gpio$GPIO_BOOT/value
echo 0 > /sys/class/gpio/gpio$GPIO_EN/value
sleep 1
echo 1 > /sys/class/gpio/gpio$GPIO_EN/value

echo $GPIO_BOOT > /sys/class/gpio/unexport
echo $GPIO_EN > /sys/class/gpio/unexport

echo sdio-pwrseq > /sys/bus/platform/drivers/pwrseq_simple/bind
echo ff380000.mmc > /sys/bus/platform/drivers/dwmmc_rockchip/bind

Note

On Debian, the esptool package provided by the package feed is too old. Instead, please install esptool software from pip:

apt-get -y install python3-pip
pip3 install --user esptool

Note

By default, esptool is not available in our Yocto core-image-minimal image.