MPS2 Mbed OS automated testing

The aim of this guide is to walk you through using the Mbed OS greentea testing tools to run automated tests on the Arm MPS2.

For more information, the main greentea page is here: https://github.com/ARMmbed/greentea

 

Preparation

Before starting, ensure the following:

  • The MPS2 has been configured to run Cortex-M3 DesignStart (Evaluation kit available for download from here)
  • The MPS2 has been configured to load binaries called 'mbed.bin' in the root directory of the MPS2 drive
  • Both the USB coming from the MPS2 and the USB from the UART port are connected to your host machine (and all drivers have finished installing) (don’t connect terminal to uart)
  • The MPS2 has been properly mounted as a drive. On Windows this should be automatic. On Linux you may need to configure your automounter.
  • Note what serial port is being used by the MPS2. In Windows, this can be found in the Device Manager and should show up as 'COMx' where 'x' is a number.
    • On Linux, you may need to look in your '/dev' directory. The final serial port may look like '/dev/ttyACM0', but this will ultimately depend on your OS.

 

Environment setup

These instructions use the virtual environment 'virtualenv' which is optional.  System installations under virtualenv are non-persistent, thus allowing you to avoid lasting modifications to your computers system.

 If you wish to install and run the virtual environment, run the following commands in the directory you wish to set up the tests in:

> pip install virtualenv

> virtualenv venv

Activate the virtual environment.

    - On Windows:    > .\venv\Scripts\activate

    - On Linux/Mac : > source venv/bin/activate

 

Install tools

From the same directory, run the following commands, in the order given, to install the necessary tools and Mbed OS

> pip install mbed-cli mbed-ls

> pip install -U mbed-greentea

> pip install -U mbed-host-tests

> git clone https://github.com/ARMmbed/mbed-os

> cd mbed-os

 

Identify target board

Now that the tools are installed, we need to find your MPS2's unique 'target id'. Run the following:

> mbedls

This should produce output similar to this:

+---------------+----------------------+-------------+-------------+--------------------------+-----------------+

| platform_name | platform_name_unique | mount_point | serial_port | target_id                | daplink_version |

+---------------+----------------------+-------------+-------------+--------------------------+-----------------+

| ARM_CM3DS_MPS2| ARM_CM3DS_MPS2[0]    | E:          | unknown     | 50040200074D652F3828F333 | 0001            |

+---------------+----------------------+-------------+-------------+--------------------------+-----------------+

 

Notice how the 'serial_port' is showing up as 'unknown'. We need to tell mbedls which serial port to use.

 

Create a 'mbedls.json' file within the 'mbed-os' directory you are currently in. Add the following:

 

{

    "50040200074D652F3828F333": {

        "serial_port": "COM11"

    }

}

 

Where the 24 figure number should match the 'target_id' that was listed when running 'mbedls'.

 

You'll also need to change 'COM11' to the correct serial port. You should have found this earlier, please see the "Preparation" steps above for more information.

 

After saving the file, run 'mbedls' again and you should see that the serial port is correctly set (example below):

 

> mbedls

+---------------+----------------------+-------------+-------------+--------------------------+-----------------+

| platform_name | platform_name_unique | mount_point | serial_port | target_id                | daplink_version |

+---------------+----------------------+-------------+-------------+--------------------------+-----------------+

| ARM_CM3DS_MPS2| ARM_CM3DS_MPS2[0]    | E:          | COM11       |50040200074D652F3828F333 | 0001            |

+---------------+----------------------+-------------+-------------+--------------------------+-----------------+

 

Finally run the following

> mbedls --mock 5004:ARM_CM3DS_MPS2

where the 4 figure number is the first four digits from the 'target id' that we see when we run 'mbedls'

 

Building and running tests

From the mbed-os directory run the following:

 

> mbed test -m ARM_CM3DS_MPS2 -t ARM

You should see the tests build (if not already done) then start seeing tests run.

It will take approximately 30 minutes to complete.