Loading doc/testplan-mynewt.md +157 Changes for doc/testplan-mynewt.md: 157 added lines, 0 removed lines. Original line number Diff line number Diff line ## mcuboot test plan The current target for running the tests is the Freedom K64F board. ### Basic sign support (RSA/EC/EC256) For each supported signing algorithm, check that non-signed, and signed with wrong key images are not swapped to, and image signed with correct key is swapped to. For the 3 algorithms supported, rsa, ec and ec256, two files are provided: key_<sign-algo>.pem, key_<sign-algo>_2.pem. And a keys file with the C public key data for key_<sign-algo>.pem. Build and load mcuboot: * `newt build k64f_boot_<sign-algo>` * `newt load k64f_boot_<sign-algo>` Build and load good image in slot 0: * `newt create-image k64f_blinky 1.0.1 key_<sign-algo>.pem` * `newt load k64f_blinky` NOTE: If testing RSA/PSS `newt create-image` needs to be passed in the extra flag `--rsa-pss` eg: `newt create-image k64f_blinky 1.0.1 key_rsa.pem --rsa-pss` Build and load image in slot 1 with no signing, signed with key_<sign-algo>_2.pem and signed with key_<sign-algo>.pem. Mark each one as test image and check that swap only happens for image signed with key_<sign-algo>.pem. Both others should be erased. * `newt create-image k64f_blinky2 1.0.2 <one-of-the-sign-keys-or-none>` * `newtmgr image upload k64f_blinky2` * `newtmgr image list` * `newtmgr image test <hash of slot 1>` ### Image signed with more than one key FIXME: this is currently not functional, skip this section! Build and load mcuboot: * `newt build k64f_boot_rsa_ec` * `newt load k64f_boot_rsa_ec` Build and load good image in slot 0: * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` * `newt load k64f_blinky` Build and load image in slot 1 with no signing, signed with key_<sign-algo>_2.pem and signed with key_<sign-algo>.pem. Mark each one as test image and check that swap only happens for image signed with key_<sign-algo>.pem. Both others should be erased. Use all of this options: * `newt create-image k64f_blinky2 1.0.2` And load * `newtmgr image upload k64f_blinky2` * `newtmgr image list` * `newtmgr image test <hash of slot 1>` ### Overwrite only functionality Build/load mcuboot: * `newt build k64f_boot_rsa_noswap` * `newt load k64f_boot_rsa_noswap` Build/load blinky to slot 0: * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` * `newt load k64f_blinky` Build/load blinky2 both with bad and good key, followed by a permanent swap request: * `newt create-image k64f_blinky2 1.0.2 <bad and good rsa keys>.pem` * `newtmgr image upload k64f_blinky2` * `newtmgr image list` * `newtmgr image confirm <hash of slot 1>` This should not swap and delete the image in slot 1 when signed with the wrong key, otherwise the image in slot 1 should be *moved* to slot 0 and slot 1 should be empty. ### Validate slot 0 option Build/load mcuboot: * `newt build k64f_boot_rsa_validate0` * `newt load k64f_boot_rsa_validate0` Build non-signed image: * `newt create-image k64f_blinky 1.0.1` * `newt load k64f_blinky` * Reset and no image should be run Build signed image with invalid key: * `newt create-image k64f_blinky 1.0.1 key_rsa_2.pem` * `newt load k64f_blinky` * Reset and no image should be run Build signed image with *valid* key: * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` * `newt load k64f_blinky` * Reset and image *should* run ### Swap with random failures DISCLAIMER: be careful with copy/paste of commands, this test uses another target/app! Build/load mcuboot: * `newt build k64f_boot_rsa` * `newt load k64f_boot_rsa` Build/load slinky to slot 0: * `newt create-image k64f_slinky 1.0.1 key_rsa.pem` * `newt load k64f_slinky` Build/load slinky2 to slot 1: * `newt create-image k64f_slinky2 1.0.2 key_rsa.pem` * `newtmgr image upload k64f_slinky2` Confirm that both images are installed, request a permanent request to the image in slot 1 and check that it works. * `newtmgr image list` * `newtmgr image confirm <hash of slot 1>` If everything works, now proceed with requests for permanent swap to the image in slot 1 and do random swaps (as much as you like!). When the swap finishes confirm that the swap was finished with the previous slot 1 image now in slot 0 and vice-versa. ### Help * Mass erase MCU $ pyocd-flashtool -ce * Flashing image in slot 1: $ pyocd-flashtool -se --address 0x80000 ${IMG_FILE} bin testplan/mynewt/Makefile +91 Changes for testplan/mynewt/Makefile: 91 added lines, 0 removed lines. Original line number Diff line number Diff line BLINKY := k64f_blinky BLINKY2 := k64f_blinky2 SLINKY := k64f_slinky SLINKY2 := k64f_slinky2 BOOT_RSA := k64f_boot_rsa BOOT_RSA_PSS := k64f_boot_rsa_pss BOOT_EC := k64f_boot_ec BOOT_EC256 := k64f_boot_ec256 BOOT_RSA_EC := k64f_boot_rsa_ec BOOT_RSA_VALIDATE0 := k64f_boot_rsa_validate0 BOOT_RSA_NOSWAP := k64f_boot_rsa_noswap RSA_KEY_1 := key_rsa.pem RSA_KEY_2 := key_rsa_2.pem BLINKY2_IMG := bin/targets/$(BLINKY2)/app/apps/blinky/blinky.img FLASH_ERASE := pyocd-flashtool -ce NEWTMGR_CONN := --conn k64f NEWTMGR_IMG := newtmgr $(NEWTMGR_CONN) image all: build-apps build-mcuboot build-blinky: @echo "* Building blinky for slot 0... \c" @newt build -q $(BLINKY) @echo "ok" build-blinky2: @echo "* Building blinky2 for slot 1... \c" @newt build -q $(BLINKY2) @echo "ok" build-slinky: @echo "* Building slinky for slot 0... \c" @newt build -q $(SLINKY) @echo "ok" build-slinky2: @echo "* Building slinky2 for slot 1... \c" @newt build -q $(SLINKY2) @echo "ok" build-boot-rsa: @echo "* Building mcuboot with RSA... \c" @newt build -q $(BOOT_RSA) @echo "ok" build-boot-rsa-pss: @echo "* Building mcuboot with RSA/PSS... \c" @newt build -q $(BOOT_RSA_PSS) @echo "ok" build-boot-ec: @echo "* Building mcuboot with EC... \c" @newt build -q $(BOOT_EC) @echo "ok" build-boot-ec256: @echo "* Building mcuboot with EC256... \c" @newt build -q $(BOOT_EC256) @echo "ok" # FIXME: multi-key signing does not work yet... build-boot-rsa-ec: @echo "* Building mcuboot with RSA + EC... \c" @newt build -q $(BOOT_RSA_EC) @echo "ok" build-boot-rsa-validate0: @echo "* Building mcuboot with slot 0 validation... \c" @newt build -q $(BOOT_RSA_VALIDATE0) @echo "ok" build-boot-rsa-noswap: @echo "* Building mcuboot with overwrite only upgrade... \c" @newt build -q $(BOOT_RSA_NOSWAP) @echo "ok" build-apps: build-blinky build-blinky2 build-slinky build-slinky2 build-mcuboot: build-boot-rsa build-boot-rsa-pss build-boot-ec \ build-boot-ec256 build-boot-rsa-validate0 build-boot-rsa-noswap clean: rm -rf bin/ .PHONY: all clean testplan/mynewt/apps/blinky/pkg.yml +35 Changes for testplan/mynewt/apps/blinky/pkg.yml: 35 added lines, 0 removed lines. Original line number Diff line number Diff line # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # pkg.name: apps/blinky pkg.type: app pkg.description: Basic example application which blinks an LED. pkg.author: "Apache Mynewt <dev@mynewt.incubator.apache.org>" pkg.homepage: "http://mynewt.apache.org/" pkg.keywords: pkg.deps: - "@mcuboot/boot/bootutil" - "@apache-mynewt-core/kernel/os" - "@apache-mynewt-core/hw/hal" - "@apache-mynewt-core/sys/console/full" - "@apache-mynewt-core/mgmt/newtmgr" - "@apache-mynewt-core/mgmt/newtmgr/transport/nmgr_shell" - "@apache-mynewt-core/mgmt/imgmgr" - "@apache-mynewt-core/sys/log/stub" testplan/mynewt/apps/blinky/src/main.c +x+78 Changes for testplan/mynewt/apps/blinky/src/main.c: 78 added lines, 0 removed lines. Original line number Diff line number Diff line /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include <assert.h> #include <string.h> #include "sysinit/sysinit.h" #include "os/os.h" #include "bsp/bsp.h" #include "hal/hal_gpio.h" #ifdef ARCH_sim #include "mcu/mcu_sim.h" #endif #define BLINKY_PRIO (8) #define BLINKY_STACK_SIZE OS_STACK_ALIGN(128) static struct os_task task1; static volatile int g_task1_loops; /* For LED toggling */ int g_led_pin; static void blinky_handler(void *arg) { while (1) { ++g_task1_loops; os_time_delay(OS_TICKS_PER_SEC / MYNEWT_VAL(BLINKY_TICKS_PER_SEC)); /* Toggle the LED */ hal_gpio_toggle(g_led_pin); } } int main(int argc, char **argv) { os_stack_t *pstack; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); g_led_pin = LED_BLINK_PIN; hal_gpio_init_out(g_led_pin, 1); pstack = malloc(sizeof(os_stack_t) * BLINKY_STACK_SIZE); assert(pstack); os_task_init(&task1, "blinky", blinky_handler, NULL, BLINKY_PRIO, OS_WAIT_FOREVER, pstack, BLINKY_STACK_SIZE); while (1) { os_eventq_run(os_eventq_dflt_get()); } return 0; } testplan/mynewt/apps/blinky/syscfg.yml +8 Changes for testplan/mynewt/apps/blinky/syscfg.yml: 8 added lines, 0 removed lines. Original line number Diff line number Diff line syscfg.defs: BLINKY_TICKS_PER_SEC: value: 1 syscfg.vals: REBOOT_LOG_ENTRY_COUNT: 0 REBOOT_LOG_CONSOLE: 0 SHELL_TASK: 1 Loading
doc/testplan-mynewt.md +157 Changes for doc/testplan-mynewt.md: 157 added lines, 0 removed lines. Original line number Diff line number Diff line ## mcuboot test plan The current target for running the tests is the Freedom K64F board. ### Basic sign support (RSA/EC/EC256) For each supported signing algorithm, check that non-signed, and signed with wrong key images are not swapped to, and image signed with correct key is swapped to. For the 3 algorithms supported, rsa, ec and ec256, two files are provided: key_<sign-algo>.pem, key_<sign-algo>_2.pem. And a keys file with the C public key data for key_<sign-algo>.pem. Build and load mcuboot: * `newt build k64f_boot_<sign-algo>` * `newt load k64f_boot_<sign-algo>` Build and load good image in slot 0: * `newt create-image k64f_blinky 1.0.1 key_<sign-algo>.pem` * `newt load k64f_blinky` NOTE: If testing RSA/PSS `newt create-image` needs to be passed in the extra flag `--rsa-pss` eg: `newt create-image k64f_blinky 1.0.1 key_rsa.pem --rsa-pss` Build and load image in slot 1 with no signing, signed with key_<sign-algo>_2.pem and signed with key_<sign-algo>.pem. Mark each one as test image and check that swap only happens for image signed with key_<sign-algo>.pem. Both others should be erased. * `newt create-image k64f_blinky2 1.0.2 <one-of-the-sign-keys-or-none>` * `newtmgr image upload k64f_blinky2` * `newtmgr image list` * `newtmgr image test <hash of slot 1>` ### Image signed with more than one key FIXME: this is currently not functional, skip this section! Build and load mcuboot: * `newt build k64f_boot_rsa_ec` * `newt load k64f_boot_rsa_ec` Build and load good image in slot 0: * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` * `newt load k64f_blinky` Build and load image in slot 1 with no signing, signed with key_<sign-algo>_2.pem and signed with key_<sign-algo>.pem. Mark each one as test image and check that swap only happens for image signed with key_<sign-algo>.pem. Both others should be erased. Use all of this options: * `newt create-image k64f_blinky2 1.0.2` And load * `newtmgr image upload k64f_blinky2` * `newtmgr image list` * `newtmgr image test <hash of slot 1>` ### Overwrite only functionality Build/load mcuboot: * `newt build k64f_boot_rsa_noswap` * `newt load k64f_boot_rsa_noswap` Build/load blinky to slot 0: * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` * `newt load k64f_blinky` Build/load blinky2 both with bad and good key, followed by a permanent swap request: * `newt create-image k64f_blinky2 1.0.2 <bad and good rsa keys>.pem` * `newtmgr image upload k64f_blinky2` * `newtmgr image list` * `newtmgr image confirm <hash of slot 1>` This should not swap and delete the image in slot 1 when signed with the wrong key, otherwise the image in slot 1 should be *moved* to slot 0 and slot 1 should be empty. ### Validate slot 0 option Build/load mcuboot: * `newt build k64f_boot_rsa_validate0` * `newt load k64f_boot_rsa_validate0` Build non-signed image: * `newt create-image k64f_blinky 1.0.1` * `newt load k64f_blinky` * Reset and no image should be run Build signed image with invalid key: * `newt create-image k64f_blinky 1.0.1 key_rsa_2.pem` * `newt load k64f_blinky` * Reset and no image should be run Build signed image with *valid* key: * `newt create-image k64f_blinky 1.0.1 key_rsa.pem` * `newt load k64f_blinky` * Reset and image *should* run ### Swap with random failures DISCLAIMER: be careful with copy/paste of commands, this test uses another target/app! Build/load mcuboot: * `newt build k64f_boot_rsa` * `newt load k64f_boot_rsa` Build/load slinky to slot 0: * `newt create-image k64f_slinky 1.0.1 key_rsa.pem` * `newt load k64f_slinky` Build/load slinky2 to slot 1: * `newt create-image k64f_slinky2 1.0.2 key_rsa.pem` * `newtmgr image upload k64f_slinky2` Confirm that both images are installed, request a permanent request to the image in slot 1 and check that it works. * `newtmgr image list` * `newtmgr image confirm <hash of slot 1>` If everything works, now proceed with requests for permanent swap to the image in slot 1 and do random swaps (as much as you like!). When the swap finishes confirm that the swap was finished with the previous slot 1 image now in slot 0 and vice-versa. ### Help * Mass erase MCU $ pyocd-flashtool -ce * Flashing image in slot 1: $ pyocd-flashtool -se --address 0x80000 ${IMG_FILE} bin
testplan/mynewt/Makefile +91 Changes for testplan/mynewt/Makefile: 91 added lines, 0 removed lines. Original line number Diff line number Diff line BLINKY := k64f_blinky BLINKY2 := k64f_blinky2 SLINKY := k64f_slinky SLINKY2 := k64f_slinky2 BOOT_RSA := k64f_boot_rsa BOOT_RSA_PSS := k64f_boot_rsa_pss BOOT_EC := k64f_boot_ec BOOT_EC256 := k64f_boot_ec256 BOOT_RSA_EC := k64f_boot_rsa_ec BOOT_RSA_VALIDATE0 := k64f_boot_rsa_validate0 BOOT_RSA_NOSWAP := k64f_boot_rsa_noswap RSA_KEY_1 := key_rsa.pem RSA_KEY_2 := key_rsa_2.pem BLINKY2_IMG := bin/targets/$(BLINKY2)/app/apps/blinky/blinky.img FLASH_ERASE := pyocd-flashtool -ce NEWTMGR_CONN := --conn k64f NEWTMGR_IMG := newtmgr $(NEWTMGR_CONN) image all: build-apps build-mcuboot build-blinky: @echo "* Building blinky for slot 0... \c" @newt build -q $(BLINKY) @echo "ok" build-blinky2: @echo "* Building blinky2 for slot 1... \c" @newt build -q $(BLINKY2) @echo "ok" build-slinky: @echo "* Building slinky for slot 0... \c" @newt build -q $(SLINKY) @echo "ok" build-slinky2: @echo "* Building slinky2 for slot 1... \c" @newt build -q $(SLINKY2) @echo "ok" build-boot-rsa: @echo "* Building mcuboot with RSA... \c" @newt build -q $(BOOT_RSA) @echo "ok" build-boot-rsa-pss: @echo "* Building mcuboot with RSA/PSS... \c" @newt build -q $(BOOT_RSA_PSS) @echo "ok" build-boot-ec: @echo "* Building mcuboot with EC... \c" @newt build -q $(BOOT_EC) @echo "ok" build-boot-ec256: @echo "* Building mcuboot with EC256... \c" @newt build -q $(BOOT_EC256) @echo "ok" # FIXME: multi-key signing does not work yet... build-boot-rsa-ec: @echo "* Building mcuboot with RSA + EC... \c" @newt build -q $(BOOT_RSA_EC) @echo "ok" build-boot-rsa-validate0: @echo "* Building mcuboot with slot 0 validation... \c" @newt build -q $(BOOT_RSA_VALIDATE0) @echo "ok" build-boot-rsa-noswap: @echo "* Building mcuboot with overwrite only upgrade... \c" @newt build -q $(BOOT_RSA_NOSWAP) @echo "ok" build-apps: build-blinky build-blinky2 build-slinky build-slinky2 build-mcuboot: build-boot-rsa build-boot-rsa-pss build-boot-ec \ build-boot-ec256 build-boot-rsa-validate0 build-boot-rsa-noswap clean: rm -rf bin/ .PHONY: all clean
testplan/mynewt/apps/blinky/pkg.yml +35 Changes for testplan/mynewt/apps/blinky/pkg.yml: 35 added lines, 0 removed lines. Original line number Diff line number Diff line # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # pkg.name: apps/blinky pkg.type: app pkg.description: Basic example application which blinks an LED. pkg.author: "Apache Mynewt <dev@mynewt.incubator.apache.org>" pkg.homepage: "http://mynewt.apache.org/" pkg.keywords: pkg.deps: - "@mcuboot/boot/bootutil" - "@apache-mynewt-core/kernel/os" - "@apache-mynewt-core/hw/hal" - "@apache-mynewt-core/sys/console/full" - "@apache-mynewt-core/mgmt/newtmgr" - "@apache-mynewt-core/mgmt/newtmgr/transport/nmgr_shell" - "@apache-mynewt-core/mgmt/imgmgr" - "@apache-mynewt-core/sys/log/stub"
testplan/mynewt/apps/blinky/src/main.c +x+78 Changes for testplan/mynewt/apps/blinky/src/main.c: 78 added lines, 0 removed lines. Original line number Diff line number Diff line /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include <assert.h> #include <string.h> #include "sysinit/sysinit.h" #include "os/os.h" #include "bsp/bsp.h" #include "hal/hal_gpio.h" #ifdef ARCH_sim #include "mcu/mcu_sim.h" #endif #define BLINKY_PRIO (8) #define BLINKY_STACK_SIZE OS_STACK_ALIGN(128) static struct os_task task1; static volatile int g_task1_loops; /* For LED toggling */ int g_led_pin; static void blinky_handler(void *arg) { while (1) { ++g_task1_loops; os_time_delay(OS_TICKS_PER_SEC / MYNEWT_VAL(BLINKY_TICKS_PER_SEC)); /* Toggle the LED */ hal_gpio_toggle(g_led_pin); } } int main(int argc, char **argv) { os_stack_t *pstack; #ifdef ARCH_sim mcu_sim_parse_args(argc, argv); #endif sysinit(); g_led_pin = LED_BLINK_PIN; hal_gpio_init_out(g_led_pin, 1); pstack = malloc(sizeof(os_stack_t) * BLINKY_STACK_SIZE); assert(pstack); os_task_init(&task1, "blinky", blinky_handler, NULL, BLINKY_PRIO, OS_WAIT_FOREVER, pstack, BLINKY_STACK_SIZE); while (1) { os_eventq_run(os_eventq_dflt_get()); } return 0; }
testplan/mynewt/apps/blinky/syscfg.yml +8 Changes for testplan/mynewt/apps/blinky/syscfg.yml: 8 added lines, 0 removed lines. Original line number Diff line number Diff line syscfg.defs: BLINKY_TICKS_PER_SEC: value: 1 syscfg.vals: REBOOT_LOG_ENTRY_COUNT: 0 REBOOT_LOG_CONSOLE: 0 SHELL_TASK: 1