blob: fe18b799173b51948d8eb5c1d47d55304f9b76b3 [file] [log] [blame] [view]
David Brownd2fcc212017-09-11 14:47:48 -06001# Zephyr Test Plan
2
3The following roughly describes how mcuboot is tested on Zephyr. The
4testing 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
9Note that at the time of release of 0.9.0-rc2, the change [MPU flash
10write][flashwrite] had not been merged. This change fixes a problem interaction
11between the MPU and the flash drivers. Without this change, if the
12MPU is enabled (the default), the bootloader will abort immediately on
13boot, generally before printing any messages.
14
15At this time, most of the test variants are done by modifying either
16the code or Makefiles. A future goal is to automate this testing.
17
18## Sanity Check
19
20Begin by running make in `samples/zephyr`:
21
22 $ make clean
23 $ make all
24
25This will result in three binaries: `mcuboot.bin`,
26`signed-hello1.bin`, and `signed-hello2.bin`.
27
28The second file is marked as an "upgrade" by the image tool, so
29has an appended image trailer.
30
31Begin by doing a full erase, and programming the first image:
32
33 $ pyocd-flashtool -ce
34 $ make flash_boot
35
36After it resets, look for "main: Starting bootloader", a few debug
37messages, and lastly: "main: Unable to find bootable image".
38
39Then, load hello1:
40
41 $ make flash_hello1
42
43This should print "main: Jumping to the first image slot", and you
44should get an image "Hello World number 1!".
45
46For kicks, program slot 2's image into slot one. This has to be done
47manually, and it is good to verify these addresses in the Makefile:
48
49 $ pyocd-flashtool -a 0x20000 signed-hello1.bin
50
51This should boot, printing "Upgraded hello!".
52
53Now put back image 1, and put image 2 in as the upgrade:
54
55 $ make flash_hello1
56 $ make flash_hello2
57
58This should print a message: `boot_swap_type: Swap type: test`, and
59you should see "Upgraded hello!".
60
61Now reset the target::
62
63 $ pyocd-tool reset
64
65And you should see a revert and "Hello world number 1" running.
66
67Repeat this, to make sure we can mark the image as OK, and that a
68revert doesn't happen:
69
70 $ make flash_hello1
71 $ make flash_hello2
72
73We should have just booted the Upgraded hello. Mark this as OK:
74
75 $ pyocd-flashtool -a 0x7ffe8 image_ok.bin
76 $ pyocd-tool reset
77
78And make sure this stays in the "Upgraded hello" image.
79
80## Other Signature Combinations
81
82**note**: Make sure you don't have changes in your tree, as the
83following step will undo them.
84
85As part of the above sanity check, we have tested the RSA signature
86algorithm, along with the new RSA-PSS signature algorithm. To test
87other configurations, we need to make some modifications to the code.
88This is easiest to do by applying some patches (in
89`testplan/zephyr`). For each of these patches, perform something
90along the lines of:
91
92 $ cd ../..
93 $ git apply testplan/zephyr/0001-try-rsa-pkcs1-v15.patch
94 $ cd samples/zephyr
95 $ make clean
96 $ make all
97 $ pyocd-flashtool -ce
98 $ make flash_boot
99 $ make flash_hello1
100
101Make sure image one boots if it is supposed to (and doesn't if it is
102not supposed to). Then try the upgrade:
103
104 $ make flash_hello2
105
106After this, make sure that the the image does or doesn't perform the
107upgrade (see test table below).
108
109After the upgrade runs, reset to make sure the revert works (or
110doesn't for the noted cases below):
111
112 $ pyocd-tool reset
113
114Then undo the change:
115
116 $ cd ../..
117 $ git checkout -- .
118
119and repeat the above steps for each patch.
120
121The following patches are available:
122
123| Patch | hello1 boot? | Upgrade ? |
124|-------|--------------|-----------|
125| 0001-bad-old-rsa-in-boot-not-in-image.patch | no | no |
126| 0001-bad-old-RSA-no-slot0-check.patch | yes | no |
127| 0001-good-rsa-pkcs-v1.5-good.patch | yes | yes |
128| 0001-bad-ECDSA-P256-bootloader-not-in-images.patch | no | no |
129| 0001-partial-ECDSA-P256-bootloader-slot0-ok-slot1-bad.patch | yes | no |
130| 0001-good-ECDSA-P256-bootloader-images-signed.patch | yes | yes |
131| 0001-partial-ECDSA-P256-bootloader-slot-0-bad-sig.patch | no | yes<sup>1</sup> |
132| 0001-partial-ECDSA-P256-bootloader-slot-1-bad-sig.patch | yes | no |
133| 0001-partial-ECDSA-P256-slot-0-bad-no-verification.patch | no | yes<sup>1</sup> |
134
135<sup>1</sup>These tests with hello1 bad should perform an upgrade when
136hello2 is flashed, but they should not revert the image afterwards.
137
138[flashwrite]: https://github.com/zephyrproject-rtos/zephyr/pull/654