├── esp-rom-sys ├── libs │ ├── esp32c2 │ │ └── unused │ ├── esp32c3 │ │ └── unused │ ├── esp32c6 │ │ └── unused │ ├── esp32h2 │ │ └── unused │ ├── esp32s2 │ │ └── unused │ ├── esp32s3 │ │ └── unused │ ├── esp32 │ │ └── libesp_rom.a │ └── README.md ├── ld │ ├── esp32 │ │ ├── libesp_rom_sys.a │ │ ├── rom-functions.x │ │ └── rom │ │ │ ├── esp32.rom.eco3.ld │ │ │ ├── additional.ld │ │ │ └── esp32.rom.spiflash_legacy.ld │ ├── esp32c2 │ │ ├── libesp_rom_sys.a │ │ ├── rom-functions.x │ │ └── rom │ │ │ ├── esp32c2.rom.version.ld │ │ │ └── additional.ld │ ├── esp32c3 │ │ ├── libesp_rom_sys.a │ │ ├── rom │ │ │ ├── esp32c3.rom.version.ld │ │ │ ├── esp32c3.rom.ble_master.ld │ │ │ ├── esp32c3.rom.ble_dtm.ld │ │ │ ├── additional.ld │ │ │ ├── esp32c3.rom.ble_cca.ld │ │ │ ├── esp32c3.rom.ble_test.ld │ │ │ ├── esp32c3.rom.ble_scan.ld │ │ │ └── esp32c3.rom.ble_smp.ld │ │ └── rom-functions.x │ ├── esp32c6 │ │ ├── libesp_rom_sys.a │ │ ├── rom │ │ │ ├── esp32c6.rom.version.ld │ │ │ └── additional.ld │ │ └── rom-functions.x │ ├── esp32h2 │ │ ├── libesp_rom_sys.a │ │ ├── rom-functions.x │ │ └── rom │ │ │ ├── esp32h2.rom.version.ld │ │ │ └── additional.ld │ ├── esp32s2 │ │ ├── libesp_rom_sys.a │ │ ├── rom-functions.x │ │ └── rom │ │ │ └── additional.ld │ └── esp32s3 │ │ ├── libesp_rom_sys.a │ │ ├── rom │ │ ├── esp32s3.rom.version.ld │ │ ├── esp32s3.rom.ble_master.ld │ │ ├── esp32s3.rom.ble_dtm.ld │ │ ├── additional.ld │ │ ├── esp32s3.rom.ble_cca.ld │ │ ├── esp32s3.rom.ble_test.ld │ │ ├── esp32s3.rom.ble_scan.ld │ │ └── esp32s3.rom.ble_smp.ld │ │ └── rom-functions.x ├── src │ └── rom │ │ └── spiflash.rs ├── CHANGELOG.md └── Cargo.toml ├── .gitattributes ├── esp-alloc ├── .clippy.toml ├── src │ └── heap │ │ ├── mod.rs │ │ └── llff.rs ├── build.rs └── esp_config.yml ├── esp-hal ├── .clippy.toml ├── MIGRATING-1.0.0-rc.1.md ├── ld │ ├── sections │ │ ├── eh_frame.x │ │ ├── metadata.x │ │ ├── dram2.x │ │ ├── text.x │ │ ├── fixups │ │ │ └── rtc_fast_rwdata_dummy.x │ │ ├── rodata.x │ │ ├── stack.x │ │ ├── rwtext.x │ │ ├── rtc_slow.x │ │ ├── rtc_fast.x │ │ └── rwdata.x │ ├── esp32 │ │ ├── linkall.x │ │ └── esp32.x │ ├── esp32s2 │ │ ├── linkall.x │ │ └── esp32s2.x │ ├── esp32s3 │ │ ├── linkall.x │ │ └── esp32s3.x │ ├── esp32c2 │ │ └── linkall.x │ ├── esp32c3 │ │ └── linkall.x │ ├── esp32c6 │ │ ├── linkall.x │ │ └── esp32c6.x │ ├── esp32h2 │ │ ├── linkall.x │ │ └── esp32h2.x │ ├── README.md │ └── xtensa │ │ └── hal-defaults.x └── src │ ├── analog │ ├── mod.rs │ └── adc │ │ └── calibration │ │ └── mod.rs │ ├── soc │ ├── esp32c2 │ │ └── mod.rs │ ├── esp32 │ │ ├── mod.rs │ │ └── regi2c.rs │ └── esp32c3 │ │ └── mod.rs │ ├── i2c │ └── mod.rs │ ├── asynch.rs │ ├── i2s │ └── mod.rs │ ├── rom │ └── mod.rs │ └── gpio │ └── placeholder.rs ├── esp-println └── .clippy.toml ├── esp-storage ├── .clippy.toml ├── src │ ├── hardware.rs │ ├── lib.rs │ └── buffer.rs └── build.rs ├── esp-radio ├── MIGRATING-0.16.0.md ├── .clippy.toml ├── src │ ├── memory_fence.rs │ ├── radio │ │ ├── mod.rs │ │ └── radio_esp32s2.rs │ ├── time.rs │ ├── compat │ │ ├── mod.rs │ │ ├── mutex.rs │ │ └── misc.rs │ └── ieee802154 │ │ └── frame.rs └── esp_config.yml ├── resources ├── .prettierrc.json └── 404.html.jinja ├── xtensa-lx-rt ├── src │ └── interrupt.rs ├── interrupt_level_masks.rs.template └── Cargo.toml ├── esp-hal-procmacros └── testdata │ └── ulp_code.elf ├── esp-bootloader-esp-idf ├── testdata │ ├── factory_app_two_ota.bin │ ├── single_factory_no_ota.bin │ ├── single_factory_no_ota.csv │ └── factory_app_two_ota.csv ├── src │ ├── rom.rs │ └── non_rom.rs └── esp_config.yml ├── esp-riscv-rt └── build.rs ├── extras ├── bench-server │ └── Cargo.toml ├── esp-wifishark │ ├── Cargo.toml │ └── README.md └── ieee802154-sniffer │ ├── Cargo.toml │ └── README.md ├── hil-test ├── build.rs ├── .cargo │ └── config.toml └── src │ └── bin │ ├── storage_read_app_desc.rs │ ├── misc_non_drivers │ └── clock_monitor.rs │ ├── misc_non_drivers.rs │ └── esp_radio.rs ├── esp-sync ├── build.rs └── CHANGELOG.md ├── .cargo └── config.toml ├── examples ├── ota │ └── update │ │ ├── partitions.csv │ │ └── .cargo │ │ └── config.toml ├── async │ ├── embassy_rmt_rx │ │ ├── build.rs │ │ └── .cargo │ │ │ └── config.toml │ ├── embassy_rmt_tx │ │ └── .cargo │ │ │ └── config.toml │ ├── embassy_serial │ │ └── .cargo │ │ │ └── config.toml │ ├── embassy_spi │ │ └── .cargo │ │ │ └── config.toml │ ├── embassy_hello_world │ │ ├── .cargo │ │ │ └── config.toml │ │ └── src │ │ │ └── main.rs │ ├── embassy_multicore │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── embassy_multiprio │ │ └── .cargo │ │ │ └── config.toml │ ├── embassy_usb_serial │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── embassy_usb_serial_jtag │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── embassy_multicore_interrupt │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ └── embassy_hello_world_defmt │ │ ├── .cargo │ │ └── config.toml │ │ └── src │ │ └── main.rs ├── ble │ ├── scanner │ │ └── .cargo │ │ │ └── config.toml │ └── bas_peripheral │ │ └── .cargo │ │ └── config.toml ├── esp-now │ ├── esp_now │ │ └── .cargo │ │ │ └── config.toml │ ├── embassy_esp_now │ │ └── .cargo │ │ │ └── config.toml │ └── embassy_esp_now_duplex │ │ └── .cargo │ │ └── config.toml ├── interrupt │ ├── gpio │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ └── uart │ │ ├── .cargo │ │ └── config.toml │ │ └── Cargo.toml ├── peripheral │ ├── hmac │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── touch │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── twai │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── etm_timer │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── lp_core │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ ├── usb_serial │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── debug_assist │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── dma │ │ ├── extmem2mem │ │ │ ├── .cargo │ │ │ │ └── config.toml │ │ │ └── Cargo.toml │ │ └── mem2mem │ │ │ ├── .cargo │ │ │ └── config.toml │ │ │ └── Cargo.toml │ ├── spi │ │ ├── loopback │ │ │ ├── .cargo │ │ │ │ └── config.toml │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── slave_dma │ │ │ ├── .cargo │ │ │ │ └── config.toml │ │ │ └── Cargo.toml │ │ └── loopback_dma_psram │ │ │ ├── .cargo │ │ │ └── config.toml │ │ │ └── Cargo.toml │ └── flash_read_write │ │ └── .cargo │ │ └── config.toml ├── ieee802154 │ ├── ieee802154_sniffer │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── ieee802154_receive_frame │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── src │ │ │ └── main.rs │ │ └── Cargo.toml │ ├── ieee802154_send_frame │ │ ├── .cargo │ │ │ └── config.toml │ │ └── Cargo.toml │ ├── ieee802154_receive_all_frames │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── src │ │ │ └── main.rs │ │ └── Cargo.toml │ └── ieee802154_send_broadcast_frame │ │ ├── .cargo │ │ └── config.toml │ │ └── Cargo.toml └── wifi │ ├── coex │ └── .cargo │ │ └── config.toml │ ├── dhcp │ └── .cargo │ │ └── config.toml │ ├── 80211_tx │ └── .cargo │ │ └── config.toml │ ├── sniffer │ └── .cargo │ │ └── config.toml │ ├── static_ip │ └── .cargo │ │ └── config.toml │ ├── access_point │ └── .cargo │ │ └── config.toml │ ├── embassy_dhcp │ └── .cargo │ │ └── config.toml │ ├── embassy_sntp │ └── .cargo │ │ └── config.toml │ ├── access_point_with_sta │ └── .cargo │ │ └── config.toml │ ├── embassy_access_point │ └── .cargo │ │ └── config.toml │ └── embassy_access_point_with_sta │ └── .cargo │ └── config.toml ├── .github ├── workflows │ └── issue_handler.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.md │ └── bug_report.md ├── PULL_REQUEST_TEMPLATE.md └── rust-matchers.json ├── esp-phy ├── phy_provides.x ├── src │ └── phy_init_data │ │ └── mod.rs ├── esp_config.yml ├── CHANGELOG.md ├── build.rs └── README.md ├── qa-test ├── build.rs ├── src │ └── bin │ │ ├── temperature_sensor.rs │ │ ├── sleep_timer.rs │ │ ├── i2c_bmp180_calibration_data.rs │ │ └── i2c_ssd1306_length_test.rs └── .cargo │ └── config.toml ├── rustfmt.toml ├── esp-metadata-generated ├── rustfmt.toml └── Cargo.toml ├── esp-backtrace └── esp_config.yml ├── esp-lp-hal ├── .cargo │ └── config.toml ├── examples │ ├── i2c.rs │ ├── uart.rs │ └── blinky.rs ├── build.rs └── ld │ ├── link-ulp.x │ └── link-lp.x ├── esp-rtos ├── esp_config.yml └── build.rs ├── Cargo.toml ├── xtensa-lx └── Cargo.toml ├── .gitignore ├── xtensa-lx-rt-proc-macros └── Cargo.toml ├── .lycheeignore ├── esp-metadata ├── src │ └── cfg │ │ ├── rsa.rs │ │ └── aes.rs └── Cargo.toml ├── LICENSE-MIT └── esp-config └── src └── generate └── markdown.rs /esp-rom-sys/libs/esp32c2/unused: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/esp32c3/unused: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/esp32c6/unused: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/esp32h2/unused: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/esp32s2/unused: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/esp32s3/unused: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | CHANGELOG.md merge=union 2 | -------------------------------------------------------------------------------- /esp-alloc/.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | -------------------------------------------------------------------------------- /esp-hal/.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | -------------------------------------------------------------------------------- /esp-println/.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-storage/.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | -------------------------------------------------------------------------------- /esp-radio/MIGRATING-0.16.0.md: -------------------------------------------------------------------------------- 1 | # Migration Guide from 0.16.0 to 0.17.0 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c2/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c6/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32h2/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s2/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/libesp_rom_sys.a: -------------------------------------------------------------------------------- 1 | INCLUDE "rom-functions.x" 2 | -------------------------------------------------------------------------------- /esp-hal/MIGRATING-1.0.0-rc.1.md: -------------------------------------------------------------------------------- 1 | # Migration Guide from 1.0.0-rc.1 to 1.0.0 2 | -------------------------------------------------------------------------------- /resources/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "tabWidth": 2 4 | } 5 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/eh_frame.x: -------------------------------------------------------------------------------- 1 | SECTIONS { 2 | .eh_frame 0 (INFO) : 3 | { 4 | KEEP(*(.eh_frame)); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/esp32/libesp_rom.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjoernQ/esp-hal/main/esp-rom-sys/libs/esp32/libesp_rom.a -------------------------------------------------------------------------------- /xtensa-lx-rt/src/interrupt.rs: -------------------------------------------------------------------------------- 1 | //! Interrupts 2 | 3 | include!(concat!(env!("OUT_DIR"), "/interrupt_level_masks.rs")); 4 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | INCLUDE "alias.x" 3 | INCLUDE "esp32.x" 4 | INCLUDE "hal-defaults.x" 5 | 6 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32s2/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | INCLUDE "alias.x" 3 | INCLUDE "esp32s2.x" 4 | INCLUDE "hal-defaults.x" 5 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32s3/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | INCLUDE "alias.x" 3 | INCLUDE "esp32s3.x" 4 | INCLUDE "hal-defaults.x" 5 | -------------------------------------------------------------------------------- /esp-hal-procmacros/testdata/ulp_code.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjoernQ/esp-hal/main/esp-hal-procmacros/testdata/ulp_code.elf -------------------------------------------------------------------------------- /esp-hal/ld/sections/metadata.x: -------------------------------------------------------------------------------- 1 | SECTIONS { 2 | .espressif.metadata 0 (INFO) : 3 | { 4 | KEEP(*(.espressif.metadata)); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/testdata/factory_app_two_ota.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjoernQ/esp-hal/main/esp-bootloader-esp-idf/testdata/factory_app_two_ota.bin -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/testdata/single_factory_no_ota.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjoernQ/esp-hal/main/esp-bootloader-esp-idf/testdata/single_factory_no_ota.bin -------------------------------------------------------------------------------- /esp-riscv-rt/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | // required for `riscv-rt-macros` to actually generate code 3 | println!("cargo:rustc-env=RISCV_RT_BASE_ISA=rv32i"); 4 | } 5 | -------------------------------------------------------------------------------- /extras/bench-server/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bench-server" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | pretty_env_logger = "0.5.0" 8 | log = "0.4.0" -------------------------------------------------------------------------------- /esp-hal/ld/sections/dram2.x: -------------------------------------------------------------------------------- 1 | /* an uninitialized section of RAM otherwise not useable */ 2 | SECTIONS { 3 | .dram2_uninit (NOLOAD) : ALIGN(4) { 4 | *(.dram2_uninit) 5 | } > dram2_seg 6 | } 7 | -------------------------------------------------------------------------------- /esp-radio/.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | 3 | [[disallowed-types]] 4 | path = "core::time::Duration" 5 | reason = "Use `esp_hal::time::Duration` instead of `core::time::Duration`" 6 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s2/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32s2.rom.api.ld" 2 | INCLUDE "rom/esp32s2.rom.ld" 3 | INCLUDE "rom/esp32s2.rom.libgcc.ld" 4 | INCLUDE "rom/esp32s2.rom.spiflash_legacy.ld" 5 | 6 | INCLUDE "rom/additional.ld" 7 | -------------------------------------------------------------------------------- /esp-radio/src/memory_fence.rs: -------------------------------------------------------------------------------- 1 | pub(crate) fn memory_fence() { 2 | #[cfg(xtensa)] 3 | unsafe { 4 | core::arch::asm!("memw"); 5 | } 6 | 7 | #[cfg(riscv)] 8 | unsafe { 9 | core::arch::asm!("fence"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32c2/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | 3 | REGION_ALIAS("ROTEXT", IROM); 4 | REGION_ALIAS("RODATA", DROM); 5 | 6 | REGION_ALIAS("RWDATA", DRAM); 7 | REGION_ALIAS("RWTEXT", IRAM); 8 | 9 | INCLUDE "esp32c2.x" 10 | INCLUDE "hal-defaults.x" 11 | -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/testdata/single_factory_no_ota.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 1M, 6 | -------------------------------------------------------------------------------- /extras/esp-wifishark/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "esp-wifishark" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | r-extcap = "0.2.4" 8 | pcap-file = "2.0.0" 9 | serialport = "4.2.1" 10 | clap = { version = "4.3.5", features = ["derive"] } 11 | -------------------------------------------------------------------------------- /extras/ieee802154-sniffer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sniffer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | r-extcap = "0.2.4" 8 | pcap-file = "2.0.0" 9 | serialport = "4.2.0" 10 | clap = { version = "4.1.7", features = ["derive"] } 11 | -------------------------------------------------------------------------------- /hil-test/build.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | fn main() -> Result<(), Box> { 4 | // Define all necessary configuration symbols for the configured device: 5 | esp_metadata_generated::Chip::from_cargo_feature()?.define_cfgs(); 6 | 7 | Ok(()) 8 | } 9 | -------------------------------------------------------------------------------- /esp-alloc/src/heap/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(heap_algorithm_llff)] 2 | mod llff; 3 | #[cfg(heap_algorithm_tlsf)] 4 | mod tlsf; 5 | 6 | #[cfg(heap_algorithm_llff)] 7 | pub(crate) use llff::LlffHeap as Heap; 8 | #[cfg(heap_algorithm_tlsf)] 9 | pub(crate) use tlsf::TlsfHeap as Heap; 10 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/text.x: -------------------------------------------------------------------------------- 1 | 2 | 3 | SECTIONS { 4 | 5 | .text : ALIGN(4) 6 | { 7 | #IF riscv 8 | KEEP(*(.init)); 9 | KEEP(*(.init.rust)); 10 | KEEP(*(.text.abort)); 11 | #ENDIF 12 | *(.literal .text .literal.* .text.*) 13 | } > ROTEXT 14 | 15 | } -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c2/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32c2.rom.api.ld" 2 | INCLUDE "rom/esp32c2.rom.heap.ld" 3 | INCLUDE "rom/esp32c2.rom.ld" 4 | INCLUDE "rom/esp32c2.rom.libgcc.ld" 5 | INCLUDE "rom/esp32c2.rom.rvfp.ld" 6 | INCLUDE "rom/esp32c2.rom.version.ld" 7 | 8 | INCLUDE "rom/additional.ld" 9 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32h2/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32h2.rom.api.ld" 2 | INCLUDE "rom/esp32h2.rom.heap.ld" 3 | INCLUDE "rom/esp32h2.rom.ld" 4 | INCLUDE "rom/esp32h2.rom.libgcc.ld" 5 | INCLUDE "rom/esp32h2.rom.spiflash.ld" 6 | INCLUDE "rom/esp32h2.rom.version.ld" 7 | 8 | INCLUDE "rom/additional.ld" 9 | -------------------------------------------------------------------------------- /esp-sync/build.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | fn main() -> Result<(), Box> { 4 | // Define all necessary configuration symbols for the configured device: 5 | let chip = esp_metadata_generated::Chip::from_cargo_feature()?; 6 | chip.define_cfgs(); 7 | 8 | Ok(()) 9 | } 10 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.version.ld: -------------------------------------------------------------------------------- 1 | /* ROM version variables for esp32c3 2 | * 3 | * These addresses should be compatible with any ROM version for this chip. 4 | * 5 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 6 | */ 7 | _rom_chip_id = 0x40000010; 8 | _rom_eco_version = 0x40000014; 9 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.version.ld: -------------------------------------------------------------------------------- 1 | /* ROM version variables for esp32s3 2 | * 3 | * These addresses should be compatible with any ROM version for this chip. 4 | * 5 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 6 | */ 7 | _rom_chip_id = 0x40000570; 8 | _rom_eco_version = 0x40000574; 9 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32.rom.api.ld" 2 | INCLUDE "rom/esp32.rom.eco3.ld" 3 | INCLUDE "rom/esp32.rom.ld" 4 | INCLUDE "rom/esp32.rom.libgcc.ld" 5 | INCLUDE "rom/esp32.rom.redefined.ld" 6 | INCLUDE "rom/esp32.rom.spiflash_legacy.ld" 7 | INCLUDE "rom/esp32.rom.syscalls.ld" 8 | 9 | INCLUDE "rom/additional.ld" 10 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32c3/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | 3 | REGION_ALIAS("ROTEXT", IROM); 4 | REGION_ALIAS("RODATA", DROM); 5 | 6 | REGION_ALIAS("RWDATA", DRAM); 7 | REGION_ALIAS("RWTEXT", IRAM); 8 | 9 | REGION_ALIAS("RTC_FAST_RWTEXT", RTC_FAST); 10 | REGION_ALIAS("RTC_FAST_RWDATA", RTC_FAST); 11 | 12 | INCLUDE "esp32c3.x" 13 | INCLUDE "hal-defaults.x" 14 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32c6/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | 3 | REGION_ALIAS("ROTEXT", ROM); 4 | REGION_ALIAS("RODATA", ROM); 5 | 6 | REGION_ALIAS("RWTEXT", RAM); 7 | REGION_ALIAS("RWDATA", RAM); 8 | 9 | REGION_ALIAS("RTC_FAST_RWTEXT", RTC_FAST); 10 | REGION_ALIAS("RTC_FAST_RWDATA", RTC_FAST); 11 | 12 | INCLUDE "esp32c6.x" 13 | INCLUDE "hal-defaults.x" 14 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32h2/linkall.x: -------------------------------------------------------------------------------- 1 | INCLUDE "memory.x" 2 | 3 | REGION_ALIAS("ROTEXT", ROM); 4 | REGION_ALIAS("RODATA", ROM); 5 | 6 | REGION_ALIAS("RWTEXT", RAM); 7 | REGION_ALIAS("RWDATA", RAM); 8 | 9 | REGION_ALIAS("RTC_FAST_RWTEXT", RTC_FAST); 10 | REGION_ALIAS("RTC_FAST_RWDATA", RTC_FAST); 11 | 12 | INCLUDE "esp32h2.x" 13 | INCLUDE "hal-defaults.x" 14 | -------------------------------------------------------------------------------- /esp-hal/src/analog/mod.rs: -------------------------------------------------------------------------------- 1 | //! # Analog Peripherals 2 | //! 3 | //! ## Overview 4 | //! The `analog` module provides drivers for the various analog peripherals 5 | //! available on the device. For more information about a peripheral driver, 6 | //! please refer to the relevant module documentation. 7 | 8 | #[cfg(adc)] 9 | pub mod adc; 10 | #[cfg(dac)] 11 | pub mod dac; 12 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | xtask = "run --package xtask --" 3 | xclean = "xtask clean" 4 | xdoc = "run --package xtask --features=deploy-docs,preview-docs --" 5 | xfmt = "xtask fmt-packages" 6 | qa = "xtask run example qa-test" 7 | xcheck = "run --quiet --package xtask --features=semver-checks --" 8 | xrelease = "run --package xtask --features=release -- release" 9 | -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/testdata/factory_app_two_ota.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs, data, nvs, 0x9000, 0x4000, 4 | otadata, data, ota, 0xd000, 0x2000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 1M, 7 | ota_0, app, ota_0, 0x110000, 1M, 8 | ota_1, app, ota_1, 0x210000, 1M, 9 | -------------------------------------------------------------------------------- /examples/ota/update/partitions.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | nvs, data, nvs, 0x9000, 0x4000, 4 | otadata, data, ota, 0xd000, 0x2000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x100000, 7 | ota_0, app, ota_0, 0x110000, 0x100000, 8 | ota_1, app, ota_1, 0x210000, 0x100000, 9 | -------------------------------------------------------------------------------- /esp-alloc/build.rs: -------------------------------------------------------------------------------- 1 | use esp_config::generate_config_from_yaml_definition; 2 | 3 | fn main() { 4 | // emit config 5 | println!("cargo:rerun-if-changed=./esp_config.yml"); 6 | let cfg_yaml = std::fs::read_to_string("./esp_config.yml") 7 | .expect("Failed to read esp_config.yml for esp-alloc"); 8 | generate_config_from_yaml_definition(&cfg_yaml, true, true, None).unwrap(); 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/issue_handler.yml: -------------------------------------------------------------------------------- 1 | name: Add new issues to project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | 8 | jobs: 9 | add-to-project: 10 | name: Add issue to project 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/add-to-project@v0.5.0 14 | with: 15 | project-url: https://github.com/orgs/esp-rs/projects/2 16 | github-token: ${{ secrets.PAT }} -------------------------------------------------------------------------------- /esp-alloc/esp_config.yml: -------------------------------------------------------------------------------- 1 | crate: esp-alloc 2 | 3 | options: 4 | - name: heap_algorithm 5 | description: "The heap algorithm to use. TLSF offers higher performance 6 | and bounded allocation time, but uses more memory." 7 | default: 8 | - value: '"LLFF"' 9 | constraints: 10 | - type: 11 | validator: enumeration 12 | value: 13 | - "LLFF" 14 | - "TLSF" 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Ask questions in Matrix channel (Recommended) 4 | url: https://matrix.to/#/#esp-rs:matrix.org 5 | about: Ask any questions directly in our Matrix channel. 6 | - name: Ask questions in GitHub Discussions 7 | url: https://github.com/esp-rs/esp-hal/discussions/new 8 | about: Post your questions and engage in discussions via GitHub. 9 | -------------------------------------------------------------------------------- /esp-phy/phy_provides.x: -------------------------------------------------------------------------------- 1 | EXTERN( __esp_phy_enter_critical ); 2 | EXTERN( __esp_phy_exit_critical ); 3 | EXTERN( __esp_phy_esp_dport_access_reg_read ); 4 | EXTERN( __esp_phy_rtc_get_xtal ); 5 | 6 | PROVIDE( phy_enter_critical = __esp_phy_enter_critical ); 7 | PROVIDE( phy_exit_critical = __esp_phy_exit_critical ); 8 | PROVIDE( esp_dport_access_reg_read = __esp_phy_esp_dport_access_reg_read ); 9 | PROVIDE( rtc_get_xtal = __esp_phy_rtc_get_xtal ); 10 | -------------------------------------------------------------------------------- /esp-radio/src/radio/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(esp32, path = "radio_esp32.rs")] 2 | #[cfg_attr(esp32c2, path = "radio_esp32c2.rs")] 3 | #[cfg_attr(esp32c3, path = "radio_esp32c3.rs")] 4 | #[cfg_attr(esp32c6, path = "radio_esp32c6.rs")] 5 | #[cfg_attr(esp32h2, path = "radio_esp32h2.rs")] 6 | #[cfg_attr(esp32s3, path = "radio_esp32s3.rs")] 7 | #[cfg_attr(esp32s2, path = "radio_esp32s2.rs")] 8 | mod chip_specific; 9 | 10 | pub(crate) use chip_specific::*; 11 | -------------------------------------------------------------------------------- /esp-hal/ld/README.md: -------------------------------------------------------------------------------- 1 | # ROM functions 2 | 3 | Files in the `rom` subdirectories are taken from esp-idf 4 | 5 | - DON'T include any `*newlib*` functions 6 | - systimer, wdt and mbedtls shouldn't be included 7 | - make sure to align the version you take the files from with esp-wifi-sys - NEVER randomly sync the files with other versions 8 | - some additional functions are needed from ROM - see `additional.ld` (these are usually defined in the `*newlib*` files) 9 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c6/rom/esp32c6.rom.version.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM version variables for esp32c6 7 | * 8 | * These addresses should be compatible with any ROM version for this chip. 9 | * 10 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 11 | */ 12 | _rom_chip_id = 0x40000010; 13 | _rom_eco_version = 0x40000014; 14 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32h2/rom/esp32h2.rom.version.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM version variables for esp32h2 7 | * 8 | * These addresses should be compatible with any ROM version for this chip. 9 | * 10 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 11 | */ 12 | _rom_chip_id = 0x40000010; 13 | _rom_eco_version = 0x40000014; 14 | -------------------------------------------------------------------------------- /esp-rom-sys/libs/README.md: -------------------------------------------------------------------------------- 1 | The libs directory may contain `libesp_rom.a` (or any other static library) meant to patch ROM functions. 2 | 3 | Additionally you can have a `add_rwtext` file which adds to the `.rwtext` section. 4 | 5 | Remember the linker scripts usually define the ROM functions weakly which means we can patch them. 6 | 7 | Patches for all chips should originate from one ESP-IDF version only and that should be documented in the crate's README.md. 8 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32/rom/esp32.rom.eco3.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ESP32 ECO3 ROM address table 3 | Secure Boot Version 2 API's imported from the ROM 4 | */ 5 | PROVIDE ( ets_secure_boot_verify_signature = 0x4006543c); 6 | PROVIDE ( ets_secure_boot_verify_boot_bootloader = 0x400655ec); 7 | PROVIDE ( ets_use_secure_boot_v2 = 0x4000f8d4); 8 | PROVIDE ( ets_rsa_pss_verify = 0x40065310); 9 | PROVIDE ( ets_mgf1_sha256 = 0x400651a8); 10 | PROVIDE ( ets_emsa_pss_verify = 0x4006520c); 11 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c2/rom/esp32c2.rom.version.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /* ROM version variables for esp32c2 8 | * 9 | * These addresses should be compatible with any ROM version for this chip. 10 | * 11 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 12 | */ 13 | _rom_chip_id = 0x40000010; 14 | _rom_eco_version = 0x40000014; 15 | -------------------------------------------------------------------------------- /qa-test/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | // Allow building QA tests in CI in debug mode 3 | println!("cargo:rustc-check-cfg=cfg(is_not_release)"); 4 | println!("cargo:rerun-if-env-changed=CI"); 5 | if std::env::var("CI").is_err() { 6 | if let Ok(level) = std::env::var("OPT_LEVEL") { 7 | if level == "0" || level == "1" { 8 | println!("cargo::rustc-cfg=is_not_release"); 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2024" 2 | 3 | # Comments 4 | format_code_in_doc_comments = true 5 | normalize_comments = true 6 | wrap_comments = true 7 | 8 | # Code in comments 9 | doc_comment_code_block_width = 100 10 | comment_width = 100 11 | 12 | # Enums 13 | enum_discrim_align_threshold = 35 14 | 15 | # Imports 16 | group_imports = "StdExternalCrate" 17 | imports_granularity = "Crate" 18 | imports_layout = "HorizontalVertical" 19 | -------------------------------------------------------------------------------- /examples/async/embassy_rmt_rx/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | // Allow building examples in CI in debug mode 3 | println!("cargo:rustc-check-cfg=cfg(is_not_release)"); 4 | println!("cargo:rerun-if-env-changed=CI"); 5 | if std::env::var("CI").is_err() { 6 | if let Ok(level) = std::env::var("OPT_LEVEL") { 7 | if level == "0" || level == "1" { 8 | println!("cargo::rustc-cfg=is_not_release"); 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32/esp32.x: -------------------------------------------------------------------------------- 1 | INCLUDE exception.x 2 | 3 | /* ESP32 fixups */ 4 | INCLUDE "fixups/rtc_fast_rwdata_dummy.x" 5 | /* END ESP32 fixups */ 6 | 7 | /* Shared sections - ordering matters */ 8 | SECTIONS { 9 | INCLUDE "rwtext.x" 10 | INCLUDE "rwdata.x" 11 | } 12 | INCLUDE "rodata.x" 13 | INCLUDE "text.x" 14 | INCLUDE "rtc_fast.x" 15 | INCLUDE "rtc_slow.x" 16 | INCLUDE "stack.x" 17 | INCLUDE "dram2.x" 18 | INCLUDE "metadata.x" 19 | INCLUDE "eh_frame.x" 20 | /* End of Shared sections */ 21 | -------------------------------------------------------------------------------- /esp-hal/src/soc/esp32c2/mod.rs: -------------------------------------------------------------------------------- 1 | //! # SOC (System-on-Chip) module (ESP32-C2) 2 | //! 3 | //! ## Overview 4 | //! 5 | //! The `SOC` module provides access, functions and structures that are useful 6 | //! for interacting with various system-related peripherals on `ESP32-C2` chip. 7 | 8 | crate::unstable_module! { 9 | pub mod clocks; 10 | pub mod trng; 11 | } 12 | pub mod gpio; 13 | pub(crate) mod regi2c; 14 | 15 | pub(crate) use esp32c2 as pac; 16 | 17 | pub(crate) fn pre_init() {} 18 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c6/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32c6.rom.api.ld" 2 | INCLUDE "rom/esp32c6.rom.coexist.ld" 3 | INCLUDE "rom/esp32c6.rom.heap.ld" 4 | INCLUDE "rom/esp32c6.rom.ld" 5 | INCLUDE "rom/esp32c6.rom.libgcc.ld" 6 | INCLUDE "rom/esp32c6.rom.net80211.ld" 7 | INCLUDE "rom/esp32c6.rom.phy.ld" 8 | INCLUDE "rom/esp32c6.rom.pp.ld" 9 | INCLUDE "rom/esp32c6.rom.rvfp.ld" 10 | INCLUDE "rom/esp32c6.rom.spiflash.ld" 11 | INCLUDE "rom/esp32c6.rom.version.ld" 12 | 13 | INCLUDE "rom/additional.ld" 14 | -------------------------------------------------------------------------------- /esp-phy/src/phy_init_data/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(esp32c3, path = "phy_init_data_esp32c3.rs")] 2 | #[cfg_attr(esp32c2, path = "phy_init_data_esp32c2.rs")] 3 | #[cfg_attr(esp32c6, path = "phy_init_data_esp32c6.rs")] 4 | #[cfg_attr(esp32h2, path = "phy_init_data_esp32h2.rs")] 5 | #[cfg_attr(esp32, path = "phy_init_data_esp32.rs")] 6 | #[cfg_attr(esp32s3, path = "phy_init_data_esp32s3.rs")] 7 | #[cfg_attr(esp32s2, path = "phy_init_data_esp32s2.rs")] 8 | mod chip_phy_init_data; 9 | pub(crate) use chip_phy_init_data::PHY_INIT_DATA_DEFAULT; 10 | -------------------------------------------------------------------------------- /esp-radio/src/time.rs: -------------------------------------------------------------------------------- 1 | //! Time conversions 2 | //! 3 | //! We're using 1ms per tick, to offer a decent-ish timeout range on u32. 4 | 5 | #![allow(unused)] 6 | 7 | pub(crate) const fn blob_ticks_to_micros(ticks: u32) -> u32 { 8 | ticks.saturating_mul(1_000) 9 | } 10 | 11 | pub(crate) const fn micros_to_blob_ticks(micros: u32) -> u32 { 12 | micros / 1_000 13 | } 14 | 15 | pub(crate) const fn blob_ticks_to_millis(ticks: u32) -> u32 { 16 | ticks 17 | } 18 | 19 | pub(crate) const fn millis_to_blob_ticks(millis: u32) -> u32 { 20 | millis 21 | } 22 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/fixups/rtc_fast_rwdata_dummy.x: -------------------------------------------------------------------------------- 1 | /* 2 | This fix up is required when the RTC fast memory is split across two address spaces. 3 | This fix up pads the _data bus_ address space by the size of the code accessed by the instruction bus. 4 | */ 5 | 6 | SECTIONS { 7 | .rtc_fast.dummy (NOLOAD) : 8 | { 9 | _rtc_dummy_start = ABSOLUTE(.); /* needed to make section proper size */ 10 | . = . + SIZEOF(.rtc_fast.text); 11 | _rtc_dummy_end = ABSOLUTE(.); /* needed to make section proper size */ 12 | } > RTC_FAST_RWDATA 13 | } 14 | INSERT BEFORE .rtc_fast.data; -------------------------------------------------------------------------------- /esp-hal/src/analog/adc/calibration/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))] 2 | pub use self::basic::AdcCalBasic; 3 | #[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))] 4 | pub use self::curve::{AdcCalCurve, AdcHasCurveCal}; 5 | #[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))] 6 | pub use self::line::{AdcCalLine, AdcHasLineCal}; 7 | 8 | #[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))] 9 | mod basic; 10 | #[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))] 11 | mod curve; 12 | #[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))] 13 | mod line; 14 | -------------------------------------------------------------------------------- /esp-metadata-generated/rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2024" 2 | 3 | # Comments 4 | format_code_in_doc_comments = true 5 | normalize_comments = true 6 | normalize_doc_attributes = true 7 | wrap_comments = true 8 | 9 | # Code in comments 10 | doc_comment_code_block_width = 100 11 | comment_width = 100 12 | format_strings = true 13 | 14 | # Enums 15 | enum_discrim_align_threshold = 35 16 | 17 | # Imports 18 | group_imports = "StdExternalCrate" 19 | imports_granularity = "Crate" 20 | imports_layout = "HorizontalVertical" 21 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/rodata.x: -------------------------------------------------------------------------------- 1 | SECTIONS { 2 | /* For ESP App Description, must be placed first in image */ 3 | .rodata_desc : ALIGN(4) 4 | { 5 | KEEP(*(.rodata_desc)); 6 | KEEP(*(.rodata_desc.*)); 7 | } > RODATA 8 | 9 | .rodata : ALIGN(4) 10 | { 11 | . = ALIGN (4); 12 | _rodata_start = ABSOLUTE(.); 13 | *(.rodata .rodata.*) 14 | *(.srodata .srodata.*) 15 | . = ALIGN(4); 16 | _rodata_end = ABSOLUTE(.); 17 | } > RODATA 18 | 19 | .rodata.wifi : ALIGN(4) 20 | { 21 | . = ALIGN(4); 22 | *( .rodata_wlog_*.* ) 23 | . = ALIGN(4); 24 | } > RODATA 25 | } 26 | -------------------------------------------------------------------------------- /examples/ble/scanner/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: ["feature request", "bug jury"] 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Motivations 11 | 12 | 13 | 14 | ## Solution 15 | 16 | 17 | 18 | ## Alternatives 19 | 20 | 21 | 22 | ## Additional context 23 | 24 | -------------------------------------------------------------------------------- /esp-backtrace/esp_config.yml: -------------------------------------------------------------------------------- 1 | crate: esp-backtrace 2 | 3 | options: 4 | - name: backtrace_frames 5 | description: The maximum number of frames that will be printed in a backtrace. 6 | default: 7 | - value: 10 8 | 9 | - name: stack-dump-max-size 10 | description: Max amount of stack to dump. 11 | default: 12 | - value: '"8K"' 13 | constraints: 14 | - type: 15 | validator: enumeration 16 | value: 17 | - '4K' 18 | - '8K' 19 | - '16K' 20 | - '32K' 21 | active: 'chip == "esp32c2" || chip == "esp32c3" || chip == "esp32c6" || chip == "esp32h2"' 22 | -------------------------------------------------------------------------------- /examples/esp-now/esp_now/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/interrupt/gpio/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/interrupt/uart/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/hmac/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/touch/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/twai/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/stack.x: -------------------------------------------------------------------------------- 1 | SECTIONS { 2 | /* must be last segment using RWDATA */ 3 | .stack (NOLOAD) : ALIGN(4) 4 | { 5 | _stack_end = ABSOLUTE(.); 6 | _stack_end_cpu0 = ABSOLUTE(.); 7 | 8 | /* The stack_guard for `stack-protector` mitigation - https://doc.rust-lang.org/rustc/exploit-mitigations.html#stack-smashing-protection */ 9 | __stack_chk_guard = ABSOLUTE(_stack_end) + ${ESP_HAL_CONFIG_STACK_GUARD_OFFSET}; 10 | 11 | . = ORIGIN(RWDATA) + LENGTH(RWDATA); 12 | 13 | . = ALIGN (4); 14 | _stack_start = ABSOLUTE(.); 15 | _stack_start_cpu0 = ABSOLUTE(.); 16 | } > RWDATA 17 | } 18 | -------------------------------------------------------------------------------- /examples/async/embassy_rmt_rx/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_rmt_tx/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_serial/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_spi/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/ble/bas_peripheral/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/etm_timer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/lp_core/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/usb_serial/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32s3.rom.api.ld" 2 | INCLUDE "rom/esp32s3.rom.ld" 3 | INCLUDE "rom/esp32s3.rom.libgcc.ld" 4 | INCLUDE "rom/esp32s3.rom.version.ld" 5 | 6 | /* 7 | TODO if BT_CTRL_RUN_IN_FLASH_ONLY 8 | 9 | INCLUDE "rom/esp32s3.rom.ble_50.ld" 10 | INCLUDE "rom/esp32s3.rom.ble_cca.ld" 11 | INCLUDE "rom/esp32s3.rom.ble_dtm.ld" 12 | INCLUDE "rom/esp32s3.rom.ble_master.ld" 13 | INCLUDE "rom/esp32s3.rom.ble_scan.ld" 14 | INCLUDE "rom/esp32s3.rom.ble_smp.ld" 15 | INCLUDE "rom/esp32s3.rom.ble_test.ld" 16 | */ 17 | 18 | INCLUDE "rom/esp32s3.rom.bt_funcs.ld" 19 | 20 | INCLUDE "rom/additional.ld" 21 | -------------------------------------------------------------------------------- /examples/async/embassy_hello_world/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_multicore/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_multiprio/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_usb_serial/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/esp-now/embassy_esp_now/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/debug_assist/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/dma/extmem2mem/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/dma/mem2mem/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/spi/loopback/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/spi/slave_dma/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_usb_serial_jtag/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/esp-now/embassy_esp_now_duplex/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_sniffer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/flash_read_write/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/async/embassy_multicore_interrupt/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_receive_frame/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_send_frame/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/peripheral/spi/loopback_dma_psram/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /esp-lp-hal/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | esp32c6 = "build --release --examples --features=esp32c6 --target riscv32imac-unknown-none-elf" 3 | esp32s2 = "build --release --example=blinky --features=esp32s2 --target riscv32imc-unknown-none-elf" 4 | esp32s3 = "build --release --example=blinky --features=esp32s3 --target riscv32imc-unknown-none-elf" 5 | 6 | [build] 7 | # target = "riscv32imc-unknown-none-elf" # ESP32-S2 + ESP32-S3 8 | target = "riscv32imac-unknown-none-elf" # ESP32-C6 9 | 10 | [target.'cfg(target_arch = "riscv32")'] 11 | rustflags = [ 12 | "-C", "link-arg=-Tlink.x", 13 | ] 14 | 15 | [unstable] 16 | build-std = ["core"] 17 | -------------------------------------------------------------------------------- /esp-phy/esp_config.yml: -------------------------------------------------------------------------------- 1 | crate: esp-phy 2 | 3 | options: 4 | - name: phy_enable_usb 5 | description: "Keeps USB running when using WiFi. 6 | This allows debugging and log messages via USB Serial JTAG. 7 | Turn off for best WiFi performance." 8 | default: 9 | - value: true 10 | 11 | - name: phy_skip_calibration_after_deep_sleep 12 | description: "Use PHY_RF_CAL_NONE after deep sleep." 13 | default: 14 | - value: false 15 | 16 | - name: phy_full_calibration 17 | description: "Use PHY_RF_CAL_FULL instead of PHY_RF_CAL_PARTIAL." 18 | default: 19 | - value: true 20 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_receive_all_frames/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_send_broadcast_frame/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["core", "alloc"] 25 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.ble_master.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32c3.rom.ld for esp32c3 7 | * 8 | * 9 | * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* master */ 17 | f_hci_le_create_con_cmd_handler = 0; 18 | f_hci_le_create_con_cancel_cmd_handler = 0; 19 | lld_init_end_ind_handler = 0; 20 | r_lld_init_init = 0; 21 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c6/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memset = 0x400004a8; 2 | memcpy = 0x400004ac; 3 | memmove = 0x400004b0; 4 | memcmp = 0x400004b4; 5 | 6 | strncmp = 0x400004c4; 7 | strncpy = 0x400004bc; 8 | strcpy = 0x400004b8; 9 | 10 | abs = 0x40000578; 11 | 12 | PROVIDE(strcat = 0x4000052c); 13 | PROVIDE(strcmp = 0x400004c0); 14 | PROVIDE(strchr = 0x40000534); 15 | PROVIDE(strlcpy = 0x40000544); 16 | PROVIDE(strstr = 0x400004cc); 17 | PROVIDE(strcasecmp = 0x40000524); 18 | 19 | EXTERN(__mktime); 20 | EXTERN(__strnlen); 21 | EXTERN(__atoi); 22 | 23 | PROVIDE ( strnlen = __strnlen ); 24 | PROVIDE ( atoi = __atoi ); 25 | PROVIDE ( mktime = __mktime ); 26 | 27 | syscall_table_ptr = 0x4087ffd4; 28 | -------------------------------------------------------------------------------- /examples/async/embassy_hello_world_defmt/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "link-arg=-Tdefmt.x", 6 | "-C", "force-frame-pointers", 7 | ] 8 | 9 | [target.'cfg(target_arch = "xtensa")'] 10 | runner = "espflash flash --monitor" 11 | rustflags = [ 12 | # GNU LD 13 | "-C", "link-arg=-Wl,-Tlinkall.x", 14 | "-C", "link-arg=-Tdefmt.x", 15 | "-C", "link-arg=-nostartfiles", 16 | 17 | # LLD 18 | # "-C", "link-arg=-Tlinkall.x", 19 | # "-C", "linker=rust-lld", 20 | ] 21 | 22 | [env] 23 | DEFMT_LOG = "info" 24 | 25 | [unstable] 26 | build-std = ["core"] 27 | -------------------------------------------------------------------------------- /esp-hal/ld/xtensa/hal-defaults.x: -------------------------------------------------------------------------------- 1 | ENTRY(Reset) 2 | 3 | PROVIDE(__zero_bss = default_mem_hook); 4 | PROVIDE(__init_data = default_mem_hook); 5 | PROVIDE(__init_persistent = default_mem_hook); 6 | PROVIDE(__post_init = no_init_hook); 7 | 8 | PROVIDE(DefaultHandler = EspDefaultHandler); 9 | 10 | PROVIDE(level1_interrupt = DefaultHandler); 11 | PROVIDE(level2_interrupt = DefaultHandler); 12 | PROVIDE(level3_interrupt = DefaultHandler); 13 | PROVIDE(level4_interrupt = DefaultHandler); 14 | PROVIDE(level5_interrupt = DefaultHandler); 15 | PROVIDE(level6_interrupt = DefaultHandler); 16 | PROVIDE(level7_interrupt = DefaultHandler); 17 | 18 | /* external interrupts (from PAC) */ 19 | INCLUDE "device.x" 20 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.ble_master.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32s3.rom.ld for esp32s3 7 | * 8 | * 9 | * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* master */ 17 | f_hci_le_create_con_cmd_handler = 0x40000000; 18 | f_hci_le_create_con_cancel_cmd_handler = 0x40000000; 19 | lld_init_end_ind_handler = 0x40000000; 20 | r_lld_init_init = 0x40000000; 21 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32s2/esp32s2.x: -------------------------------------------------------------------------------- 1 | INCLUDE exception.x 2 | 3 | /* This represents .rwtext but in .data */ 4 | SECTIONS { 5 | .rwdata_dummy (NOLOAD) : ALIGN(4) 6 | { 7 | . = . + SIZEOF(.rwtext) + SIZEOF(.rwtext.wifi); 8 | } > RWDATA 9 | } 10 | INSERT BEFORE .data; 11 | 12 | INCLUDE "fixups/rtc_fast_rwdata_dummy.x" 13 | /* End of fixups for esp32s2 */ 14 | 15 | /* Shared sections - ordering matters */ 16 | SECTIONS { 17 | INCLUDE "rwtext.x" 18 | INCLUDE "rwdata.x" 19 | } 20 | INCLUDE "rodata.x" 21 | INCLUDE "text.x" 22 | INCLUDE "rtc_fast.x" 23 | INCLUDE "rtc_slow.x" 24 | INCLUDE "stack.x" 25 | INCLUDE "dram2.x" 26 | INCLUDE "metadata.x" 27 | INCLUDE "eh_frame.x" 28 | /* End of Shared sections */ 29 | -------------------------------------------------------------------------------- /examples/ota/update/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor --partition-table=examples/ota/update/partitions.csv" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor --partition-table=examples/ota/update/partitions.csv" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | 23 | [unstable] 24 | build-std = ["alloc", "core"] 25 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c2/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memset = 0x40000488; 2 | memcpy = 0x4000048c; 3 | memmove = 0x40000490; 4 | memcmp = 0x40000494; 5 | 6 | strcpy = 0x40000498; 7 | strncpy = 0x4000049c; 8 | strncmp = 0x400004a4; 9 | 10 | PROVIDE ( strcat = 0x4000050c ); 11 | PROVIDE ( strcmp = 0x400004a0 ); 12 | PROVIDE ( strchr = 0x40000514 ); 13 | PROVIDE ( strlcpy = 0x40000524 ); 14 | PROVIDE ( strstr = 0x400004ac ); 15 | PROVIDE ( strcasecmp = 0x40000504 ); 16 | 17 | EXTERN(__mktime); 18 | EXTERN(__strnlen); 19 | EXTERN(__atoi); 20 | 21 | PROVIDE ( strnlen = __strnlen ); 22 | PROVIDE ( atoi = __atoi ); 23 | PROVIDE ( mktime = __mktime ); 24 | 25 | PROVIDE( abs = 0x40000558 ); 26 | 27 | syscall_table_ptr = 0x3fcdffd8; 28 | -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/src/rom.rs: -------------------------------------------------------------------------------- 1 | use esp_rom_sys::rom::md5; 2 | 3 | pub struct Crc32 {} 4 | 5 | impl Crc32 { 6 | pub fn new() -> Self { 7 | Self {} 8 | } 9 | 10 | pub fn crc(&self, data: &[u8]) -> u32 { 11 | esp_rom_sys::rom::crc::crc32_le(u32::MAX, data) 12 | } 13 | } 14 | 15 | pub struct Md5 { 16 | context: md5::Context, 17 | } 18 | 19 | impl Md5 { 20 | pub fn new() -> Self { 21 | Self { 22 | context: md5::Context::new(), 23 | } 24 | } 25 | 26 | pub fn update(&mut self, data: &[u8]) { 27 | self.context.consume(data); 28 | } 29 | 30 | pub fn finalize(self) -> [u8; 16] { 31 | self.context.compute().0 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /esp-hal/src/i2c/mod.rs: -------------------------------------------------------------------------------- 1 | //! # Inter-Integrated Circuit (I2C) 2 | //! 3 | //! I2C is a serial, synchronous, multi-device, half-duplex communication 4 | //! protocol that allows co-existence of multiple masters and slaves on the 5 | //! same bus. I2C uses two bidirectional open-drain lines: serial data line 6 | //! (SDA) and serial clock line (SCL), pulled up by resistors. 7 | //! 8 | //! For more information, see 9 | #![doc = crate::trm_markdown_link!("i2c")] 10 | 11 | pub mod master; 12 | 13 | #[cfg(soc_has_lp_i2c0)] 14 | crate::unstable_module! { 15 | pub mod lp_i2c; 16 | } 17 | 18 | #[cfg(esp32s3)] // Only support ESP32-S3 for now. 19 | #[cfg(soc_has_rtc_i2c)] 20 | crate::unstable_module! { 21 | pub mod rtc; 22 | } 23 | -------------------------------------------------------------------------------- /esp-lp-hal/examples/i2c.rs: -------------------------------------------------------------------------------- 1 | //! Uses `LP_I2C` and reads calibration data from BMP180 sensor. 2 | //! 3 | //! This example dumps the calibration data from a BMP180 sensor, to view them, 4 | //! logic analyzer or oscilloscope is required. 5 | //! 6 | //! The following wiring is assumed: 7 | //! - SDA => GPIO6 8 | //! - SCL => GPIO7 9 | 10 | //% CHIPS: esp32c6 11 | 12 | #![no_std] 13 | #![no_main] 14 | 15 | use esp_lp_hal::{i2c::LpI2c, prelude::*}; 16 | use panic_halt as _; 17 | 18 | #[entry] 19 | fn main(mut i2c: LpI2c) -> ! { 20 | let _peripherals = esp32c6_lp::Peripherals::take().unwrap(); 21 | 22 | loop { 23 | let mut data = [0u8; 22]; 24 | i2c.write_read(0x77, &[0xaa], &mut data).ok(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.ble_dtm.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32c3.rom.ld for esp32c3 7 | * 8 | * 9 | * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* DTM */ 17 | f_hci_le_rx_test_cmd_handler = 0; 18 | f_hci_le_tx_test_cmd_handler = 0; 19 | f_hci_le_enh_rx_test_cmd_handler = 0; 20 | f_hci_le_enh_tx_test_cmd_handler = 0; 21 | f_hci_le_test_end_cmd_handler = 0; 22 | r_lld_test_init = 0; 23 | -------------------------------------------------------------------------------- /esp-rtos/esp_config.yml: -------------------------------------------------------------------------------- 1 | crate: esp-rtos 2 | 3 | options: 4 | - name: tick_rate_hz 5 | description: 'Tick rate of the task scheduler in Hertz' 6 | default: 7 | - value: 100 8 | constraints: 9 | - type: 10 | validator: positive_integer 11 | 12 | - name: sw-task-overflow-detection 13 | description: 'Enable software-based stack overflow detection. The stack guard value and offset is based on esp-hal configuration.' 14 | default: 15 | - value: false 16 | 17 | - name: hw-task-overflow-detection 18 | description: 'Enable hardware-based stack overflow detection. The stack watermark is based on the esp-hal stack-guard-offset configuration.' 19 | default: 20 | - value: true 21 | -------------------------------------------------------------------------------- /examples/wifi/coex/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/dhcp/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/80211_tx/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/sniffer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/static_ip/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32h2/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memset = 0x400004a0; 2 | memcpy = 0x400004a4; 3 | memmove = 0x400004a8; 4 | memcmp = 0x400004ac; 5 | 6 | strncmp = 0x400004bc; 7 | strncpy = 0x400004b4; 8 | strcpy = 0x400004b0; 9 | 10 | abs = 0x40000570; 11 | 12 | PROVIDE( strcat = 0x40000524 ); 13 | PROVIDE( strcmp = 0x400004b8 ); 14 | PROVIDE( strchr = 0x4000052c ); 15 | PROVIDE( strlcpy = 0x4000053c ); 16 | PROVIDE( strstr = 0x400004c4 ); 17 | PROVIDE( strcasecmp = 0x4000051c ); 18 | 19 | PROVIDE( memchr = 0x40000514 ); 20 | 21 | EXTERN(__mktime); 22 | EXTERN(__strnlen); 23 | EXTERN(__atoi); 24 | 25 | PROVIDE ( strnlen = __strnlen ); 26 | PROVIDE ( atoi = __atoi ); 27 | PROVIDE ( mktime = __mktime ); 28 | 29 | syscall_table_ptr = 0x4084ffd4; 30 | -------------------------------------------------------------------------------- /examples/wifi/access_point/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/embassy_dhcp/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/embassy_sntp/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /esp-lp-hal/examples/uart.rs: -------------------------------------------------------------------------------- 1 | //! Uses `LP_UART` and logs "Hello World from LP Core". 2 | //! 3 | //! Uses GPIO4 for RX and GPIO5 for TX. GPIOs can't be changed. 4 | //! 5 | //! It is neccessary to use Serial-Uart bridge connected to TX and RX to see 6 | //! logs from LP_UART. Make sure the LP RAM is cleared before loading the code. 7 | 8 | //% CHIPS: esp32c6 9 | 10 | #![no_std] 11 | #![no_main] 12 | 13 | use core::fmt::Write; 14 | 15 | use embedded_hal::delay::DelayNs; 16 | use esp_lp_hal::{delay::Delay, prelude::*, uart::LpUart}; 17 | use panic_halt as _; 18 | 19 | #[entry] 20 | fn main(mut uart: LpUart) -> ! { 21 | loop { 22 | writeln!(uart, "Hello World from LP Core").unwrap(); 23 | Delay.delay_ms(1000); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s2/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memcmp = 0x4001ab40; 2 | memcpy = 0x4001aba8; 3 | memmove = 0x4001acb0; 4 | memset = 0x4001ad3c; 5 | 6 | strcpy = 0x40007cfc; 7 | strncpy = 0x40007f20; 8 | strncmp = 0x4001ae64; 9 | 10 | bzero = 0x400078c8; 11 | 12 | PROVIDE ( cache_dbus_mmu_set = 0x40018eb0 ); 13 | 14 | PROVIDE ( strcat = 0x4001ad90 ); 15 | PROVIDE ( strcmp = 0x40007be4 ); 16 | PROVIDE ( strchr = 0x4001adb0 ); 17 | PROVIDE ( strlcpy = 0x4001adf8 ); 18 | PROVIDE ( strstr = 0x4001aee8 ); 19 | 20 | EXTERN(__strcasecmp); 21 | EXTERN(__mktime); 22 | EXTERN(__strnlen); 23 | EXTERN(__atoi); 24 | 25 | PROVIDE ( strcasecmp = __strcasecmp ); 26 | PROVIDE ( strnlen = __strnlen ); 27 | PROVIDE ( atoi = __atoi ); 28 | PROVIDE ( mktime = __mktime ); 29 | -------------------------------------------------------------------------------- /examples/wifi/access_point_with_sta/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/embassy_access_point/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /examples/wifi/embassy_access_point_with_sta/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "espflash flash --monitor" 3 | rustflags = [ 4 | "-C", "link-arg=-Tlinkall.x", 5 | "-C", "force-frame-pointers", 6 | ] 7 | 8 | [target.'cfg(target_arch = "xtensa")'] 9 | runner = "espflash flash --monitor" 10 | rustflags = [ 11 | # GNU LD 12 | "-C", "link-arg=-Wl,-Tlinkall.x", 13 | "-C", "link-arg=-nostartfiles", 14 | 15 | # LLD 16 | # "-C", "link-arg=-Tlinkall.x", 17 | # "-C", "linker=rust-lld", 18 | ] 19 | 20 | [env] 21 | ESP_LOG = "info" 22 | SSID = "SSID" 23 | PASSWORD = "PASSWORD" 24 | STATIC_IP = "1.1.1.1 " 25 | GATEWAY_IP = "1.1.1.1" 26 | HOST_IP = "1.1.1.1" 27 | 28 | [unstable] 29 | build-std = ["alloc", "core"] 30 | -------------------------------------------------------------------------------- /extras/ieee802154-sniffer/README.md: -------------------------------------------------------------------------------- 1 | # IEEE 802.15.4 Sniffer 2 | 3 | This is an extcap to be used with the `ieee802154_sniffer` example. (Make sure the ESP32-C6/ESP32-H2 is connected via UART-bridge, not JTAG-Serial) 4 | 5 | To use it, build via `cargo build --release` and copy the resulting executable to the Wireshark's `extcap` folder. 6 | 7 | Then you should see a new capture interface in Wireshark 8 | 9 | If you are running the ieee802154_sniffer example this capture interface can connect via serialport to give you insights on what is going on. 10 | 11 | By default it tries to identify exactly one serialport. If that doesn't work for you, you can configure the serialport via the Wireshark UI. 12 | 13 | In Wireshark use `ITU-T-CRC-16` as `FCS format` 14 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["xtask"] 4 | exclude = [ 5 | "esp-alloc", 6 | "esp-backtrace", 7 | "esp-bootloader-esp-idf", 8 | "esp-config", 9 | "esp-hal", 10 | "esp-hal-procmacros", 11 | "esp-rom-sys", 12 | "esp-lp-hal", 13 | "esp-metadata", 14 | "esp-metadata-generated", 15 | "esp-phy", 16 | "esp-println", 17 | "esp-rtos", 18 | "esp-radio-rtos-driver", 19 | "esp-riscv-rt", 20 | "esp-radio", 21 | "esp-storage", 22 | "esp-sync", 23 | "examples", 24 | "extras/bench-server", 25 | "extras/esp-wifishark", 26 | "extras/ieee802154-sniffer", 27 | "hil-test", 28 | "qa-test", 29 | "xtensa-lx", 30 | "xtensa-lx-rt", 31 | "xtensa-lx-rt-proc-macros", 32 | ] 33 | -------------------------------------------------------------------------------- /examples/peripheral/touch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "touch" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | critical-section = "1" 9 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 16 | 17 | [features] 18 | esp32 = ["esp-backtrace/esp32", "esp-bootloader-esp-idf/esp32", "esp-hal/esp32"] 19 | 20 | [profile.release] 21 | debug = true 22 | debug-assertions = true 23 | lto = "fat" 24 | codegen-units = 1 25 | -------------------------------------------------------------------------------- /extras/esp-wifishark/README.md: -------------------------------------------------------------------------------- 1 | # esp-wifishark 2 | 3 | This is an extcap to be used with esp-radio and the `dump_packets` config option. 4 | 5 | To use it build via `cargo build --release` and copy the resulting executable to the Wireshark's `extcap` folder. 6 | 7 | Then you should see two new capture interfaces in Wireshark 8 | - esp-radio HCI capture (for Bluetooth HCI) 9 | - esp-radio Ethernet capture (for WiFi traffic) 10 | 11 | If you are running an application using esp-radio's `dump_packets` config and logging at INFO level active these capture interfaces can connect via serialport to give you insights on what is going on. 12 | 13 | By default it tries to identify exactly one serialport. If that doesn't work for you, you can configure the serialport via the Wireshark UI. 14 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memcmp = 0x4000c260; 2 | memcpy = 0x4000c2c8; 3 | memmove = 0x4000c3c0; 4 | memset = 0x4000c44c; 5 | 6 | PROVIDE ( strcpy = 0x400013ac ); 7 | PROVIDE ( abs = 0x40056340 ); 8 | PROVIDE ( strncpy = 0x400015d4 ); 9 | PROVIDE ( strncmp = 0x4000c5f4 ); 10 | 11 | PROVIDE ( bzero = 0x4000c1f4 ); 12 | 13 | PROVIDE ( strcat = 0x4000c518 ); 14 | PROVIDE ( strcmp = 0x40001274 ); 15 | PROVIDE ( strchr = 0x4000c53c ); 16 | PROVIDE ( strlcpy = 0x4000c584 ); 17 | PROVIDE ( strstr = 0x4000c674 ); 18 | PROVIDE ( strcasecmp = 0x400011cc ); 19 | 20 | PROVIDE ( memchr = 0x4000c244 ); 21 | 22 | EXTERN(__mktime); 23 | EXTERN(__strnlen); 24 | EXTERN(__atoi); 25 | 26 | PROVIDE ( strnlen = __strnlen ); 27 | PROVIDE ( atoi = __atoi ); 28 | PROVIDE ( mktime = __mktime ); 29 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.ble_dtm.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32s3.rom.ld for esp32s3 7 | * 8 | * 9 | * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* DTM */ 17 | f_hci_le_rx_test_cmd_handler = 0x40000000; 18 | f_hci_le_tx_test_cmd_handler = 0x40000000; 19 | f_hci_le_enh_rx_test_cmd_handler = 0x40000000; 20 | f_hci_le_enh_tx_test_cmd_handler = 0x40000000; 21 | f_hci_le_test_end_cmd_handler = 0x40000000; 22 | r_lld_test_init = 0x40000000; 23 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memset = 0x40000354; 2 | memcpy = 0x40000358; 3 | memmove = 0x4000035c; 4 | memcmp = 0x40000360; 5 | 6 | strncmp = 0x40000370; 7 | strncpy = 0x40000368; 8 | strcpy = 0x40000364; 9 | 10 | abs = 0x40000424; 11 | 12 | PROVIDE(cache_dbus_mmu_set = 0x40000564); 13 | 14 | PROVIDE( strcat = 0x400003d8 ); 15 | PROVIDE( strcmp = 0x4000036c ); 16 | PROVIDE( strchr = 0x400003e0 ); 17 | PROVIDE( strlcpy = 0x400003f0 ); 18 | PROVIDE( strstr = 0x40000378 ); 19 | PROVIDE( strcasecmp = 0x400003d0 ); 20 | 21 | PROVIDE( memchr = 0x400003c8 ); 22 | 23 | EXTERN(__mktime); 24 | EXTERN(__strnlen); 25 | EXTERN(__atoi); 26 | 27 | PROVIDE ( strnlen = __strnlen ); 28 | PROVIDE ( atoi = __atoi ); 29 | PROVIDE ( mktime = __mktime ); 30 | 31 | syscall_table_ptr = 0x3fcdffe0; 32 | -------------------------------------------------------------------------------- /examples/peripheral/lp_core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lp-core" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 9 | "panic-handler", 10 | "println", 11 | ] } 12 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 13 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 14 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 15 | 16 | [features] 17 | esp32c6 = [ 18 | "esp-backtrace/esp32c6", 19 | "esp-bootloader-esp-idf/esp32c6", 20 | "esp-hal/esp32c6", 21 | ] 22 | 23 | [profile.release] 24 | debug = true 25 | debug-assertions = true 26 | lto = "fat" 27 | codegen-units = 1 28 | -------------------------------------------------------------------------------- /xtensa-lx/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xtensa-lx" 3 | version = "0.13.0" 4 | edition = "2024" 5 | rust-version = "1.86.0" 6 | description = "Low-level access to Xtensa LX processors and peripherals" 7 | documentation = "https://docs.espressif.com/projects/rust/xtensa-lx/latest/" 8 | repository = "https://github.com/esp-rs/esp-hal" 9 | license = "MIT OR Apache-2.0" 10 | categories = ["embedded", "hardware-support", "no-std"] 11 | keywords = ["lx", "peripheral", "register", "xtensa"] 12 | 13 | [package.metadata.espressif] 14 | requires_target = ["xtensa-esp32-none-elf", "xtensa-esp32s2-none-elf", "xtensa-esp32s3-none-elf"] 15 | 16 | [lib] 17 | bench = false 18 | test = false 19 | 20 | [dependencies] 21 | critical-section = "1" 22 | 23 | [features] 24 | -------------------------------------------------------------------------------- /esp-radio/esp_config.yml: -------------------------------------------------------------------------------- 1 | crate: esp-radio 2 | 3 | options: 4 | - name: wifi_max_burst_size 5 | description: See [smoltcp's documentation](https://docs.rs/smoltcp/0.10.0/smoltcp/phy/struct.DeviceCapabilities.html#structfield.max_burst_size) 6 | default: 7 | - value: 3 8 | constraints: 9 | - type: 10 | validator: non_negative_integer 11 | 12 | - name: wifi_mtu 13 | description: "MTU, see [smoltcp's documentation](https://docs.rs/smoltcp/0.10.0/smoltcp/phy/struct.DeviceCapabilities.html#structfield.max_transmission_unit)" 14 | default: 15 | - value: 1492 16 | constraints: 17 | - type: 18 | validator: positive_integer 19 | 20 | - name: dump_packets 21 | description: "Dump packets via an info log statement" 22 | default: 23 | - value: false 24 | -------------------------------------------------------------------------------- /hil-test/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(target_arch = "riscv32")'] 2 | runner = "probe-rs run --preverify" 3 | rustflags = [ 4 | "--cfg", "embedded_test", 5 | 6 | "-C", "link-arg=-Tembedded-test.x", 7 | "-C", "link-arg=-Tdefmt.x", 8 | "-C", "link-arg=-Tlinkall.x", 9 | "-C", "force-frame-pointers", 10 | ] 11 | 12 | [target.'cfg(target_arch = "xtensa")'] 13 | runner = "probe-rs run --preverify" 14 | rustflags = [ 15 | "--cfg", "embedded_test", 16 | 17 | "-C", "link-arg=-nostartfiles", 18 | "-C", "link-arg=-Tembedded-test.x", 19 | "-C", "link-arg=-Tdefmt.x", 20 | "-C", "link-arg=-Wl,-Tlinkall.x", 21 | ] 22 | 23 | [env] 24 | DEFMT_LOG = "info,embedded_test=warn,esp_rtos=trace" 25 | 26 | [unstable] 27 | build-std = ["core", "alloc"] 28 | 29 | [net] 30 | git-fetch-with-cli = true 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 8 | Cargo.lock 9 | 10 | # These are backup files generated by rustfmt 11 | **/*.rs.bk 12 | 13 | # MSVC Windows builds of rustc generate these, which store debugging information 14 | *.pdb 15 | 16 | # Wokwi related files 17 | diagram.json 18 | wokwi.toml 19 | 20 | # We'll ignore VS Code settings (at least for now...) 21 | **/.vscode/settings.json 22 | **/.zed/ 23 | 24 | # Ignore generated documentation 25 | docs/ 26 | 27 | # Ignore the generated release plan 28 | release_plan.jsonc 29 | 30 | # Ignore the generated semver baselines 31 | api-baseline/ 32 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom-functions.x: -------------------------------------------------------------------------------- 1 | INCLUDE "rom/esp32c3.rom.api.ld" 2 | INCLUDE "rom/esp32c3.rom.eco3.ld" 3 | /* TODO 4 | INCLUDE "rom/esp32c3.rom.eco7.ld" 5 | */ 6 | INCLUDE "rom/esp32c3.rom.ld" 7 | INCLUDE "rom/esp32c3.rom.libgcc.ld" 8 | INCLUDE "rom/esp32c3.rom.version.ld" 9 | 10 | /* 11 | TODO if BT_CTRL_RUN_IN_FLASH_ONLY 12 | 13 | INCLUDE "rom/esp32c3.rom.ble_50.ld" 14 | INCLUDE "rom/esp32c3.rom.ble_cca.ld" 15 | INCLUDE "rom/esp32c3.rom.ble_dtm.ld" 16 | INCLUDE "rom/esp32c3.rom.ble_master.ld" 17 | INCLUDE "rom/esp32c3.rom.ble_scan.ld" 18 | INCLUDE "rom/esp32c3.rom.ble_smp.ld" 19 | INCLUDE "rom/esp32c3.rom.ble_test.ld" 20 | */ 21 | 22 | INCLUDE "rom/esp32c3.rom.bt_funcs.ld" 23 | INCLUDE "rom/esp32c3.rom.eco3_bt_funcs.ld" 24 | /* 25 | TODO 26 | INCLUDE "rom/esp32c3.rom.eco7_bt_funcs.ld" 27 | */ 28 | 29 | INCLUDE "rom/additional.ld" 30 | -------------------------------------------------------------------------------- /xtensa-lx-rt/interrupt_level_masks.rs.template: -------------------------------------------------------------------------------- 1 | pub enum CpuInterruptLevel { 2 | Level1, 3 | Level2, 4 | Level3, 5 | Level4, 6 | Level5, 7 | Level6, 8 | Level7, 9 | } 10 | 11 | impl CpuInterruptLevel { 12 | pub const fn mask(&self) -> u32 { 13 | match &self { 14 | CpuInterruptLevel::Level1 => {{ XCHAL_INTLEVEL1_MASK }}u32, 15 | CpuInterruptLevel::Level2 => {{ XCHAL_INTLEVEL2_MASK }}u32, 16 | CpuInterruptLevel::Level3 => {{ XCHAL_INTLEVEL3_MASK }}u32, 17 | CpuInterruptLevel::Level4 => {{ XCHAL_INTLEVEL4_MASK }}u32, 18 | CpuInterruptLevel::Level5 => {{ XCHAL_INTLEVEL5_MASK }}u32, 19 | CpuInterruptLevel::Level6 => {{ XCHAL_INTLEVEL6_MASK }}u32, 20 | CpuInterruptLevel::Level7 => {{ XCHAL_INTLEVEL7_MASK }}u32, 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/additional.ld: -------------------------------------------------------------------------------- 1 | memset = 0x400011e8; 2 | memcpy = 0x400011f4; 3 | memmove = 0x40001200; 4 | memcmp = 0x4000120c; 5 | 6 | strcpy = 0x40001218; 7 | strncpy = 0x40001224; 8 | strncmp = 0x4000123c; 9 | 10 | bzero = 0x40001260; 11 | 12 | PROVIDE(cache_dbus_mmu_set = 0x400019b0); 13 | PROVIDE( Cache_Suspend_DCache_Autoload = 0x40001734 ); 14 | PROVIDE( Cache_Suspend_DCache = 0x400018b4 ); 15 | 16 | PROVIDE( strcat = 0x40001374 ); 17 | PROVIDE( strcmp = 0x40001230 ); 18 | PROVIDE( strchr = 0x4000138c ); 19 | PROVIDE( strlcpy = 0x400013bc ); 20 | PROVIDE( strstr = 0x40001254 ); 21 | PROVIDE( strcasecmp = 0x4000135c ); 22 | 23 | EXTERN(__mktime); 24 | EXTERN(__strnlen); 25 | EXTERN(__atoi); 26 | 27 | PROVIDE ( strnlen = __strnlen ); 28 | PROVIDE ( atoi = __atoi ); 29 | PROVIDE ( mktime = __mktime ); 30 | 31 | syscall_table_ptr = 0x3fceffd4; 32 | -------------------------------------------------------------------------------- /esp-sync/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | 12 | 13 | ### Changed 14 | 15 | - Added `#[inline]` attributes to ensure better codegen (#4627) 16 | 17 | ### Fixed 18 | 19 | 20 | ### Removed 21 | 22 | 23 | ## [v0.1.1] - 2025-10-30 24 | 25 | ## [v0.1.0] - 2025-10-13 26 | 27 | ### Added 28 | 29 | - Initial release (#4023) 30 | 31 | [v0.1.0]: https://github.com/esp-rs/esp-hal/releases/tag/esp-sync-v0.1.0 32 | [v0.1.1]: https://github.com/esp-rs/esp-hal/compare/esp-sync-v0.1.0...esp-sync-v0.1.1 33 | [Unreleased]: https://github.com/esp-rs/esp-hal/compare/esp-sync-v0.1.1...HEAD 34 | -------------------------------------------------------------------------------- /xtensa-lx-rt-proc-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xtensa-lx-rt-proc-macros" 3 | version = "0.5.0" 4 | edition = "2024" 5 | rust-version = "1.86.0" 6 | description = "Attributes re-exported in `xtensa-lx-rt`" 7 | documentation = "https://docs.espressif.com/projects/rust/xtensa-lx-rt-proc-macros/latest/" 8 | repository = "https://github.com/esp-rs/esp-hal" 9 | license = "MIT OR Apache-2.0" 10 | keywords = ["esp32", "xtensa-lx-rt", "runtime", "startup"] 11 | categories = ["embedded", "no-std"] 12 | 13 | [package.metadata.espressif] 14 | requires_target = ["xtensa-esp32-none-elf", "xtensa-esp32s2-none-elf", "xtensa-esp32s3-none-elf"] 15 | 16 | [lib] 17 | proc-macro = true 18 | 19 | [dependencies] 20 | proc-macro2 = "1.0.95" 21 | quote = "1.0" 22 | syn = { version = "2.0", default-features = false, features = ["full", "parsing", "printing", "proc-macro", "clone-impls"] } 23 | -------------------------------------------------------------------------------- /esp-hal/src/soc/esp32/mod.rs: -------------------------------------------------------------------------------- 1 | //! # SOC (System-on-Chip) module (ESP32) 2 | //! 3 | //! ## Overview 4 | //! 5 | //! The `SOC` module provides access, functions and structures that are useful 6 | //! for interacting with various system-related peripherals on `ESP32` chip. 7 | 8 | crate::unstable_module! { 9 | pub mod clocks; 10 | pub mod trng; 11 | } 12 | pub mod cpu_control; 13 | pub mod gpio; 14 | pub(crate) mod regi2c; 15 | 16 | pub(crate) use esp32 as pac; 17 | 18 | #[cfg_attr(not(feature = "unstable"), allow(unused))] 19 | pub(crate) mod constants { 20 | /// The base clock frequency for the I2S peripheral (Hertz). 21 | pub const I2S_SCLK: u32 = 160_000_000; 22 | /// The default clock source for I2S operations. 23 | pub const I2S_DEFAULT_CLK_SRC: u32 = 2; 24 | } 25 | 26 | pub(crate) unsafe fn configure_cpu_caches() {} 27 | 28 | pub(crate) fn pre_init() {} 29 | -------------------------------------------------------------------------------- /esp-phy/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | 12 | - `last_calibration_result` to get the result of the last calibration (#4479) 13 | 14 | ### Changed 15 | 16 | 17 | ### Fixed 18 | 19 | 20 | ### Removed 21 | 22 | 23 | ## [v0.1.1] - 2025-10-30 24 | 25 | ## [v0.1.0] - 2025-10-13 26 | 27 | ### Added 28 | 29 | - Initial release (#3892) 30 | 31 | [v0.1.0]: https://github.com/esp-rs/esp-hal/releases/tag/esp-phy-v0.1.0 32 | [v0.1.1]: https://github.com/esp-rs/esp-hal/compare/esp-phy-v0.1.0...esp-phy-v0.1.1 33 | [Unreleased]: https://github.com/esp-rs/esp-hal/compare/esp-phy-v0.1.1...HEAD 34 | -------------------------------------------------------------------------------- /.lycheeignore: -------------------------------------------------------------------------------- 1 | # Local/private network addresses 2 | # Local/private network addresses (protocol-aware) 3 | ^https?://localhost 4 | ^https?://127\.0\.0\.1 5 | ^https?://0\.0\.0\.0 6 | .*\.local 7 | ^https?://192\.168\..* 8 | ^https?://10\..* 9 | ^https?://172\.(1[6-9]|2[0-9]|3[0-1])\..* 10 | 11 | # Template placeholders 12 | %7B[^%]+%7D 13 | \{[^}]+\} 14 | 15 | # GitHub compare links (ignore only these) 16 | ^https://github\.com/.*/compare/.*\.\.\..* 17 | 18 | # GitHub patterns 19 | releases/tag/$ 20 | 21 | # Shield.io badges 22 | img\.shields\.io/badge/MSRV- 23 | 24 | # TODO: remove once released 25 | docs\.espressif\.com/projects/rust/esp-phy/latest/ 26 | docs\.espressif\.com/projects/rust/esp-rtos/latest/ 27 | docs\.espressif\.com/projects/rust/esp-radio-rtos-driver/latest/ 28 | docs\.espressif\.com/projects/rust/esp-radio/latest/ 29 | docs\.espressif\.com/projects/rust/esp-sync/latest/ 30 | -------------------------------------------------------------------------------- /esp-hal/src/asynch.rs: -------------------------------------------------------------------------------- 1 | //! Asynchronous utilities. 2 | use core::task::Waker; 3 | 4 | use embassy_sync::waitqueue::GenericAtomicWaker; 5 | use esp_sync::RawMutex; 6 | 7 | /// Utility struct to register and wake a waker. 8 | pub struct AtomicWaker { 9 | waker: GenericAtomicWaker, 10 | } 11 | 12 | impl AtomicWaker { 13 | /// Create a new `AtomicWaker`. 14 | #[allow(clippy::new_without_default)] 15 | pub const fn new() -> Self { 16 | Self { 17 | waker: GenericAtomicWaker::new(RawMutex::new()), 18 | } 19 | } 20 | 21 | /// Register a waker. Overwrites the previous waker, if any. 22 | #[inline] 23 | pub fn register(&self, w: &Waker) { 24 | self.waker.register(w); 25 | } 26 | 27 | /// Wake the registered waker, if any. 28 | #[crate::ram] 29 | pub fn wake(&self) { 30 | self.waker.wake(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /esp-storage/src/hardware.rs: -------------------------------------------------------------------------------- 1 | use esp_rom_sys as _; 2 | use esp_rom_sys::rom::spiflash::*; 3 | use procmacros::ram; 4 | 5 | use crate::maybe_with_critical_section; 6 | 7 | #[ram] 8 | pub(crate) fn spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 { 9 | maybe_with_critical_section(|| unsafe { esp_rom_spiflash_read(src_addr, data, len) }) 10 | } 11 | 12 | #[ram] 13 | pub(crate) fn spiflash_unlock() -> i32 { 14 | maybe_with_critical_section(|| unsafe { esp_rom_spiflash_unlock() }) 15 | } 16 | 17 | #[ram] 18 | pub(crate) fn spiflash_erase_sector(sector_number: u32) -> i32 { 19 | maybe_with_critical_section(|| unsafe { esp_rom_spiflash_erase_sector(sector_number) }) 20 | } 21 | 22 | #[ram] 23 | pub(crate) fn spiflash_write(dest_addr: u32, data: *const u32, len: u32) -> i32 { 24 | maybe_with_critical_section(|| unsafe { esp_rom_spiflash_write(dest_addr, data, len) }) 25 | } 26 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/rwtext.x: -------------------------------------------------------------------------------- 1 | #IF riscv 2 | .trap : ALIGN(4) 3 | { 4 | _trap_section_origin = .; 5 | KEEP(*(.trap)); 6 | *(.trap.*); 7 | } > RWTEXT 8 | #ENDIF 9 | 10 | .rwtext : ALIGN(4) 11 | { 12 | . = ALIGN (4); 13 | *(.rwtext.literal .rwtext .rwtext.literal.* .rwtext.*) 14 | /* unconditionally add patched SPI-flash ROM functions (from esp-rom-sys) - the linker is still happy if there are none */ 15 | *:esp_rom_spiflash.*(.literal .literal.* .text .text.*) 16 | . = ALIGN(4); 17 | } > RWTEXT 18 | 19 | .rwtext.wifi : 20 | { 21 | . = ALIGN(4); 22 | *( .wifi0iram .wifi0iram.*) 23 | *( .wifirxiram .wifirxiram.*) 24 | *( .wifislprxiram .wifislprxiram.*) 25 | *( .wifislpiram .wifislpiram.*) 26 | *( .phyiram .phyiram.*) 27 | *( .iram1 .iram1.*) 28 | *( .wifiextrairam.* ) 29 | *( .coexiram.* ) 30 | . = ALIGN(4); 31 | 32 | _rwtext_len = . - ORIGIN(RWTEXT); 33 | } > RWTEXT 34 | -------------------------------------------------------------------------------- /examples/peripheral/etm_timer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "etm-timer" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 9 | "panic-handler", 10 | "println", 11 | ] } 12 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 13 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 14 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 15 | 16 | [features] 17 | esp32c6 = [ 18 | "esp-backtrace/esp32c6", 19 | "esp-bootloader-esp-idf/esp32c6", 20 | "esp-hal/esp32c6", 21 | ] 22 | esp32h2 = [ 23 | "esp-backtrace/esp32h2", 24 | "esp-bootloader-esp-idf/esp32h2", 25 | "esp-hal/esp32h2", 26 | ] 27 | 28 | [profile.release] 29 | debug = true 30 | debug-assertions = true 31 | lto = "fat" 32 | codegen-units = 1 33 | -------------------------------------------------------------------------------- /examples/peripheral/spi/loopback_dma_psram/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "spi-loopback-dma" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-alloc = { path = "../../../../esp-alloc" } 9 | esp-backtrace = { path = "../../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../../esp-hal", features = [ 15 | "log-04", 16 | "psram", 17 | "unstable", 18 | ] } 19 | esp-println = { path = "../../../../esp-println", features = ["log-04"] } 20 | log = "0.4.27" 21 | 22 | [features] 23 | esp32s3 = [ 24 | "esp-backtrace/esp32s3", 25 | "esp-bootloader-esp-idf/esp32s3", 26 | "esp-hal/esp32s3", 27 | ] 28 | 29 | [profile.release] 30 | debug = true 31 | debug-assertions = true 32 | lto = "fat" 33 | codegen-units = 1 34 | -------------------------------------------------------------------------------- /esp-metadata-generated/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "esp-metadata-generated" 3 | version = "0.3.0" 4 | edition = "2024" 5 | rust-version = "1.86.0" 6 | description = "Generated metadata for Espressif devices" 7 | documentation = "https://docs.espressif.com/projects/rust/esp-metadata-generated/latest/" 8 | repository = "https://github.com/esp-rs/esp-hal" 9 | license = "MIT OR Apache-2.0" 10 | 11 | [package.metadata.espressif] 12 | check-configs = [ 13 | { features = [] }, 14 | { features = ["build-script"] }, 15 | ] 16 | clippy-configs = [] # don't waste time on this 17 | 18 | [dependencies] 19 | 20 | [features] 21 | build-script = [] 22 | _device-selected = [] 23 | esp32 = ["_device-selected"] 24 | esp32c2 = ["_device-selected"] 25 | esp32c3 = ["_device-selected"] 26 | esp32c6 = ["_device-selected"] 27 | esp32h2 = ["_device-selected"] 28 | esp32s2 = ["_device-selected"] 29 | esp32s3 = ["_device-selected"] 30 | -------------------------------------------------------------------------------- /examples/peripheral/dma/extmem2mem/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dma-extmem2mem" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | aligned = "0.4.2" 9 | esp-alloc = { path = "../../../../esp-alloc" } 10 | esp-backtrace = { path = "../../../../esp-backtrace", features = [ 11 | "panic-handler", 12 | "println", 13 | ] } 14 | esp-bootloader-esp-idf = { path = "../../../../esp-bootloader-esp-idf" } 15 | esp-hal = { path = "../../../../esp-hal", features = [ 16 | "log-04", 17 | "psram", 18 | "unstable", 19 | ] } 20 | esp-println = { path = "../../../../esp-println", features = ["log-04"] } 21 | log = "0.4.27" 22 | 23 | [features] 24 | esp32s3 = [ 25 | "esp-backtrace/esp32s3", 26 | "esp-bootloader-esp-idf/esp32s3", 27 | "esp-hal/esp32s3", 28 | ] 29 | 30 | [profile.release] 31 | debug = true 32 | debug-assertions = true 33 | lto = "fat" 34 | codegen-units = 1 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: ["bug", "bug jury"] 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Bug description 11 | 12 | 13 | 14 | ## To Reproduce 15 | 16 | 17 | 1. ... 18 | 2. ... 19 | 20 | 21 | 22 | 23 | 24 | ## Expected behavior 25 | 26 | 27 | 28 | ## Environment 29 | 30 | - Target device: [e.g. ESP32-S3] 31 | - Crate name and version: [e.g. esp-hal 1.0.0] -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.ble_cca.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32c3.rom.ld for esp32c3 7 | * 8 | * 9 | * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* SW CCA */ 17 | r_lld_cca_con_evt_start_handle = 0; 18 | r_lld_hw_cca_end_isr = 0; 19 | r_lld_hw_cca_isr_eco = 0; 20 | r_lld_cca_bb_sync_found_handle = 0; 21 | r_lld_cca_data_reset = 0; 22 | r_lld_cca_sw_init = 0; 23 | r_lld_cca_con_evt_end_handle = 0; 24 | r_lld_cca_alloc = 0; 25 | r_lld_cca_sw_alloc = 0; 26 | r_lld_cca_sw_free = 0; 27 | r_lld_cca_free = 0; 28 | r_cca_init = 0; 29 | r_lld_hw_cca_evt_handler = 0; 30 | r_lld_sw_cca_evt_handler = 0; 31 | r_ble_sw_cca_check_isr = 0; 32 | -------------------------------------------------------------------------------- /examples/peripheral/usb_serial/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "usb-serial" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 9 | "panic-handler", 10 | "println", 11 | ] } 12 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 13 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 14 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 15 | usb-device = "0.3.2" 16 | usbd-serial = "0.2.2" 17 | 18 | [features] 19 | esp32s2 = [ 20 | "esp-backtrace/esp32s2", 21 | "esp-bootloader-esp-idf/esp32s2", 22 | "esp-hal/esp32s2", 23 | ] 24 | esp32s3 = [ 25 | "esp-backtrace/esp32s3", 26 | "esp-bootloader-esp-idf/esp32s3", 27 | "esp-hal/esp32s3", 28 | ] 29 | 30 | [profile.release] 31 | debug = true 32 | debug-assertions = true 33 | lto = "fat" 34 | codegen-units = 1 35 | -------------------------------------------------------------------------------- /esp-hal/src/i2s/mod.rs: -------------------------------------------------------------------------------- 1 | //! # Inter-IC Sound (I2S) 2 | 3 | use crate::dma::DmaEligible; 4 | 5 | pub mod master; 6 | 7 | #[cfg(esp32)] 8 | pub mod parallel; 9 | 10 | crate::any_peripheral! { 11 | /// Any I2S peripheral. 12 | pub peripheral AnyI2s<'d> { 13 | #[cfg(soc_has_i2s0)] 14 | I2s0(crate::peripherals::I2S0<'d>), 15 | #[cfg(soc_has_i2s1)] 16 | I2s1(crate::peripherals::I2S1<'d>), 17 | } 18 | } 19 | 20 | impl<'d> DmaEligible for AnyI2s<'d> { 21 | #[cfg(gdma)] 22 | type Dma = crate::dma::AnyGdmaChannel<'d>; 23 | #[cfg(pdma)] 24 | type Dma = crate::dma::AnyI2sDmaChannel<'d>; 25 | 26 | fn dma_peripheral(&self) -> crate::dma::DmaPeripheral { 27 | match &self.0 { 28 | #[cfg(soc_has_i2s0)] 29 | any::Inner::I2s0(_) => crate::dma::DmaPeripheral::I2s0, 30 | #[cfg(soc_has_i2s1)] 31 | any::Inner::I2s1(_) => crate::dma::DmaPeripheral::I2s1, 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/esp_config.yml: -------------------------------------------------------------------------------- 1 | crate: esp-bootloader-esp-idf 2 | 3 | options: 4 | - name: mmu_page_size 5 | description: ESP32-C2, ESP32-C6 and ESP32-H2 support configurable page sizes. This is currently only used to populate the app descriptor. 6 | default: 7 | - value: '"64k"' 8 | constraints: 9 | - type: 10 | validator: enumeration 11 | value: 12 | - 8k 13 | - 16k 14 | - 32k 15 | - 64k 16 | 17 | - name: esp_idf_version 18 | description: ESP-IDF version used in the application descriptor. Currently it's not checked by the bootloader. 19 | default: 20 | - value: '"0.0.0"' 21 | 22 | - name: partition-table-offset 23 | description: "The address of partition table (by default 0x8000). Allows you to 24 | move the partition table, it gives more space for the bootloader. Note that the 25 | bootloader and app will both need to be compiled with the same 26 | PARTITION_TABLE_OFFSET value." 27 | default: 28 | - value: 32768 29 | -------------------------------------------------------------------------------- /esp-lp-hal/build.rs: -------------------------------------------------------------------------------- 1 | use std::{env, error::Error, fs, path::PathBuf}; 2 | 3 | use esp_metadata_generated::Chip; 4 | 5 | fn main() -> Result<(), Box> { 6 | // Determine the name of the configured device: 7 | let chip = Chip::from_cargo_feature()?; 8 | 9 | // Define all necessary configuration symbols for the configured device: 10 | chip.define_cfgs(); 11 | 12 | // Copy the required linker script to the `out` directory: 13 | let source_file = match chip { 14 | Chip::Esp32c6 => "ld/link-lp.x", 15 | Chip::Esp32s2 | Chip::Esp32s3 => "ld/link-ulp.x", 16 | _ => unreachable!(), 17 | }; 18 | 19 | // Put the linker script somewhere the linker can find it: 20 | let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); 21 | println!("cargo:rustc-link-search={}", out.display()); 22 | fs::copy(source_file, out.join("link.x"))?; 23 | println!("cargo:rerun-if-changed=ld/link-ulp.x"); 24 | 25 | // Done! 26 | Ok(()) 27 | } 28 | -------------------------------------------------------------------------------- /esp-metadata/src/cfg/rsa.rs: -------------------------------------------------------------------------------- 1 | use crate::cfg::Value; 2 | 3 | impl super::RsaProperties { 4 | pub(super) fn computed_properties(&self) -> impl Iterator { 5 | let increment = self.size_increment; 6 | let memory_bits = self.memory_size_bytes * 8; 7 | 8 | [ 9 | ( 10 | "rsa.exponentiation", 11 | false, 12 | Value::NumberList( 13 | (increment..=memory_bits) 14 | .step_by(increment as usize) 15 | .collect(), 16 | ), 17 | ), 18 | ( 19 | "rsa.multiplication", 20 | false, 21 | Value::NumberList( 22 | (increment..=memory_bits / 2) 23 | .step_by(increment as usize) 24 | .collect(), 25 | ), 26 | ), 27 | ] 28 | .into_iter() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /esp-hal/src/soc/esp32c3/mod.rs: -------------------------------------------------------------------------------- 1 | //! # SOC (System-on-Chip) module (ESP32-C3) 2 | //! 3 | //! ## Overview 4 | //! 5 | //! The `SOC` module provides access, functions and structures that are useful 6 | //! for interacting with various system-related peripherals on `ESP32-C3` chip. 7 | //! 8 | //! Also few constants are defined in this module for `ESP32-C3` chip: 9 | //! * I2S_SCLK: 160_000_000 - I2S clock frequency 10 | //! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source 11 | 12 | crate::unstable_module! { 13 | pub mod clocks; 14 | pub mod trng; 15 | } 16 | pub mod gpio; 17 | pub(crate) mod regi2c; 18 | 19 | pub(crate) use esp32c3 as pac; 20 | 21 | #[cfg_attr(not(feature = "unstable"), allow(unused))] 22 | pub(crate) mod constants { 23 | /// The base clock frequency for the I2S peripheral (Hertz). 24 | pub const I2S_SCLK: u32 = 160_000_000; 25 | /// The default clock source for I2S operations. 26 | pub const I2S_DEFAULT_CLK_SRC: u8 = 2; 27 | } 28 | 29 | pub(crate) fn pre_init() {} 30 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.ble_test.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32c3.rom.ld for esp32c3 7 | * 8 | * 9 | * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | 17 | /* overwrite */ 18 | lld_acl_rx_ind_handler = 0; 19 | lld_con_estab_ind_handler = 0; 20 | lld_adv_rep_ind_handler = 0; 21 | llm_rpa_renew_to_handler = 0; 22 | lld_scan_end_ind_handler = 0; 23 | llm_scan_period_to_handler = 0; 24 | 25 | /* nvds */ 26 | r_nvds_init = 0; 27 | f_nvds_get = 0; 28 | f_nvds_del = 0; 29 | f_nvds_put = 0; 30 | 31 | /* controller flash */ 32 | r_flash_init = 0; 33 | r_flash_env_init = 0; 34 | r_flash_env_deinit = 0; 35 | 36 | /* QA test */ 37 | f_hci_vendor_ble_qa_test_cmd_handler = 0; 38 | -------------------------------------------------------------------------------- /qa-test/src/bin/temperature_sensor.rs: -------------------------------------------------------------------------------- 1 | //! This example uses the internal temperature sensor to measure the chip's 2 | //! temperature 3 | 4 | //% CHIPS: esp32c6 esp32c3 5 | 6 | #![no_std] 7 | #![no_main] 8 | 9 | use esp_backtrace as _; 10 | use esp_hal::{ 11 | delay::Delay, 12 | main, 13 | tsens::{Config, TemperatureSensor}, 14 | }; 15 | use esp_println::println; 16 | 17 | esp_bootloader_esp_idf::esp_app_desc!(); 18 | 19 | #[main] 20 | fn main() -> ! { 21 | esp_println::logger::init_logger_from_env(); 22 | let peripherals = esp_hal::init(esp_hal::Config::default()); 23 | 24 | let temperature_sensor = TemperatureSensor::new(peripherals.TSENS, Config::default()).unwrap(); 25 | let delay = Delay::new(); 26 | 27 | // Wait for the sensor to stabilize 28 | delay.delay_micros(200); 29 | 30 | loop { 31 | let temp = temperature_sensor.get_temperature(); 32 | println!("Temperature: {:.2}°C", temp.to_celsius()); 33 | delay.delay_millis(1_000); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32h2/esp32h2.x: -------------------------------------------------------------------------------- 1 | /* The ESP32-C2 and ESP32-C3 have interrupt IDs 1-31, while the ESP32-C6 and ESP32-H2 have 2 | IDs 0-31, so we much define the handler for the one additional interrupt 3 | ID: */ 4 | PROVIDE(interrupt0 = DefaultHandler); 5 | 6 | SECTIONS { 7 | /* Shared sections - ordering matters */ 8 | INCLUDE "rwtext.x" 9 | INCLUDE "rwdata.x" 10 | /* End of Shared sections */ 11 | } 12 | 13 | SECTIONS { 14 | /** 15 | * Bootloader really wants to have separate segments for ROTEXT and RODATA 16 | * Thus, we need to force a gap here. 17 | */ 18 | .text_gap (NOLOAD): { 19 | . = . + 4; 20 | . = ALIGN(4) + 0x20; 21 | } > ROM 22 | } 23 | INSERT BEFORE .text; 24 | 25 | /* Shared sections #2 - ordering matters */ 26 | INCLUDE "rodata.x" 27 | INCLUDE "text.x" 28 | INCLUDE "rtc_fast.x" 29 | INCLUDE "stack.x" 30 | INCLUDE "dram2.x" 31 | INCLUDE "metadata.x" 32 | INCLUDE "eh_frame.x" 33 | /* End of Shared sections #2 */ 34 | 35 | _dram_data_start = ORIGIN( RAM ) + SIZEOF(.trap) + SIZEOF(.rwtext); 36 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32c6/esp32c6.x: -------------------------------------------------------------------------------- 1 | /* esp32c6 fixups */ 2 | /* The ESP32-C2 and ESP32-C3 have interrupt IDs 1-31, while the ESP32-C6 has 3 | IDs 0-31, so we much define the handler for the one additional interrupt 4 | ID: */ 5 | PROVIDE(interrupt0 = DefaultHandler); 6 | 7 | SECTIONS { 8 | /* Shared sections - ordering matters */ 9 | INCLUDE "rwtext.x" 10 | INCLUDE "rwdata.x" 11 | /* End of Shared sections */ 12 | } 13 | 14 | SECTIONS { 15 | /** 16 | * Bootloader really wants to have separate segments for ROTEXT and RODATA 17 | * Thus, we need to force a gap here. 18 | */ 19 | .text_gap (NOLOAD): { 20 | . = . + 4; 21 | . = ALIGN(4) + 0x20; 22 | } > ROM 23 | } 24 | INSERT BEFORE .text; 25 | /* end of esp32c6 fixups */ 26 | 27 | /* Shared sections #2 - ordering matters */ 28 | INCLUDE "rodata.x" 29 | INCLUDE "text.x" 30 | INCLUDE "rtc_fast.x" 31 | INCLUDE "stack.x" 32 | INCLUDE "dram2.x" 33 | INCLUDE "metadata.x" 34 | INCLUDE "eh_frame.x" 35 | /* End of Shared sections #2 */ 36 | 37 | _dram_data_start = ORIGIN( RAM ) + SIZEOF(.trap) + SIZEOF(.rwtext); 38 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/rtc_slow.x: -------------------------------------------------------------------------------- 1 | 2 | 3 | SECTIONS { 4 | .rtc_slow.text : { 5 | . = ALIGN(4); 6 | *(.rtc_slow.literal .rtc_slow.text .rtc_slow.literal.* .rtc_slow.text.*) 7 | . = ALIGN(4); 8 | } > rtc_slow_seg AT > RODATA 9 | 10 | .rtc_slow.data : 11 | { 12 | . = ALIGN(4); 13 | _rtc_slow_data_start = ABSOLUTE(.); 14 | *(.rtc_slow.data .rtc_slow.data.*) 15 | _rtc_slow_data_end = ABSOLUTE(.); 16 | . = ALIGN(4); 17 | } > rtc_slow_seg AT > RODATA 18 | 19 | /* LMA of .data */ 20 | _rtc_slow_sidata = LOADADDR(.rtc_slow.data); 21 | 22 | .rtc_slow.bss (NOLOAD) : 23 | { 24 | . = ALIGN(4); 25 | _rtc_slow_bss_start = ABSOLUTE(.); 26 | *(.rtc_slow.bss .rtc_slow.bss.*) 27 | _rtc_slow_bss_end = ABSOLUTE(.); 28 | . = ALIGN(4); 29 | } > rtc_slow_seg 30 | 31 | .rtc_slow.persistent (NOLOAD) : 32 | { 33 | . = ALIGN(4); 34 | _rtc_slow_persistent_start = ABSOLUTE(.); 35 | *(.rtc_slow.persistent .rtc_slow.persistent.*) 36 | _rtc_slow_persistent_end = ABSOLUTE(.); 37 | . = ALIGN(4); 38 | } > rtc_slow_seg 39 | } 40 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_receive_all_frames/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![no_main] 3 | 4 | use esp_alloc as _; 5 | use esp_backtrace as _; 6 | use esp_hal::main; 7 | use esp_println::println; 8 | use esp_radio::ieee802154::{Config, Ieee802154}; 9 | 10 | esp_bootloader_esp_idf::esp_app_desc!(); 11 | 12 | #[main] 13 | fn main() -> ! { 14 | esp_println::logger::init_logger_from_env(); 15 | let peripherals = esp_hal::init(esp_hal::Config::default()); 16 | 17 | esp_alloc::heap_allocator!(size: 24 * 1024); 18 | 19 | let mut ieee802154 = Ieee802154::new(peripherals.IEEE802154); 20 | 21 | ieee802154.set_config(Config { 22 | channel: 15, 23 | promiscuous: true, 24 | rx_when_idle: true, 25 | auto_ack_rx: false, 26 | auto_ack_tx: false, 27 | ..Default::default() 28 | }); 29 | 30 | println!("Start receiving:"); 31 | ieee802154.start_receive(); 32 | 33 | loop { 34 | if let Some(frame) = ieee802154.received() { 35 | println!("Received {:?}\n", &frame); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/rtc_fast.x: -------------------------------------------------------------------------------- 1 | 2 | 3 | SECTIONS { 4 | .rtc_fast.text : { 5 | . = ALIGN(4); 6 | *(.rtc_fast.literal .rtc_fast.text .rtc_fast.literal.* .rtc_fast.text.*) 7 | . = ALIGN(4); 8 | } > RTC_FAST_RWTEXT AT > RODATA 9 | 10 | .rtc_fast.data : 11 | { 12 | . = ALIGN(4); 13 | _rtc_fast_data_start = ABSOLUTE(.); 14 | *(.rtc_fast.data .rtc_fast.data.*) 15 | _rtc_fast_data_end = ABSOLUTE(.); 16 | . = ALIGN(4); 17 | } > RTC_FAST_RWDATA AT > RODATA 18 | 19 | /* LMA of .data */ 20 | _rtc_fast_sidata = LOADADDR(.rtc_fast.data); 21 | 22 | .rtc_fast.bss (NOLOAD) : 23 | { 24 | . = ALIGN(4); 25 | _rtc_fast_bss_start = ABSOLUTE(.); 26 | *(.rtc_fast.bss .rtc_fast.bss.*) 27 | _rtc_fast_bss_end = ABSOLUTE(.); 28 | . = ALIGN(4); 29 | } > RTC_FAST_RWDATA 30 | 31 | .rtc_fast.persistent (NOLOAD) : 32 | { 33 | . = ALIGN(4); 34 | _rtc_fast_persistent_start = ABSOLUTE(.); 35 | *(.rtc_fast.persistent .rtc_fast.persistent.*) 36 | _rtc_fast_persistent_end = ABSOLUTE(.); 37 | . = ALIGN(4); 38 | } > RTC_FAST_RWDATA 39 | } 40 | -------------------------------------------------------------------------------- /esp-lp-hal/ld/link-ulp.x: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | ENTRY(reset_vector) 8 | 9 | CONFIG_ULP_COPROC_RESERVE_MEM = 8 * 1024; 10 | 11 | MEMORY 12 | { 13 | ram(RW) : ORIGIN = 0, LENGTH = CONFIG_ULP_COPROC_RESERVE_MEM 14 | } 15 | 16 | SECTIONS 17 | { 18 | . = ORIGIN(ram); 19 | 20 | .text : 21 | { 22 | *(.text.vectors) /* Default reset vector must link to offset 0x0 */ 23 | 24 | KEEP(*(.init)); 25 | KEEP(*(.init.rust)); 26 | *(.text) 27 | *(.text*) 28 | } >ram 29 | 30 | .rodata ALIGN(4): 31 | { 32 | *(.rodata) 33 | *(.rodata*) 34 | } > ram 35 | 36 | .data ALIGN(4): 37 | { 38 | *(.data) 39 | *(.data*) 40 | *(.sdata) 41 | *(.sdata*) 42 | } > ram 43 | 44 | .bss ALIGN(4) : 45 | { 46 | *(.bss) 47 | *(.bss*) 48 | *(.sbss) 49 | *(.sbss*) 50 | } >ram 51 | 52 | __stack_top = ORIGIN(ram) + LENGTH(ram); 53 | } 54 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.ble_cca.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32s3.rom.ld for esp32s3 7 | * 8 | * 9 | * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* SW CCA */ 17 | r_lld_cca_con_evt_start_handle = 0x40000000; 18 | r_lld_hw_cca_end_isr = 0x40000000; 19 | r_lld_hw_cca_isr_eco = 0x40000000; 20 | r_lld_cca_bb_sync_found_handle = 0x40000000; 21 | r_lld_cca_data_reset = 0x40000000; 22 | r_lld_cca_sw_init = 0x40000000; 23 | r_lld_cca_con_evt_end_handle = 0x40000000; 24 | r_lld_cca_alloc = 0x40000000; 25 | r_lld_cca_sw_alloc = 0x40000000; 26 | r_lld_cca_sw_free = 0x40000000; 27 | r_lld_cca_free = 0x40000000; 28 | r_cca_init = 0x40000000; 29 | r_lld_hw_cca_evt_handler = 0x40000000; 30 | r_lld_sw_cca_evt_handler = 0x40000000; 31 | r_ble_sw_cca_check_isr = 0x40000000; 32 | -------------------------------------------------------------------------------- /esp-storage/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! ## Feature Flags 2 | #![doc = document_features::document_features!(feature_label = r#"{feature}"#)] 3 | #![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")] 4 | #![cfg_attr(not(all(test, feature = "emulation")), no_std)] 5 | 6 | #[cfg_attr(not(feature = "emulation"), path = "hardware.rs")] 7 | #[cfg_attr(feature = "emulation", path = "stub.rs")] 8 | mod chip_specific; 9 | 10 | mod buffer; 11 | mod common; 12 | 13 | pub use common::{FlashStorage, FlashStorageError}; 14 | 15 | pub mod ll; 16 | mod nor_flash; 17 | mod storage; 18 | 19 | #[cfg(not(feature = "emulation"))] 20 | #[inline(always)] 21 | fn maybe_with_critical_section(f: impl FnOnce() -> R) -> R { 22 | #[cfg(feature = "critical-section")] 23 | { 24 | static LOCK: esp_sync::RawMutex = esp_sync::RawMutex::new(); 25 | 26 | LOCK.lock(f) 27 | } 28 | 29 | #[cfg(not(feature = "critical-section"))] 30 | f() 31 | } 32 | 33 | #[cfg(feature = "emulation")] 34 | fn maybe_with_critical_section(f: impl FnOnce() -> R) -> R { 35 | f() 36 | } 37 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.ble_test.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32s3.rom.ld for esp32s3 7 | * 8 | * 9 | * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | 17 | /* overwrite */ 18 | lld_acl_rx_ind_handler = 0x40000000; 19 | lld_con_estab_ind_handler = 0x40000000; 20 | lld_adv_rep_ind_handler = 0x40000000; 21 | llm_rpa_renew_to_handler = 0x40000000; 22 | lld_scan_end_ind_handler = 0x40000000; 23 | llm_scan_period_to_handler = 0x40000000; 24 | 25 | /* nvds */ 26 | r_nvds_init = 0x40000000; 27 | f_nvds_get = 0x40000000; 28 | f_nvds_del = 0x40000000; 29 | f_nvds_put = 0x40000000; 30 | 31 | /* controller flash */ 32 | r_flash_init = 0x40000000; 33 | r_flash_env_init = 0x40000000; 34 | r_flash_env_deinit = 0x40000000; 35 | 36 | /* QA test */ 37 | f_hci_vendor_ble_qa_test_cmd_handler = 0x40000000; 38 | -------------------------------------------------------------------------------- /esp-metadata/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "esp-metadata" 3 | version = "0.10.0" 4 | edition = "2024" 5 | rust-version = "1.86.0" 6 | description = "Metadata for Espressif devices" 7 | documentation = "https://docs.espressif.com/projects/rust/esp-metadata/latest/" 8 | repository = "https://github.com/esp-rs/esp-hal" 9 | license = "MIT OR Apache-2.0" 10 | 11 | [package.metadata.espressif] 12 | forever-unstable = true 13 | check-configs = [ 14 | { features = [] }, 15 | { features = ["clap"] }, 16 | ] 17 | clippy-configs = [] # don't waste time on this 18 | 19 | [dependencies] 20 | anyhow = "1.0" 21 | clap = { version = "4.5", features = ["derive"], optional = true } 22 | convert_case = "0.8" 23 | basic-toml = "0.1" 24 | serde = { version = "1.0", default-features = false, features = ["derive"] } 25 | somni-parser = "0.2.1" 26 | somni-expr = "0.2" 27 | strum = { version = "0.27", features = ["derive"] } 28 | proc-macro2 = "1" 29 | quote = "1" 30 | indexmap = { version = "2", features = ["serde"] } 31 | 32 | [features] 33 | default = [] 34 | clap = ["dep:clap"] 35 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright 2021 esp-rs 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /esp-alloc/src/heap/llff.rs: -------------------------------------------------------------------------------- 1 | use core::{alloc::Layout, ptr::NonNull}; 2 | 3 | use linked_list_allocator::Heap; 4 | 5 | pub(crate) struct LlffHeap { 6 | heap: Heap, 7 | } 8 | 9 | impl LlffHeap { 10 | pub unsafe fn new(heap_bottom: *mut u8, size: usize) -> Self { 11 | let mut heap = Heap::empty(); 12 | unsafe { heap.init(heap_bottom, size) }; 13 | Self { heap } 14 | } 15 | 16 | pub fn size(&self) -> usize { 17 | self.heap.size() 18 | } 19 | 20 | pub fn used(&self) -> usize { 21 | self.heap.used() 22 | } 23 | 24 | pub fn free(&self) -> usize { 25 | self.heap.free() 26 | } 27 | 28 | pub fn allocate(&mut self, layout: Layout) -> Option> { 29 | self.heap.allocate_first_fit(layout).ok() 30 | } 31 | 32 | pub(crate) unsafe fn try_deallocate(&mut self, ptr: NonNull, layout: Layout) -> bool { 33 | if self.heap.bottom() <= ptr.as_ptr() && self.heap.top() >= ptr.as_ptr() { 34 | unsafe { self.heap.deallocate(ptr, layout) }; 35 | true 36 | } else { 37 | false 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_receive_frame/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![no_main] 3 | 4 | use esp_alloc as _; 5 | use esp_backtrace as _; 6 | use esp_hal::main; 7 | use esp_println::println; 8 | use esp_radio::ieee802154::{Config, Ieee802154}; 9 | 10 | esp_bootloader_esp_idf::esp_app_desc!(); 11 | 12 | #[main] 13 | fn main() -> ! { 14 | esp_println::logger::init_logger_from_env(); 15 | let peripherals = esp_hal::init(esp_hal::Config::default()); 16 | 17 | esp_alloc::heap_allocator!(size: 24 * 1024); 18 | 19 | let mut ieee802154 = Ieee802154::new(peripherals.IEEE802154); 20 | 21 | ieee802154.set_config(Config { 22 | channel: 15, 23 | promiscuous: false, 24 | rx_when_idle: true, 25 | auto_ack_rx: true, 26 | auto_ack_tx: true, 27 | pan_id: Some(0x4242), 28 | short_addr: Some(0x2323), 29 | ..Default::default() 30 | }); 31 | 32 | println!("Start receiving:"); 33 | ieee802154.start_receive(); 34 | 35 | loop { 36 | if let Some(frame) = ieee802154.received() { 37 | println!("Received {:?}\n", &frame); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /qa-test/src/bin/sleep_timer.rs: -------------------------------------------------------------------------------- 1 | //! Demonstrates deep sleep with timer wakeup 2 | 3 | //% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 esp32c2 4 | 5 | #![no_std] 6 | #![no_main] 7 | 8 | use core::time::Duration; 9 | 10 | use esp_backtrace as _; 11 | use esp_hal::{ 12 | delay::Delay, 13 | main, 14 | rtc_cntl::{Rtc, SocResetReason, reset_reason, sleep::TimerWakeupSource, wakeup_cause}, 15 | system::Cpu, 16 | }; 17 | use esp_println::println; 18 | 19 | esp_bootloader_esp_idf::esp_app_desc!(); 20 | 21 | #[main] 22 | fn main() -> ! { 23 | let peripherals = esp_hal::init(esp_hal::Config::default()); 24 | 25 | let delay = Delay::new(); 26 | let mut rtc = Rtc::new(peripherals.LPWR); 27 | 28 | println!("up and runnning!"); 29 | let reason = reset_reason(Cpu::ProCpu).unwrap_or(SocResetReason::ChipPowerOn); 30 | println!("reset reason: {:?}", reason); 31 | let wake_reason = wakeup_cause(); 32 | println!("wake reason: {:?}", wake_reason); 33 | 34 | let timer = TimerWakeupSource::new(Duration::from_secs(5)); 35 | println!("sleeping!"); 36 | delay.delay_millis(100); 37 | rtc.sleep_deep(&[&timer]); 38 | } 39 | -------------------------------------------------------------------------------- /examples/async/embassy_multicore/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "embassy-multicore" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | embassy-executor = "0.9.0" 9 | embassy-sync = "0.7" 10 | embassy-time = "0.5.0" 11 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 12 | "panic-handler", 13 | "println", 14 | ] } 15 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 16 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 17 | esp-rtos = { path = "../../../esp-rtos", features = ["embassy", "log-04"] } 18 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 19 | static_cell = "2.1.1" 20 | 21 | [features] 22 | esp32 = [ 23 | "esp-backtrace/esp32", 24 | "esp-bootloader-esp-idf/esp32", 25 | "esp-rtos/esp32", 26 | "esp-hal/esp32", 27 | ] 28 | esp32s3 = [ 29 | "esp-backtrace/esp32s3", 30 | "esp-bootloader-esp-idf/esp32s3", 31 | "esp-rtos/esp32s3", 32 | "esp-hal/esp32s3", 33 | ] 34 | 35 | [profile.release] 36 | debug = true 37 | debug-assertions = true 38 | lto = "fat" 39 | codegen-units = 1 40 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_receive_frame/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ieee802154-receive-frame" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-alloc = { path = "../../../esp-alloc" } 9 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 16 | esp-radio = { path = "../../../esp-radio", features = [ 17 | "ieee802154", 18 | "unstable", 19 | ] } 20 | 21 | [features] 22 | esp32c6 = [ 23 | "esp-backtrace/esp32c6", 24 | "esp-bootloader-esp-idf/esp32c6", 25 | "esp-hal/esp32c6", 26 | "esp-radio/esp32c6", 27 | ] 28 | esp32h2 = [ 29 | "esp-backtrace/esp32h2", 30 | "esp-bootloader-esp-idf/esp32h2", 31 | "esp-hal/esp32h2", 32 | "esp-radio/esp32h2", 33 | ] 34 | 35 | [profile.release] 36 | debug = true 37 | debug-assertions = true 38 | lto = "fat" 39 | codegen-units = 1 40 | -------------------------------------------------------------------------------- /esp-radio/src/compat/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | pub mod common; 4 | pub mod malloc; 5 | pub mod misc; 6 | pub mod mutex; 7 | pub mod queue; 8 | pub mod semaphore; 9 | 10 | #[cfg(any(feature = "wifi", all(feature = "ble", bt_controller = "npl")))] 11 | pub mod timer_compat; 12 | 13 | pub(crate) const OSI_FUNCS_TIME_BLOCKING: u32 = u32::MAX; 14 | 15 | #[unsafe(no_mangle)] 16 | unsafe extern "C" fn __esp_radio_putchar(_c: u8) { 17 | #[cfg(feature = "sys-logs")] 18 | { 19 | static mut BUFFER: [u8; 256] = [0u8; 256]; 20 | static mut IDX: usize = 0; 21 | 22 | unsafe { 23 | let buffer = core::ptr::addr_of_mut!(BUFFER); 24 | if _c == 0 || _c == b'\n' || IDX == (*buffer).len() - 1 { 25 | if _c != 0 { 26 | BUFFER[IDX] = _c; 27 | } else { 28 | IDX = IDX.saturating_sub(1); 29 | } 30 | 31 | info!("{}", core::str::from_utf8_unchecked(&BUFFER[..IDX])); 32 | IDX = 0; 33 | } else { 34 | BUFFER[IDX] = _c; 35 | IDX += 1; 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_receive_all_frames/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ieee802154-receive-all-frames" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-alloc = { path = "../../../esp-alloc" } 9 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 16 | esp-radio = { path = "../../../esp-radio", features = [ 17 | "ieee802154", 18 | "unstable", 19 | ] } 20 | 21 | [features] 22 | esp32c6 = [ 23 | "esp-backtrace/esp32c6", 24 | "esp-bootloader-esp-idf/esp32c6", 25 | "esp-hal/esp32c6", 26 | "esp-radio/esp32c6", 27 | ] 28 | esp32h2 = [ 29 | "esp-backtrace/esp32h2", 30 | "esp-bootloader-esp-idf/esp32h2", 31 | "esp-hal/esp32h2", 32 | "esp-radio/esp32h2", 33 | ] 34 | 35 | [profile.release] 36 | debug = true 37 | debug-assertions = true 38 | lto = "fat" 39 | codegen-units = 1 40 | -------------------------------------------------------------------------------- /esp-rom-sys/src/rom/spiflash.rs: -------------------------------------------------------------------------------- 1 | //! Definitions of ROM functions related to flash memory. 2 | 3 | /// The operation succeeded 4 | pub const ESP_ROM_SPIFLASH_RESULT_OK: i32 = 0; 5 | 6 | /// The operation errored 7 | pub const ESP_ROM_SPIFLASH_RESULT_ERR: i32 = 1; 8 | 9 | /// The operation timed out 10 | pub const ESP_ROM_SPIFLASH_RESULT_TIMEOUT: i32 = 2; 11 | 12 | unsafe extern "C" { 13 | /// Read Data from Flash via ROM code, you should Erase it yourself if need. 14 | /// 15 | /// `src_addr` should be 4 bytes aligned. 16 | /// `len` should be 4 bytes aligned. 17 | pub fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32; 18 | 19 | /// Clear all SR bits except QE bit. 20 | pub fn esp_rom_spiflash_unlock() -> i32; 21 | 22 | /// Erase a sector of flash. Uses SPI flash command 20H. 23 | pub fn esp_rom_spiflash_erase_sector(sector_number: u32) -> i32; 24 | 25 | /// Write Data to Flash, you should Erase it yourself if need. 26 | /// 27 | /// `dest_addr` should be 4 bytes aligned. 28 | /// `len` should be 4 bytes aligned. 29 | pub fn esp_rom_spiflash_write(dest_addr: u32, data: *const u32, len: u32) -> i32; 30 | } 31 | -------------------------------------------------------------------------------- /examples/async/embassy_multicore_interrupt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "embassy-multicore-interrupt" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | embassy-executor = "0.9.0" 9 | embassy-sync = "0.7" 10 | embassy-time = "0.5.0" 11 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 12 | "panic-handler", 13 | "println", 14 | ] } 15 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 16 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 17 | esp-rtos = { path = "../../../esp-rtos", features = ["embassy", "log-04"] } 18 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 19 | static_cell = "2.1.1" 20 | 21 | [features] 22 | esp32 = [ 23 | "esp-backtrace/esp32", 24 | "esp-bootloader-esp-idf/esp32", 25 | "esp-rtos/esp32", 26 | "esp-hal/esp32", 27 | ] 28 | esp32s3 = [ 29 | "esp-backtrace/esp32s3", 30 | "esp-bootloader-esp-idf/esp32s3", 31 | "esp-rtos/esp32s3", 32 | "esp-hal/esp32s3", 33 | ] 34 | 35 | [profile.release] 36 | debug = true 37 | debug-assertions = true 38 | lto = "fat" 39 | codegen-units = 1 40 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_send_frame/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ieee802154-send-frame" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-alloc = { path = "../../../esp-alloc" } 9 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 16 | esp-radio = { path = "../../../esp-radio", features = [ 17 | "ieee802154", 18 | "unstable", 19 | ] } 20 | ieee802154 = "0.6.1" 21 | 22 | [features] 23 | esp32c6 = [ 24 | "esp-backtrace/esp32c6", 25 | "esp-bootloader-esp-idf/esp32c6", 26 | "esp-hal/esp32c6", 27 | "esp-radio/esp32c6", 28 | ] 29 | esp32h2 = [ 30 | "esp-backtrace/esp32h2", 31 | "esp-bootloader-esp-idf/esp32h2", 32 | "esp-hal/esp32h2", 33 | "esp-radio/esp32h2", 34 | ] 35 | 36 | [profile.release] 37 | debug = true 38 | debug-assertions = true 39 | lto = "fat" 40 | codegen-units = 1 41 | -------------------------------------------------------------------------------- /examples/async/embassy_usb_serial/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "embassy-usb-serial" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | embassy-executor = "0.9.0" 9 | embassy-futures = "0.1" 10 | embassy-usb = { version = "0.5.0", default-features = false } 11 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 12 | "panic-handler", 13 | "println", 14 | ] } 15 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 16 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 17 | esp-rtos = { path = "../../../esp-rtos", features = ["embassy", "log-04"] } 18 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 19 | 20 | [features] 21 | esp32s2 = [ 22 | "esp-backtrace/esp32s2", 23 | "esp-bootloader-esp-idf/esp32s2", 24 | "esp-rtos/esp32s2", 25 | "esp-hal/esp32s2", 26 | ] 27 | esp32s3 = [ 28 | "esp-backtrace/esp32s3", 29 | "esp-bootloader-esp-idf/esp32s3", 30 | "esp-rtos/esp32s3", 31 | "esp-hal/esp32s3", 32 | ] 33 | 34 | [profile.release] 35 | debug = true 36 | debug-assertions = true 37 | lto = "fat" 38 | codegen-units = 1 39 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_sniffer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ieee802154-sniffer" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | cfg-if = "1" 9 | esp-alloc = { path = "../../../esp-alloc" } 10 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 11 | "panic-handler", 12 | "println", 13 | ] } 14 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 15 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 16 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 17 | esp-radio = { path = "../../../esp-radio", features = [ 18 | "ieee802154", 19 | "unstable", 20 | ] } 21 | ieee802154 = "0.6.1" 22 | 23 | [features] 24 | esp32c6 = [ 25 | "esp-backtrace/esp32c6", 26 | "esp-bootloader-esp-idf/esp32c6", 27 | "esp-hal/esp32c6", 28 | "esp-radio/esp32c6", 29 | ] 30 | esp32h2 = [ 31 | "esp-backtrace/esp32h2", 32 | "esp-bootloader-esp-idf/esp32h2", 33 | "esp-hal/esp32h2", 34 | "esp-radio/esp32h2", 35 | ] 36 | 37 | [profile.release] 38 | debug = true 39 | debug-assertions = true 40 | lto = "fat" 41 | codegen-units = 1 42 | -------------------------------------------------------------------------------- /esp-hal/src/soc/esp32/regi2c.rs: -------------------------------------------------------------------------------- 1 | use crate::rom::regi2c::{RegI2cMaster, RegI2cRegister, define_regi2c}; 2 | 3 | define_regi2c! { 4 | master: REGI2C_BBPLL(0x66, 4) { 5 | reg: I2C_BBPLL_IR_CAL_DELAY(0) {} 6 | reg: I2C_BBPLL_IR_CAL_EXT_CAP(1) {} 7 | reg: I2C_BBPLL_OC_LREF(2) {} 8 | reg: I2C_BBPLL_OC_DIV_REG(3) {} 9 | reg: I2C_BBPLL_OC_ENB_FCAL(4) {} 10 | reg: I2C_BBPLL_OC_DCUR(5) {} 11 | reg: I2C_BBPLL_BBADC_DSMP(9) {} 12 | reg: I2C_BBPLL_OC_ENB_VCON(10) {} 13 | reg: I2C_BBPLL_ENDIV5(11) {} 14 | reg: I2C_BBPLL_BBADC_CAL_REG(12) {} 15 | } 16 | } 17 | 18 | pub(crate) fn regi2c_read(block: u8, host_id: u8, reg_add: u8) -> u8 { 19 | unsafe extern "C" { 20 | pub(crate) fn esp_rom_regi2c_read(block: u8, block_hostid: u8, reg_add: u8) -> u8; 21 | } 22 | unsafe { esp_rom_regi2c_read(block, host_id, reg_add) } 23 | } 24 | 25 | pub(crate) fn regi2c_write(block: u8, host_id: u8, reg_add: u8, data: u8) { 26 | unsafe extern "C" { 27 | pub(crate) fn rom_i2c_writeReg(block: u8, block_hostid: u8, reg_add: u8, indata: u8); 28 | } 29 | unsafe { rom_i2c_writeReg(block, host_id, reg_add, data) }; 30 | } 31 | -------------------------------------------------------------------------------- /examples/ieee802154/ieee802154_send_broadcast_frame/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ieee802154-send-broadcast-frame" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-alloc = { path = "../../../esp-alloc" } 9 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 16 | esp-radio = { path = "../../../esp-radio", features = [ 17 | "ieee802154", 18 | "unstable", 19 | ] } 20 | ieee802154 = "0.6.1" 21 | 22 | [features] 23 | esp32c6 = [ 24 | "esp-backtrace/esp32c6", 25 | "esp-bootloader-esp-idf/esp32c6", 26 | "esp-hal/esp32c6", 27 | "esp-radio/esp32c6", 28 | ] 29 | esp32h2 = [ 30 | "esp-backtrace/esp32h2", 31 | "esp-bootloader-esp-idf/esp32h2", 32 | "esp-hal/esp32h2", 33 | "esp-radio/esp32h2", 34 | ] 35 | 36 | [profile.release] 37 | debug = true 38 | debug-assertions = true 39 | lto = "fat" 40 | codegen-units = 1 41 | -------------------------------------------------------------------------------- /esp-storage/build.rs: -------------------------------------------------------------------------------- 1 | use esp_metadata_generated::{Chip, emit_check_cfg_directives}; 2 | 3 | fn main() -> Result<(), String> { 4 | if !cfg!(feature = "emulation") { 5 | // Load the configuration file for the configured device: 6 | let chip = Chip::from_cargo_feature()?; 7 | 8 | // Define all necessary configuration symbols for the configured device: 9 | chip.define_cfgs(); 10 | } else { 11 | // Even though we don't have a chip, make sure we're not warned about the config symbols. 12 | emit_check_cfg_directives(); 13 | } 14 | if cfg!(feature = "esp32") { 15 | match std::env::var("OPT_LEVEL") { 16 | Ok(level) if std::env::var("CI").is_err() => { 17 | if level != "2" && level != "3" && level != "s" { 18 | Err(format!( 19 | "Building esp-storage for ESP32 needs optimization level 2, 3 or s - yours is {level}. See https://github.com/esp-rs/esp-storage" 20 | )) 21 | } else { 22 | Ok(()) 23 | } 24 | } 25 | _ => Ok(()), 26 | } 27 | } else { 28 | Ok(()) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /qa-test/src/bin/i2c_bmp180_calibration_data.rs: -------------------------------------------------------------------------------- 1 | //! Read calibration data from BMP180 sensor 2 | //! 3 | //! This example dumps the calibration data from a BMP180 sensor 4 | //! 5 | //! The following wiring is assumed: 6 | //! - SDA => GPIO4 7 | //! - SCL => GPIO5 8 | 9 | //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 10 | //% TAG: bmp180 11 | 12 | #![no_std] 13 | #![no_main] 14 | 15 | use esp_backtrace as _; 16 | use esp_hal::{ 17 | i2c::master::{Config, I2c}, 18 | main, 19 | }; 20 | use esp_println::println; 21 | 22 | esp_bootloader_esp_idf::esp_app_desc!(); 23 | 24 | #[main] 25 | fn main() -> ! { 26 | esp_println::logger::init_logger_from_env(); 27 | let peripherals = esp_hal::init(esp_hal::Config::default()); 28 | 29 | // Create a new peripheral object with the described wiring and standard 30 | // I2C clock speed: 31 | let mut i2c = I2c::new(peripherals.I2C0, Config::default()) 32 | .unwrap() 33 | .with_sda(peripherals.GPIO4) 34 | .with_scl(peripherals.GPIO5); 35 | 36 | loop { 37 | let mut data = [0u8; 22]; 38 | i2c.write_read(0x77, &[0xaa], &mut data).ok(); 39 | 40 | println!("{:02x?}", data); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /esp-hal/src/rom/mod.rs: -------------------------------------------------------------------------------- 1 | //! # ESP ROM libraries 2 | //! 3 | //! ## Overview 4 | //! The `rom` driver provides functionality related to the ROM (Read-Only 5 | //! Memory) on ESP chips. It includes implementations for the [CRC (Cyclic 6 | //! Redundancy Check)] and [MD5 (Message Digest 5)] algorithms. 7 | //! 8 | //! The driver's functionality allows users to perform CRC calculations and MD5 9 | //! hashing using the ROM functions provided by the ESP chip. This can be useful 10 | //! for various applications that require data integrity checks or cryptographic 11 | //! operations. 12 | //! 13 | //! It uses `CRC` error-checking techniques to detect changes in data during 14 | //! transmission or storage. 15 | //! 16 | //! This module also implements the `MD5` algorithm, which is widely used for 17 | //! cryptographic hash function. It's commonly used to verify data integrity and 18 | //! to check whether the data has been modified. 19 | //! 20 | //! Safe abstractions to the additional libraries provided in the ESP's 21 | //! Read-Only Memory. 22 | //! 23 | //! [CRC (Cyclic Redundancy Check)]: ./crc/index.html 24 | //! [MD5 (Message Digest 5)]: ./md5/index.html 25 | 26 | pub use esp_rom_sys::rom::*; 27 | 28 | pub(crate) mod regi2c; 29 | -------------------------------------------------------------------------------- /esp-radio/src/radio/radio_esp32s2.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "wifi")] 2 | #[allow(unused_imports)] 3 | use crate::hal::{interrupt, peripherals}; 4 | 5 | pub(crate) fn setup_radio_isr() { 6 | // wifi enabled in set_isr 7 | // ble not supported 8 | } 9 | 10 | pub(crate) fn shutdown_radio_isr() { 11 | // ble not supported 12 | } 13 | 14 | #[cfg(feature = "wifi")] 15 | #[unsafe(no_mangle)] 16 | extern "C" fn WIFI_MAC() { 17 | unsafe { 18 | let (fnc, arg) = crate::wifi::os_adapter::ISR_INTERRUPT_1; 19 | trace!("interrupt WIFI_MAC {:?} {:?}", fnc, arg); 20 | 21 | if !fnc.is_null() { 22 | let fnc: fn(*mut crate::sys::c_types::c_void) = core::mem::transmute(fnc); 23 | fnc(arg); 24 | } 25 | } 26 | } 27 | 28 | #[cfg(feature = "wifi")] 29 | #[unsafe(no_mangle)] 30 | extern "C" fn WIFI_PWR() { 31 | unsafe { 32 | let (fnc, arg) = crate::wifi::os_adapter::ISR_INTERRUPT_1; 33 | 34 | trace!("interrupt WIFI_PWR {:?} {:?}", fnc, arg); 35 | 36 | if !fnc.is_null() { 37 | let fnc: fn(*mut crate::sys::c_types::c_void) = core::mem::transmute(fnc); 38 | fnc(arg); 39 | } 40 | 41 | trace!("interrupt 1 done"); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /esp-hal/src/gpio/placeholder.rs: -------------------------------------------------------------------------------- 1 | //! Placeholder pins/signals. 2 | //! 3 | //! These are useful to pass them into peripheral drivers where you don't want 4 | //! an actual pin but one is required. 5 | // This module also contains peripheral signal impls for `Level` to avoid 6 | // polluting the main module. 7 | 8 | use super::*; 9 | 10 | /// Placeholder pin, used when no pin is required when using a peripheral. 11 | /// 12 | /// When used as a peripheral signal, `NoPin` is equivalent to [`Level::Low`]. 13 | #[derive(Default, Clone, Copy)] 14 | pub struct NoPin; 15 | 16 | impl private::Sealed for NoPin {} 17 | 18 | impl embedded_hal::digital::ErrorType for NoPin { 19 | type Error = core::convert::Infallible; 20 | } 21 | 22 | impl embedded_hal::digital::OutputPin for NoPin { 23 | fn set_low(&mut self) -> Result<(), Self::Error> { 24 | Ok(()) 25 | } 26 | 27 | fn set_high(&mut self) -> Result<(), Self::Error> { 28 | Ok(()) 29 | } 30 | } 31 | 32 | impl embedded_hal::digital::StatefulOutputPin for NoPin { 33 | fn is_set_high(&mut self) -> Result { 34 | Ok(false) 35 | } 36 | 37 | fn is_set_low(&mut self) -> Result { 38 | Ok(false) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /esp-bootloader-esp-idf/src/non_rom.rs: -------------------------------------------------------------------------------- 1 | use crc::{Algorithm, Crc}; 2 | use md5::Digest; 3 | 4 | static ALGO_CRC32_NORMAL: Algorithm = Algorithm { 5 | width: 32, 6 | poly: 0x04c11db7, 7 | init: 0, 8 | refin: true, 9 | refout: true, 10 | xorout: 0xffffffff, 11 | check: 0, 12 | residue: 0, 13 | }; 14 | 15 | pub struct Crc32 { 16 | algo: Crc, 17 | } 18 | 19 | impl Crc32 { 20 | pub fn new() -> Self { 21 | Self { 22 | algo: Crc::::new(&ALGO_CRC32_NORMAL), 23 | } 24 | } 25 | 26 | pub fn crc(&self, data: &[u8]) -> u32 { 27 | let mut digest = self.algo.digest(); 28 | digest.update(&data); 29 | digest.finalize() 30 | } 31 | } 32 | 33 | pub struct Md5 { 34 | context: md5::Md5, 35 | } 36 | 37 | impl Md5 { 38 | pub fn new() -> Self { 39 | Self { 40 | context: md5::Md5::new(), 41 | } 42 | } 43 | 44 | pub fn update(&mut self, data: &[u8]) { 45 | self.context.update(data); 46 | } 47 | 48 | pub fn finalize(self) -> [u8; 16] { 49 | let digest = self.context.finalize(); 50 | let mut hash = [0; 16]; 51 | hash.copy_from_slice(&digest); 52 | hash 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /esp-phy/build.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error as StdError; 2 | 3 | use esp_config::generate_config_from_yaml_definition; 4 | 5 | fn main() -> Result<(), Box> { 6 | // Load the configuration for the configured device: 7 | let chip = esp_metadata_generated::Chip::from_cargo_feature()?; 8 | 9 | // Define all necessary configuration symbols for the configured device: 10 | chip.define_cfgs(); 11 | 12 | println!("cargo:rerun-if-changed=./esp_config.yml"); 13 | let cfg_yaml = std::fs::read_to_string("./esp_config.yml") 14 | .expect("Failed to read esp_config.yml for esp-phy"); 15 | let _cfg = generate_config_from_yaml_definition(&cfg_yaml, true, true, Some(chip)).unwrap(); 16 | 17 | let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap()); 18 | println!("cargo:rustc-link-search={}", out.display()); 19 | 20 | let linker_script = "phy_provides.x"; 21 | let out_file = out.join("libesp-phy.a"); 22 | let _ = std::fs::copy(linker_script, out_file); 23 | println!("cargo:rerun-if-changed={linker_script}"); 24 | // exploit the fact that linkers treat an unknown library format as a linker 25 | // script 26 | println!("cargo:rustc-link-lib=esp-phy"); 27 | 28 | Ok(()) 29 | } 30 | -------------------------------------------------------------------------------- /esp-rtos/build.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | use esp_config::generate_config_from_yaml_definition; 4 | 5 | fn main() -> Result<(), Box> { 6 | // Ensure that exactly one chip has been specified: 7 | let chip = esp_metadata_generated::Chip::from_cargo_feature()?; 8 | 9 | // Define all necessary configuration symbols for the configured device: 10 | chip.define_cfgs(); 11 | 12 | // emit config 13 | println!("cargo:rerun-if-changed=./esp_config.yml"); 14 | let cfg_yaml = std::fs::read_to_string("./esp_config.yml") 15 | .expect("Failed to read esp_config.yml for esp-rtos"); 16 | generate_config_from_yaml_definition(&cfg_yaml, true, true, Some(chip)).unwrap(); 17 | 18 | // Emit the default stack guard offset if not set by the user. 19 | if std::env::var("ESP_HAL_CONFIG_STACK_GUARD_OFFSET").is_err() { 20 | println!("cargo:rustc-env=ESP_HAL_CONFIG_STACK_GUARD_OFFSET=60"); 21 | } 22 | 23 | let debug_build = ["0", "1"]; 24 | println!("cargo:rustc-check-cfg=cfg(debug_build)"); 25 | if let Ok(level) = std::env::var("OPT_LEVEL") 26 | && debug_build.iter().any(|&x| x == level) 27 | { 28 | println!("cargo:rustc-cfg=debug_build") 29 | } 30 | 31 | Ok(()) 32 | } 33 | -------------------------------------------------------------------------------- /examples/async/embassy_hello_world_defmt/src/main.rs: -------------------------------------------------------------------------------- 1 | //! embassy hello world 2 | //! 3 | //! This is an example of running the embassy executor with multiple tasks 4 | //! concurrently. 5 | 6 | #![no_std] 7 | #![no_main] 8 | 9 | use embassy_executor::Spawner; 10 | use embassy_time::{Duration, Timer}; 11 | use esp_backtrace as _; 12 | use esp_hal::{interrupt::software::SoftwareInterruptControl, timer::timg::TimerGroup}; 13 | use esp_println as _; 14 | 15 | esp_bootloader_esp_idf::esp_app_desc!(); 16 | 17 | #[embassy_executor::task] 18 | async fn run() { 19 | loop { 20 | defmt::info!("Hello world from embassy!"); 21 | Timer::after(Duration::from_millis(1_000)).await; 22 | } 23 | } 24 | 25 | #[esp_rtos::main] 26 | async fn main(spawner: Spawner) { 27 | let peripherals = esp_hal::init(esp_hal::Config::default()); 28 | 29 | defmt::info!("Init!"); 30 | 31 | let sw_int = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); 32 | let timg0 = TimerGroup::new(peripherals.TIMG0); 33 | esp_rtos::start(timg0.timer0, sw_int.software_interrupt0); 34 | 35 | spawner.spawn(run()).ok(); 36 | 37 | loop { 38 | defmt::info!("Bing!"); 39 | Timer::after(Duration::from_millis(5_000)).await; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /esp-config/src/generate/markdown.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::Write; 2 | 3 | use crate::{ConfigOption, Value}; 4 | 5 | pub(crate) const DOC_TABLE_HEADER: &str = r#" 6 | | Option | Stability | Default value | Allowed values | 7 | |--------|:---------:|:------------------:|:-------------------:| 8 | "#; 9 | 10 | pub(crate) const SELECTED_TABLE_HEADER: &str = r#" 11 | | Name | Selected value | 12 | |------|----------------| 13 | "#; 14 | 15 | pub(crate) fn write_doc_table_line(mut table: impl Write, name: &str, option: &ConfigOption) { 16 | let allowed_values = option 17 | .constraint 18 | .as_ref() 19 | .and_then(|validator| validator.description()) 20 | .unwrap_or_default(); 21 | 22 | writeln!( 23 | table, 24 | "|

