MCUboot, but in Rust

Overview

MCUboot - In Rust

This project is the beginnings of a fresh implementation of MCUboot in Rust. At this point, it implements SHA256 image verification, booting a chained image, and works on the LPC55S69 LPCXpresso development, using the lp55-hal crate. This is more a proof of concept.

Some things that are implemented:

  • The boot code lives in its own crate. This supports cargo test to perform some unit testing (which is incomplete). When built with 'std' enabled, the crate prints various pieces of information out, and is useful for debuggin.
  • The boot crate can be used no_std, and has no diagnostics, and returns very simple error codes.
  • boards/lpc55s69 contains a build of a bootloader using the boot crate. Upon successfully validaing an image, it will chain boot to that crate.
  • hello/lpc55s69 contains a simple hello/blinky application to demonstrate the bootloader. The signed version can be placed in the appropriate slot to test the bootloader.

Things that still need to be done:

  • Other types of verification, such as signatures.
  • Upgrades. The main motivation of this project is to develop a new swap algorithm and status storage that is appropriate for large-write devices (hence the LPC55S69).
  • Everything else. MCUboot has a lot of other functionality.
  • Broader support. Probably worth adding at least one other board to work to generalize the board support to make these support files minimal.
  • Zephyr support. Related to getting Rust to work on Zephyr would make this an ideal application of that.

Some issues with the LPC55S69 specifically:

  • There are several issue with the tip version, and some of the other dependencies I use. This uses a submodule with a fork of the lpc55-hal crate to address these issues.
  • The HW SHA256 engine doesn't compile, and rather than fix this at this time, just replace the offending code with a todo!(). When adding the idea of crypto providers to boot, this can be addressed to add support for the LPC's hardware crypto support.
  • Clock initialization can only be done once. Until addressed, the boot main doesn't initialize any clocks. It appears that clock initialization is leaving the CPU connected to the PLL while trying to program it.

How to try it.

In order to test this out, you will currently need an LPCXpresso55S69 development board. I was able to get it to work with the jlink firmware.

  • Install the jlink tools for your platform.
  • Install the Arm toolchain gdb. On ubuntu, this is gdb-arm-none-eabi
  • Install socat.
  • Make sure you have rust installed. Rustup is the easiest way to do this.
  • Install imgtool from the main mcuboot project:
$ pip install -u imgtool
  • Install the thumbv8m.main-none-eabi target if you haven't
$ rustup target add thumbv8m.main-none-eabi
  • Build the 'hello world' application.
$ cd hello/lpc55s69
$ cargo build
$ make sign
$ cd ../..

this should generate a signed.bin which is a signed version.

  • Test the boot code.
$ cd boot
$ cargo test
$ cd ..

note that, at this time, these tests are incomplete, and actually fail to print out what it is doing.

  • Test on the target You'll need three windows for this. Each window should be in the boards/lpc55s69 directory.

In one window, start the jlink gdb server:

$ make jlink

In another window, run socat to dump semihosting messages.

$ make semi

And in the third window, start gdb.

$ cargo run

This should load both the executable under test, and the signed.bin image created earlier.

You might also like...
clone of grep cli written in Rust. From Chapter 12 of the Rust Programming Language book

minigrep is a clone of the grep cli in rust Minigrep will find a query string in a file. To test it out, clone the project and run cargo run body poem

Rust-blog - Educational blog posts for Rust beginners

pretzelhammer's Rust blog 🦀 I write educational content for Rust beginners and Rust advanced beginners. My posts are listed below in reverse chronolo

The ray tracer challenge in rust - Repository to follow my development of
The ray tracer challenge in rust - Repository to follow my development of "The Raytracer Challenge" book by Jamis Buck in the language Rust

The Ray Tracer Challenge This repository contains all the code written, while step by implementing Ray Tracer, based on the book "The Ray Tracer Chall

Learn-rust-the-hard-way - "Learn C The Hard Way" by Zed Shaw Converted to Rust

Learn Rust The Hard Way This is an implementation of Zed Shaw's Learn X The Hard Way for the Rust Programming Language. Installing Rust TODO: Instruct

