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