From 46e9d0f94620b7d792d3fac8616bd035af0fd4b7 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Wed, 8 Jan 2025 15:49:33 +0100 Subject: [PATCH] feat: Remove web Wokwi simulations --- .github/workflows/wokwi_projects.yml | 91 ---------------------------- book/src/02_0_preparations.md | 22 ++++--- book/src/02_4_hello_board.md | 9 --- book/src/03_3_2_http_client.md | 13 ---- book/src/04_3_1_i2c.md | 14 ----- book/src/04_3_2_i2c.md | 13 ---- book/src/04_4_1_interrupts.md | 13 ---- 7 files changed, 15 insertions(+), 160 deletions(-) delete mode 100644 .github/workflows/wokwi_projects.yml diff --git a/.github/workflows/wokwi_projects.yml b/.github/workflows/wokwi_projects.yml deleted file mode 100644 index 19c3157c..00000000 --- a/.github/workflows/wokwi_projects.yml +++ /dev/null @@ -1,91 +0,0 @@ ---- -name: Wokwi.com CI - -on: - push: - paths: - - '.github/workflows/wokwi_projects.yml' - pull_request: - paths: - - '.github/workflows/wokwi_projects.yml' - schedule: - - cron: "50 7 * * *" - workflow_dispatch: - -jobs: - wokwi-check: - name: ${{ matrix.project.name }} - if: github.repository == 'esp-rs/std-training' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - project: - - name: "hardware-check" - id: "360342886675214337" - path: "intro/hardware-check" - - name: http-client - id: "333372159510446675" - path: "intro/http-client" - - name: button-interrupt - id: "333374799393849940" - path: "advanced/button-interrupt" - - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Download project code - run: | - wget -q -O ${{ matrix.project.name }}.zip https://wokwi.com/api/projects/${{ matrix.project.id }}/zip - unzip ${{ matrix.project.name }}.zip -d ${{ matrix.project.name }} - mkdir -p ${{ matrix.project.name }}/src - rm -rf ${{ matrix.project.path }}/src/*.rs - cp ${{ matrix.project.name }}/*.rs ${{ matrix.project.path }}/src/ - rm -rf ${{ matrix.project.path }}/Cargo.toml - cp ${{ matrix.project.name }}/Cargo.toml ${{ matrix.project.path }}/Cargo.toml - - - name: Create wokwi.toml - run: echo -e "[wokwi]\nversion = 1\nfirmware = '${{ matrix.project.name }}/${{ matrix.project.name }}'\nelf = '${{ matrix.project.name }}/${{ matrix.project.name }}'" > ${{ matrix.project.path }}/wokwi.toml - - - name: Update ownership - run: | - sudo chown 1000:1000 -R ${{ matrix.project.path }} - - - name: Pull Docker image - run: docker image pull espressif/rust-std-training - - - name: Test code example in Docker image - uses: addnab/docker-run-action@v3 - with: - image: espressif/rust-std-training:latest - options: -u esp -v ${{ github.workspace }}:/home/esp/workspace - run: | - cd /home/esp/workspace/${{ matrix.project.path }} - if [ -f cfg.toml.example ]; then - # Rename file to cfg.toml - cp cfg.toml.example cfg.toml - # Replace defaults - sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "Wokwi-GUEST"/g' cfg.toml - sed -i 's/wifi_psk = "hunter2"/wifi_psk = ""/g' cfg.toml - fi - /home/esp/.cargo/bin/cargo build --release --out-dir /home/esp/workspace/${{ matrix.project.path }}/${{ matrix.project.name }} -Z unstable-options - rm -rf /home/esp/workspace/${{ matrix.project.path }}/target - - - run: cat ${{ matrix.project.path }}/wokwi.toml - - - name: Wokwi CI check - uses: wokwi/wokwi-ci-action@v1 - with: - token: ${{ secrets.WOKWI_CLI_TOKEN }} - path: ${{ matrix.project.path }} - timeout: 30000 - scenario: ${{ github.workspace }}/.github/${{ matrix.project.name }}.test.yaml - fail_text: 'Error' - - - name: Upload source code - if: success() || failure() - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.project.name }}_${{ matrix.project.id }} - path: ${{ matrix.project.path }} diff --git a/book/src/02_0_preparations.md b/book/src/02_0_preparations.md index c6e18400..0a88ee46 100644 --- a/book/src/02_0_preparations.md +++ b/book/src/02_0_preparations.md @@ -33,15 +33,23 @@ Anchor comments can be ignored, they are only used to introduce those parts of c ## Simulating Projects -Certain projects can be simulated with [Wokwi][wokwi]. Look for indications in the book to identify projects available for simulation. Simulation can be accomplished through two methods: -- Using wokwi.com: Conduct the build process and code editing directly through the browser. -- Using [Wokwi VS Code extension][wokwi-vscode]: Leverage VS Code to edit projects and perform builds. Utilize the Wokwi VS Code extension to simulate the resulting binaries. - - This approach requires some [installation][wokwi-installation] - - This approach assumes that the project is built in debug mode - - This approach allows [debugging the project][wokwi-debug] +Certain projects can be simulated, or at least partially simulated, with [Wokwi][wokwi]. Here is the list of projects that support Wokwi simulation: +- `intro/hello-world` +- `intro/http-client` +- `advanced/i2c-sensor-reading` +- `advanced/i2c-driver` +- `advanced/button-interrupt` + +Before jumping into any simulation project, you need to [setup the extension][wokwi-installation]. To simulate one project: + +1. Press F1, select `Wokwi: Select Config File`, and choose the `wokwi.toml` of the project you want to simulate. + 1. Edit the corresponding `wokwi.toml` file to simulate the exercise or the solution project. +2. Build your project in `debug` mode. +3. Press F1 again and select `Wokwi: Start Simulator`. + +You can also [debug the project][wokwi-debug]. [wokwi]: https://wokwi.com/ -[wokwi-vscode]: https://docs.wokwi.com/vscode/getting-started [wokwi-installation]: https://docs.wokwi.com/vscode/getting-started#installation [wokwi-debug]: https://docs.wokwi.com/vscode/debugging diff --git a/book/src/02_4_hello_board.md b/book/src/02_4_hello_board.md index 46c2e7b7..5ff454a1 100644 --- a/book/src/02_4_hello_board.md +++ b/book/src/02_4_hello_board.md @@ -76,15 +76,6 @@ You can also monitor the device without flashing it with the following command: espflash monitor ``` -## Simulation - -This project is available for simulation through two methods: -- [Wokwi project](https://wokwi.com/projects/360342886675214337?build-cache=disable) -- Wokwi VS Code extension: - 1. Press F1, select `Wokwi: Select Config File`, and choose `intro/hardware-check/wokwi.toml`. - 2. Build your project. - 3. Press F1 again and select `Wokwi: Start Simulator`. - ## Troubleshooting ### Build Errors diff --git a/book/src/03_3_2_http_client.md b/book/src/03_3_2_http_client.md index e9c84c49..79549182 100644 --- a/book/src/03_3_2_http_client.md +++ b/book/src/03_3_2_http_client.md @@ -69,19 +69,6 @@ The status error can be returned with the [Anyhow](https://docs.rs/anyhow/latest ✅ Write a custom `Error` enum to represent these errors. Implement the `std::error::Error` trait for your error. - -## Simulation - -This project is available for simulation through two methods: -- Wokwi projects: - - [Exercise](https://wokwi.com/projects/360722140931768321?build-cache=disable) - - [Solution](https://wokwi.com/projects/333372159510446675?build-cache=disable) -- Wokwi files are also present in the project folder to simulate it with Wokwi VS Code extension: - 1. Press F1, select `Wokwi: Select Config File` and choose `intro/http-client/wokwi.toml` - - Edit the `wokwi.toml` file to select between exercise and solution simulation - 2. Build you project - 3. Press F1 again and select `Wokwi: Start Simulator` - ## Troubleshooting - `missing WiFi name/password`: ensure that you've configured `cfg.toml` according to `cfg.toml.example` - a common problem is that the package name and config section name don't match. diff --git a/book/src/04_3_1_i2c.md b/book/src/04_3_1_i2c.md index e9d55834..10501dfe 100644 --- a/book/src/04_3_1_i2c.md +++ b/book/src/04_3_1_i2c.md @@ -125,17 +125,3 @@ GYRO: X: 0.00 Y: 0.00 Z: 0:00 TEMP: [local temperature] °C HUM: [local humidity] % ``` - -## Simulation - -This project is available for simulation through two methods: -- Wokwi projects - - [Exercise](https://wokwi.com/projects/360623713943950337?build-cache=disable) - - [Solution Part 2](https://wokwi.com/projects/360344742047853569?build-cache=disable) -- Wokwi files are also present in the project folder to simulate it with Wokwi VS Code extension: - 1. Press F1, select `Wokwi: Select Config File` and choose `advanced/i2c-sensor-reading/wokwi.toml` - - Edit the `wokwi.toml` file to select between exercise and solutions simulation - 2. Build you project - 3. Press F1 again and select `Wokwi: Start Simulator` - -When simulating this project, expect the following hardcoded values: `TEMP: 24.61 °C | HUM: 36.65 % | GYRO: X= 0.00 Y= 0.00 Z= 0.00` diff --git a/book/src/04_3_2_i2c.md b/book/src/04_3_2_i2c.md index 5ee3629b..af76e634 100644 --- a/book/src/04_3_2_i2c.md +++ b/book/src/04_3_2_i2c.md @@ -68,16 +68,3 @@ Registers can have different meanings, in essence, they are **a location that ca In this specific context, we are using an external device (since it is a sensor, even if it is on the same PCB). It is addressable by I2C, and we are reading and writing to its register addresses. The addresses each identify a unique location that contains some information. In this case, we want the address for the location that contains the current temperature, as read by the sensor. You can find the register map of the ICM-42670 in [section 14](https://invensense.tdk.com/wp-content/uploads/2021/07/DS-000451-ICM-42670-P-v1.0.pdf) should you want to try to get other interesting data from this sensor. - - - -## Simulation - -This project is available for simulation through two methods: -- Wokwi projects - - [Exercise](https://wokwi.com/projects/360728357589094401?build-cache=disable) - - [Solution](https://wokwi.com/projects/333375074521317970?build-cache=disable) -- Wokwi files are also present in the project folder to simulate it with Wokwi VS Code extension: - 1. Press F1, select `Wokwi: Select Config File` and choose `advanced/i2c-driver/wokwi.toml` - 2. Build you project - 3. Press F1 again and select `Wokwi: Start Simulator` diff --git a/book/src/04_4_1_interrupts.md b/book/src/04_4_1_interrupts.md index 19af03c1..87c3be71 100644 --- a/book/src/04_4_1_interrupts.md +++ b/book/src/04_4_1_interrupts.md @@ -30,16 +30,3 @@ cargo run --example solution 🔎 In this exercise we are using notifications, which only give the latest value, so if the interrupt is triggered multiple times before the value of the notification is read, you will only be able to read the latest one. Queues, on the other hand, allow receiving multiple values. See `esp_idf_hal::task::queue::Queue` for more details. - -## Simulation - -This project is available for simulation through two methods: -- Wokwi projects - - [Exercise](https://wokwi.com/projects/360623288920412161?build-cache=disable) - - [Solution](https://wokwi.com/projects/333374799393849940?build-cache=disable) - - The Solution project contains solution for [Random LED Color on pushinig a Button](./04_4_2_interrupts.md) -- Wokwi files are also present in the project folder to simulate it with Wokwi VS Code extension: - 1. Press F1, select `Wokwi: Select Config File` and choose `advanced/button-interrupt/wokwi.toml` - - Edit the `wokwi.toml` file to select between exercise and solution simulation - 2. Build you project - 3. Press F1 again and select `Wokwi: Start Simulator`