From 7403b5e53f903535bef4f4157c5b47dc41df04a5 Mon Sep 17 00:00:00 2001 From: Jakob Dalsgaard Date: Fri, 8 Oct 2021 21:40:40 +0200 Subject: [PATCH] First commit --- .cargo/config | 15 +++++++++++++++ Cargo.toml | 20 ++++++++++++++++++++ build.rs | 26 ++++++++++++++++++++++++++ env.sh | 7 +++++++ sdkconfig.defaults | 6 ++++++ src/main.rs | 4 ++++ 6 files changed, 78 insertions(+) create mode 100644 .cargo/config create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 env.sh create mode 100644 sdkconfig.defaults create mode 100644 src/main.rs diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..d84a073 --- /dev/null +++ b/.cargo/config @@ -0,0 +1,15 @@ +[build] +target = "xtensa-esp32-espidf" + +[target.xtensa-esp32-espidf] +linker = "ldproxy" + +[unstable] +build-std = ["std", "panic_abort"] +build-std-features = ["panic_immediate_abort"] +configurable-env = true # No longer necessary since 1.56, as it was stabilized: https://github.com/rust-lang/cargo/blob/master/src/cargo/core/features.rs#L698 +extra-link-arg = true # No longer necessary since 1.56, as it was stabilized: https://github.com/rust-lang/cargo/blob/master/src/cargo/core/features.rs#L695 + +[env] +ESP_IDF_SYS_GLOB_BASE = { value = ".", relative = true } + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f920ff1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "rusty-espresso" +version = "0.1.0" +edition = "2018" + + + +[features] +bind = [] + +[dependencies] +anyhow = {version = "1", features = ["backtrace"]} +esp-idf-sys = { version = "0.20" } +embedded-svc = "0.8.3" +esp-idf-svc = { version = "0.20", features = ["binstart"] } +esp-idf-hal = "0.20" + +[build-dependencies] +embuild = "0.24" +anyhow = "1" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..c69dcc7 --- /dev/null +++ b/build.rs @@ -0,0 +1,26 @@ +use std::path::PathBuf; + +use embuild::{ + self, bingen, + build::{CfgArgs, LinkArgs}, + cargo, symgen, +}; + +// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641 +fn main() -> anyhow::Result<()> { + LinkArgs::output_propagated("ESP_IDF")?; + + let cfg = CfgArgs::try_from_env("ESP_IDF")?; + + if cfg.get("esp32s2").is_some() { + let ulp_elf = PathBuf::from("ulp").join("rust-esp32-ulp-hello"); + symgen::run(&ulp_elf, 0x5000_0000)?; // This is where the RTC Slow Mem is mapped within the ESP32-S2 memory space + bingen::run(&ulp_elf)?; + + cargo::track_file(ulp_elf); + } + + cfg.output(); + + Ok(()) +} diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..3818eb7 --- /dev/null +++ b/env.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +export PATH=$HOME/xtensa-esp32-elf-clang/bin:$PATH +. $HOME/esp/esp-idf/export.sh +rustup default esp + + diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100644 index 0000000..fde0066 --- /dev/null +++ b/sdkconfig.defaults @@ -0,0 +1,6 @@ +CONFIG_LWIP_L2_TO_L3_COPY=y +CONFIG_LWIP_IP_FORWARD=y +CONFIG_LWIP_IPV4_NAPT=y +#CONFIG_ESP_SYSTEM_USE_EH_FRAME=y +#CONFIG_COMPILER_CXX_EXCEPTIONS=y + diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7da3a48 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,4 @@ + +fn main() { + println!("Hello, world!"); +}