Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.

Upstream: https://github.com/ARMmbed/DAPLink

Committer:
Pawel Zarembski
Date:
Tue Apr 07 12:55:42 2020 +0200
Revision:
0:01f31e923fe2
hani: DAPLink with reset workaround

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pawel Zarembski 0:01f31e923fe2 1 # Automated Tests
Pawel Zarembski 0:01f31e923fe2 2
Pawel Zarembski 0:01f31e923fe2 3 DAPLink has an extensive automated test suite. It can be run on the current development environment (Windows and Linux) or a release package (Windows, Mac or Linux). Test results are written to the current directory and printed to the console.
Pawel Zarembski 0:01f31e923fe2 4
Pawel Zarembski 0:01f31e923fe2 5 Tests are launched by running ``python test/run_test.py`` in the Python virtual environment. The test logic discovers connected DAPLink boards and targets only those boards. Likewise, it detects what firmware you have built and targets only that firmware. Specify --help to view testing options (``run_test.py --help``).
Pawel Zarembski 0:01f31e923fe2 6
Pawel Zarembski 0:01f31e923fe2 7 The tests rely on information in ``test/info.py``. If you are porting DAPLink to a new board, you will need to add to info.py. See [Adding a new board](PORT_BOARD.md) for details.
Pawel Zarembski 0:01f31e923fe2 8
Pawel Zarembski 0:01f31e923fe2 9 ## Preparing bootloader for Tests
Pawel Zarembski 0:01f31e923fe2 10 * Build the bootloader or interface project to be tested.
Pawel Zarembski 0:01f31e923fe2 11 * [Enable automation mode](ENABLE_AUTOMATION.md) on the board if it has not been enabled already.
Pawel Zarembski 0:01f31e923fe2 12
Pawel Zarembski 0:01f31e923fe2 13 ## Test on Windows
Pawel Zarembski 0:01f31e923fe2 14 ### Prepare Host Machine
Pawel Zarembski 0:01f31e923fe2 15 Windows drive indexing needs to be turned off prior to running the tests.
Pawel Zarembski 0:01f31e923fe2 16
Pawel Zarembski 0:01f31e923fe2 17 * Disable indexing on removable drives
Pawel Zarembski 0:01f31e923fe2 18 Run gpedit.msc (<Windows>+<R> to open run window) then go to:
Pawel Zarembski 0:01f31e923fe2 19 Computer Configuration \ Administrative Templates \ Windows Components \ Search \ Do not allow locations on removable drives to be added to libraries. Enable the setting there.
Pawel Zarembski 0:01f31e923fe2 20
Pawel Zarembski 0:01f31e923fe2 21 ### Running Tests
Pawel Zarembski 0:01f31e923fe2 22 * Open CMD and cd to DAPLink directory.
Pawel Zarembski 0:01f31e923fe2 23 * Activate virtual env, launch tests by running ``python test/run_test.py``
Pawel Zarembski 0:01f31e923fe2 24 Specifying --firmwaredir is optional. For target images, either provide mbed.org authentication or use --targetdir to specify the location of pre-built target app binaries.
Pawel Zarembski 0:01f31e923fe2 25 * Test results will be printed to console
Pawel Zarembski 0:01f31e923fe2 26
Pawel Zarembski 0:01f31e923fe2 27 ## Test on Linux
Pawel Zarembski 0:01f31e923fe2 28 ### Prepare Host Machine
Pawel Zarembski 0:01f31e923fe2 29 Linux may have a daemon called modemmanager that sends unsolicitated traffic to DAPLink. This will cause serial port tests to fail, typically at band rate initialization.
Pawel Zarembski 0:01f31e923fe2 30 To check if modemmanager service is running, run ``systemctl | grep Modem``. Modem Manager will be displayed if so. To disable this service, run ``systemctl disable ModemManager.service``.
Pawel Zarembski 0:01f31e923fe2 31 Alternatively, this daemon can be removed with ``sudo apt-get purge modemmanager``.
Pawel Zarembski 0:01f31e923fe2 32
Pawel Zarembski 0:01f31e923fe2 33 **Step 1.** Build Firmware Releases
Pawel Zarembski 0:01f31e923fe2 34 The firmware images under test need to be built on Windows. Under tools directory, run ``build_release_uvision.bat``. Then copy the generated uvision_release directory to Linux.
Pawel Zarembski 0:01f31e923fe2 35
Pawel Zarembski 0:01f31e923fe2 36 **Step 2.** Install Tools
Pawel Zarembski 0:01f31e923fe2 37 Install [Python 2, 2.7.9 or above](https://www.python.org/downloads/).
Pawel Zarembski 0:01f31e923fe2 38 Install [Git](https://git-scm.com/downloads).
Pawel Zarembski 0:01f31e923fe2 39
Pawel Zarembski 0:01f31e923fe2 40 **Step 3.** Get the sources and create a virtual environment.
Pawel Zarembski 0:01f31e923fe2 41
Pawel Zarembski 0:01f31e923fe2 42 ```
Pawel Zarembski 0:01f31e923fe2 43 $ git clone https://github.com/mbedmicro/DAPLink
Pawel Zarembski 0:01f31e923fe2 44 $ cd DAPLink
Pawel Zarembski 0:01f31e923fe2 45 $ pip install virtualenv
Pawel Zarembski 0:01f31e923fe2 46 $ virtualenv venv
Pawel Zarembski 0:01f31e923fe2 47 ```
Pawel Zarembski 0:01f31e923fe2 48 **Step 4.** Update tools
Pawel Zarembski 0:01f31e923fe2 49
Pawel Zarembski 0:01f31e923fe2 50 ```
Pawel Zarembski 0:01f31e923fe2 51 $ source venv/bin/activate
Pawel Zarembski 0:01f31e923fe2 52 $ sudo pip install -r requirements.txt
Pawel Zarembski 0:01f31e923fe2 53 ```
Pawel Zarembski 0:01f31e923fe2 54
Pawel Zarembski 0:01f31e923fe2 55 ### Running Tests
Pawel Zarembski 0:01f31e923fe2 56 ```
Pawel Zarembski 0:01f31e923fe2 57 $ sudo python test/run_test.py --force --firmwaredir <path_to_uvision_release>
Pawel Zarembski 0:01f31e923fe2 58 ```
Pawel Zarembski 0:01f31e923fe2 59
Pawel Zarembski 0:01f31e923fe2 60 --firmwaredir is required. For target images, either provide mbed.org authentication or use --targetdir to specify the location of pre-built target app binaries.
Pawel Zarembski 0:01f31e923fe2 61 Test results will be printed to console.
Pawel Zarembski 0:01f31e923fe2 62
Pawel Zarembski 0:01f31e923fe2 63 ## Test on Mac
Pawel Zarembski 0:01f31e923fe2 64 ### Prepare Host Machine
Pawel Zarembski 0:01f31e923fe2 65 Refer to the steps for Linux.
Pawel Zarembski 0:01f31e923fe2 66
Pawel Zarembski 0:01f31e923fe2 67 ### Running Tests
Pawel Zarembski 0:01f31e923fe2 68 Refer to the steps for Linux.
Pawel Zarembski 0:01f31e923fe2 69
Pawel Zarembski 0:01f31e923fe2 70 ## Two Areas of Testing
Pawel Zarembski 0:01f31e923fe2 71 Tests are grouped into two categories
Pawel Zarembski 0:01f31e923fe2 72
Pawel Zarembski 0:01f31e923fe2 73 * Tests that validate how DAPLink is used for programming the target device and even the HIC itself via MSD--by copying an image file to the MSD drive (most users will drag-and-drop). These tests do not run by default but can be turned on by specifying --testdl.
Pawel Zarembski 0:01f31e923fe2 74
Pawel Zarembski 0:01f31e923fe2 75
Pawel Zarembski 0:01f31e923fe2 76 * Tests that validate the MSD, CDC, and CMSIS-DAP endpoints. These tests run by default, but can be turned off by specifying --notestendpt
Pawel Zarembski 0:01f31e923fe2 77
Pawel Zarembski 0:01f31e923fe2 78 The endpoint tests rely on a target application--a small UART program that implements a simple protocol. The target app is used by all three endpoint sub-tests.
Pawel Zarembski 0:01f31e923fe2 79
Pawel Zarembski 0:01f31e923fe2 80 For mbed boards that are registered on mbed.org, the test builds the target application code on the fly in the cloud using the mbed RESTful Compile API. It then downloads the resulting image and downloads it to the target. The UART application source is in the mbed mercurial repository [daplink-validation](https://developer.mbed.org/users/c1728p9/code/daplink-validation/). For this workflow, you must specify your mbed.org user id and password via --user and --password.
Pawel Zarembski 0:01f31e923fe2 81
Pawel Zarembski 0:01f31e923fe2 82 For boards that are not mbed enabled or not registered on mbed.org, the test accepts pre-built applications via the --targetdir option. You will need to build the UART application, porting it to whatever platform is suitable if the board is not mbed enabled.
Pawel Zarembski 0:01f31e923fe2 83
Pawel Zarembski 0:01f31e923fe2 84 Currently, the tests only work in one fashion in any given run--using the Compile API or using pre-built binaries. That is, you cannot test (in one run) multiple boards if some have their target app built with Compile API and others have pre-built binaries.
Pawel Zarembski 0:01f31e923fe2 85
Pawel Zarembski 0:01f31e923fe2 86 ## CMSIS-DAP Tests
Pawel Zarembski 0:01f31e923fe2 87 The CMSIS-DAP tests (referred to as "HID" tests in the python code) require pyOCD. Fortunately, pyOCD is listed in ``requirements.txt``, and thus it is downloaded and made available to the tests automatically when you set up your DAPLink python virtual environment. This is fine if you're doing regression testing, but won't be of much help if you're trying to test a new DAPLink port. The publicly released pyOCD is unlikely to support your new board. You will need to combine your DAPLink porting efforts with a pyOCD porting effort if you want to fully validate your DAPLink firmware with the automated tests.
Pawel Zarembski 0:01f31e923fe2 88
Pawel Zarembski 0:01f31e923fe2 89 Assuming you have a pyOCD workspace on your local machine that supports your board, you'll need to tell the DAPLink tests to use that pyOCD instead of the one it downloaded from the Internet. The way to do that is to, while in the DAPLink virtual environment, cd to the root of your pyOCD workspace and run ``pip install --editable ./``, then cd back to the DAPLink workspace to run the tests.