Compare commits

...
Sign in to create a new pull request.

20 commits

Author SHA1 Message Date
bfdfab79aa use esp-hal from ../esp-hal 2024-11-27 00:17:46 +03:00
6197be039a make it work with the latest esp-hal 2024-11-27 00:00:03 +03:00
a9529aa211 make it compile and run with the latest trouble crate 2024-11-26 23:52:49 +03:00
Данила Горнушко
1381620b3d fixing trouble 2024-11-26 19:00:34 +03:00
Данила Горнушко
a1a950e9ff update deps 2024-09-19 13:17:41 +03:00
okhsunrog
2697a0ed0d gitignore 2024-09-12 21:51:50 +03:00
Данила Горнушко
f5b30552b8 update deps 2024-09-12 18:08:40 +03:00
Данила Горнушко
5fcc52ca9c working ble code 2024-09-12 18:05:34 +03:00
Данила Горнушко
9d8a2e3eee update deps 2024-09-12 11:59:49 +03:00
okhsunrog
d4da0f4bd5 now clippy works in RustRover! 2024-09-12 02:42:02 +03:00
okhsunrog
60a1d49d32 fix trouble-host imports (RustRover bug) 2024-09-12 02:32:43 +03:00
okhsunrog
ed18bf1ef0 continue adding ble code 2024-09-12 02:21:06 +03:00
okhsunrog
2950b148df update anyhow + esp-hal 2024-09-11 21:52:31 +03:00
Данила Горнушко
d3eb568007 more logs 2024-09-11 17:58:06 +03:00
Данила Горнушко
83bf5f1899 Increase heap allocator size to 128 KB
Updated the heap allocator in `main.rs` from 72 KB to 128 KB to support additional memory requirements.
2024-09-11 16:57:47 +03:00
Данила Горнушко
0c767111e1 Add BLE and allocator support
Integrated BLE initialization and added `esp-alloc` for dynamic memory management. Updated `Cargo.toml` and `Cargo.lock` with necessary dependencies, and adjusted `main.rs` to accommodate BLE features and system timer initialization.
2024-09-11 16:55:55 +03:00
Данила Горнушко
5ec737c150 latest embassy + minimal code that builds 2024-09-11 16:18:18 +03:00
okhsunrog
5fdfcad72e trying to make trouble work 2024-09-11 13:46:52 +03:00
okhsunrog
f7c1cd688d update deps, defmt in trouble is now fixed 2024-09-11 12:51:40 +03:00
okhsunrog
9832445a4e update esp-hal 2024-09-09 15:21:17 +03:00
14 changed files with 1240 additions and 438 deletions

View file

