Skip to content

Cargo template for embedded Rust on the MAX78000FTHR board

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

sigpwny/max78000fthr-template

Repository files navigation

MAX78000FTHR Template

This is a Cargo template for embedded Rust development with Analog Device's MAX78000FTHR board. It uses the max78000-hal crate.

Currently, only the main ARM Cortex-M4 core is supported. The optional RISC-V core is not supported.

This template is based on the cortex-m-quickstart template.

Quick Resources

Analog Devices docs

docs.rs

  • max7800x-hal - Hardware Abstraction Layer for the MAX7800x family of microcontrollers
  • max78000-pac - Peripheral Access Crate for the MAX78000

Dependencies

To build embedded programs using this template you'll need:

rustup default beta
cargo install cargo-generate
  • rust-std components (pre-compiled core crate) for the ARM Cortex-M targets. For this MAX78000 template, we are using the thumbv7em-none-eabihf target, but you could also use thumbv7em-none-eabi.
rustup target add thumbv7em-none-eabihf

Getting Started

Note

Be sure to check out the embedded Rust book for additional guidance. It covers important things like flashing, running, and debugging programs in detail.

You can generate a new project using this template by running:

cargo generate --git https://github.com/sigpwny/max78000fthr-template.git

Alternatively, you can clone this repository and manually edit the Cargo.toml file to configure your project. You won't be able to build the project until you've replaced the placeholder values.

[package]
name = "{{project-name}}" # Be sure to replace this with your project name
version = "0.1.0"
authors = ["{{authors}}"] # Be sure to replace this with your name(s)
edition = "2021"
publish = false

Building

You can build the contents in src with:

cargo build

Alternatively, you can build some of the included example code in examples with:

# cargo build --example <example-name>
cargo build --example blinky

Flashing

Via DAPLink (OpenOCD + GDB)

Note

This flashing method is quick, but is intended only for rapid development. It will also only work for boards with debug enabled. For production, you should use other methods.

The MAX78000FTHR board includes a DAPLink debugger (via a MAX32625 chip) which sits between the Micro-USB port and the MAX78000 microcontroller. This DAPLink can be used to flash the MAX78000.

Prerequisites

Both of the above tools can be installed via Analog Device's MSDK.

In one terminal, start OpenOCD with a GDB server using the following command. This will use the openocd.cfg file to configure OpenOCD and automatically connect to the board.

# C:\MaximSDK\Tools\OpenOCD\openocd.exe
openocd.exe --search "C:/MaximSDK/Tools/OpenOCD/scripts"

In another terminal, start GDB with the following command:

# C:\MaximSDK\Tools\GNUTools\10.3\bin\arm-none-eabi-gdb.exe
arm-none-eabi-gdb.exe --command=openocd.gdb ./target/thumbv7em-none-eabihf/debug/{{project-name}}

The openocd.gdb file contains the GDB commands to connect to OpenOCD's GDB server and flash the program (using the load command). Be sure to customize this file to your project's needs.

Via DAPLink (Drag-and-Drop)

You will need to create a binary firmware file (.bin) from the built ELF file using arm-none-eabi-objcopy or cargo-binutils.

TODO: More instructions here.

Via Custom Bootloader

If you are using a custom bootloader, you will need to format the generated ELF file into a format compatible with your bootloader (most likely, you'll need to use arm-none-eabi-objcopy or cargo-binutils). Refer to your bootloader's documentation for more information.

Visual Studio Code

This template includes launch configurations for debugging Cortex-M programs with Visual Studio Code located in the .vscode/ directory. See .vscode/README.md for more information.

If you're not using VS Code, you can safely delete the directory from the generated project.

License

This template is licensed under either of:

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Cargo template for embedded Rust on the MAX78000FTHR board

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks