1# Runtime chosen image sample application 2 3This sample demonstrates how to use a non flash storage to retrieve the image 4being booted. It was tested on a FRDM K64F. Both slots are used to store two 5different images. The image to be booted is selected based on a button press. 6 7## Build 8 9Build mcuboot. First, ensure ZEPHYR_SDK_INSTALL_DIR is defined. From the 10sample directory, run the following commands: 11 12``` 13 source <path-to-zephyr>/zephyr-env.sh 14 15 west build -p -b frdm_k64f ../../../boot/zephyr/ -- \ 16 -DEXTRA_ZEPHYR_MODULES=$PWD/hooks -DEXTRA_CONF_FILE="$PWD/sample.conf" 17 18 west build -t flash 19``` 20 21Then, build the sample application to be loaded. We need to build it twice, one 22for each slot. From the sample 23app directory (mcuboot/samples/non-flash-source/zephyr/app), run: 24 25``` 26 west build -p -b frdm_k64f . 27 west flash 28``` 29 30Then change the overlay file to use the second slot. For instance, open 31`boards/frdm_k64f.overlay` and change the line: 32 33``` 34 zephyr,code-partition = &slot0_partition; 35 36``` 37 38to: 39 40``` 41 zephyr,code-partition = &slot1_partition; 42``` 43 44And build and flash again: 45 46``` 47 west build -b frdm_k64f . 48 west flash 49``` 50 51## Run 52 53Open a serial terminal to see the output and reset the board. It shall boot the 54image on slot0 by default. By keeping the SW2 button pressed during reset, the 55bootloader will boot the one on slot1. 56