Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import, test of esp-rs/rust#96
- Loading branch information
0 parents
commit 99ccf14
Showing
9 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[build] | ||
# Uncomment the relevant target for your chip here (ESP32, ESP32-S2, ESP32-S3 or ESP32-C3) | ||
#target = "xtensa-esp32-espidf" | ||
#target = "xtensa-esp32s2-espidf" | ||
#target = "xtensa-esp32s3-espidf" | ||
target = "riscv32imc-esp-espidf" | ||
|
||
[target.xtensa-esp32-espidf] | ||
linker = "ldproxy" | ||
|
||
[target.xtensa-esp32s2-espidf] | ||
linker = "ldproxy" | ||
|
||
[target.xtensa-esp32s3-espidf] | ||
linker = "ldproxy" | ||
|
||
[target.riscv32imc-esp-espidf] | ||
linker = "ldproxy" | ||
|
||
# Future - necessary for the experimental "native build" of esp-idf-sys with ESP32C3 | ||
# See also https://github.com/ivmarkov/embuild/issues/16 | ||
rustflags = ["-C", "default-linker-libraries"] | ||
|
||
[unstable] | ||
build-std = ["std", "panic_abort"] | ||
|
||
[env] | ||
# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF stable (v4.4) | ||
ESP_IDF_VERSION = { value = "branch:release/v4.4" } | ||
# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF master (v5.0) | ||
#ESP_IDF_VERSION = { value = "master" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/.vscode | ||
/.embuild | ||
/target | ||
/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "esp-fs-tests" | ||
version = "0.1.0" | ||
authors = ["Scott Mabin <scott@mabez.dev>"] | ||
edition = "2018" | ||
resolver = "2" | ||
|
||
[profile.release] | ||
opt-level = "s" | ||
|
||
[profile.dev] | ||
debug = true # Symbols are nice and they don't increase the size on Flash | ||
opt-level = "z" | ||
|
||
[features] | ||
default = ["native"] | ||
native = ["esp-idf-sys/native"] | ||
|
||
[dependencies] | ||
esp-idf-sys = { version = "0.30.6", features = ["binstart"] } | ||
c_str_macro = "1.0.3" | ||
|
||
|
||
[build-dependencies] | ||
embuild = "0.28" | ||
anyhow = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## esp-fs-tests | ||
|
||
To run the test suite on a esp32c3, run the following command. Make sure `cargo-espflash` is installed. | ||
|
||
```bash | ||
cargo +nightly espflash --features native --partition-table partitions.csv --monitor /dev/ttyUSB0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641 | ||
fn main() -> anyhow::Result<()> { | ||
embuild::build::CfgArgs::output_propagated("ESP_IDF")?; | ||
embuild::build::LinkArgs::output_propagated("ESP_IDF") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Name, Type, SubType, Offset, Size, Flags | ||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap | ||
nvs, data, nvs, 0x9000, 0x6000, | ||
phy_init, data, phy, 0xf000, 0x1000, | ||
factory, app, factory, 0x10000, 1M, | ||
storage, data, spiffs, , 0xF0000, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[toolchain] | ||
|
||
|
||
channel = "nightly" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K) | ||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7000 | ||
|
||
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default). | ||
# This allows to use 1 ms granuality for thread sleeps (10 ms by default). | ||
#CONFIG_FREERTOS_HZ=1000 | ||
|
||
# Workaround for https://github.com/espressif/esp-idf/issues/7631 | ||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n | ||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use esp_idf_sys::*; | ||
use c_str_macro::c_str; | ||
use std::ffi::CStr; | ||
|
||
fn main() { | ||
esp_idf_sys::link_patches(); | ||
|
||
init_partition(c_str!("/storage"), c_str!("storage"), 3); | ||
std::fs::write("/storage/test_file", "hello").unwrap(); | ||
|
||
test_read_to_string(); | ||
|
||
println!("Testing complete!"); | ||
} | ||
|
||
fn init_partition(path: &CStr, label: &CStr, max_files: u32) { | ||
let storage_conf = esp_vfs_spiffs_conf_t { | ||
base_path: path.as_ptr(), | ||
partition_label: label.as_ptr(), | ||
max_files, | ||
format_if_mount_failed: true, | ||
}; | ||
|
||
unsafe { esp_vfs_spiffs_register(&storage_conf) }; | ||
} | ||
|
||
fn test_read_to_string() { | ||
let str = std::fs::read_to_string("/storage/test_file").unwrap(); | ||
|
||
println!("String is: {:?}", str); | ||
assert_eq!("hello", str); | ||
} |