Learn to write Rust procedural macros [Rust Latam conference, Montevideo Uruguay, March 2019]
Learn to write Rust procedural macros [Rust Latam conference, Montevideo Uruguay, March 2019]

Rust Latam: procedural macros workshop This repo contains a selection of projects designed to learn to write Rust procedural macros — Rust code that g

The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language.

rcc The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language. Compilers Language Co

Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed.

integra8 Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed. | This repo is in a "work in progress"

Rust Sandbox [code for 15 concepts of Rust language]

Rust-Programming-Tutorial Rust Sandbox [code for 15 concepts of Rust language]. The first time I've been introduced to Rust was on January 2022, you m

TypeRust - simple Rust playground where you can build or run your Rust code and share it with others

Rust playground Welcome to TypeRust! This is a simple Rust playground where you can build or run your Rust code and share it with others. There are a

Comments
  • lpc55 crashes if image area is unwritten

    lpc55 crashes if image area is unwritten

    The simulated flash driver will bus fault if the flash device has not been written at the address of the first image. This can easily be recreated by erasing the flash, and then not programming an image in.

    The datasheet for the device lists a possible way to use the controller to read without causing a fault, and the ECC register can then be used to determine if the read was successful.

    opened by d3zd3z 0
  • Clock initialization can only happen once on lpc55

    Clock initialization can only happen once on lpc55

    If boot does an lpc55-hal clock initialization, and then run application also does a clock initialization, the board will lock up. It appears that the CPU is still being clocked off of the pll when the code tries initializing the PLL again.

    bug 
    opened by d3zd3z 0
Owner
null
🗝️ Superbacked, but in Rust

Hyperbacked A clone of Superbacked, written in Rust. Basically, it stores secrets securely using printable PDFs that contain encrypted QR-Codes. The e

null 46 Jan 26, 2023
Like wc, but unicode-aware, and with per-line mode

Like wc, but unicode-aware, and with per-line mode

Skyler Hawthorne 34 May 24, 2022
Parsley, Sage, Rosemary, but no Thyme

Parsley, Sage, Rosemary, but no Thyme A tiny command line tool that runs your command for you and tries to tell you how much longer the damn thing is

Hendrik Sollich 3 Dec 29, 2022
PE Parsing, but blazing fast

PE Parser A blazing fast ?? PE Parser written in Rust Motivation The main goals of pe-parser is to write something suitable for a PE Loader. Is editin

Isaac Marovitz 8 Apr 21, 2023
It's a library AND a binary, but at what cost?

aria-of-borrow It's a library AND a binary, but at what cost? This is a simple toy project that demonstrates the various failure modes of trying to ma

Aria Beingessner 5 Apr 2, 2024
Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

RUST GYM Rust Solutions Leetcode Solutions in Rust AdventOfCode Solutions in Rust This project demostrates how to create Data Structures and to implem

Larry Fantasy 635 Jan 3, 2023
Simple autoclicker written in Rust, to learn the Rust language.

RClicker is an autoclicker written in Rust, written to learn more about the Rust programming language. RClicker was was written by me to learn more ab

null 7 Nov 15, 2022
Rust programs written entirely in Rust

mustang Programs written entirely in Rust Mustang is a system for building programs built entirely in Rust, meaning they do not depend on any part of

Dan Gohman 561 Dec 26, 2022
Rust 核心库和标准库的源码级中文翻译,可作为 IDE 工具的智能提示 (Rust core library and standard library translation. can be used as IntelliSense for IDE tools)

Rust 标准库中文版 这是翻译 Rust 库 的地方, 相关源代码来自于 https://github.com/rust-lang/rust。 如果您不会说英语,那么拥有使用中文的文档至关重要,即使您会说英语,使用母语也仍然能让您感到愉快。Rust 标准库是高质量的,不管是新手还是老手,都可以从中

wtklbm 493 Jan 4, 2023
A library for extracting #[no_mangle] pub extern "C" functions (https://docs.rust-embedded.org/book/interoperability/rust-with-c.html#no_mangle)

A library for extracting #[no_mangle] pub extern "C" functions In order to expose a function with C binary interface for interoperability with other p

Dmitrii - Demenev 0 Feb 17, 2022