Skip to content

Commit

Permalink
esp32c3: Add MCUboot support files for testing
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Henrique Nihei <[email protected]>
  • Loading branch information
gustavonihei committed Oct 14, 2022
1 parent 85e34bb commit e89ee26
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Binary file added esp32c3-hal/mcuboot-esp32c3.bin
Binary file not shown.
4 changes: 4 additions & 0 deletions esp32c3-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extern "C" {
num: u32,
fixed: u32,
) -> i32;
fn esp_rom_printf(format: *const u8, ...) -> i32;

/* IROM metadata:
* - Destination address (VMA) for IROM region
Expand Down Expand Up @@ -424,6 +425,9 @@ pub fn mp_hook() -> bool {
#[cfg(feature = "mcuboot")]
unsafe {
configure_mmu();

static MESSAGE: &[u8] = b"Welcome to Rust from MCUboot!\n\0";
esp_rom_printf(MESSAGE.as_ptr());
}

unsafe {
Expand Down
37 changes: 37 additions & 0 deletions esp32c3-hal/test_mcuboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
#
# Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
#
# SPDX-License-Identifier: Apache-2.0
#

SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")

set -eo pipefail

usage() {
echo ""
echo "USAGE: ${SCRIPT_NAME} <ELF>"
echo ""
}

if [ -z "${1}" ]; then
echo "ERROR: Missing application ELF file."
usage
exit 1
fi

# MCUboot's tool for image signing and key management
if ! command -v imgtool &> /dev/null; then
echo ""
echo "imgtool not found. Please run: \"pip install imgtool\""
echo ""
exit 1
fi

elf_file=${1}

objcopy -O ihex "${elf_file}" app.hex
imgtool sign --pad --align 4 -v 0 -s auto -H 32 --pad-header -S 0x100000 app.hex app.bin
esptool.py -c esp32c3 -p /dev/ttyUSB0 -b 921600 --after no_reset write_flash -fs 4MB -fm dio -ff 40m 0x0 ./mcuboot-esp32c3.bin 0x110000 ./app.bin
picocom -b 115200 /dev/ttyUSB0 --imap lfcrlf

0 comments on commit e89ee26

Please sign in to comment.