Hello world!
This commit is contained in:
parent
21d8e85292
commit
e0230679c2
11 changed files with 282 additions and 0 deletions
34
.cargo/config.toml
Normal file
34
.cargo/config.toml
Normal file
|
@ -0,0 +1,34 @@
|
|||
[build]
|
||||
# Uncomment the relevant target for your chip here (ESP32, ESP32-S2, ESP32-S3 or ESP32-C3)
|
||||
target = "xtensa-esp32-espidf"
|
||||
#target = "xtensa-esp32s2-espidf"
|
||||
#target = "xtensa-esp32s3-espidf"
|
||||
#target = "riscv32imc-esp-espidf"
|
||||
|
||||
[target.xtensa-esp32-espidf]
|
||||
linker = "ldproxy"
|
||||
|
||||
[target.xtensa-esp32s2-espidf]
|
||||
linker = "ldproxy"
|
||||
|
||||
[target.xtensa-esp32s3-espidf]
|
||||
linker = "ldproxy"
|
||||
|
||||
[target.riscv32imc-esp-espidf]
|
||||
linker = "ldproxy"
|
||||
|
||||
# Future - necessary for the experimental "native build" of esp-idf-sys with ESP32C3
|
||||
# See also https://github.com/ivmarkov/embuild/issues/16
|
||||
rustflags = ["-C", "default-linker-libraries"]
|
||||
|
||||
[unstable]
|
||||
|
||||
build-std = ["std", "panic_abort"]
|
||||
#build-std-features = ["panic_immediate_abort"] # Required for older ESP-IDF versions without a realpath implementation
|
||||
|
||||
[env]
|
||||
# Note: these variables are not used when using pio builder
|
||||
# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF stable (v4.4)
|
||||
ESP_IDF_VERSION = { value = "branch:release/v4.4" }
|
||||
# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF master (mainline)
|
||||
#ESP_IDF_VERSION = { value = "master" }
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
/.vscode
|
||||
/.embuild
|
||||
/target
|
||||
/Cargo.lock
|
24
Cargo.toml
Normal file
24
Cargo.toml
Normal file
|
@ -0,0 +1,24 @@
|
|||
[package]
|
||||
name = "e-bike-tracker-device"
|
||||
version = "0.1.0"
|
||||
authors = ["Vladan Popovic <vladanovic@gmail.com>"]
|
||||
edition = "2018"
|
||||
resolver = "2"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
|
||||
[profile.dev]
|
||||
debug = true # Symbols are nice and they don't increase the size on Flash
|
||||
opt-level = "z"
|
||||
|
||||
[features]
|
||||
pio = ["esp-idf-sys/pio"]
|
||||
|
||||
[dependencies]
|
||||
esp-idf-sys = { version = "0.31.5", features = ["binstart"] }
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
embuild = "0.29"
|
||||
anyhow = "1"
|
5
build.rs
Normal file
5
build.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641
|
||||
fn main() -> anyhow::Result<()> {
|
||||
embuild::build::CfgArgs::output_propagated("ESP_IDF")?;
|
||||
embuild::build::LinkArgs::output_propagated("ESP_IDF")
|
||||
}
|
115
docs/README.md
Normal file
115
docs/README.md
Normal file
|
@ -0,0 +1,115 @@
|
|||
# e_bike_tracker_device
|
||||
|
||||
## Dev Containers
|
||||
This repository offers Dev Containers supports for:
|
||||
- [Gitpod](https://gitpod.io/)
|
||||
- ["Open in Gitpod" button](https://www.gitpod.io/docs/getting-started#open-in-gitpod-button)
|
||||
- [VS Code Dev Containers](https://code.visualstudio.com/docs/remote/containers#_quick-start-open-an-existing-folder-in-a-container)
|
||||
- [GitHub Codespaces](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace)
|
||||
> **Note**
|
||||
>
|
||||
> In order to use Gitpod the project needs to be published in a GitLab, GitHub,
|
||||
> or Bitbucket repository.
|
||||
>
|
||||
> In [order to use GitHub Codespaces](https://github.com/features/codespaces#faq)
|
||||
> the project needs to be published in a GitHub repository and the user needs
|
||||
> to be part of the Codespaces beta or have the project under an organization.
|
||||
|
||||
If using VS Code or GitHub Codespaces, you can pull the image instead of building it
|
||||
from the Dockerfile by selecting the `image` property instead of `build` in
|
||||
`.devcontainer/devcontainer.json`.
|
||||
|
||||
When using Dev Containers, some tooling to facilitate building, flashing and
|
||||
simulating in Wokwi is also added.
|
||||
### Build
|
||||
- Terminal approach:
|
||||
|
||||
```
|
||||
scripts/build.sh [debug | release]
|
||||
```
|
||||
> If no argument is passed, `release` will be used as default
|
||||
|
||||
|
||||
- UI approach:
|
||||
|
||||
The default build task is already set to build the project, and it can be used
|
||||
in VS Code and Gitpod:
|
||||
- From the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (`Ctrl-Shift-P` or `Cmd-Shift-P`) run the `Tasks: Run Build Task` command.
|
||||
- `Terminal`-> `Run Build Task` in the menu.
|
||||
- With `Ctrl-Shift-B` or `Cmd-Shift-B`.
|
||||
- From the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (`Ctrl-Shift-P` or `Cmd-Shift-P`) run the `Tasks: Run Task` command and
|
||||
select `Build`.
|
||||
- From UI: Press `Build` on the left side of the Status Bar.
|
||||
|
||||
### Flash
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> When using GitHub Codespaces, we need to make the ports
|
||||
> public, [see instructions](https://docs.github.com/en/codespaces/developing-in-codespaces/forwarding-ports-in-your-codespace#sharing-a-port).
|
||||
|
||||
- Terminal approach:
|
||||
- Using `flash.sh` script:
|
||||
|
||||
```
|
||||
scripts/flash.sh [debug | release]
|
||||
```
|
||||
> If no argument is passed, `release` will be used as default
|
||||
|
||||
- UI approach:
|
||||
- From the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (`Ctrl-Shift-P` or `Cmd-Shift-P`) run the `Tasks: Run Task` command and
|
||||
select `Build & Flash`.
|
||||
- From UI: Press `Build & Flash` on the left side of the Status Bar.
|
||||
- Any alternative flashing method from host machine.
|
||||
|
||||
|
||||
### Wokwi Simulation
|
||||
When using a custom Wokwi project, please change the `WOKWI_PROJECT_ID` in
|
||||
`run-wokwi.sh`. If no project id is specified, a DevKit for esp32 will be
|
||||
used.
|
||||
> **Warning**
|
||||
>
|
||||
> ESP32-S3 is not available in Wokwi
|
||||
|
||||
- Terminal approach:
|
||||
|
||||
```
|
||||
scripts/run-wokwi.sh [debug | release]
|
||||
```
|
||||
> If no argument is passed, `release` will be used as default
|
||||
|
||||
- UI approach:
|
||||
|
||||
The default test task is already set to build the project, and it can be used
|
||||
in VS Code and Gitpod:
|
||||
- From the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (`Ctrl-Shift-P` or `Cmd-Shift-P`) run the `Tasks: Run Test Task` command
|
||||
- With `Ctrl-Shift-,` or `Cmd-Shift-,`
|
||||
> **Note**
|
||||
>
|
||||
> This Shortcut is not available in Gitpod by default.
|
||||
- From the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (`Ctrl-Shift-P` or `Cmd-Shift-P`) run the `Tasks: Run Task` command and
|
||||
select `Build & Run Wokwi`.
|
||||
- From UI: Press `Build & Run Wokwi` on the left side of the Status Bar.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The simulation will pause if the browser tab is in the background.This may
|
||||
> affect the execution, specially when debuging.
|
||||
|
||||
#### Debuging with Wokwi
|
||||
|
||||
Wokwi offers debugging with GDB.
|
||||
|
||||
- Terminal approach:
|
||||
```
|
||||
$HOME/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb target/xtensa-esp32-espidf/debug/e_bike_tracker_device -ex "target remote localhost:9333"
|
||||
```
|
||||
|
||||
> [Wokwi Blog: List of common GDB commands for debugging.](https://blog.wokwi.com/gdb-avr-arduino-cheatsheet/?utm_source=urish&utm_medium=blog)
|
||||
- UI approach:
|
||||
1. Run the Wokwi Simulation in `debug` profile
|
||||
2. Go to `Run and Debug` section of the IDE (`Ctrl-Shift-D or Cmd-Shift-D`)
|
||||
3. Start Debugging by pressing the Play Button or pressing `F5`
|
||||
4. Choose the proper user:
|
||||
- `esp` when using VS Code or GitHub Codespaces
|
||||
- `gitpod` when using Gitpod
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "esp"
|
24
scripts/build.sh
Executable file
24
scripts/build.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Gitpod and VsCode Codespaces tasks do not source the user environment
|
||||
if [ "${USER}" == "gitpod" ]; then
|
||||
which idf.py >/dev/null || {
|
||||
source ~/export-esp.sh > /dev/null 2>&1
|
||||
}
|
||||
elif [ "${CODESPACE_NAME}" != "" ]; then
|
||||
which idf.py >/dev/null || {
|
||||
source ~/export-esp.sh > /dev/null 2>&1
|
||||
}
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
""|"release")
|
||||
cargo build --release
|
||||
;;
|
||||
"debug")
|
||||
cargo build
|
||||
;;
|
||||
*)
|
||||
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
|
||||
exit 1;;
|
||||
esac
|
22
scripts/flash.sh
Executable file
22
scripts/flash.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_MODE=""
|
||||
case "$1" in
|
||||
""|"release")
|
||||
bash scripts/build.sh
|
||||
BUILD_MODE="release"
|
||||
;;
|
||||
"debug")
|
||||
bash scripts/build.sh debug
|
||||
BUILD_MODE="debug"
|
||||
;;
|
||||
*)
|
||||
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
export ESP_ARCH=xtensa-esp32-espidf
|
||||
|
||||
web-flash --chip esp32 target/${ESP_ARCH}/${BUILD_MODE}/e-bike-tracker-device
|
36
scripts/run-wokwi.sh
Executable file
36
scripts/run-wokwi.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_MODE=""
|
||||
case "$1" in
|
||||
""|"release")
|
||||
bash scripts/build.sh
|
||||
BUILD_MODE="release"
|
||||
;;
|
||||
"debug")
|
||||
bash scripts/build.sh debug
|
||||
BUILD_MODE="debug"
|
||||
;;
|
||||
*)
|
||||
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
if [ "${USER}" == "gitpod" ];then
|
||||
gp_url=$(gp url 9012)
|
||||
echo "gp_url=${gp_url}"
|
||||
export WOKWI_HOST=${gp_url:8}
|
||||
elif [ "${CODESPACE_NAME}" != "" ];then
|
||||
export WOKWI_HOST=${CODESPACE_NAME}-9012.githubpreview.dev
|
||||
fi
|
||||
|
||||
export ESP_ARCH=xtensa-esp32-espidf
|
||||
|
||||
# TODO: Update with your Wokwi Project
|
||||
export WOKWI_PROJECT_ID=""
|
||||
if [ "${WOKWI_PROJECT_ID}" == "" ]; then
|
||||
wokwi-server --chip esp32 target/${ESP_ARCH}/${BUILD_MODE}/e-bike-tracker-device
|
||||
else
|
||||
wokwi-server --chip esp32 --id ${WOKWI_PROJECT_ID} target/${ESP_ARCH}/${BUILD_MODE}/e-bike-tracker-device
|
||||
fi
|
11
sdkconfig.defaults
Normal file
11
sdkconfig.defaults
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7000
|
||||
|
||||
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
|
||||
# This allows to use 1 ms granuality for thread sleeps (10 ms by default).
|
||||
#CONFIG_FREERTOS_HZ=1000
|
||||
|
||||
# Workaround for https://github.com/espressif/esp-idf/issues/7631
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200
|
5
src/main.rs
Normal file
5
src/main.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Add table
Reference in a new issue