AutoPTS on Windows 10 with nRF52 board¶
Overview¶
This tutorial shows how to setup AutoPTS client and server to run both on Windows 10. We use WSL1 with Ubuntu only to build a Zephyr project to an elf file, because Zephyr SDK is not available on Windows yet. Tutorial covers only nrf52840dk.
Update Windows and drivers¶
Update Windows in:
Start -> Settings -> Update & Security -> Windows Update
Update drivers, following the instructions from your hardware vendor.
Install Python 3¶
Download and install Python 3. Setup was tested with versions >=3.8. Let the installer add the Python installation directory to the PATH and disable the path length limitation.
Install Git¶
Download and install Git. During installation enable option: Enable experimental support for pseudo consoles. We will use Git Bash as Windows terminal.
Install PTS 8¶
Install latest PTS from https://www.bluetooth.org. Remember to install drivers from installation directory “C:/Program Files (x86)/Bluetooth SIG/Bluetooth PTS/PTS Driver/win64/CSRBlueCoreUSB.inf”
Setup Zephyr project for Windows¶
Setup from Zephyr site https://docs.zephyrproject.org/latest/getting_started/index.html:
Open Git Bash and go to home:
cd ~
Install west:
pip3 install west
Get the Zephyr source code:
west init zephyrproject:
Go into freshly created folder:
cd zephyrproject
Run:
west update
Export a Zephyr CMake package. This allows CMake to automatically load boilerplate code required for building Zephyr applications:
west zephyr-export
Zephyr’s scripts/requirements.txt file declares additional Python dependencies. Install them with pip:
pip3 install -r ~\zephyrproject\zephyr\scripts\requirements.txt
Setup WSL1 with Ubuntu 20.4¶
Setup Install Ubuntu 20.4 on WSL1. Open PowerShell as Administrator and run:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Restart Windows. After restart, open Microsoft Store and install Ubuntu 20.4 LTS.
Run Ubuntu. You will be asked to create a user account and password:
When finished, run commands:
sudo apt update
sudo apt upgrade
Install python3:
sudo apt install python3
Install pip:
sudo apt install python3-pip
Install west:
pip3 install --user -U west
Export local bin to PATH:
echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc
Reload PATH:
source ~/.bashrc
Install cmake:
sudo apt install cmake
Go to your zephyrproject:
cd /mnt/c/Users/Codecoup/zephyrproject
and then run:
west zephyr-export
pip3 install --user wheel
pip3 install --user -r /mnt/c/Users/codecoup/zephyrproject/zephyr/scripts/requirements.txt
Check if all modules have been installed:
pip3 list
If modules still will be missing, just install them with:
pip3 install <module_name>
Install Ninja:
pip3 install ninja
Go to home:
cd ~
Download latest toolchain installer from https://github.com/zephyrproject-rtos/sdk-ng/releases. Move it to ~
mv /mnt/c/Users/Codecoup/Downloads/zephyr-sdk-<your_version>-setup.run ~
Give permissions to the installer:
chmod +x zephyr-sdk-<your_version>-setup.run
and run the installer:
./zephyr-sdk-<your_version>-setup.run -- -d ~/zephyr-sdk-<your_version>
Copy rules:
sudo cp ~/zephyr-sdk-<your_version>/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
Restart the Ubuntu machine. You may want to shutdown all WSL consoles from Windows’s Git Bash:
wsl --shutdown
After Ubuntu restart, go to:
cd /mnt/c/Users/codecoup/zephyrproject
and test if west can build:
west build -p auto -b nrf52840dk_nrf52840 zephyr/tests/bluetooth/tester/
From now on, you can build projects by typing in Windows’s Git Bash:
wsl -d Ubuntu-20.04 -u codecoup -- bash -c -i "cd /mnt/c/Users/Codecoup/zephyrproject/ ; west build -p auto -b nrf52840dk_nrf52840 zephyr/tests/bluetooth/tester/"
Install nrftools¶
On Windows download latest nrftools (version >= 10.12.1) from site https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download and run default install.
Flash board¶
In Device Manager find COM port of your nrf board. In my case it is COM3.
In Git Bash, go to zephyrproject
cd ~/zephyrproject
You can display flashing options with:
west flash --help
and flash board with built earlier elf file:
west flash --skip-rebuild --board-dir /dev/ttyS2 --elf-file ~/zephyrproject/build/zephyr/zephyr.elf
Note that west does not accept COMs, so use /dev/ttyS2 as the COM3 equivalent, /dev/ttyS2 as the COM3 equivalent, etc.(/dev/ttyS + decremented COM number).
Setup auto-pts project¶
In Git Bash, clone project repo:
git clone https://github.com/intel/auto-pts.git
Go into the project folder:
cd auto-pts
Install required python modules:
pip3 install --user wheel
pip3 install --user -r autoptsserver_requirements.txt
pip3 install --user -r autoptsclient_requirements.txt
Install socat.exe¶
Download and extract socat.exe from https://sourceforge.net/projects/unix-utils/files/socat/1.7.3.2/ into folder ~/socat-1.7.3.2-1-x86_64/.
Add path to directory of socat.exe to PATH:
Running AutoPTS¶
Server and client by default will run on localhost address. Run server:
python ./autoptsserver.py -S 65000
Run client:
python ./autoptsclient-zephyr.py zephyr-master ~/zephyrproject/build/zephyr/zephyr.elf -t COM3 -b nrf52 -S 65000 -C 65001
At the first run, when Windows asks, enable connection through firewall: