-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
enelson1001
committed
Dec 4, 2023
0 parents
commit aa7c6f9
Showing
19 changed files
with
3,544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[build] | ||
target = "xtensa-esp32s3-espidf" | ||
|
||
[target.xtensa-esp32s3-espidf] | ||
linker = "ldproxy" | ||
# runner = "espflash --monitor" # Select this runner for espflash v1.x.x | ||
runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x | ||
rustflags = [ | ||
# Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110 | ||
"--cfg", | ||
"espidf_time64", | ||
|
||
# Added the following 2 entries so lvgl will build without getting string.h file not found | ||
"--sysroot", | ||
"/home/ed/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-13.2.0_20230928/xtensa-esp-elf/xtensa-esp-elf/include", | ||
] | ||
[unstable] | ||
build-std = ["std", "panic_abort"] | ||
|
||
[env] | ||
MCU="esp32s3" | ||
# Note: this variable is not used by the pio builder (`cargo build --features pio`) | ||
ESP_IDF_VERSION = "v5.1.1" | ||
|
||
# The directory that has the lvgl config files - lv_conf.h, lv_drv_conf.h | ||
DEP_LV_CONFIG_PATH = { relative = true, value = "lvgl-configs" } | ||
|
||
# Required to make lvgl build correctly otherwise get wrong file type | ||
CROSS_COMPILE = "xtensa-esp32-elf" | ||
|
||
# Directory for custom fonts (written in C) that Lvgl can use | ||
LVGL_FONTS_DIR = {relative = true, value = "custom-fonts"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.rs linguist-detectable=true | ||
*.c linguist-detectable=false | ||
*.h linguist-detectable=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- "**/README.md" | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
rust-checks: | ||
name: Rust Checks | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
action: | ||
- command: build | ||
args: --release | ||
- command: fmt | ||
args: --all -- --check --color always | ||
- command: clippy | ||
args: --all-targets --all-features --workspace -- -D warnings | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Enable caching | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Install gcc-multilib | ||
run: sudo apt-get install g++-multilib | ||
- name: Setup Rust | ||
uses: esp-rs/[email protected] | ||
with: | ||
default: true | ||
buildtargets: esp32s3 | ||
ldproxy: true | ||
- name: Run command | ||
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/.vscode | ||
/.embuild | ||
/target | ||
/Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[package] | ||
name = "rust-esp32s3-lvgl-demo" | ||
version = "0.1.0" | ||
authors = ["enelson1001 <ednelson5080@gmail>"] | ||
edition = "2021" | ||
resolver = "2" | ||
rust-version = "1.71" | ||
|
||
[profile.release] | ||
opt-level = "s" | ||
|
||
[profile.dev] | ||
debug = true # Symbols are nice and they don't increase the size on Flash | ||
opt-level = "z" | ||
|
||
[features] | ||
default = ["std", "embassy", "esp-idf-svc/native"] | ||
|
||
pio = ["esp-idf-svc/pio"] | ||
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"] | ||
alloc = ["esp-idf-svc/alloc"] | ||
nightly = ["esp-idf-svc/nightly"] | ||
experimental = ["esp-idf-svc/experimental"] | ||
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"] | ||
|
||
[dependencies] | ||
log = { version = "0.4", default-features = false } | ||
esp-idf-svc = { version = "0.47.3", default-features = false } | ||
|
||
esp-idf-hal = { version = "0.42.1" } | ||
esp-idf-sys = { version = "0.33.3" } | ||
|
||
cstr_core = "0.2.1" | ||
embedded-graphics-core = "0.4.0" | ||
|
||
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2", default-features = false, features = [ | ||
"embedded_graphics", | ||
"unsafe_no_autoinit", | ||
] } | ||
|
||
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2" } | ||
|
||
[build-dependencies] | ||
embuild = "0.31.3" | ||
|
||
[package.metadata.esp-idf-sys] | ||
extra_components = [{ bindings_header = "bindings.h" }] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Rust ESP32S3 Lvgl Demo | ||
|
||
The purpose of this demo is to get lv-binding-rust (Lvgl) running on the ESP32S3 development board | ||
|
||
## Development Board | ||
Aliexpress ESP32-8048S070 - 7 inch 800x400 TN RGB with ESP32S3, 8M PSRAM, 16M Flash, 512KB SRAM | ||
|
||
## Overview | ||
This application shows how to use lv-binding-rust crate on a ESP32S3 device. The program will display a clock time on a blue backgound screen. | ||
The clock time is a simulated time of 21:00 to 21::59 where the seconds are incremented each second and repeats the 00-59 seconds forever. | ||
|
||
|
||
## partition-table folder | ||
The partition-table folder contains a file called partitons.csv. This file increases the default factory/app partiton from the default of 1M to 3M. | ||
This allows us more space for our program and since the flash size is 16M this should not be a problem. This file will be called when we flash the device. | ||
|
||
## custom-fonts folder | ||
The custom-fonts folder contains our custom fonts. The customs fonts are converted from TTF fonts using lvgl online font converter at https://lvgl.io/tools/fontconverter. I used https://ttfonts.net to find a font I liked and then downloaded the font. In the lvgl-online-font-converter I used the font name plus the font size for the name of the font. I chose Bpp of 2 bit-per-pixel and set the range of 0x30-0x3A since I only need numbers and the ":" character. After clicking on "Convert" the file will be downloaded. I placed this downloaded file (*.c) into the custom-fonts folder. Then I created a header file which has an extern to my *.c file, along with changing the ifndef and define names. | ||
To use this custom font, I added ```LVGL_FONTS_DIR = {relative = true, value = "custom-fonts"}``` to my config.toml under [env]. This allows our font to be compiled when lvgl is compiled. | ||
|
||
## lvgl-configs folder | ||
The lvgl-configs folder holds the lv_config.h and lv_drv_conf.h files which are required by lvgl to compile. Everything in lv_drv_conf.h file is set to 0 as I am not using the lvgl drivers. I don't think I changed anything in the lv_conf.h file. | ||
|
||
## lcd_panel.rs file | ||
The LCD RGB display driver. | ||
|
||
## sdkconfig.defaults file | ||
Increased the main task stack size to 60000 to allow app to run without crashing. | ||
|
||
The following needs to be added for using PSRAM. | ||
``` | ||
CONFIG_SPIRAM=y | ||
CONFIG_SPIRAM_MODE_OCT=y | ||
CONFIG_SPIRAM_SPEED_80M=y | ||
# Enabling the following configurations can help increase the PCLK frequency in the case when | ||
# the Frame Buffer is allocated from the PSRAM and fetched by EDMA | ||
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y | ||
CONFIG_SPIRAM_RODATA=y | ||
``` | ||
|
||
## bindings.h file in project root directory | ||
This file contains additional bindings required for using esp_lcd_panel esp-idf component that is available on the ESP32S3 device. | ||
|
||
## Cargo.toml project file | ||
I added the following to the "dependencies" section. | ||
``` | ||
esp-idf-hal = { version = "0.42.1" } | ||
esp-idf-sys = { version = "0.33.3" } | ||
cstr_core = "0.2.1" | ||
embedded-graphics-core = "0.4.0" | ||
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2", default-features = false, features = [ | ||
"embedded_graphics", | ||
"unsafe_no_autoinit", | ||
] } | ||
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2" } | ||
``` | ||
|
||
You need to a 'package.metadata.esp-idf-sys' section so the bindings.h file will be include. | ||
``` | ||
[package.metadata.esp-idf-sys] | ||
extra_components = [{ bindings_header = "bindings.h" }] | ||
``` | ||
|
||
## config.toml | ||
To get lv-bindings-rust to comple and build I made the following changes to the config.toml file. | ||
``` | ||
[build] | ||
target = "xtensa-esp32-espidf" | ||
[target.xtensa-esp32-espidf] | ||
linker = "ldproxy" | ||
# runner = "espflash --monitor" # Select this runner for espflash v1.x.x | ||
runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x | ||
rustflags = [ | ||
# Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110 | ||
"--cfg", | ||
"espidf_time64", | ||
# Added the following 2 entries so lvgl will build without getting string.h file not found | ||
"--sysroot", | ||
"/home/ed/.rustup/toolchains/esp/xtensa-esp32s3-elf/esp-13.2.0_20230928/xtensa-esp-elf/xtensa-esp-elf/include", | ||
] | ||
[unstable] | ||
build-std = ["std", "panic_abort"] | ||
[env] | ||
MCU = "esp32" | ||
# Note: this variable is not used by the pio builder (`cargo build --features pio`) | ||
ESP_IDF_VERSION = "v5.1.1" | ||
# The directory that has the lvgl config files - lv_conf.h, lv_drv_conf.h | ||
DEP_LV_CONFIG_PATH = { relative = true, value = "lvgl-configs" } | ||
# Required to make lvgl build correctly otherwise get wrong file type | ||
CROSS_COMPILE = "xtensa-esp32-elf" | ||
# Directory for custom fonts (written in C) that Lvgl can use | ||
LVGL_FONTS_DIR = {relative = true, value = "custom-fonts"} | ||
``` | ||
|
||
## lv-binding-rust fork | ||
I updated my fork of lv-binding-rust to include PR153 ie the changes recommended by madwizard-thomas. | ||
|
||
|
||
## Building the project | ||
The changes to config.toml, Cargo.toml and to build.rs allowed me to build lv-binding-rust without any errors. I do get 2 warnings about va_list not being FFI-safe. | ||
|
||
|
||
## Flashing the ESP32S3 device | ||
I used the following command to flash the ESP32S3 device. | ||
``` | ||
$ cargo espflash flash --partition-table=partition-table/partitions.csv --monitor | ||
``` | ||
|
||
## Picture of Aliexpress ESP32S3 running the demo | ||
![esp32s3-demo](photos/esp32s3-demo.jpg) | ||
|
||
|
||
# Versions | ||
### v1.0 : | ||
- initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#if CONFIG_IDF_TARGET_ESP32S3 | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/include/esp_lcd_types.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/include/esp_lcd_panel_rgb.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/include/esp_lcd_panel_io.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/include/esp_lcd_panel_ops.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/include/esp_lcd_panel_vendor.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/include/esp_lcd_panel_commands.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/interface/esp_lcd_panel_interface.h" | ||
#include ".embuild/espressif/esp-idf/v5.1.1/components/esp_lcd/interface/esp_lcd_panel_io_interface.h" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
embuild::espidf::sysenv::output(); | ||
} |
Oops, something went wrong.