A fork of pulp-os for the xteink4 adding custom apps
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: esp-generate scaffold (esp32c3, embassy, alloc, unstable-hal)

hansmrtn 450c54b1

+223
+17
.cargo/config.toml
··· 1 + [target.riscv32imc-unknown-none-elf] 2 + runner = "espflash flash --monitor --chip esp32c3" 3 + 4 + [env] 5 + ESP_LOG="info" 6 + 7 + [build] 8 + rustflags = [ 9 + # Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.) 10 + # NOTE: May negatively impact performance of produced code 11 + "-C", "force-frame-pointers", 12 + ] 13 + 14 + target = "riscv32imc-unknown-none-elf" 15 + 16 + [unstable] 17 + build-std = ["alloc", "core"]
+1
.clippy.toml
··· 1 + stack-size-threshold = 1024
+26
.gitignore
··· 1 + # will have compiled files and executables 2 + debug/ 3 + target/ 4 + 5 + # Editor configuration 6 + .vscode/ 7 + .zed/ 8 + .helix/ 9 + .nvim.lua 10 + 11 + # These are backup files generated by rustfmt 12 + **/*.rs.bk 13 + 14 + # MSVC Windows builds of rustc generate these, which store debugging information 15 + *.pdb 16 + 17 + # RustRover 18 + # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 19 + # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 20 + # and can be added to the global gitignore or merged into this file. For a more nuclear 21 + # option (not recommended) you can uncomment the following to ignore the entire idea folder. 22 + #.idea/ 23 + 24 + 25 + # Ignore .DS_Store file in mac 26 + **/.DS_Store
+50
Cargo.toml
··· 1 + [package] 2 + edition = "2024" 3 + name = "pulp-os" 4 + rust-version = "1.88" 5 + version = "0.1.0" 6 + 7 + [[bin]] 8 + name = "pulp-os" 9 + path = "./src/bin/main.rs" 10 + 11 + [dependencies] 12 + esp-hal = { version = "~1.0", features = ["esp32c3", "log-04", "unstable"] } 13 + 14 + esp-rtos = { version = "0.2.0", features = [ 15 + "embassy", 16 + "esp-alloc", 17 + "esp32c3", 18 + "log-04", 19 + ] } 20 + 21 + esp-bootloader-esp-idf = { version = "0.4.0", features = ["esp32c3", "log-04"] } 22 + log = "0.4.27" 23 + 24 + embassy-executor = { version = "0.9.1", features = ["log"] } 25 + embassy-time = { version = "0.5.0", features = ["log"] } 26 + esp-alloc = "0.9.0" 27 + esp-backtrace = { version = "0.18.1", features = [ 28 + "esp32c3", 29 + "panic-handler", 30 + "println", 31 + ] } 32 + esp-println = { version = "0.16.1", features = ["esp32c3", "log-04"] } 33 + 34 + critical-section = "1.2.0" 35 + static_cell = "2.1.1" 36 + 37 + 38 + [profile.dev] 39 + # Rust debug is too slow. 40 + # For debug builds always builds with some optimization 41 + opt-level = "s" 42 + 43 + [profile.release] 44 + codegen-units = 1 # LLVM can perform better optimizations using a single thread 45 + debug = 2 46 + debug-assertions = false 47 + incremental = false 48 + lto = 'fat' 49 + opt-level = 's' 50 + overflow-checks = false
+70
build.rs
··· 1 + fn main() { 2 + linker_be_nice(); 3 + // make sure linkall.x is the last linker script (otherwise might cause problems with flip-link) 4 + println!("cargo:rustc-link-arg=-Tlinkall.x"); 5 + } 6 + 7 + fn linker_be_nice() { 8 + let args: Vec<String> = std::env::args().collect(); 9 + if args.len() > 1 { 10 + let kind = &args[1]; 11 + let what = &args[2]; 12 + 13 + match kind.as_str() { 14 + "undefined-symbol" => match what.as_str() { 15 + what if what.starts_with("_defmt_") => { 16 + eprintln!(); 17 + eprintln!( 18 + "💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`" 19 + ); 20 + eprintln!(); 21 + } 22 + "_stack_start" => { 23 + eprintln!(); 24 + eprintln!("💡 Is the linker script `linkall.x` missing?"); 25 + eprintln!(); 26 + } 27 + what if what.starts_with("esp_rtos_") => { 28 + eprintln!(); 29 + eprintln!( 30 + "💡 `esp-radio` has no scheduler enabled. Make sure you have initialized `esp-rtos` or provided an external scheduler." 31 + ); 32 + eprintln!(); 33 + } 34 + "embedded_test_linker_file_not_added_to_rustflags" => { 35 + eprintln!(); 36 + eprintln!( 37 + "💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests" 38 + ); 39 + eprintln!(); 40 + } 41 + "free" 42 + | "malloc" 43 + | "calloc" 44 + | "get_free_internal_heap_size" 45 + | "malloc_internal" 46 + | "realloc_internal" 47 + | "calloc_internal" 48 + | "free_internal" => { 49 + eprintln!(); 50 + eprintln!( 51 + "💡 Did you forget the `esp-alloc` dependency or didn't enable the `compat` feature on it?" 52 + ); 53 + eprintln!(); 54 + } 55 + _ => (), 56 + }, 57 + // we don't have anything helpful for "missing-lib" yet 58 + _ => { 59 + std::process::exit(1); 60 + } 61 + } 62 + 63 + std::process::exit(0); 64 + } 65 + 66 + println!( 67 + "cargo:rustc-link-arg=--error-handling-script={}", 68 + std::env::current_exe().unwrap().display() 69 + ); 70 + }
+4
rust-toolchain.toml
··· 1 + [toolchain] 2 + channel = "stable" 3 + components = ["rust-src"] 4 + targets = ["riscv32imc-unknown-none-elf"]
+54
src/bin/main.rs
··· 1 + #![no_std] 2 + #![no_main] 3 + #![deny( 4 + clippy::mem_forget, 5 + reason = "mem::forget is generally not safe to do with esp_hal types, especially those \ 6 + holding buffers for the duration of a data transfer." 7 + )] 8 + #![deny(clippy::large_stack_frames)] 9 + 10 + use embassy_executor::Spawner; 11 + use embassy_time::{Duration, Timer}; 12 + use esp_backtrace as _; 13 + use esp_hal::clock::CpuClock; 14 + use esp_hal::timer::timg::TimerGroup; 15 + use log::info; 16 + 17 + extern crate alloc; 18 + 19 + // This creates a default app-descriptor required by the esp-idf bootloader. 20 + // For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description> 21 + esp_bootloader_esp_idf::esp_app_desc!(); 22 + 23 + #[allow( 24 + clippy::large_stack_frames, 25 + reason = "it's not unusual to allocate larger buffers etc. in main" 26 + )] 27 + #[esp_rtos::main] 28 + async fn main(spawner: Spawner) -> ! { 29 + // generator version: 1.2.0 30 + 31 + esp_println::logger::init_logger_from_env(); 32 + 33 + let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max()); 34 + let peripherals = esp_hal::init(config); 35 + 36 + esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 66320); 37 + 38 + let timg0 = TimerGroup::new(peripherals.TIMG0); 39 + let sw_interrupt = 40 + esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); 41 + esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0); 42 + 43 + info!("Embassy initialized!"); 44 + 45 + // TODO: Spawn some tasks 46 + let _ = spawner; 47 + 48 + loop { 49 + info!("Hello world!"); 50 + Timer::after(Duration::from_secs(1)).await; 51 + } 52 + 53 + // for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0/examples 54 + }
+1
src/lib.rs
··· 1 + #![no_std]