blob: 9b701510ffd830ae002708657834099c8ba80ace [file] [log] [blame] [view]
Roman Okhrimenkodc0ca082023-06-21 20:49:51 +03001# Zephyr test plan
David Brownd2fcc212017-09-11 14:47:48 -06002
Roman Okhrimenkodc0ca082023-06-21 20:49:51 +03003The following roughly describes how MCUboot is tested on Zephyr. The
David Brownd2fcc212017-09-11 14:47:48 -06004testing is done with the code in `samples/zephyr`. These examples
5were written using the FRDM-K64F, but other boards should be similar.
6At this time, however, the partitions are hardcoded in the Makefile
7targets to flash.
8
Marti Bolivar38d67f72017-11-14 20:22:03 -05009Note that the script "run-tests.sh" in that directory is helpful for
10automating the process, and provides simple "y or n" prompts for each
11test case and expected result.
12
David Brown1d3f67d2017-09-14 15:10:24 -060013## Building and running.
David Brownd2fcc212017-09-11 14:47:48 -060014
David Brown1d3f67d2017-09-14 15:10:24 -060015The tests are build using the various `test-*` targets in
16`samples/zephyr/Makefile`. For each test, invoke `make` with that
17target:
David Brownd2fcc212017-09-11 14:47:48 -060018
David Brown1d3f67d2017-09-14 15:10:24 -060019 $ make test-good-rsa
David Brownd2fcc212017-09-11 14:47:48 -060020
David Brown1d3f67d2017-09-14 15:10:24 -060021Begin by doing a full erase, and programming the bootloader itself:
David Brownd2fcc212017-09-11 14:47:48 -060022
Maureen Helm0e0c4882019-02-18 17:20:00 -060023 $ pyocd erase --chip
David Brownd2fcc212017-09-11 14:47:48 -060024 $ make flash_boot
25
26After it resets, look for "main: Starting bootloader", a few debug
27messages, and lastly: "main: Unable to find bootable image".
28
29Then, load hello1:
30
31 $ make flash_hello1
32
33This should print "main: Jumping to the first image slot", and you
David Brown1d3f67d2017-09-14 15:10:24 -060034should get an image "hello1".
David Brownd2fcc212017-09-11 14:47:48 -060035
David Brown1d3f67d2017-09-14 15:10:24 -060036Note that there are comments with each test target describing the
37intended behavior for each of these steps. Sometimes an upgrade will
38happen and sometimes it will not.
David Brownd2fcc212017-09-11 14:47:48 -060039
David Brownd2fcc212017-09-11 14:47:48 -060040 $ make flash_hello2
41
42This should print a message: `boot_swap_type: Swap type: test`, and
David Brown1d3f67d2017-09-14 15:10:24 -060043you should see "hello2".
David Brownd2fcc212017-09-11 14:47:48 -060044
45Now reset the target::
46
Maureen Helm0e0c4882019-02-18 17:20:00 -060047 $ pyocd commander -c reset
David Brownd2fcc212017-09-11 14:47:48 -060048
David Brown1d3f67d2017-09-14 15:10:24 -060049And you should see a revert and "hello1" running.
50
51## Testing that mark ok works
David Brownd2fcc212017-09-11 14:47:48 -060052
53Repeat this, to make sure we can mark the image as OK, and that a
54revert doesn't happen:
55
56 $ make flash_hello1
57 $ make flash_hello2
58
David Brown1d3f67d2017-09-14 15:10:24 -060059We should have just booted the hello2. Mark this as OK:
David Brownd2fcc212017-09-11 14:47:48 -060060
Maureen Helm0e0c4882019-02-18 17:20:00 -060061 $ pyocd flash -a 0x7ffe8 image_ok.bin
62 $ pyocd commander -c reset
David Brownd2fcc212017-09-11 14:47:48 -060063
David Brown1d3f67d2017-09-14 15:10:24 -060064And make sure this stays in the "hello2" image.
David Brownd2fcc212017-09-11 14:47:48 -060065
David Brown1d3f67d2017-09-14 15:10:24 -060066This step doesn't make sense on the tests where the upgrade doesn't
67happen.
David Brownd2fcc212017-09-11 14:47:48 -060068
David Brown1d3f67d2017-09-14 15:10:24 -060069## Testing all configurations
David Brownd2fcc212017-09-11 14:47:48 -060070
David Brown1d3f67d2017-09-14 15:10:24 -060071Repeat these steps for each of the `test-*` targest in the Makefile.