**{key}**

{description}

| {stability} | {default} | {allowed}", 25 | description = option.description, 26 | key = name, 27 | stability = option.stability, 28 | default = option.display_hint.format_value(&option.default_value), 29 | allowed = allowed_values 30 | ) 31 | .unwrap(); 32 | } 33 | 34 | pub(crate) fn write_summary_table_line(mut table: impl Write, name: &str, value: &Value) { 35 | writeln!(table, "|**{name}**|{value}|").unwrap(); 36 | } 37 | -------------------------------------------------------------------------------- /esp-lp-hal/examples/blinky.rs: -------------------------------------------------------------------------------- 1 | //! Counts a 32 bit value at a known point in memory, and blink GPIO1. 2 | //! 3 | //! When using the ESP32-C6's LP core, this address in memory is `0x5000_2000`. 4 | //! 5 | //! When using the ESP32-S2 or ESP32-S3's ULP core, this address in memory is 6 | //! `0x5000_0400` (but is `0x400`` from the ULP's point of view!). 7 | //! 8 | //! Make sure the LP RAM is cleared before loading the code. 9 | 10 | #![no_std] 11 | #![no_main] 12 | 13 | use embedded_hal::{delay::DelayNs, digital::OutputPin}; 14 | use esp_lp_hal::{delay::Delay, gpio::Output, prelude::*}; 15 | use panic_halt as _; 16 | 17 | cfg_if::cfg_if! { 18 | if #[cfg(feature = "esp32c6")] { 19 | const ADDRESS: u32 = 0x5000_2000; 20 | } else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] { 21 | const ADDRESS: u32 = 0x400; 22 | } 23 | } 24 | 25 | #[entry] 26 | fn main(mut gpio1: Output<1>) -> ! { 27 | let mut i: u32 = 0; 28 | 29 | let ptr = ADDRESS as *mut u32; 30 | 31 | loop { 32 | i = i.wrapping_add(1u32); 33 | unsafe { 34 | ptr.write_volatile(i); 35 | } 36 | 37 | gpio1.set_high().unwrap(); 38 | Delay.delay_ms(500); 39 | 40 | gpio1.set_low().unwrap(); 41 | Delay.delay_ms(500); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.ble_scan.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32c3.rom.ld for esp32c3 7 | * 8 | * 9 | * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | 17 | /* BLE scan */ 18 | f_hci_le_set_scan_param_cmd_handler = 0; 19 | f_hci_le_set_scan_en_cmd_handler = 0; 20 | f_llm_scan_period_to_handler_hack = 0; 21 | f_lld_adv_rep_ind_handler_hack = 0; 22 | r_lld_scan_init = 0; 23 | r_lld_scan_restart = 0; 24 | f_lld_scan_end_ind_handler_hack = 0; 25 | r_llm_env_adv_dup_filt_deinit_eco = 0; 26 | llm_exception_list_init = 0; 27 | llm_duplicate_list_init = 0; 28 | f_hci_vendor_ble_update_duplicate_exceptional_list_cmd_handler = 0; 29 | f_hci_vendor_ble_init_adv_flow_control_cmd_handler = 0; 30 | f_hci_vendor_ble_update_adv_report_flow_control_cmd_handler = 0; 31 | coex_schm_ble_scan_stop = 0; 32 | 33 | f_hci_le_set_ext_scan_param_cmd_handler = 0; 34 | f_hci_le_set_ext_scan_en_cmd_handler = 0; 35 | r_lld_scan_process_pkt_rx_ext_adv = 0; 36 | r_lld_scan_trunc_ind = 0; 37 | -------------------------------------------------------------------------------- /esp-storage/src/buffer.rs: -------------------------------------------------------------------------------- 1 | use core::{mem::MaybeUninit, slice}; 2 | 3 | pub fn uninit_slice(bytes: &[u8]) -> &[MaybeUninit] { 4 | unsafe { core::slice::from_raw_parts(bytes.as_ptr() as *const _, bytes.len()) } 5 | } 6 | 7 | pub fn uninit_slice_mut(bytes: &mut [u8]) -> &mut [MaybeUninit] { 8 | unsafe { core::slice::from_raw_parts_mut(bytes.as_mut_ptr() as *mut _, bytes.len()) } 9 | } 10 | 11 | pub type FlashWordBuffer = FlashBuffer<4>; 12 | 13 | pub type FlashSectorBuffer = FlashBuffer<4096>; 14 | 15 | #[repr(C, align(4))] 16 | pub union FlashBuffer { 17 | bytes: [MaybeUninit; N], 18 | } 19 | 20 | impl FlashBuffer { 21 | pub const fn uninit() -> Self { 22 | Self { 23 | bytes: [MaybeUninit::uninit(); N], 24 | } 25 | } 26 | 27 | pub fn as_bytes_mut(&mut self) -> &mut [MaybeUninit] { 28 | unsafe { self.bytes.as_mut() } 29 | } 30 | 31 | pub unsafe fn assume_init_bytes(&self) -> &[u8] { 32 | unsafe { slice::from_raw_parts(self.bytes.as_ptr() as *const _, self.bytes.len()) } 33 | } 34 | 35 | pub unsafe fn assume_init_bytes_mut(&mut self) -> &mut [u8] { 36 | unsafe { slice::from_raw_parts_mut(self.bytes.as_mut_ptr() as *mut _, self.bytes.len()) } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/async/embassy_hello_world/src/main.rs: -------------------------------------------------------------------------------- 1 | //! embassy hello world 2 | //! 3 | //! This is an example of running the embassy executor with multiple tasks 4 | //! concurrently. 5 | 6 | #![no_std] 7 | #![no_main] 8 | 9 | use embassy_executor::Spawner; 10 | use embassy_time::{Duration, Timer}; 11 | use esp_backtrace as _; 12 | use esp_hal::{interrupt::software::SoftwareInterruptControl, timer::timg::TimerGroup}; 13 | 14 | esp_bootloader_esp_idf::esp_app_desc!(); 15 | 16 | #[embassy_executor::task] 17 | async fn run() { 18 | loop { 19 | esp_println::println!("Hello world from embassy!"); 20 | Timer::after(Duration::from_millis(1_000)).await; 21 | } 22 | } 23 | 24 | #[esp_rtos::main] 25 | async fn main(spawner: Spawner) { 26 | esp_println::logger::init_logger_from_env(); 27 | let peripherals = esp_hal::init(esp_hal::Config::default()); 28 | 29 | esp_println::println!("Init!"); 30 | 31 | let sw_int = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); 32 | let timg0 = TimerGroup::new(peripherals.TIMG0); 33 | esp_rtos::start(timg0.timer0, sw_int.software_interrupt0); 34 | 35 | spawner.spawn(run()).ok(); 36 | 37 | loop { 38 | esp_println::println!("Bing!"); 39 | Timer::after(Duration::from_millis(5_000)).await; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /hil-test/src/bin/storage_read_app_desc.rs: -------------------------------------------------------------------------------- 1 | //! Test we place the app descriptor at the right position in the image and we 2 | //! can read it 3 | 4 | //% CHIPS: esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6 esp32h2 5 | //% FEATURES: unstable esp-storage 6 | 7 | #![no_std] 8 | #![no_main] 9 | 10 | use embedded_storage::ReadStorage; 11 | use esp_bootloader_esp_idf::EspAppDesc; 12 | use esp_storage::FlashStorage; 13 | use hil_test as _; 14 | 15 | #[embedded_test::tests(default_timeout = 3)] 16 | mod tests { 17 | use super::*; 18 | 19 | #[test] 20 | fn test_can_read_app_desc() { 21 | let peripherals = esp_hal::init(esp_hal::Config::default()); 22 | 23 | let mut bytes = [0u8; 256]; 24 | 25 | let mut flash = FlashStorage::new(peripherals.FLASH); 26 | 27 | // esp-idf 2nd stage bootloader would expect the app-descriptor at the start of 28 | // DROM it also expects DROM segment to the the first page of the 29 | // app-image and we need to account for the image header - so we end up 30 | // with flash-address 0x10_000 + 0x20 31 | flash.read(0x10_020, &mut bytes).unwrap(); 32 | 33 | assert_eq!(&bytes, unsafe { 34 | core::mem::transmute::<&EspAppDesc, &[u8; 256]>(&hil_test::ESP_APP_DESC) 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xtensa-lx-rt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xtensa-lx-rt" 3 | version = "0.21.0" 4 | edition = "2024" 5 | rust-version = "1.88.0" 6 | description = "Minimal startup/runtime for Xtensa LX CPUs" 7 | documentation = "https://docs.espressif.com/projects/rust/xtensa-lx-rt/latest/" 8 | repository = "https://github.com/esp-rs/esp-hal" 9 | license = "MIT OR Apache-2.0" 10 | keywords = ["lx", "peripheral", "register", "xtensa"] 11 | categories = ["embedded", "hardware-support", "no-std"] 12 | links = "xtensa-lx-rt" 13 | 14 | [package.metadata.espressif] 15 | requires_target = ["xtensa-esp32-none-elf", "xtensa-esp32s2-none-elf", "xtensa-esp32s3-none-elf"] 16 | 17 | [lib] 18 | bench = false 19 | test = false 20 | 21 | [dependencies] 22 | document-features = "0.2" 23 | defmt = {version = "1.0.1", optional = true} 24 | macros = { version = "0.5.0", package = "xtensa-lx-rt-proc-macros", path = "../xtensa-lx-rt-proc-macros" } 25 | xtensa-lx = { version = "0.13.0", path = "../xtensa-lx" } 26 | 27 | [build-dependencies] 28 | 29 | [features] 30 | ## Save and restore float registers for exceptions 31 | float-save-restore = [] 32 | 33 | ## Implement `defmt::Format` 34 | defmt = ["dep:defmt"] 35 | 36 | [lints.rust] 37 | unexpected_cfgs = "allow" 38 | -------------------------------------------------------------------------------- /esp-hal/ld/sections/rwdata.x: -------------------------------------------------------------------------------- 1 | .data : ALIGN(4) 2 | { 3 | _data_start = ABSOLUTE(.); 4 | . = ALIGN (4); 5 | 6 | #IF ESP_HAL_CONFIG_PLACE_SWITCH_TABLES_IN_RAM 7 | *(.rodata.*_esp_hal_internal_handler*) 8 | *(.rodata..Lswitch.table.*) 9 | *(.rodata.cst*) 10 | #ENDIF 11 | 12 | #IF ESP_HAL_CONFIG_PLACE_ANON_IN_RAM 13 | *(.rodata..Lanon .rodata..Lanon.*) 14 | #ENDIF 15 | 16 | *(.sdata .sdata.* .sdata2 .sdata2.*); 17 | *(.data .data.*); 18 | *(.data1) 19 | _data_end = ABSOLUTE(.); 20 | . = ALIGN(4); 21 | } > RWDATA 22 | 23 | /* LMA of .data */ 24 | _sidata = LOADADDR(.data); 25 | 26 | .data.wifi : 27 | { 28 | . = ALIGN(4); 29 | *( .dram1 .dram1.*) 30 | . = ALIGN(4); 31 | } > RWDATA 32 | 33 | .bss (NOLOAD) : ALIGN(4) 34 | { 35 | _bss_start = ABSOLUTE(.); 36 | . = ALIGN (4); 37 | *(.dynsbss) 38 | *(.sbss) 39 | *(.sbss.*) 40 | *(.gnu.linkonce.sb.*) 41 | *(.scommon) 42 | *(.sbss2) 43 | *(.sbss2.*) 44 | *(.gnu.linkonce.sb2.*) 45 | *(.dynbss) 46 | *(.sbss .sbss.* .bss .bss.*); 47 | *(.share.mem) 48 | *(.gnu.linkonce.b.*) 49 | *(COMMON) 50 | _bss_end = ABSOLUTE(.); 51 | . = ALIGN(4); 52 | } > RWDATA 53 | 54 | .noinit (NOLOAD) : ALIGN(4) 55 | { 56 | . = ALIGN(4); 57 | *(.noinit .noinit.*) 58 | *(.uninit .uninit.*) 59 | . = ALIGN(4); 60 | } > RWDATA 61 | -------------------------------------------------------------------------------- /esp-radio/src/compat/mutex.rs: -------------------------------------------------------------------------------- 1 | use esp_radio_rtos_driver::semaphore::SemaphoreKind; 2 | 3 | use crate::{ 4 | preempt::semaphore::{SemaphoreHandle, SemaphorePtr}, 5 | sys::c_types::c_void, 6 | }; 7 | 8 | pub(crate) fn mutex_create(recursive: bool) -> *mut c_void { 9 | let ptr = SemaphoreHandle::new(if recursive { 10 | SemaphoreKind::RecursiveMutex 11 | } else { 12 | SemaphoreKind::Mutex 13 | }) 14 | .leak() 15 | .as_ptr() 16 | .cast(); 17 | 18 | trace!("mutex_create -> {:?}", ptr); 19 | 20 | ptr 21 | } 22 | 23 | pub(crate) fn mutex_delete(mutex: *mut c_void) { 24 | let ptr = unwrap!(SemaphorePtr::new(mutex.cast()), "mutex is null"); 25 | 26 | let handle = unsafe { SemaphoreHandle::from_ptr(ptr) }; 27 | core::mem::drop(handle); 28 | } 29 | 30 | pub(crate) fn mutex_lock(mutex: *mut c_void) -> i32 { 31 | let ptr = unwrap!(SemaphorePtr::new(mutex.cast()), "mutex is null"); 32 | 33 | let handle = unsafe { SemaphoreHandle::ref_from_ptr(&ptr) }; 34 | 35 | handle.take(None) as i32 36 | } 37 | 38 | pub(crate) fn mutex_unlock(mutex: *mut c_void) -> i32 { 39 | let ptr = unwrap!(SemaphorePtr::new(mutex.cast()), "mutex is null"); 40 | 41 | let handle = unsafe { SemaphoreHandle::ref_from_ptr(&ptr) }; 42 | 43 | handle.give() as i32 44 | } 45 | -------------------------------------------------------------------------------- /hil-test/src/bin/misc_non_drivers/clock_monitor.rs: -------------------------------------------------------------------------------- 1 | #[embedded_test::tests(default_timeout = 3)] 2 | mod tests { 3 | use esp_hal::rtc_cntl::Rtc; 4 | 5 | struct Context<'a> { 6 | rtc: Rtc<'a>, 7 | } 8 | #[init] 9 | fn init() -> Context<'static> { 10 | let peripherals = esp_hal::init(esp_hal::Config::default()); 11 | let rtc = Rtc::new(peripherals.LPWR); 12 | 13 | Context { rtc } 14 | } 15 | 16 | #[test] 17 | fn test_estimated_clock(mut ctx: Context<'static>) { 18 | let target_frequency = if cfg!(esp32c2) { 19 | 26 20 | } else if cfg!(esp32h2) { 21 | 32 22 | } else { 23 | 40 24 | }; 25 | 26 | // The internal RC oscillators are not very accurate at all. Leave a 20% acceptance range 27 | // around the expected value. 28 | let twenty_percent = 20 * target_frequency / 100; 29 | let expected_range = 30 | (target_frequency - twenty_percent)..=(target_frequency + twenty_percent); 31 | 32 | let measured_frequency = ctx.rtc.estimate_xtal_frequency(); 33 | hil_test::assert!( 34 | expected_range.contains(&measured_frequency), 35 | "Measured frequency: {}", 36 | measured_frequency 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /qa-test/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | esp32 = "run --release --features=esp32 --target=xtensa-esp32-none-elf" 3 | esp32c2 = "run --release --features=esp32c2 --target=riscv32imc-unknown-none-elf" 4 | esp32c3 = "run --release --features=esp32c3 --target=riscv32imc-unknown-none-elf" 5 | esp32c6 = "run --release --features=esp32c6 --target=riscv32imac-unknown-none-elf" 6 | esp32h2 = "run --release --features=esp32h2 --target=riscv32imac-unknown-none-elf" 7 | esp32s2 = "run --release --features=esp32s2 --target=xtensa-esp32s2-none-elf" 8 | esp32s3 = "run --release --features=esp32s3 --target=xtensa-esp32s3-none-elf" 9 | 10 | [target.'cfg(target_arch = "riscv32")'] 11 | runner = "espflash flash --monitor" 12 | rustflags = [ 13 | "-C", "link-arg=-Tlinkall.x", 14 | "-C", "force-frame-pointers", 15 | ] 16 | 17 | [target.'cfg(target_arch = "xtensa")'] 18 | runner = "espflash flash --monitor" 19 | rustflags = [ 20 | # GNU LD 21 | "-C", "link-arg=-Wl,-Tlinkall.x", 22 | "-C", "link-arg=-nostartfiles", 23 | 24 | # LLD 25 | # "-C", "link-arg=-Tlinkall.x", 26 | # "-C", "linker=rust-lld", 27 | ] 28 | 29 | [env] 30 | ESP_LOG = "info" 31 | SSID = "SSID" 32 | PASSWORD = "PASSWORD" 33 | STATIC_IP = "1.1.1.1 " 34 | GATEWAY_IP = "1.1.1.1" 35 | HOST_IP = "1.1.1.1" 36 | 37 | [unstable] 38 | build-std = ["alloc", "core"] 39 | -------------------------------------------------------------------------------- /esp-rom-sys/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | 12 | 13 | ### Changed 14 | 15 | 16 | ### Fixed 17 | 18 | - Fixed `ets_update_cpu_frequency_rom` not linking on ESP32 (#4500) 19 | 20 | ### Removed 21 | 22 | 23 | ## [v0.1.3] - 2025-10-30 24 | 25 | ## [v0.1.2] - 2025-10-13 26 | 27 | ### Added 28 | 29 | - Initialize the syscall table (#4177) 30 | 31 | ### Changed 32 | 33 | - Updated linker scripts (#4113) 34 | 35 | ### Fixed 36 | 37 | - esp32: c2, c3, s2, s3: fixed "Defalut" typo in ld scripts (#4180) 38 | 39 | ## [v0.1.1] - 2025-07-16 40 | 41 | ## [v0.1.0] - 2025-07-01 42 | 43 | [v0.1.0]: https://github.com/esp-rs/esp-hal/releases/tag/esp-rom-sys-v0.1.0 44 | [v0.1.1]: https://github.com/esp-rs/esp-hal/compare/esp-rom-sys-v0.1.0...esp-rom-sys-v0.1.1 45 | [v0.1.2]: https://github.com/esp-rs/esp-hal/compare/esp-rom-sys-v0.1.1...esp-rom-sys-v0.1.2 46 | [v0.1.3]: https://github.com/esp-rs/esp-hal/compare/esp-rom-sys-v0.1.2...esp-rom-sys-v0.1.3 47 | [Unreleased]: https://github.com/esp-rs/esp-hal/compare/esp-rom-sys-v0.1.3...HEAD 48 | -------------------------------------------------------------------------------- /hil-test/src/bin/misc_non_drivers.rs: -------------------------------------------------------------------------------- 1 | //! Miscellaneous simple tests 2 | //! 3 | //! Clock Monitor Test 4 | //! 5 | //! Ensure invariants of locks are upheld. 6 | //! 7 | //! Async Delay Test 8 | //! Specifically tests the various implementations of the 9 | //! `embedded_hal_async::delay::DelayNs` trait. 10 | //! This test does not configure embassy, as it doesn't need a timer queue 11 | //! implementation or an embassy time driver. 12 | //! 13 | //! DMA macro tests 14 | //! 15 | //! DMA Mem2Mem Tests 16 | //! 17 | //! Initialization tests 18 | //! 19 | //! The goal of this test suite is to collect smaller, simpler test cases, to keep the overall 20 | //! number of test suites low(er). 21 | 22 | //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 23 | //% FEATURES: unstable 24 | 25 | #![no_std] 26 | #![no_main] 27 | 28 | #[path = "misc_non_drivers/clock_monitor.rs"] 29 | mod clock_monitor; 30 | #[path = "misc_non_drivers/critical_section.rs"] 31 | mod critical_section; 32 | #[path = "misc_non_drivers/delay_async.rs"] 33 | mod delay_async; 34 | #[path = "misc_non_drivers/dma_macros.rs"] 35 | mod dma_macros; 36 | #[cfg(not(esp32))] 37 | #[path = "misc_non_drivers/dma_mem2mem.rs"] 38 | mod dma_mem2mem; 39 | #[path = "misc_non_drivers/init.rs"] 40 | mod init; 41 | #[path = "misc_non_drivers/simple.rs"] 42 | mod simple; 43 | -------------------------------------------------------------------------------- /examples/peripheral/debug_assist/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "debug-assist" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | cfg-if = "1" 9 | critical-section = "1" 10 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 11 | "panic-handler", 12 | "println", 13 | ] } 14 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 15 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 16 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 17 | 18 | [features] 19 | esp32c2 = [ 20 | "esp-backtrace/esp32c2", 21 | "esp-bootloader-esp-idf/esp32c2", 22 | "esp-hal/esp32c2", 23 | ] 24 | esp32c3 = [ 25 | "esp-backtrace/esp32c3", 26 | "esp-bootloader-esp-idf/esp32c3", 27 | "esp-hal/esp32c3", 28 | ] 29 | esp32c6 = [ 30 | "esp-backtrace/esp32c6", 31 | "esp-bootloader-esp-idf/esp32c6", 32 | "esp-hal/esp32c6", 33 | ] 34 | esp32h2 = [ 35 | "esp-backtrace/esp32h2", 36 | "esp-bootloader-esp-idf/esp32h2", 37 | "esp-hal/esp32h2", 38 | ] 39 | esp32s3 = [ 40 | "esp-backtrace/esp32s3", 41 | "esp-bootloader-esp-idf/esp32s3", 42 | "esp-hal/esp32s3", 43 | ] 44 | 45 | [profile.release] 46 | debug = true 47 | debug-assertions = true 48 | lto = "fat" 49 | codegen-units = 1 50 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Thank you for your contribution! 2 | 3 | We appreciate the time and effort you've put into this pull request. 4 | To help us review it efficiently, please ensure you've gone through the following checklist: 5 | 6 | ### Submission Checklist 📝 7 | - [ ] I have updated existing examples or added new ones (if applicable). 8 | - [ ] I have used `cargo xtask fmt-packages` command to ensure that all changed code is formatted correctly. 9 | - [ ] My changes were added to the [`CHANGELOG.md`](https://github.com/esp-rs/esp-hal/blob/main/esp-hal/CHANGELOG.md) in the **_proper_** section. 10 | - [ ] I have added necessary changes to user code to the latest [Migration Guide](https://github.com/esp-rs/esp-hal/blob/main/esp-hal). 11 | - [ ] My changes are in accordance to the [esp-rs developer guidelines](https://github.com/esp-rs/esp-hal/blob/main/documentation/DEVELOPER-GUIDELINES.md) 12 | 13 | #### Extra: 14 | - [ ] I have read the [CONTRIBUTING.md guide](https://github.com/esp-rs/esp-hal/blob/main/documentation/CONTRIBUTING.md) and followed its instructions. 15 | 16 | ### Pull Request Details 📖 17 | 18 | #### Description 19 | Please provide a clear and concise description of your changes, including the motivation behind these changes. The context is crucial for the reviewers. 20 | 21 | #### Testing 22 | Describe how you tested your changes. 23 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32c3/rom/esp32c3.rom.ble_smp.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32c3.rom.ld for esp32c3 7 | * 8 | * 9 | * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* SMP */ 17 | f_ll_pause_enc_req_handler = 0; 18 | f_ll_pause_enc_rsp_handler = 0; 19 | f_ll_enc_req_handler = 0; 20 | f_ll_enc_rsp_handler = 0; 21 | f_ll_start_enc_req_handler = 0; 22 | f_ll_start_enc_rsp_handler = 0; 23 | f_hci_le_start_enc_cmd_handler = 0; 24 | f_hci_le_ltk_req_reply_cmd_handler = 0; 25 | f_hci_le_ltk_req_neg_reply_cmd_handler = 0; 26 | f_llc_encrypt_ind_handler = 0; 27 | f_llc_op_encrypt_ind_handler = 0; 28 | f_hci_le_rd_local_p256_public_key_cmd_handler = 0; 29 | f_hci_le_generate_dhkey_cmd_handler = 0; 30 | f_hci_le_enc_cmd_handler = 0; 31 | r_rwip_crypt_evt_handler = 0; 32 | 33 | /* LE ping */ 34 | f_ll_ping_req_handler = 0; 35 | f_ll_ping_rsp_handler = 0; 36 | f_llc_op_le_ping_ind_handler = 0; 37 | f_llc_auth_payl_nearly_op_handler = 0; 38 | f_llc_auth_payl_real_to_handler = 0; 39 | f_llc_auth_payl_nearly_to_handler = 0; 40 | 41 | /* ecc */ 42 | r_ecc_init = 0; 43 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32/rom/esp32.rom.spiflash_legacy.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* 7 | Address table for SPI driver functions in ESP32 ROM. 8 | These functions are only linked from ROM when SPI_FLASH_ROM_DRIVER_PATCH is not set in configuration. 9 | */ 10 | 11 | PROVIDE ( esp_rom_spiflash_write_encrypted = 0x40062e78 ); 12 | PROVIDE ( esp_rom_spiflash_erase_area = 0x400631ac ); 13 | PROVIDE ( esp_rom_spiflash_erase_block = 0x40062c4c ); 14 | PROVIDE ( esp_rom_spiflash_erase_chip = 0x40062c14 ); 15 | PROVIDE ( esp_rom_spiflash_erase_sector = 0x40062ccc ); 16 | PROVIDE ( esp_rom_spiflash_attach = 0x40062a6c ); 17 | PROVIDE ( esp_rom_spiflash_lock = 0x400628f0 ); 18 | PROVIDE ( esp_rom_spiflash_read = 0x40062ed8 ); 19 | PROVIDE ( esp_rom_spiflash_config_readmode = 0x40062b64 ); /* SPIMasterReadModeCnfig */ 20 | PROVIDE ( esp_rom_spiflash_read_status = 0x4006226c ); 21 | PROVIDE ( esp_rom_spiflash_read_statushigh = 0x40062448 ); 22 | PROVIDE ( esp_rom_spiflash_write = 0x40062d50 ); 23 | PROVIDE ( esp_rom_spiflash_enable_write = 0x40062320 ); 24 | PROVIDE ( esp_rom_spiflash_write_status = 0x400622f0 ); 25 | 26 | /* always using patched versions of these functions 27 | PROVIDE ( esp_rom_spiflash_wait_idle = 0x400622c0 ); 28 | PROVIDE ( esp_rom_spiflash_unlock = 0x400????? ); 29 | */ 30 | -------------------------------------------------------------------------------- /esp-rom-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "esp-rom-sys" 3 | version = "0.1.3" 4 | edition = "2024" 5 | rust-version = "1.87.0" 6 | description = "ROM code support" 7 | documentation = "https://docs.espressif.com/projects/rust/esp-rom-sys/latest/" 8 | keywords = ["embedded", "esp32", "espressif"] 9 | categories = ["embedded", "hardware-support", "no-std"] 10 | repository = "https://github.com/esp-rs/esp-hal" 11 | license = "MIT OR Apache-2.0" 12 | 13 | links = "esp_rom_sys" 14 | 15 | [package.metadata.espressif] 16 | forever-unstable = true 17 | check-configs = [{ features = [] }] 18 | clippy-configs = [{ features = [] }] 19 | 20 | [package.metadata.docs.rs] 21 | default-target = "riscv32imac-unknown-none-elf" 22 | features = ["esp32c6"] 23 | 24 | [lib] 25 | bench = false 26 | test = false 27 | 28 | [dependencies] 29 | cfg-if = "1" 30 | document-features = "0.2" 31 | 32 | [build-dependencies] 33 | esp-metadata-generated = { version = "0.3.0", path = "../esp-metadata-generated", features = ["build-script"] } 34 | 35 | [features] 36 | #! ### Chip selection 37 | #! One of the following features must be enabled to select the target chip: 38 | 39 | ## 40 | esp32 = [] 41 | ## 42 | esp32c2 = [] 43 | ## 44 | esp32c3 = [] 45 | ## 46 | esp32c6 = [] 47 | ## 48 | esp32h2 = [] 49 | ## 50 | esp32s2 = [] 51 | ## 52 | esp32s3 = [] 53 | -------------------------------------------------------------------------------- /examples/peripheral/twai/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "twai" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 9 | "panic-handler", 10 | "println", 11 | ] } 12 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 13 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 14 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 15 | nb = "1.1.0" 16 | 17 | [features] 18 | esp32 = ["esp-backtrace/esp32", "esp-bootloader-esp-idf/esp32", "esp-hal/esp32"] 19 | esp32c3 = [ 20 | "esp-backtrace/esp32c3", 21 | "esp-bootloader-esp-idf/esp32c3", 22 | "esp-hal/esp32c3", 23 | ] 24 | esp32c6 = [ 25 | "esp-backtrace/esp32c6", 26 | "esp-bootloader-esp-idf/esp32c6", 27 | "esp-hal/esp32c6", 28 | ] 29 | esp32h2 = [ 30 | "esp-backtrace/esp32h2", 31 | "esp-bootloader-esp-idf/esp32h2", 32 | "esp-hal/esp32h2", 33 | ] 34 | esp32s2 = [ 35 | "esp-backtrace/esp32s2", 36 | "esp-bootloader-esp-idf/esp32s2", 37 | "esp-hal/esp32s2", 38 | ] 39 | esp32s3 = [ 40 | "esp-backtrace/esp32s3", 41 | "esp-bootloader-esp-idf/esp32s3", 42 | "esp-hal/esp32s3", 43 | ] 44 | 45 | [profile.release] 46 | debug = true 47 | debug-assertions = true 48 | lto = "fat" 49 | codegen-units = 1 50 | -------------------------------------------------------------------------------- /examples/peripheral/hmac/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hmac" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 9 | "panic-handler", 10 | "println", 11 | ] } 12 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 13 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 14 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 15 | hmac = { version = "0.12.1", default-features = false } 16 | nb = "1.1.0" 17 | sha2 = { version = "0.10.8", default-features = false } 18 | 19 | [features] 20 | esp32c3 = [ 21 | "esp-backtrace/esp32c3", 22 | "esp-bootloader-esp-idf/esp32c3", 23 | "esp-hal/esp32c3", 24 | ] 25 | esp32c6 = [ 26 | "esp-backtrace/esp32c6", 27 | "esp-bootloader-esp-idf/esp32c6", 28 | "esp-hal/esp32c6", 29 | ] 30 | esp32h2 = [ 31 | "esp-backtrace/esp32h2", 32 | "esp-bootloader-esp-idf/esp32h2", 33 | "esp-hal/esp32h2", 34 | ] 35 | esp32s2 = [ 36 | "esp-backtrace/esp32s2", 37 | "esp-bootloader-esp-idf/esp32s2", 38 | "esp-hal/esp32s2", 39 | ] 40 | esp32s3 = [ 41 | "esp-backtrace/esp32s3", 42 | "esp-bootloader-esp-idf/esp32s3", 43 | "esp-hal/esp32s3", 44 | ] 45 | 46 | [profile.release] 47 | debug = true 48 | debug-assertions = true 49 | lto = "fat" 50 | codegen-units = 1 51 | -------------------------------------------------------------------------------- /esp-radio/src/compat/misc.rs: -------------------------------------------------------------------------------- 1 | use crate::compat::malloc::malloc; 2 | 3 | // these are not called but needed for linking 4 | #[unsafe(no_mangle)] 5 | unsafe extern "C" fn __esp_radio_fwrite( 6 | ptr: *const (), 7 | size: usize, 8 | count: usize, 9 | stream: *const (), 10 | ) -> usize { 11 | todo!("fwrite {:?} {} {} {:?}", ptr, size, count, stream) 12 | } 13 | 14 | #[unsafe(no_mangle)] 15 | unsafe extern "C" fn __esp_radio_fopen(filename: *const u8, mode: *const u8) -> *const () { 16 | todo!("fopen {:?} {:?}", filename, mode) 17 | } 18 | 19 | #[unsafe(no_mangle)] 20 | unsafe extern "C" fn __esp_radio_fgets(str: *const u8, count: u32, file: *const ()) -> *const u8 { 21 | todo!("fgets {:?} {} {:?}", str, count, file) 22 | } 23 | 24 | #[unsafe(no_mangle)] 25 | unsafe extern "C" fn __esp_radio_fclose(stream: *const ()) -> i32 { 26 | todo!("fclose {:?}", stream); 27 | } 28 | 29 | // We cannot just use the ROM function since it needs to allocate memory 30 | #[unsafe(no_mangle)] 31 | unsafe extern "C" fn __esp_radio_strdup(str: *const core::ffi::c_char) -> *const core::ffi::c_char { 32 | trace!("strdup {:?}", str); 33 | 34 | unsafe { 35 | let s = core::ffi::CStr::from_ptr(str); 36 | let len = s.count_bytes() + 1; 37 | let p = malloc(len); 38 | if !p.is_null() { 39 | core::ptr::copy_nonoverlapping(str, p.cast(), len); 40 | } 41 | p.cast() 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.ble_scan.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32s3.rom.ld for esp32s3 7 | * 8 | * 9 | * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | 17 | /* BLE scan */ 18 | 19 | f_hci_le_set_scan_param_cmd_handler = 0x40000000; 20 | f_hci_le_set_scan_en_cmd_handler = 0x40000000; 21 | f_llm_scan_period_to_handler_hack = 0x40000000; 22 | f_lld_adv_rep_ind_handler_hack = 0x40000000; 23 | r_lld_scan_init = 0x40000000; 24 | r_lld_scan_restart = 0x40000000; 25 | f_lld_scan_end_ind_handler_hack = 0x40000000; 26 | r_llm_env_adv_dup_filt_deinit_eco = 0x40000000; 27 | llm_exception_list_init = 0x40000000; 28 | llm_duplicate_list_init = 0x40000000; 29 | f_hci_vendor_ble_update_duplicate_exceptional_list_cmd_handler = 0x40000000; 30 | f_hci_vendor_ble_init_adv_flow_control_cmd_handler = 0x40000000; 31 | f_hci_vendor_ble_update_adv_report_flow_control_cmd_handler = 0x40000000; 32 | coex_schm_ble_scan_stop = 0x40000000; 33 | 34 | f_hci_le_set_ext_scan_param_cmd_handler = 0x40000000; 35 | f_hci_le_set_ext_scan_en_cmd_handler = 0x40000000; 36 | r_lld_scan_process_pkt_rx_ext_adv = 0x40000000; 37 | r_lld_scan_trunc_ind = 0x40000000; 38 | -------------------------------------------------------------------------------- /examples/peripheral/dma/mem2mem/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dma-mem2mem" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | cfg-if = "1" 9 | esp-backtrace = { path = "../../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../../esp-println", features = ["log-04"] } 16 | log = "0.4.27" 17 | 18 | [features] 19 | esp32c2 = [ 20 | "esp-backtrace/esp32c2", 21 | "esp-bootloader-esp-idf/esp32c2", 22 | "esp-hal/esp32c2", 23 | ] 24 | esp32c3 = [ 25 | "esp-backtrace/esp32c3", 26 | "esp-bootloader-esp-idf/esp32c3", 27 | "esp-hal/esp32c3", 28 | ] 29 | esp32c6 = [ 30 | "esp-backtrace/esp32c6", 31 | "esp-bootloader-esp-idf/esp32c6", 32 | "esp-hal/esp32c6", 33 | ] 34 | esp32h2 = [ 35 | "esp-backtrace/esp32h2", 36 | "esp-bootloader-esp-idf/esp32h2", 37 | "esp-hal/esp32h2", 38 | ] 39 | esp32s2 = [ 40 | "esp-backtrace/esp32s2", 41 | "esp-bootloader-esp-idf/esp32s2", 42 | "esp-hal/esp32s2", 43 | ] 44 | esp32s3 = [ 45 | "esp-backtrace/esp32s3", 46 | "esp-bootloader-esp-idf/esp32s3", 47 | "esp-hal/esp32s3", 48 | ] 49 | 50 | [profile.release] 51 | debug = true 52 | debug-assertions = true 53 | lto = "fat" 54 | codegen-units = 1 55 | -------------------------------------------------------------------------------- /examples/peripheral/spi/slave_dma/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "spi-slave-dma" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | cfg-if = "1" 9 | esp-backtrace = { path = "../../../../esp-backtrace", features = [ 10 | "panic-handler", 11 | "println", 12 | ] } 13 | esp-bootloader-esp-idf = { path = "../../../../esp-bootloader-esp-idf" } 14 | esp-hal = { path = "../../../../esp-hal", features = ["log-04", "unstable"] } 15 | esp-println = { path = "../../../../esp-println", features = ["log-04"] } 16 | log = "0.4.27" 17 | 18 | [features] 19 | esp32c2 = [ 20 | "esp-backtrace/esp32c2", 21 | "esp-bootloader-esp-idf/esp32c2", 22 | "esp-hal/esp32c2", 23 | ] 24 | esp32c3 = [ 25 | "esp-backtrace/esp32c3", 26 | "esp-bootloader-esp-idf/esp32c3", 27 | "esp-hal/esp32c3", 28 | ] 29 | esp32c6 = [ 30 | "esp-backtrace/esp32c6", 31 | "esp-bootloader-esp-idf/esp32c6", 32 | "esp-hal/esp32c6", 33 | ] 34 | esp32h2 = [ 35 | "esp-backtrace/esp32h2", 36 | "esp-bootloader-esp-idf/esp32h2", 37 | "esp-hal/esp32h2", 38 | ] 39 | esp32s2 = [ 40 | "esp-backtrace/esp32s2", 41 | "esp-bootloader-esp-idf/esp32s2", 42 | "esp-hal/esp32s2", 43 | ] 44 | esp32s3 = [ 45 | "esp-backtrace/esp32s3", 46 | "esp-bootloader-esp-idf/esp32s3", 47 | "esp-hal/esp32s3", 48 | ] 49 | 50 | [profile.release] 51 | debug = true 52 | debug-assertions = true 53 | lto = "fat" 54 | codegen-units = 1 55 | -------------------------------------------------------------------------------- /examples/async/embassy_usb_serial_jtag/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "embassy-usb-serial-jtag" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | embassy-executor = "0.9.0" 9 | embassy-sync = "0.7" 10 | embedded-io-async = "0.7.0" 11 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 12 | "panic-handler", 13 | "println", 14 | ] } 15 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 16 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 17 | esp-rtos = { path = "../../../esp-rtos", features = ["embassy", "log-04"] } 18 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 19 | heapless = "0.8.0" 20 | static_cell = "2.1.1" 21 | 22 | [features] 23 | esp32c3 = [ 24 | "esp-backtrace/esp32c3", 25 | "esp-bootloader-esp-idf/esp32c3", 26 | "esp-rtos/esp32c3", 27 | "esp-hal/esp32c3", 28 | ] 29 | esp32c6 = [ 30 | "esp-backtrace/esp32c6", 31 | "esp-bootloader-esp-idf/esp32c6", 32 | "esp-rtos/esp32c6", 33 | "esp-hal/esp32c6", 34 | ] 35 | esp32h2 = [ 36 | "esp-backtrace/esp32h2", 37 | "esp-bootloader-esp-idf/esp32h2", 38 | "esp-rtos/esp32h2", 39 | "esp-hal/esp32h2", 40 | ] 41 | esp32s3 = [ 42 | "esp-backtrace/esp32s3", 43 | "esp-bootloader-esp-idf/esp32s3", 44 | "esp-rtos/esp32s3", 45 | "esp-hal/esp32s3", 46 | ] 47 | 48 | [profile.release] 49 | debug = true 50 | debug-assertions = true 51 | lto = "fat" 52 | codegen-units = 1 53 | -------------------------------------------------------------------------------- /examples/peripheral/spi/loopback/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "spi_loopback" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | esp-backtrace = { path = "../../../../esp-backtrace", features = [ 9 | "panic-handler", 10 | "println", 11 | ] } 12 | esp-bootloader-esp-idf = { path = "../../../../esp-bootloader-esp-idf" } 13 | esp-hal = { path = "../../../../esp-hal", features = ["log-04", "unstable"] } 14 | esp-println = { path = "../../../../esp-println", features = ["log-04"] } 15 | 16 | [features] 17 | esp32 = ["esp-backtrace/esp32", "esp-bootloader-esp-idf/esp32", "esp-hal/esp32"] 18 | esp32c2 = [ 19 | "esp-backtrace/esp32c2", 20 | "esp-bootloader-esp-idf/esp32c2", 21 | "esp-hal/esp32c2", 22 | ] 23 | esp32c3 = [ 24 | "esp-backtrace/esp32c3", 25 | "esp-bootloader-esp-idf/esp32c3", 26 | "esp-hal/esp32c3", 27 | ] 28 | esp32c6 = [ 29 | "esp-backtrace/esp32c6", 30 | "esp-bootloader-esp-idf/esp32c6", 31 | "esp-hal/esp32c6", 32 | ] 33 | esp32h2 = [ 34 | "esp-backtrace/esp32h2", 35 | "esp-bootloader-esp-idf/esp32h2", 36 | "esp-hal/esp32h2", 37 | ] 38 | esp32s2 = [ 39 | "esp-backtrace/esp32s2", 40 | "esp-bootloader-esp-idf/esp32s2", 41 | "esp-hal/esp32s2", 42 | ] 43 | esp32s3 = [ 44 | "esp-backtrace/esp32s3", 45 | "esp-bootloader-esp-idf/esp32s3", 46 | "esp-hal/esp32s3", 47 | ] 48 | 49 | [profile.release] 50 | debug = true 51 | debug-assertions = true 52 | lto = "fat" 53 | codegen-units = 1 54 | -------------------------------------------------------------------------------- /examples/interrupt/gpio/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gpio_interrupt" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | cfg-if = "1" 9 | critical-section = "1" 10 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 11 | "panic-handler", 12 | "println", 13 | ] } 14 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 15 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 16 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 17 | 18 | [features] 19 | esp32 = ["esp-backtrace/esp32", "esp-bootloader-esp-idf/esp32", "esp-hal/esp32"] 20 | esp32c2 = [ 21 | "esp-backtrace/esp32c2", 22 | "esp-bootloader-esp-idf/esp32c2", 23 | "esp-hal/esp32c2", 24 | ] 25 | esp32c3 = [ 26 | "esp-backtrace/esp32c3", 27 | "esp-bootloader-esp-idf/esp32c3", 28 | "esp-hal/esp32c3", 29 | ] 30 | esp32c6 = [ 31 | "esp-backtrace/esp32c6", 32 | "esp-bootloader-esp-idf/esp32c6", 33 | "esp-hal/esp32c6", 34 | ] 35 | esp32h2 = [ 36 | "esp-backtrace/esp32h2", 37 | "esp-bootloader-esp-idf/esp32h2", 38 | "esp-hal/esp32h2", 39 | ] 40 | esp32s2 = [ 41 | "esp-backtrace/esp32s2", 42 | "esp-bootloader-esp-idf/esp32s2", 43 | "esp-hal/esp32s2", 44 | ] 45 | esp32s3 = [ 46 | "esp-backtrace/esp32s3", 47 | "esp-bootloader-esp-idf/esp32s3", 48 | "esp-hal/esp32s3", 49 | ] 50 | 51 | [profile.release] 52 | debug = true 53 | debug-assertions = true 54 | lto = "fat" 55 | codegen-units = 1 56 | -------------------------------------------------------------------------------- /examples/interrupt/uart/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uart_interrupt" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | cfg-if = "1.0.0" 9 | critical-section = "1.1.3" 10 | esp-backtrace = { path = "../../../esp-backtrace", features = [ 11 | "panic-handler", 12 | "println", 13 | ] } 14 | esp-bootloader-esp-idf = { path = "../../../esp-bootloader-esp-idf" } 15 | esp-hal = { path = "../../../esp-hal", features = ["log-04", "unstable"] } 16 | esp-println = { path = "../../../esp-println", features = ["log-04"] } 17 | 18 | [features] 19 | esp32 = ["esp-backtrace/esp32", "esp-bootloader-esp-idf/esp32", "esp-hal/esp32"] 20 | esp32c2 = [ 21 | "esp-backtrace/esp32c2", 22 | "esp-bootloader-esp-idf/esp32c2", 23 | "esp-hal/esp32c2", 24 | ] 25 | esp32c3 = [ 26 | "esp-backtrace/esp32c3", 27 | "esp-bootloader-esp-idf/esp32c3", 28 | "esp-hal/esp32c3", 29 | ] 30 | esp32c6 = [ 31 | "esp-backtrace/esp32c6", 32 | "esp-bootloader-esp-idf/esp32c6", 33 | "esp-hal/esp32c6", 34 | ] 35 | esp32h2 = [ 36 | "esp-backtrace/esp32h2", 37 | "esp-bootloader-esp-idf/esp32h2", 38 | "esp-hal/esp32h2", 39 | ] 40 | esp32s2 = [ 41 | "esp-backtrace/esp32s2", 42 | "esp-bootloader-esp-idf/esp32s2", 43 | "esp-hal/esp32s2", 44 | ] 45 | esp32s3 = [ 46 | "esp-backtrace/esp32s3", 47 | "esp-bootloader-esp-idf/esp32s3", 48 | "esp-hal/esp32s3", 49 | ] 50 | 51 | [profile.release] 52 | debug = true 53 | debug-assertions = true 54 | lto = "fat" 55 | codegen-units = 1 56 | -------------------------------------------------------------------------------- /esp-rom-sys/ld/esp32s3/rom/esp32s3.rom.ble_smp.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | /* ROM function interface esp32s3.rom.ld for esp32s3 7 | * 8 | * 9 | * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b 10 | * 11 | * Compatible with ROM where ECO version equal or greater to 0. 12 | * 13 | * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. 14 | */ 15 | 16 | /* SMP */ 17 | f_ll_pause_enc_req_handler = 0x40000000; 18 | f_ll_pause_enc_rsp_handler = 0x40000000; 19 | f_ll_enc_req_handler = 0x40000000; 20 | f_ll_enc_rsp_handler = 0x40000000; 21 | f_ll_start_enc_req_handler = 0x40000000; 22 | f_ll_start_enc_rsp_handler = 0x40000000; 23 | f_hci_le_start_enc_cmd_handler = 0x40000000; 24 | f_hci_le_ltk_req_reply_cmd_handler = 0x40000000; 25 | f_hci_le_ltk_req_neg_reply_cmd_handler = 0x40000000; 26 | f_llc_encrypt_ind_handler = 0x40000000; 27 | f_llc_op_encrypt_ind_handler = 0x40000000; 28 | f_hci_le_rd_local_p256_public_key_cmd_handler = 0x40000000; 29 | f_hci_le_generate_dhkey_cmd_handler = 0x40000000; 30 | f_hci_le_enc_cmd_handler = 0x40000000; 31 | r_rwip_crypt_evt_handler = 0x40000000; 32 | 33 | /* LE ping */ 34 | f_ll_ping_req_handler = 0x40000000; 35 | f_ll_ping_rsp_handler = 0x40000000; 36 | f_llc_op_le_ping_ind_handler = 0x40000000; 37 | f_llc_auth_payl_nearly_op_handler = 0x40000000; 38 | f_llc_auth_payl_real_to_handler = 0x40000000; 39 | f_llc_auth_payl_nearly_to_handler = 0x40000000; 40 | 41 | /* ecc */ 42 | r_ecc_init = 0x40000000; 43 | -------------------------------------------------------------------------------- /.github/rust-matchers.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "rust-compiler", 5 | "pattern": [ 6 | { 7 | "regexp": "^(?:\\x1B\\[[0-9;]*[a-zA-Z])*(warning|warn|error)(\\[(\\S*)\\])?(?:\\x1B\\[[0-9;]*[a-zA-Z])*: (.*?)(?:\\x1B\\[[0-9;]*[a-zA-Z])*$", 8 | "severity": 1, 9 | "message": 4, 10 | "code": 3 11 | }, 12 | { 13 | "regexp": "^(?:\\x1B\\[[0-9;]*[a-zA-Z])*\\s+(?:\\x1B\\[[0-9;]*[a-zA-Z])*-->\\s(?:\\x1B\\[[0-9;]*[a-zA-Z])*(\\S+):(\\d+):(\\d+)(?:\\x1B\\[[0-9;]*[a-zA-Z])*$", 14 | "file": 1, 15 | "line": 2, 16 | "column": 3 17 | } 18 | ] 19 | }, 20 | { 21 | "owner": "rust-formatter", 22 | "pattern": [ 23 | { 24 | "regexp": "^(Diff in (\\S+)) at line (\\d+):", 25 | "message": 1, 26 | "file": 2, 27 | "line": 3 28 | } 29 | ] 30 | }, 31 | { 32 | "owner": "rust-panic", 33 | "pattern": [ 34 | { 35 | "regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+):(\\d+)$", 36 | "message": 1, 37 | "file": 2, 38 | "line": 3, 39 | "column": 4 40 | } 41 | ] 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /hil-test/src/bin/esp_radio.rs: -------------------------------------------------------------------------------- 1 | //! Test we get an error when attempting to initialize esp-radio with interrupts 2 | //! disabled in common ways 3 | 4 | //% CHIPS(no_wifi): esp32h2 5 | //% CHIPS(no_ble): esp32s2 6 | //% CHIPS(has_wifi_ble): esp32 esp32c2 esp32c3 esp32c6 esp32s3 7 | 8 | //% FEATURES: unstable esp-radio esp-alloc esp-radio/unstable embassy 9 | //% FEATURES(no_ble): esp-radio/wifi 10 | //% FEATURES(no_wifi): esp-radio/ble 11 | //% FEATURES(has_wifi_ble): esp-radio/wifi esp-radio/ble 12 | 13 | #![no_std] 14 | #![no_main] 15 | 16 | #[cfg(multi_core)] 17 | use esp_hal::system::Stack; 18 | use hil_test as _; 19 | 20 | extern crate alloc; 21 | 22 | fn init_heap() { 23 | cfg_if::cfg_if! { 24 | if #[cfg(any(esp32, esp32s2, esp32s3, esp32c3, esp32c2, esp32c6))] { 25 | use esp_hal::ram; 26 | esp_alloc::heap_allocator!(#[ram(reclaimed)] size: 64 * 1024); 27 | esp_alloc::heap_allocator!(size: 36 * 1024); 28 | } else if #[cfg(esp32h2)] { 29 | esp_alloc::heap_allocator!(size: 72 * 1024); 30 | } 31 | } 32 | } 33 | 34 | #[cfg(multi_core)] 35 | static mut APP_CORE_STACK: Stack<8192> = Stack::new(); 36 | 37 | #[path = "esp_radio/esp_rtos.rs"] 38 | mod esp_rtos; 39 | 40 | #[path = "esp_radio/init_tests.rs"] 41 | mod init_tests; 42 | 43 | #[cfg(soc_has_bt)] 44 | #[path = "esp_radio/ble_controller.rs"] 45 | mod ble_controller; 46 | 47 | #[cfg(soc_has_wifi)] 48 | #[path = "esp_radio/wifi_controller.rs"] 49 | mod wifi_controller; 50 | 51 | #[cfg(xtensa)] 52 | #[path = "esp_radio/fpu.rs"] 53 | mod fpu; 54 | -------------------------------------------------------------------------------- /resources/404.html.jinja: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page Not Found 9 | 10 | 11 | 12 | 13 | 46 | 47 | 48 | 49 | 52 |

