Workshop o mikrokontrolérech na SKSP 2024.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Martin Mareš 3bd49f7e19 Imported libopencm3 2 months ago
..
.gitignore Imported libopencm3 2 months ago
70-libopencm3.rules Imported libopencm3 2 months ago
Jenkinsfile Imported libopencm3 2 months ago
Makefile Imported libopencm3 2 months ago
Makefile.efm32hg309-generic Imported libopencm3 2 months ago
Makefile.stm32f3-disco Imported libopencm3 2 months ago
Makefile.stm32f4disco Imported libopencm3 2 months ago
Makefile.stm32f072disco Imported libopencm3 2 months ago
Makefile.stm32f103-generic Imported libopencm3 2 months ago
Makefile.stm32f429i-disco Imported libopencm3 2 months ago
Makefile.stm32l1-generic Imported libopencm3 2 months ago
Makefile.stm32l053disco Imported libopencm3 2 months ago
Makefile.tilm4f120xl Imported libopencm3 2 months ago
README.md Imported libopencm3 2 months ago
delay.c Imported libopencm3 2 months ago
delay.h Imported libopencm3 2 months ago
delay_efm32.c Imported libopencm3 2 months ago
main-efm32hg309-generic.c Imported libopencm3 2 months ago
main-stm32f3-disco.c Imported libopencm3 2 months ago
main-stm32f4disco.c Imported libopencm3 2 months ago
main-stm32f072disco.c Imported libopencm3 2 months ago
main-stm32f103-generic.c Imported libopencm3 2 months ago
main-stm32f429i-disco.c Imported libopencm3 2 months ago
main-stm32l1-generic.c Imported libopencm3 2 months ago
main-stm32l053disco.c Imported libopencm3 2 months ago
main-tilm4f120xl.c Imported libopencm3 2 months ago
openocd.common.cfg Imported libopencm3 2 months ago
openocd.efm32hg309-generic.cfg Imported libopencm3 2 months ago
openocd.stm32f3-disco.cfg Imported libopencm3 2 months ago
openocd.stm32f4disco.cfg Imported libopencm3 2 months ago
openocd.stm32f072disco.cfg Imported libopencm3 2 months ago
openocd.stm32f103-generic.cfg Imported libopencm3 2 months ago
openocd.stm32f429i-disco.cfg Imported libopencm3 2 months ago
openocd.stm32l1-generic.cfg Imported libopencm3 2 months ago
openocd.stm32l053disco.cfg Imported libopencm3 2 months ago
stub.py Imported libopencm3 2 months ago
test_gadget0.py Imported libopencm3 2 months ago
usb-gadget0.c Imported libopencm3 2 months ago
usb-gadget0.h Imported libopencm3 2 months ago

README.md

This project, inspired by usbtest and the linux usb gadget zero driver is used for regression testing changes to the libopencm3 usb stack.

The firmware itself is meant to be portable to any supported hardware, and then identical unit test code is run against all platforms. This project can and should be built for multiple devices.

Requirements:

  • pyusb for running the tests.
  • OpenOCD >= 0.9 for automated flashing of specific boards
  • python3 for running the tests at the command line.
  • unittest-xml-reporting, only if running in CI mode. XX

Building the device firmware

There are Makefile.xxxxx files for all the currently tested targets.

make -f Makefile.stm32f4disco clean all V=1

The V=1 is optional, and turns on verbose mode, which can be useful if things don't work. This will give you a .elf file you can program using your own toolchain, but if you have a functional OpenOCD installed, then...

make -f Makefile.stm32f4disco clean all flash

Will handle flashing as well.

Setting up the test runner (using python virtual environments)

pyvenv .env  # ensures a python3 virtual env
. .env/bin/activate
pip install pyusb

If you have multiple test boards connected, have a look at opencd.common.cfg for some tips on selectively matching the right board. For people with just a single matching board, you don't need to do anything.

Tests marked as @unittest.skip are either for functionality that is known to be broken, and are awaiting code fixes, or are long running performance tests

Access rights

On some systems (most linux systems) you probably won't have access to the usb vendor id being used/hijacked by the test cases. See 70-libopencm3.rules for installation instructions, or, if you have your own system, grant yourself access to the usb vid: 0xcafe

Running the tests

Below is an example of running the full suite of tests from the command line. The argument specifies the serial number to look for in the usb gadget, if you have more than one. No argument will the tests against all gadget-zero's found.

$ python test_gadget0.py
Running tests for DUT:  stm32f072disco
.........ss................
----------------------------------------------------------------------
Ran 27 tests in 0.388s

OK (skipped=2)

To be even more brutal, run this in a shell loop.

$ while true; do python test_gadget0.py -d stm32f072disco; done

You can also run individual tests, or individual sets of tests, see the unittest documentation for more information.

Many development environments, such as PyCharm can also be used to edit and run the tests, in whole or individually, with a nice visual test runner.