wokwi / wokwi-features

Wokwi Feature requests & Bug Reports
https://wokwi.com
69 stars 17 forks source link

Improve support for Zephyr RTOS applications #516

Open kartben opened 1 year ago

kartben commented 1 year ago

The zephyr-esp32 builder is already a great start in allowing to run Zephyr apps from Wokwi. It would be great to look into generalizing/improving support by allowing the users to configure things such as:

I am around to chat more around this, and I will provide help as much as I can!

urish commented 9 months ago

Seems like it crashes when pressing the button

Does it only crash on the S3? Or also in C3?

urish commented 9 months ago

A quick workaround is to disable bouncing on the button by setting the "bounce" attribute to "0":

    {
      "type": "wokwi-pushbutton",
      "id": "btn1",
      "top": 140.6,
      "left": 48,
      "attrs": { "color": "green", "bounce": "0" }
    }

Looks like with bouncing, the button is stress-testing the interrupt mechanism :)

urish commented 9 months ago

Wow, this was a super tricky one - another subtle bug in interrupt handling, this time in Xtensa. Pushed a fix, so we should now play nicely even with a bouncy button that generates tons of interrupts in quick succession.

kartben commented 9 months ago

Wow, this was a super tricky one - another subtle bug in interrupt handling, this time in Xtensa. Pushed a fix, so we should now play nicely even with a bouncy button that generates tons of interrupts in quick succession.

Nice, thanks! I will give it a try and let you know. Hopefully this will unlock rotary encoders too! Didn't realize that the simulated button would be bouncy tho?

urish commented 9 months ago

Didn't realize that the simulated button would be bouncy tho?

Sure, we don't want folks to think their code is working just to run it on real hardware and figure out they didn't account for bouncing, right?

https://docs.wokwi.com/parts/wokwi-pushbutton#bouncing

kartben commented 9 months ago

Didn't realize that the simulated button would be bouncy tho?

Sure, we don't want folks to think their code is working just to run it on real hardware and figure out they didn't account for bouncing, right?

https://docs.wokwi.com/parts/wokwi-pushbutton#bouncing

Neat!

kartben commented 9 months ago

FWIW the encoder works like a charm too now! https://github.com/kartben/wokwi-zephyr-projects/tree/master/esp32s3-lvgl-with-encoder Note that it's not using ESP's Pulse Counter (PCNT) IP but instead plain GPIO. PCNT might not even be supported anyway, according to the wiki at least?

urish commented 9 months ago

Yes, no PCNT yet

kartben commented 9 months ago

@urish A nice one that basically worked out of the box 🥳 https://github.com/kartben/wokwi-zephyr-projects/tree/master/esp32c3-artificial-nose TinyML with Edge Impulse FTW.

Actually, come to think of it, not everything worked out of the box, it would crash when I tried to use a screen rotation that's not 0 or 180 degrees. Not sure if that's a bug? (here's the relevant code on the Zephyr side https://github.com/zephyrproject-rtos/zephyr/blob/433a85e7bf32ffc77ba194bb903bcca84c44c047/drivers/display/display_ili9xxx.c#L244)

urish commented 9 months ago

TinyML with Edge Impulse FTW.

Cool, I wanted to try Edge Impulse for a long time

It would crash when I tried to use a screen rotation that's not 0 or 180 degrees

Crash is in display garbage or actually the program would crash?

kartben commented 9 months ago

The latter. I will try to upload a bin as I realize it might be hard for you to test otherwise.

urish commented 9 months ago

elf please