404

53 |

Sorry, the page you are looking for does not exist.

54 |

Back to Documentation Index

55 |

Back to Previous Page

56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /esp-metadata/src/cfg/aes.rs: -------------------------------------------------------------------------------- 1 | use quote::quote; 2 | 3 | use crate::{cfg::GenericProperty, generate_for_each_macro, number}; 4 | 5 | #[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] 6 | pub struct AesKeyLengthOption { 7 | /// The key length in bits. 8 | pub bits: u32, 9 | 10 | /// The ID of the encryption mode. 11 | pub encrypt_mode: u32, 12 | 13 | /// The ID of the decryption mode. 14 | pub decrypt_mode: u32, 15 | } 16 | 17 | #[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] 18 | pub struct AesKeyLength { 19 | /// The supported key length options. 20 | options: Vec, 21 | } 22 | 23 | impl GenericProperty for AesKeyLength { 24 | fn macros(&self) -> Option { 25 | let bits = self 26 | .options 27 | .iter() 28 | .map(|opt| number(opt.bits)) 29 | .collect::>(); 30 | 31 | let modes = self 32 | .options 33 | .iter() 34 | .map(|opt| { 35 | let bits = number(opt.bits); 36 | let encrypt_mode = number(opt.encrypt_mode); 37 | let decrypt_mode = number(opt.decrypt_mode); 38 | quote! { 39 | #bits, #encrypt_mode, #decrypt_mode 40 | } 41 | }) 42 | .collect::>(); 43 | 44 | Some(generate_for_each_macro( 45 | "aes_key_length", 46 | &[("bits", &bits), ("modes", &modes)], 47 | )) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /esp-radio/src/ieee802154/frame.rs: -------------------------------------------------------------------------------- 1 | use alloc::vec::Vec; 2 | 3 | use ieee802154::mac::{FrameContent, Header}; 4 | 5 | pub(crate) const FRAME_SIZE: usize = 129; 6 | pub(crate) const FRAME_VERSION_1: u8 = 0x10; // IEEE 802.15.4 - 2006 & 2011 7 | pub(crate) const FRAME_VERSION_2: u8 = 0x20; // IEEE 802.15.4 - 2015 8 | 9 | const FRAME_AR_OFFSET: usize = 1; 10 | const FRAME_AR_BIT: u8 = 0x20; 11 | const FRAME_VERSION_OFFSET: usize = 2; 12 | const FRAME_VERSION_MASK: u8 = 0x30; 13 | 14 | /// IEEE 802.15.4 MAC frame 15 | #[derive(Debug, Clone, PartialEq, Eq)] 16 | pub struct Frame { 17 | /// Header 18 | pub header: Header, 19 | /// Content 20 | pub content: FrameContent, 21 | /// Payload 22 | pub payload: Vec, 23 | /// This is a 2-byte CRC checksum 24 | pub footer: [u8; 2], 25 | } 26 | 27 | /// IEEE 802.15.4 MAC frame which has been received 28 | #[derive(Debug, Clone, PartialEq, Eq)] 29 | pub struct ReceivedFrame { 30 | /// Frame 31 | pub frame: Frame, 32 | /// Receiver channel 33 | pub channel: u8, 34 | /// Received Signal Strength Indicator (RSSI) 35 | pub rssi: i8, 36 | /// Link Quality Indication (LQI) 37 | pub lqi: u8, 38 | } 39 | 40 | pub(crate) fn frame_is_ack_required(frame: &[u8]) -> bool { 41 | if frame.len() <= FRAME_AR_OFFSET { 42 | return false; 43 | } 44 | (frame[FRAME_AR_OFFSET] & FRAME_AR_BIT) != 0 45 | } 46 | 47 | pub(crate) fn frame_get_version(frame: &[u8]) -> u8 { 48 | if frame.len() <= FRAME_VERSION_OFFSET { 49 | return 0; 50 | } 51 | frame[FRAME_VERSION_OFFSET] & FRAME_VERSION_MASK 52 | } 53 | -------------------------------------------------------------------------------- /qa-test/src/bin/i2c_ssd1306_length_test.rs: -------------------------------------------------------------------------------- 1 | //! Test an SSD1306 display with various read/write data lengths. 2 | //! 3 | //! The following wiring is assumed: 4 | //! - SDA => GPIO4 5 | //! - SCL => GPIO5 6 | 7 | //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 8 | //% TAG: ssd1306 9 | 10 | #![no_std] 11 | #![no_main] 12 | 13 | use esp_backtrace as _; 14 | use esp_hal::{ 15 | i2c::master::{Config, I2c}, 16 | main, 17 | }; 18 | use esp_println::println; 19 | 20 | esp_bootloader_esp_idf::esp_app_desc!(); 21 | 22 | #[main] 23 | fn main() -> ! { 24 | esp_println::logger::init_logger_from_env(); 25 | let peripherals = esp_hal::init(esp_hal::Config::default()); 26 | 27 | // Create a new peripheral object with the described wiring and standard 28 | // I2C clock speed: 29 | let mut i2c = I2c::new(peripherals.I2C0, Config::default()) 30 | .unwrap() 31 | .with_sda(peripherals.GPIO4) 32 | .with_scl(peripherals.GPIO5); 33 | 34 | let mut data = [0u8; 1024]; 35 | 36 | println!("Testing writes"); 37 | for limit in 0..data.len() { 38 | if let Err(e) = i2c.write(0x3c, &data[0..limit]) { 39 | println!("Error with len {}: {}", limit, e); 40 | } 41 | println!("{} bytes ok", limit); 42 | } 43 | 44 | println!("Testing reads"); 45 | for limit in 0..data.len() { 46 | if let Err(e) = i2c.read(0x3c, &mut data[0..limit]) { 47 | println!("Error with len {}: {}", limit, e); 48 | } 49 | println!("{} bytes ok", limit); 50 | } 51 | 52 | println!("Done"); 53 | 54 | loop {} 55 | } 56 | -------------------------------------------------------------------------------- /esp-hal/ld/esp32s3/esp32s3.x: -------------------------------------------------------------------------------- 1 | INCLUDE exception.x 2 | 3 | SECTIONS { 4 | .rotext_dummy (NOLOAD) : 5 | { 6 | /* This dummy section represents the .rodata section within ROTEXT. 7 | * Since the same physical memory is mapped to both DROM and IROM, 8 | * we need to make sure the .rodata and .text sections don't overlap. 9 | * We skip the amount of memory taken by .rodata* in .text 10 | */ 11 | 12 | /* Start at the same alignment constraint than .flash.text */ 13 | 14 | . = ALIGN(ALIGNOF(.rodata)); 15 | . = ALIGN(ALIGNOF(.rodata.wifi)); 16 | 17 | /* Create an empty gap as big as .text section */ 18 | 19 | . = . + SIZEOF(.rodata_desc); 20 | . = . + SIZEOF(.rodata); 21 | . = . + SIZEOF(.rodata.wifi); 22 | 23 | /* Prepare the alignment of the section above. Few bytes (0x20) must be 24 | * added for the mapping header. 25 | */ 26 | 27 | . = ALIGN(0x10000) + 0x20; 28 | _rotext_reserved_start = .; 29 | } > ROTEXT 30 | } 31 | INSERT BEFORE .text; 32 | 33 | /* Similar to .rotext_dummy this represents .rwtext but in .data */ 34 | SECTIONS { 35 | .rwdata_dummy (NOLOAD) : ALIGN(4) 36 | { 37 | . = . + SIZEOF(.rwtext) + SIZEOF(.rwtext.wifi) + SIZEOF(.vectors); 38 | } > RWDATA 39 | } 40 | INSERT BEFORE .data; 41 | 42 | /* Shared sections - ordering matters */ 43 | SECTIONS { 44 | INCLUDE "rwtext.x" 45 | INCLUDE "rwdata.x" 46 | } 47 | INCLUDE "rodata.x" 48 | INCLUDE "text.x" 49 | INCLUDE "rtc_fast.x" 50 | INCLUDE "rtc_slow.x" 51 | INCLUDE "stack.x" 52 | INCLUDE "dram2.x" 53 | INCLUDE "metadata.x" 54 | INCLUDE "eh_frame.x" 55 | /* End of Shared sections */ 56 | -------------------------------------------------------------------------------- /examples/peripheral/spi/loopback/src/main.rs: -------------------------------------------------------------------------------- 1 | //! SPI loopback test 2 | //! 3 | //! The following wiring is assumed: 4 | //! - SCLK => GPIO0 5 | //! - MISO/MOSI => GPIO2 6 | //! - CS => GPIO5 7 | //! 8 | //! Depending on your target and the board you are using you have to change the 9 | //! pins. 10 | //! 11 | //! This example transfers data via SPI. 12 | 13 | #![no_std] 14 | #![no_main] 15 | 16 | use esp_backtrace as _; 17 | use esp_hal::{ 18 | delay::Delay, 19 | main, 20 | spi::{ 21 | Mode, 22 | master::{Config, Spi}, 23 | }, 24 | time::Rate, 25 | }; 26 | use esp_println::println; 27 | 28 | esp_bootloader_esp_idf::esp_app_desc!(); 29 | 30 | #[main] 31 | fn main() -> ! { 32 | esp_println::logger::init_logger_from_env(); 33 | let peripherals = esp_hal::init(esp_hal::Config::default()); 34 | 35 | let sclk = peripherals.GPIO0; 36 | let miso_mosi = peripherals.GPIO2; 37 | let cs = peripherals.GPIO5; 38 | 39 | let miso = unsafe { miso_mosi.clone_unchecked() }; 40 | 41 | let mut spi = Spi::new( 42 | peripherals.SPI2, 43 | Config::default() 44 | .with_frequency(Rate::from_khz(100)) 45 | .with_mode(Mode::_0), 46 | ) 47 | .unwrap() 48 | .with_sck(sclk) 49 | .with_miso(miso) // order matters 50 | .with_mosi(miso_mosi) // order matters 51 | .with_cs(cs); 52 | 53 | let delay = Delay::new(); 54 | 55 | loop { 56 | let mut data = [0xde, 0xca, 0xfb, 0xad]; 57 | spi.transfer(&mut data).unwrap(); 58 | println!("{:x?}", data); 59 | 60 | delay.delay_millis(250); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /esp-lp-hal/ld/link-lp.x: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | ENTRY(reset_vector) 8 | 9 | VECTOR_TABLE_LENGTH = 0x80; 10 | CONFIG_ULP_COPROC_RESERVE_MEM = 1024 * 16; 11 | CONFIG_ULP_SHARED_MEM = 0; 12 | RAM_LENGTH = CONFIG_ULP_COPROC_RESERVE_MEM - VECTOR_TABLE_LENGTH - CONFIG_ULP_SHARED_MEM; 13 | 14 | MEMORY 15 | { 16 | /*first 128byte for exception/interrupt vectors*/ 17 | vector_table(RX) : ORIGIN = 0x50000000, LENGTH = VECTOR_TABLE_LENGTH 18 | ram(RWX) : ORIGIN = 0x50000080, LENGTH = RAM_LENGTH 19 | } 20 | 21 | SECTIONS 22 | { 23 | .vector.text : 24 | { 25 | /* Exception/interrupt vectors */ 26 | __mtvec_base = .; 27 | KEEP (*(.init.vector)) 28 | __mtvec_end = .; 29 | } > vector_table 30 | 31 | . = ORIGIN(ram); 32 | 33 | .text ALIGN(4): 34 | { 35 | *(.text.vectors) /* Default reset vector must link to offset 0x80 */ 36 | 37 | KEEP(*(.init)); 38 | KEEP(*(.init.rust)); 39 | *(.text) 40 | *(.text*) 41 | } > ram 42 | 43 | .rodata ALIGN(4): 44 | { 45 | *(.rodata) 46 | *(.rodata*) 47 | } > ram 48 | 49 | .data ALIGN(4): 50 | { 51 | *(.data) 52 | *(.data*) 53 | *(.sdata) 54 | *(.sdata*) 55 | } > ram 56 | 57 | .bss ALIGN(4) : 58 | { 59 | *(.bss) 60 | *(.bss*) 61 | *(.sbss) 62 | *(.sbss*) 63 | PROVIDE(end = .); 64 | } > ram 65 | 66 | __stack_top = ORIGIN(ram) + LENGTH(ram); 67 | } 68 | -------------------------------------------------------------------------------- /esp-phy/README.md: -------------------------------------------------------------------------------- 1 | # esp-phy 2 | 3 | [![Crates.io](https://img.shields.io/crates/v/esp-phy?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp-phy) 4 | [![docs.rs](https://img.shields.io/docsrs/esp-phy?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.espressif.com/projects/rust/esp-phy/latest/) 5 | ![MSRV](https://img.shields.io/badge/MSRV-1.86.0-blue?labelColor=1C2C2E&style=flat-square) 6 | ![Crates.io](https://img.shields.io/crates/l/esp-phy?labelColor=1C2C2E&style=flat-square) 7 | [![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org) 8 | 9 | This crate implements PHY initialization handling for ESP32 devices. 10 | 11 | ## Minimum Supported Rust Version (MSRV) 12 | 13 | This crate is guaranteed to compile when using the latest stable Rust version at the time of the crate's release. It _might_ compile with older versions, but that may change in any new release, including patches. 14 | 15 | ## License 16 | 17 | Licensed under either of 18 | 19 | - Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or 20 | http://www.apache.org/licenses/LICENSE-2.0) 21 | - MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT) 22 | 23 | at your option. 24 | 25 | ### Contribution 26 | 27 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the 28 | work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any 29 | additional terms or conditions. 30 | -------------------------------------------------------------------------------- /examples/peripheral/lp_core/src/main.rs: -------------------------------------------------------------------------------- 1 | //! This shows a very basic example of running code on the LP core. 2 | //! 3 | //! Code on LP core increments a counter and continuously toggles LED. The 4 | //! current value is printed by the HP core. 5 | //! 6 | //! ⚠️ Make sure to first compile the `esp-lp-hal/examples/blinky.rs` example ⚠️ 7 | //! 8 | //! The following wiring is assumed: 9 | //! - LED => GPIO1 10 | 11 | #![no_std] 12 | #![no_main] 13 | 14 | use esp_backtrace as _; 15 | use esp_hal::{ 16 | gpio::lp_io::LowPowerOutput, 17 | load_lp_code, 18 | lp_core::{LpCore, LpCoreWakeupSource}, 19 | main, 20 | }; 21 | use esp_println::{print, println}; 22 | 23 | esp_bootloader_esp_idf::esp_app_desc!(); 24 | 25 | #[main] 26 | fn main() -> ! { 27 | esp_println::logger::init_logger_from_env(); 28 | let peripherals = esp_hal::init(esp_hal::Config::default()); 29 | 30 | // configure GPIO 1 as LP output pin 31 | 32 | let lp_pin = LowPowerOutput::new(peripherals.GPIO1); 33 | 34 | let mut lp_core = LpCore::new(peripherals.LP_CORE); 35 | lp_core.stop(); 36 | println!("lp core stopped"); 37 | 38 | // load code to LP core 39 | let lp_core_code = load_lp_code!( 40 | "../../../esp-lp-hal/target/riscv32imac-unknown-none-elf/release/examples/blinky" 41 | ); 42 | 43 | // start LP core 44 | lp_core_code.run(&mut lp_core, LpCoreWakeupSource::HpCpu, lp_pin); 45 | println!("lpcore run"); 46 | 47 | let data = (0x5000_2000) as *mut u32; 48 | loop { 49 | print!("Current {:x} \u{000d}", unsafe { 50 | data.read_volatile() 51 | }); 52 | } 53 | } 54 | --------------------------------------------------------------------------------