David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 1 | # Zephyr Test Plan |
| 2 | |
| 3 | The following roughly describes how mcuboot is tested on Zephyr. The |
| 4 | testing is done with the code in `samples/zephyr`. These examples |
| 5 | were written using the FRDM-K64F, but other boards should be similar. |
| 6 | At this time, however, the partitions are hardcoded in the Makefile |
| 7 | targets to flash. |
| 8 | |
Marti Bolivar | 38d67f7 | 2017-11-14 20:22:03 -0500 | [diff] [blame] | 9 | Note that the script "run-tests.sh" in that directory is helpful for |
| 10 | automating the process, and provides simple "y or n" prompts for each |
| 11 | test case and expected result. |
| 12 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 13 | ## Building and running. |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 14 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 15 | The tests are build using the various `test-*` targets in |
| 16 | `samples/zephyr/Makefile`. For each test, invoke `make` with that |
| 17 | target: |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 18 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 19 | $ make test-good-rsa |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 20 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 21 | Begin by doing a full erase, and programming the bootloader itself: |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 22 | |
| 23 | $ pyocd-flashtool -ce |
| 24 | $ make flash_boot |
| 25 | |
| 26 | After it resets, look for "main: Starting bootloader", a few debug |
| 27 | messages, and lastly: "main: Unable to find bootable image". |
| 28 | |
| 29 | Then, load hello1: |
| 30 | |
| 31 | $ make flash_hello1 |
| 32 | |
| 33 | This should print "main: Jumping to the first image slot", and you |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 34 | should get an image "hello1". |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 35 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 36 | Note that there are comments with each test target describing the |
| 37 | intended behavior for each of these steps. Sometimes an upgrade will |
| 38 | happen and sometimes it will not. |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 39 | |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 40 | $ make flash_hello2 |
| 41 | |
| 42 | This should print a message: `boot_swap_type: Swap type: test`, and |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 43 | you should see "hello2". |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 44 | |
| 45 | Now reset the target:: |
| 46 | |
| 47 | $ pyocd-tool reset |
| 48 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 49 | And you should see a revert and "hello1" running. |
| 50 | |
| 51 | ## Testing that mark ok works |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 52 | |
| 53 | Repeat this, to make sure we can mark the image as OK, and that a |
| 54 | revert doesn't happen: |
| 55 | |
| 56 | $ make flash_hello1 |
| 57 | $ make flash_hello2 |
| 58 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 59 | We should have just booted the hello2. Mark this as OK: |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 60 | |
| 61 | $ pyocd-flashtool -a 0x7ffe8 image_ok.bin |
| 62 | $ pyocd-tool reset |
| 63 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 64 | And make sure this stays in the "hello2" image. |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 65 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 66 | This step doesn't make sense on the tests where the upgrade doesn't |
| 67 | happen. |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 68 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 69 | ## Testing all configurations |
David Brown | d2fcc21 | 2017-09-11 14:47:48 -0600 | [diff] [blame] | 70 | |
David Brown | 1d3f67d | 2017-09-14 15:10:24 -0600 | [diff] [blame] | 71 | Repeat these steps for each of the `test-*` targest in the Makefile. |