Skip to content

Commit

Permalink
Add MCUboot
Browse files Browse the repository at this point in the history
  • Loading branch information
leonrinkel committed Oct 15, 2023
1 parent 7c54343 commit d8fca30
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
25 changes: 25 additions & 0 deletions BOOTLOADER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# bootloader

## Building

```sh
cd bootloader/mcuboot/boot/zephyr
west build -b sam_fd -p always -- \
-DCONFIG_SINGLE_APPLICATION_SLOT=y \
-DCONFIG_BOOT_SIGNATURE_TYPE_NONE=y \
-DCONFIG_BOOT_VALIDATE_SLOT0=n \
-DCONFIG_MAIN_STACK_SIZE=1024 \
-DCONFIG_MCUBOOT_SERIAL=y \
-DCONFIG_CONSOLE=n \
-DCONFIG_UART_CONSOLE=n \
-DCONFIG_BOOT_SERIAL_WAIT_FOR_DFU=y \
-DCONFIG_BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT=500 \
-DCONFIG_BOOT_ERASE_PROGRESSIVELY=y
```

## Flashing

```sh
west flash --runner jlink # or
west flash --runner pyocd
```
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,24 @@ west build -b sam_fd sam-fd-sdk/app

## Flashing

### Using a Debugger

```sh
west flash --runner jlink # or
west flash --runner pyocd
```

### Via Serial Recovery

Serial recovery mode can be entered by running a command like the following immediately after resetting. This requires a MCUboot bootloader. Please see [BOOTLOADER.md](BOOTLOADER.md) for instructions on building one.

```sh
mcumgr \
--conntype serial \
--connstring dev=/dev/cu.usbserial-110,baud=115200 \
image upload -e build/zephyr/zephyr.signed.bin
```

## License

Please see [LICENSE](LICENSE). The software side of this project is based on [Zephyr](https://www.zephyrproject.org) which is mostly licensed under the [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) license.
3 changes: 3 additions & 0 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ CONFIG_CAN=y
CONFIG_CAN_FD_MODE=y
CONFIG_LED=y
CONFIG_LED_GPIO=y

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE=y
11 changes: 8 additions & 3 deletions boards/arm/sam_fd/sam_fd.dts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,canbus = &can0;
zephyr,code-partition = &slot0_partition;
};

aliases {
Expand Down Expand Up @@ -69,9 +70,13 @@
#address-cells = <1>;
#size-cells = <1>;

storage_partition: partition@3c000 {
label = "storage";
reg = <0x0003c000 0x00004000>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x5000>;
};
slot0_partition: partition@5000 {
label = "image-0";
reg = <0x00005000 0xAFFF>;
};
};
};
Expand Down
3 changes: 3 additions & 0 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ manifest:
name-allowlist:
- cmsis
- hal_atmel
- mcuboot
- tinycrypt
- zcbor

0 comments on commit d8fca30

Please sign in to comment.