1.. _autopts-win10: 2 3AutoPTS on Windows 10 with nRF52 board 4####################################### 5 6Overview 7======== 8 9This tutorial shows how to setup AutoPTS client and server to run both on 10Windows 10. We use WSL1 with Ubuntu only to build a Zephyr project to 11an elf file, because Zephyr SDK is not available on Windows yet. 12Tutorial covers only nrf52840dk. 13 14Update Windows and drivers 15=========================== 16 17Update Windows in: 18 19Start -> Settings -> Update & Security -> Windows Update 20 21Update drivers, following the instructions from your hardware vendor. 22 23Install Python 3 24================= 25 26Download and install `Python 3 <https://www.python.org/downloads/>`_. 27Setup was tested with versions >=3.8. Let the installer add the Python 28installation directory to the PATH and disable the path length limitation. 29 30.. image:: install_python1.png 31 :height: 300 32 :width: 450 33 :align: center 34 35.. image:: install_python2.png 36 :height: 300 37 :width: 450 38 :align: center 39 40Install Git 41============ 42 43Download and install `Git <https://git-scm.com/downloads>`_. 44During installation enable option: Enable experimental support for pseudo 45consoles. We will use Git Bash as Windows terminal. 46 47.. image:: install_git.png 48 :height: 350 49 :width: 400 50 :align: center 51 52Install PTS 8 53============== 54 55Install latest PTS from https://www.bluetooth.org. Remember to install 56drivers from installation directory 57"C:/Program Files (x86)/Bluetooth SIG/Bluetooth PTS/PTS Driver/win64/CSRBlueCoreUSB.inf" 58 59.. image:: install_pts_drivers.png 60 :height: 250 61 :width: 850 62 :align: center 63 64.. note:: 65 66 Starting with PTS 8.0.1 the Bluetooth Protocol Viewer is no longer included. 67 So to capture Bluetooth events, you have to download it separately. 68 69Setup Zephyr project for Windows 70================================= 71 72Setup from Zephyr site https://docs.zephyrproject.org/latest/getting_started/index.html: 73 74Open Git Bash and go to home: 75 76.. code-block:: 77 78 cd ~ 79 80Install west: 81 82.. code-block:: 83 84 pip3 install west 85 86Get the Zephyr source code: 87 88.. code-block:: 89 90 west init zephyrproject 91 92Go into freshly created folder: 93 94.. code-block:: 95 96 cd zephyrproject 97 98Run: 99 100.. code-block:: 101 102 west update 103 104Export a Zephyr CMake package. This allows CMake to automatically load 105boilerplate code required for building Zephyr applications: 106 107.. code-block:: 108 109 west zephyr-export 110 111Zephyr’s scripts/requirements.txt file declares additional Python 112dependencies. Install them with pip: 113 114.. code-block:: 115 116 pip3 install -r ~\zephyrproject\zephyr\scripts\requirements.txt 117 118Setup WSL1 with Ubuntu 20.4 119============================ 120 121Setup Install Ubuntu 20.4 on `WSL1 <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`_. 122Open PowerShell as Administrator and run: 123 124.. code-block:: 125 126 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 127 128Restart Windows. After restart, open Microsoft Store and install Ubuntu 20.4 LTS. 129 130.. image:: install_ubuntu_on_wsl.png 131 :height: 350 132 :width: 500 133 :align: center 134 135Run Ubuntu. You will be asked to create a user account and password: 136 137.. image:: ubuntu_first_launch.png 138 :height: 150 139 :width: 800 140 :align: center 141 142When finished, run commands: 143 144.. code-block:: 145 146 sudo apt update 147 sudo apt upgrade 148 149Install python3: 150 151.. code-block:: 152 153 sudo apt install python3 154 155Install pip: 156 157.. code-block:: 158 159 sudo apt install python3-pip 160 161Install west: 162 163.. code-block:: 164 165 pip3 install --user -U west 166 167Export local bin to PATH: 168 169.. code-block:: 170 171 echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc 172 173Reload PATH: 174 175.. code-block:: 176 177 source ~/.bashrc 178 179Install cmake: 180 181.. code-block:: 182 183 sudo apt install cmake 184 185Go to your zephyrproject: 186 187.. code-block:: 188 189 cd /mnt/c/Users/Codecoup/zephyrproject 190 191and then run: 192 193.. code-block:: 194 195 west zephyr-export 196 pip3 install --user wheel 197 pip3 install --user -r /mnt/c/Users/codecoup/zephyrproject/zephyr/scripts/requirements.txt 198 199Check if all modules have been installed: 200 201.. code-block:: 202 203 pip3 list 204 205If modules still will be missing, just install them with: 206 207.. code-block:: 208 209 pip3 install <module_name> 210 211Install Ninja: 212 213.. code-block:: 214 215 pip3 install ninja 216 217Go to home: 218 219.. code-block:: 220 221 cd ~ 222 223Download latest toolchain installer from https://github.com/zephyrproject-rtos/sdk-ng/releases. Move it to ~ 224 225.. code-block:: 226 227 mv /mnt/c/Users/Codecoup/Downloads/zephyr-sdk-<your_version>-setup.run ~ 228 229Give permissions to the installer: 230 231.. code-block:: 232 233 chmod +x zephyr-sdk-<your_version>-setup.run 234 235and run the installer: 236 237.. code-block:: 238 239 ./zephyr-sdk-<your_version>-setup.run -- -d ~/zephyr-sdk-<your_version> 240 241Copy rules: 242 243.. code-block:: 244 245 sudo cp ~/zephyr-sdk-<your_version>/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d 246 247Restart the Ubuntu machine. You may want to shutdown all WSL consoles from 248Windows's Git Bash: 249 250.. code-block:: 251 252 wsl --shutdown 253 254After Ubuntu restart, go to: 255 256.. code-block:: 257 258 cd /mnt/c/Users/codecoup/zephyrproject 259 260and test if west can build: 261 262.. code-block:: 263 264 west build -p auto -b nrf52840dk_nrf52840 zephyr/tests/bluetooth/tester/ 265 266From now on, you can build projects by typing in Windows's Git Bash: 267 268.. code-block:: 269 270 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/" 271 272Install nrftools 273================= 274 275On Windows download latest nrftools (version >= 10.12.1) from site 276https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download 277and run default install. 278 279.. image:: download_nrftools_windows.png 280 :height: 350 281 :width: 500 282 :align: center 283 284Connect devices 285================ 286 287.. image:: devices_1.png 288 :height: 400 289 :width: 600 290 :align: center 291 292.. image:: devices_2.png 293 :height: 700 294 :width: 500 295 :align: center 296 297Flash board 298============ 299 300In Device Manager find COM port of your nrf board. In my case it is COM3. 301 302.. image:: device_manager.png 303 :height: 400 304 :width: 450 305 :align: center 306 307In Git Bash, go to zephyrproject 308 309.. code-block:: 310 311 cd ~/zephyrproject 312 313You can display flashing options with: 314 315.. code-block:: 316 317 west flash --help 318 319and flash board with built earlier elf file: 320 321.. code-block:: 322 323 west flash --skip-rebuild --board-dir /dev/ttyS2 --elf-file ~/zephyrproject/build/zephyr/zephyr.elf 324 325Note that west does not accept COMs, so use /dev/ttyS2 as the COM3 equivalent, 326/dev/ttyS2 as the COM3 equivalent, etc.(/dev/ttyS + decremented COM number). 327 328Setup auto-pts project 329======================= 330 331In Git Bash, clone project repo: 332 333.. code-block:: 334 335 git clone https://github.com/intel/auto-pts.git 336 337Go into the project folder: 338 339.. code-block:: 340 341 cd auto-pts 342 343Install required python modules: 344 345.. code-block:: 346 347 pip3 install --user wheel 348 pip3 install --user -r autoptsserver_requirements.txt 349 pip3 install --user -r autoptsclient_requirements.txt 350 351Install socat.exe 352================== 353 354Download and extract socat.exe from https://sourceforge.net/projects/unix-utils/files/socat/1.7.3.2/ 355into folder ~/socat-1.7.3.2-1-x86_64/. 356 357.. image:: download_socat.png 358 :height: 400 359 :width: 450 360 :align: center 361 362Add path to directory of socat.exe to PATH: 363 364.. image:: add_socat_to_path.png 365 :height: 400 366 :width: 450 367 :align: center 368 369Running AutoPTS 370================ 371 372Server and client by default will run on localhost address. Run server: 373 374.. code-block:: 375 376 python ./autoptsserver.py -S 65000 377 378.. image:: autoptsserver_run.png 379 :height: 200 380 :width: 800 381 :align: center 382 383.. note:: 384 385 If the error "ImportError: No module named pywintypes" appeared after the fresh setup, 386 uninstall and install the pywin32 module: 387 388 .. code-block:: 389 390 pip install --upgrade --force-reinstall pywin32 391 392Run client: 393 394.. code-block:: 395 396 python ./autoptsclient-zephyr.py zephyr-master ~/zephyrproject/build/zephyr/zephyr.elf -t COM3 -b nrf52 -S 65000 -C 65001 397 398.. image:: autoptsclient_run.png 399 :height: 200 400 :width: 800 401 :align: center 402 403At the first run, when Windows asks, enable connection through firewall: 404 405.. image:: allow_firewall.png 406 :height: 450 407 :width: 600 408 :align: center 409 410Troubleshooting 411================ 412 413- "When running actual hardware test mode, I have only BTP TIMEOUTs." 414 415This is a problem with connection between auto-pts client and board. There are many possible causes. Try: 416 417- Clean your auto-pts and zephyr repos with 418 419.. warning:: 420 421 This command will force the irreversible removal of all uncommitted files in the repo. 422 423.. code-block:: 424 425 git clean -fdx 426 427then build and flash tester elf again. 428 429- If you have set up Windows on virtual machine, check if guest extensions are installed properly or change USB compatibility mode in VM settings to USB 2.0. 430 431- Check, if firewall in not blocking python.exe or socat.exe. 432 433- Check if board sends ready event after restart (hex 00 00 80 ff 00 00). Open serial connection to board with e.g. PuTTy with proper COM and baud rate. After board reset you should see some strings in console. 434 435- Check if socat.exe creates tunel to board. Run in console 436 437.. code-block:: 438 439 socat.exe -x -v tcp-listen:65123 /dev/ttyS2,raw,b115200 440 441where /dev/ttyS2 is the COM3 equivalent. Open PuTTY, set connection type to Raw, IP to 127.0.0.1, port to 65123. After board reset you should see some strings in console. 442