@ -1,18 +1,21 @@
[env]
DEFMT_LOG="info"
DEFMT_LOG = "info"
[build]
target = "riscv32imc-unknown-none-elf"
target = "riscv32imc-unknown-none-elf"
rustflags = [
"-C", "link-arg=-Tdefmt.x",
"-C", "link-arg=-Tlinkall.x",
"-C",
"link-arg=-Tdefmt.x",
"-C",
"link-arg=-Tlinkall.x",
# NOTE: This is required to obtain backtraces, however it may negatively
# impact the performance of your application.
"-C", "force-frame-pointers",
"-C",
"force-frame-pointers",
]
[target.riscv32imc-unknown-none-elf]
runner = "probe-rs run --chip=esp32c3"
[unstable]
build-std = ["core"]
build-std = ["alloc", "core"]

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
# will have compiled files and executables
debug/
target/
.idea/workspace.xml
# These are backup files generated by rustfmt
**/*.rs.bk

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "trouble"]
path = trouble
url = https://github.com/embassy-rs/trouble.git

View file

@ -3,6 +3,10 @@
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/trouble/examples/apps/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/trouble/host-macros/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/trouble/host/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/trouble/host/tests" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />

2
.idea/modules.xml generated
View file

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/esp_hal_probe.iml" filepath="$PROJECT_DIR$/.idea/esp_hal_probe.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/esp_hal_snippets.iml" filepath="$PROJECT_DIR$/.idea/esp_hal_snippets.iml" />
</modules>
</component>
</project>

1
.idea/vcs.xml generated
View file

@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/trouble" vcs="Git" />
</component>
</project>

195
.idea/workspace.xml generated
View file

@ -1,195 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="ALL" />
</component>
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager">
<list default="true" id="7b22105a-0bfb-4392-932c-cec93348d8e9" name="Changes" comment="rustfmt">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="RsBuildProfile:dev" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="c4jj78ke" />
</component>
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 8
}</component>
<component name="ProjectId" id="2llP8G0IC1fHEwEaTUqH1GY9b72" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.rust.reset.selective.auto.import": "true",
"git-widget-placeholder": "main",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
"org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
"org.rust.first.attach.projects": "true",
"settings.editor.selected.configurable": "language.rust.cargo.check",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RsExternalLinterProjectSettings">
<option name="channel" value="nightly" />
</component>
<component name="RunManager" selected="Cargo.Run esp_hal_probe">
<configuration name="Run esp_hal_probe" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="buildProfileId" value="dev" />
<option name="command" value="run --package esp_hal_probe --bin esp_hal_probe" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test esp_hal_probe" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="test --workspace" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="/usr/bin" />
</component>
<component name="RustfmtProjectSettings">
<option name="useRustfmt" value="true" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="7b22105a-0bfb-4392-932c-cec93348d8e9" name="Changes" comment="" />
<created>1725751529946</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1725751529946</updated>
<workItem from="1725751530671" duration="64000" />
<workItem from="1725752698276" duration="5000" />
<workItem from="1725758634613" duration="2173000" />
</task>
<task id="LOCAL-00001" summary="latest stable esp-hal + hello world">
<option name="closed" value="true" />
<created>1725758678966</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1725758678966</updated>
</task>
<task id="LOCAL-00002" summary="latest git version of esp-hal + fix RustRover warnings + probe-rs&#10;use this command for installing working probe-rs:&#10;```&#10;cargo install probe-rs-tools \&#10; --git https://github.com/probe-rs/probe-rs \&#10; --rev 9bde591 --force --locked&#10;```">
<option name="closed" value="true" />
<created>1725759926412</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1725759926413</updated>
</task>
<task id="LOCAL-00003" summary="Remove static_cell dependency&#10;&#10;Removed the static_cell dependency from Cargo.toml and Cargo.lock. Also cleaned up comments and metadata in main.rs and updated .idea project settings.">
<option name="closed" value="true" />
<created>1725760460967</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1725760460968</updated>
</task>
<task id="LOCAL-00004" summary="Remove outdated comments and update task metadata&#10;&#10;Removed obsolete comments from `.vscode/settings.json` and updated task metadata in `.idea/workspace.xml`. These changes include the removal of the static_cell dependency and cleanup of various project settings.">
<option name="closed" value="true" />
<created>1725760510812</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1725760510812</updated>
</task>
<task id="LOCAL-00005" summary="Update comments and task metadata&#10;&#10;Removed outdated comments from `.vscode/settings.json` and updated task metadata in `.idea/workspace.xml`. These updates also include the removal of the static_cell dependency and general cleanup of project settings.">
<option name="closed" value="true" />
<created>1725760534919</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1725760534919</updated>
</task>
<task id="LOCAL-00006" summary="Fix typo and update task metadata&#10;&#10;Corrected a typo in a comment in `main.rs` from &quot;full time&quot; to &quot;full type&quot;. Updated task metadata and comments in `.idea/workspace.xml` to reflect changes and ensure consistency.">
<option name="closed" value="true" />
<created>1725760574384</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1725760574384</updated>
</task>
<task id="LOCAL-00007" summary="rustfmt">
<option name="closed" value="true" />
<created>1725760714925</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1725760714925</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="latest stable esp-hal + hello world" />
<MESSAGE value="latest git version of esp-hal + fix RustRover warnings + probe-rs&#10;use this command for installing working probe-rs:&#10;```&#10;cargo install probe-rs-tools \&#10; --git https://github.com/probe-rs/probe-rs \&#10; --rev 9bde591 --force --locked&#10;```" />
<MESSAGE value="Remove static_cell dependency&#10;&#10;Removed the static_cell dependency from Cargo.toml and Cargo.lock. Also cleaned up comments and metadata in main.rs and updated .idea project settings." />
<MESSAGE value="Remove outdated comments and update task metadata&#10;&#10;Removed obsolete comments from `.vscode/settings.json` and updated task metadata in `.idea/workspace.xml`. These changes include the removal of the static_cell dependency and cleanup of various project settings." />
<MESSAGE value="Update comments and task metadata&#10;&#10;Removed outdated comments from `.vscode/settings.json` and updated task metadata in `.idea/workspace.xml`. These updates also include the removal of the static_cell dependency and general cleanup of project settings." />
<MESSAGE value="Fix typo and update task metadata&#10;&#10;Corrected a typo in a comment in `main.rs` from &quot;full time&quot; to &quot;full type&quot;. Updated task metadata and comments in `.idea/workspace.xml` to reflect changes and ensure consistency." />
<MESSAGE value="rustfmt" />
<option name="LAST_COMMIT_MESSAGE" value="rustfmt" />
</component>
</project>

10
.vscode/settings.json vendored
View file

@ -1,9 +1,9 @@
{
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"evenBetterToml.formatter.alignComments": true,
"evenBetterToml.formatter.alignEntries": true,
"evenBetterToml.formatter.arrayAutoExpand": true,
"evenBetterToml.formatter.alignEntries": false,
"evenBetterToml.formatter.arrayAutoExpand": false,
"evenBetterToml.formatter.arrayTrailingComma": true,
"evenBetterToml.formatter.reorderArrays": true,
"evenBetterToml.formatter.reorderArrays": false,
"rust-analyzer.checkOnSave.allTargets": false
}
}

1287
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,28 +1,60 @@
[workspace]
members = [".", "trouble/host", "trouble/examples/apps"]
[package]
name = "esp_hal_probe"
version = "0.1.0"
edition = "2021"
rust-version = "1.76.0"
name = "esp_hal_snippets"
version = "0.1.0"
edition = "2021"
rust-version = "1.81.0"
[[bin]]
name = "ble_test"
path = "src/bin/ble_test.rs"
test = false
doctest = false
bench = false
[dependencies]
defmt = "0.3"
defmt-rtt = "0.4"
embassy-executor = { version = "0.6", features = ["defmt"] }
embassy-time = { version = "0.3", features = ["generic-queue-8"] }
esp-backtrace = { version = "0.14", features = ["esp32c3", "defmt", "exception-handler", "panic-handler"] }
esp-hal = { version = "0.20", features = ["esp32c3", "defmt"] }
esp-hal-embassy = { version = "0.3", features = ["esp32c3", "defmt"] }
bt-hci = { version = "0.1.2", features = ["defmt"] }
defmt = "0.3"
defmt-rtt = "0.4"
embassy-executor = { version = "0.6", features = ["defmt", "task-arena-size-65536"] }
embassy-time = { version = "0.3", features = ["generic-queue-8"] }
esp-alloc = { path = "../esp-hal/esp-alloc" }
esp-backtrace = { path = "../esp-hal/esp-backtrace", features = [
"esp32c3",
"defmt",
"exception-handler",
"panic-handler",
] }
esp-hal = { path = "../esp-hal/esp-hal", features = ["esp32c3", "defmt"] }
esp-hal-embassy = { path = "../esp-hal/esp-hal-embassy", features = ["esp32c3", "defmt"] }
esp-wifi = { path = "../esp-hal/esp-wifi", features = [
"defmt",
"esp32c3",
"ble",
] }
trouble-example-apps = { path = "./trouble/examples/apps" }
[profile.dev]
# Rust debug is too slow.
# For debug builds always builds with some optimization
opt-level = "s"
[profile.release]
codegen-units = 1
debug = 2
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
opt-level = 3
incremental = false
opt-level = 3
lto = 'fat'
overflow-checks = false
overflow-checks = false
[patch.crates-io]
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "d71434adfb7573c267d4d41a4304a2c556d59231" }
esp-hal-embassy = { git = "https://github.com/esp-rs/esp-hal", rev = "d71434adfb7573c267d4d41a4304a2c556d59231" }
esp-backtrace = { git = "https://github.com/esp-rs/esp-hal", rev = "d71434adfb7573c267d4d41a4304a2c556d59231" }
# Latest embassy
embassy-executor = { git = "https://github.com/embassy-rs/embassy.git", rev = "37111a891ca0e55efc6326e518f423e5fc677839" }
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", rev = "37111a891ca0e55efc6326e518f423e5fc677839" }
embassy-futures = { git = "https://github.com/embassy-rs/embassy.git", rev = "37111a891ca0e55efc6326e518f423e5fc677839" }
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "37111a891ca0e55efc6326e518f423e5fc677839" }
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy.git", rev = "37111a891ca0e55efc6326e518f423e5fc677839" }

View file

@ -1,4 +1,4 @@
[toolchain]
channel = "nightly"
channel = "nightly-2024-09-06"
components = ["rust-src"]
targets = ["riscv32imc-unknown-none-elf"]
targets = ["riscv32imc-unknown-none-elf"]

51
src/bin/ble_test.rs Normal file
View file

@ -0,0 +1,51 @@
#![no_std]
#![no_main]
use bt_hci::controller::ExternalController;
use defmt::info;
use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use esp_hal::{
rng::Rng,
timer::{systimer::SystemTimer, timg::TimerGroup},
};
use esp_wifi::ble::controller::BleConnector;
use trouble_example_apps::ble_bas_peripheral;
#[allow(unused)]
use {defmt_rtt as _, esp_alloc as _, esp_backtrace as _};
#[embassy_executor::task]
async fn run() {
loop {
info!("Hello world from embassy using esp-hal-async!");
// replace the log with blinking led?
Timer::after(Duration::from_millis(2_000)).await;
}
}
#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
esp_alloc::heap_allocator!(128 * 1024);
let peripherals = esp_hal::init(esp_hal::Config::default());
info!("Initializing...");
// RustRover shows error if I don't write full type here, that's weird
let timg0 = TimerGroup::new(peripherals.TIMG0);
let init = esp_wifi::init(
timg0.timer0,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
)
.unwrap();
let systimer = SystemTimer::new(peripherals.SYSTIMER);
esp_hal_embassy::init(systimer.alarm0);
spawner.spawn(run()).unwrap();
let mut bluetooth = peripherals.BT;
let connector = BleConnector::new(&init, &mut bluetooth);
let controller: ExternalController<_, 20> = ExternalController::new(connector);
info!("Starting BLE...");
ble_bas_peripheral::run(controller).await;
}

View file

@ -1,34 +0,0 @@
#![no_std]
#![no_main]
use defmt::info;
use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use esp_hal::{peripherals::TIMG0, timer::timg::TimerGroup, Blocking};
#[allow(unused)]
use {defmt_rtt as _, esp_backtrace as _};
#[embassy_executor::task]
async fn run() {
loop {
info!("Hello world from embassy using esp-hal-async!");
Timer::after(Duration::from_millis(1_000)).await;
}
}
#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
let peripherals = esp_hal::init(esp_hal::Config::default());
info!("Init!");
// RustRover shows error if I don't write full type here, that's weird
let timg0: TimerGroup<TIMG0, Blocking> = TimerGroup::new(peripherals.TIMG0);
esp_hal_embassy::init(timg0.timer0);
spawner.spawn(run()).ok();
loop {
info!("Bing!");
Timer::after(Duration::from_millis(5_000)).await;
}
}

1
trouble Submodule

@ -0,0 +1 @@
Subproject commit 31765f6bf34e79d8178ae1698da6b09c6e677b70