Francesco Servidio | 5bc9832 | 2021-11-03 13:19:22 +0100 | [diff] [blame] | 1 | ## MCUboot test plan |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 2 | |
| 3 | The current target for running the tests is the Freedom K64F board. |
| 4 | |
| 5 | ### Basic sign support (RSA/EC/EC256) |
| 6 | |
| 7 | For each supported signing algorithm, check that non-signed, and signed |
| 8 | with wrong key images are not swapped to, and image signed with correct key |
| 9 | is swapped to. |
| 10 | |
| 11 | For the 3 algorithms supported, rsa, ec and ec256, two files are provided: |
| 12 | key_<sign-algo>.pem, key_<sign-algo>_2.pem. And a keys file with the C public |
| 13 | key data for key_<sign-algo>.pem. |
| 14 | |
Francesco Servidio | 4ff0c18 | 2021-10-20 15:27:16 +0200 | [diff] [blame] | 15 | Build and load MCUboot: |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 16 | |
| 17 | * `newt build k64f_boot_<sign-algo>` |
| 18 | * `newt load k64f_boot_<sign-algo>` |
| 19 | |
| 20 | Build and load good image in slot 0: |
| 21 | |
| 22 | * `newt create-image k64f_blinky 1.0.1 key_<sign-algo>.pem` |
| 23 | * `newt load k64f_blinky` |
| 24 | |
Francesco Servidio | 2fe449d | 2021-10-21 12:38:36 +0200 | [diff] [blame] | 25 | --- |
| 26 | ***Note*** |
| 27 | |
| 28 | *If testing RSA/PSS `newt create-image` needs to be passed in the extra* |
| 29 | *flag `--rsa-pss` eg:* |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 30 | |
| 31 | `newt create-image k64f_blinky 1.0.1 key_rsa.pem --rsa-pss` |
| 32 | |
Francesco Servidio | 2fe449d | 2021-10-21 12:38:36 +0200 | [diff] [blame] | 33 | --- |
| 34 | |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 35 | Build and load image in slot 1 with no signing, signed with |
| 36 | key_<sign-algo>_2.pem and signed with key_<sign-algo>.pem. Mark each one as |
| 37 | test image and check that swap only happens for image signed with |
| 38 | key_<sign-algo>.pem. Both others should be erased. |
| 39 | |
| 40 | * `newt create-image k64f_blinky2 1.0.2 <one-of-the-sign-keys-or-none>` |
| 41 | * `newtmgr image upload k64f_blinky2` |
| 42 | * `newtmgr image list` |
| 43 | * `newtmgr image test <hash of slot 1>` |
| 44 | |
| 45 | ### Image signed with more than one key |
| 46 | |
| 47 | FIXME: this is currently not functional, skip this section! |
| 48 | |
Francesco Servidio | 4ff0c18 | 2021-10-20 15:27:16 +0200 | [diff] [blame] | 49 | Build and load MCUboot: |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 50 | |
| 51 | * `newt build k64f_boot_rsa_ec` |
| 52 | * `newt load k64f_boot_rsa_ec` |
| 53 | |
| 54 | Build and load good image in slot 0: |
| 55 | |
| 56 | * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` |
| 57 | * `newt load k64f_blinky` |
| 58 | |
| 59 | Build and load image in slot 1 with no signing, signed with |
| 60 | key_<sign-algo>_2.pem and signed with key_<sign-algo>.pem. Mark each one as |
| 61 | test image and check that swap only happens for image signed with |
| 62 | key_<sign-algo>.pem. Both others should be erased. |
| 63 | |
| 64 | Use all of this options: |
| 65 | |
| 66 | * `newt create-image k64f_blinky2 1.0.2` |
| 67 | |
| 68 | And load |
| 69 | |
| 70 | * `newtmgr image upload k64f_blinky2` |
| 71 | * `newtmgr image list` |
| 72 | * `newtmgr image test <hash of slot 1>` |
| 73 | |
| 74 | ### Overwrite only functionality |
| 75 | |
Francesco Servidio | 4ff0c18 | 2021-10-20 15:27:16 +0200 | [diff] [blame] | 76 | Build/load MCUboot: |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 77 | |
| 78 | * `newt build k64f_boot_rsa_noswap` |
| 79 | * `newt load k64f_boot_rsa_noswap` |
| 80 | |
| 81 | Build/load blinky to slot 0: |
| 82 | |
| 83 | * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` |
| 84 | * `newt load k64f_blinky` |
| 85 | |
| 86 | Build/load blinky2 both with bad and good key, followed by a permanent swap |
| 87 | request: |
| 88 | |
| 89 | * `newt create-image k64f_blinky2 1.0.2 <bad and good rsa keys>.pem` |
| 90 | * `newtmgr image upload k64f_blinky2` |
| 91 | * `newtmgr image list` |
| 92 | * `newtmgr image confirm <hash of slot 1>` |
| 93 | |
| 94 | This should not swap and delete the image in slot 1 when signed with the wrong |
| 95 | key, otherwise the image in slot 1 should be *moved* to slot 0 and slot 1 should |
| 96 | be empty. |
| 97 | |
| 98 | ### Validate slot 0 option |
| 99 | |
Francesco Servidio | 4ff0c18 | 2021-10-20 15:27:16 +0200 | [diff] [blame] | 100 | Build/load MCUboot: |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 101 | |
| 102 | * `newt build k64f_boot_rsa_validate0` |
| 103 | * `newt load k64f_boot_rsa_validate0` |
| 104 | |
| 105 | Build non-signed image: |
| 106 | |
| 107 | * `newt create-image k64f_blinky 1.0.1` |
| 108 | * `newt load k64f_blinky` |
| 109 | * Reset and no image should be run |
| 110 | |
| 111 | Build signed image with invalid key: |
| 112 | |
| 113 | * `newt create-image k64f_blinky 1.0.1 key_rsa_2.pem` |
| 114 | * `newt load k64f_blinky` |
| 115 | * Reset and no image should be run |
| 116 | |
| 117 | Build signed image with *valid* key: |
| 118 | |
| 119 | * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` |
| 120 | * `newt load k64f_blinky` |
| 121 | * Reset and image *should* run |
| 122 | |
| 123 | ### Swap with random failures |
| 124 | |
| 125 | DISCLAIMER: be careful with copy/paste of commands, this test uses another |
| 126 | target/app! |
| 127 | |
Francesco Servidio | 4ff0c18 | 2021-10-20 15:27:16 +0200 | [diff] [blame] | 128 | Build/load MCUboot: |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 129 | |
| 130 | * `newt build k64f_boot_rsa` |
| 131 | * `newt load k64f_boot_rsa` |
| 132 | |
| 133 | Build/load slinky to slot 0: |
| 134 | |
| 135 | * `newt create-image k64f_slinky 1.0.1 key_rsa.pem` |
| 136 | * `newt load k64f_slinky` |
| 137 | |
| 138 | Build/load slinky2 to slot 1: |
| 139 | |
| 140 | * `newt create-image k64f_slinky2 1.0.2 key_rsa.pem` |
| 141 | * `newtmgr image upload k64f_slinky2` |
| 142 | |
| 143 | Confirm that both images are installed, request a permanent request to the |
| 144 | image in slot 1 and check that it works. |
| 145 | |
| 146 | * `newtmgr image list` |
| 147 | * `newtmgr image confirm <hash of slot 1>` |
| 148 | |
| 149 | If everything works, now proceed with requests for permanent swap to the image |
| 150 | in slot 1 and do random swaps (as much as you like!). When the swap finishes |
| 151 | confirm that the swap was finished with the previous slot 1 image now in |
| 152 | slot 0 and vice-versa. |
| 153 | |
| 154 | ### Help |
| 155 | |
| 156 | * Mass erase MCU |
| 157 | |
Maureen Helm | 0e0c488 | 2019-02-18 17:20:00 -0600 | [diff] [blame] | 158 | $ pyocd erase --chip |
Fabio Utzig | d7f6c76 | 2017-07-27 20:50:50 -0300 | [diff] [blame] | 159 | |
| 160 | * Flashing image in slot 1: |
| 161 | |
Maureen Helm | 0e0c488 | 2019-02-18 17:20:00 -0600 | [diff] [blame] | 162 | $ pyocd flash -e sector -a 0x80000 ${IMG_FILE} bin |