{"id":13612534,"url":"https://github.com/p2mate/mch2022-rust-app","last_synced_at":"2025-04-13T12:32:10.953Z","repository":{"id":49350861,"uuid":"517444278","full_name":"p2mate/mch2022-rust-app","owner":"p2mate","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-06T13:26:37.000Z","size":282031,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-07T20:42:47.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p2mate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-24T21:48:53.000Z","updated_at":"2024-03-22T20:42:27.000Z","dependencies_parsed_at":"2022-08-27T10:01:43.212Z","dependency_job_id":null,"html_url":"https://github.com/p2mate/mch2022-rust-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2mate%2Fmch2022-rust-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2mate%2Fmch2022-rust-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2mate%2Fmch2022-rust-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2mate%2Fmch2022-rust-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p2mate","download_url":"https://codeload.github.com/p2mate/mch2022-rust-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248714625,"owners_count":21149927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T20:00:31.276Z","updated_at":"2025-04-13T12:32:10.361Z","avatar_url":"https://github.com/p2mate.png","language":"Rust","funding_links":[],"categories":["Projects"],"sub_categories":["`std`"],"readme":"Rust on the ESP32 of the MCH2022 badge\n--------------------------------------\n\n+ Install Rust toolchain from https://github.com/esp-rs/rust-build:\n  ```\n  git clone https://github.com/esp-rs/rust-build.git\n  cd rust-build\n  ./install-rust-toolchain.sh --extra-crates \"ldproxy cargo-espflash wokwi-server web-flash\" \\\n    --export-file /home/\u003cuser\u003e/export-esp.sh \\\n    --esp-idf-version \"release/v4.4\" \\\n    --minified-esp-idf \"YES\" \\\n    --build-target \"esp32\" \\\n  source /home/\u003cuser\u003e/export-esp-rust.sh  \n  ```\n+ Install cargo-generate:\n  ```\n  cargo install cargo-generate\n  ```\n+ Install the mch2022 webusb tools from https://github.com/badgeteam/mch2022-tools:\n  ```\n  pip install pyusb\n  ```\n+ Create a new project as follows:\n```\ncargo generate --git https://github.com/esp-rs/esp-idf-template cargo\ncd \u003cproject-name\u003e\n```\n+ You can generate an app image using:\n```\ncargo espflash ESP32 save-image main.bin\n```\n+ This image can then be uploaded to the badge as follows:\n```\nwebusb_push.py --run rust main.bin\n```\n+ The image can also be uploaded to the hatchery as a native ESP32 application\n+ `println!` output appears on the first serial port exposed by the MCH022 badge\n+ If your program panics, the badge will reboot to the main menu, use the serial\nport to see any panic related messages.\n+ All crates which work on ESP32 should be available\n+ When using devcontainers, it supports [Wokwi](https://wokwi.com/) simulation:\n![MCH2022 Rust App](docs/wokwi-simulation.png)\n\nLimitations\n-----------\n\n+ These instructions use the esp-idf as provided by Espressif so you won't have\naccess to the components added by the badge team. It's probably possible to use\ntheir version, but I have not tried this.\n\nExample code\n------------\n\n+ The code is a quick hack but should give you an idea on what you can do.\n\nKnown issues\n------------\n\n+ There's no VSYNC easily available so the icon doesn't move as smooth as it should\n+ Drawing is rather slow probably because of the SPI interface and the overhead of\nusing the embedded_graphics crate. Maybe writing a dedicated driver for controlling\nthe display would result in better performance.\n\nDev Containers\n------------\nThis repository offers ready-to-use devlopment environments via Dev Containers for:\n-  [Gitpod](https://gitpod.io/)[![Open ESP32 in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/github.com/SergioGasquez/mch2022-rust-app)\n-  [VS Code Dev Containers](https://code.visualstudio.com/docs/remote/containers#_quick-start-open-an-existing-folder-in-a-container)\n-  [GitHub Codespaces](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace)\n\u003e **Note**\n\u003e\n\u003e In [order to use GitHub Codespaces](https://github.com/features/codespaces#faq)\n\u003e the project needs to be published in a GitHub repository and the user needs\n\u003e to be part of the Codespaces beta or have the project under an organization.\n\nIf using VS Code or GitHub Codespaces, you can pull the image instead of building it\nfrom the Dockerfile by selecting the `image` property instead of `build` in\n`.devcontainer/devcontainer.json`. Further customization of the Dev Container can\nbe achived, see [.devcontainer.json reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference).\n\nWhen using Dev Containers, some tooling to facilitate building, flashing and\nsimulating in Wokwi is also added.\n### Build\n- Terminal approach:\n\n    ```\n    scripts/build.sh  [debug | release]\n    ```\n    \u003e If no argument is passed, `release` will be used as default\n\n\n-  UI approach:\n\n    The default build task is already set to build the project, and it can be used\n    in VS Code and Gitpod:\n    - 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.\n    - `Terminal`-\u003e `Run Build Task` in the menu.\n    - With `Ctrl-Shift-B` or `Cmd-Shift-B`.\n    - 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\n    select `Build`.\n    - From UI: Press `Build` on the left side of the Status Bar.\n\n### Flash\n\nAt the momment there is no way to flash the Badge from the containers\n\n### Wokwi Simulation\nWhen using a custom Wokwi project, please change the `WOKWI_PROJECT_ID` in\n`run-wokwi.sh`. If no project id is specified, a DevKit for esp32 will be\nused.\n\u003e **Warning**\n\u003e\n\u003e  ESP32-S3 is not available in Wokwi\n\n- Terminal approach:\n\n    ```\n    scripts/run-wokwi.sh [debug | release]\n    ```\n    \u003e If no argument is passed, `release` will be used as default\n\n- UI approach:\n\n    The default test task is already set to build the project, and it can be used\n    in VS Code and Gitpod:\n    - 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\n    - With `Ctrl-Shift-,` or `Cmd-Shift-,`\n        \u003e **Note**\n        \u003e\n        \u003e This Shortcut is not available in Gitpod by default.\n    - 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\n    select `Build \u0026 Run Wokwi`.\n    - From UI: Press `Build \u0026 Run Wokwi` on the left side of the Status Bar.\n\n\u003e **Warning**\n\u003e\n\u003e  The simulation will pause if the browser tab is in the background.This may\n\u003e affect the execution, specially when debuging.\n\n#### Debuging with Wokwi\n\nWokwi offers debugging with GDB.\n\n- Terminal approach:\n    ```\n    $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/mch -ex \"target remote localhost:9333\"\n    ```\n\n    \u003e [Wokwi Blog: List of common GDB commands for debugging.](https://blog.wokwi.com/gdb-avr-arduino-cheatsheet/?utm_source=urish\u0026utm_medium=blog)\n- UI approach:\n    1. Run the Wokwi Simulation in `debug` profile\n    2. Go to `Run and Debug` section of the IDE (`Ctrl-Shift-D or Cmd-Shift-D`)\n    3. Start Debugging by pressing the Play Button or pressing `F5`\n    4. Choose the proper user:\n        - `esp` when using VS Code or GitHub Codespaces\n        - `gitpod` when using Gitpod\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp2mate%2Fmch2022-rust-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp2mate%2Fmch2022-rust-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp2mate%2Fmch2022-rust-app/lists"}