microsoft / jacdac

Device and service catalogs for Jacdac.
https://aka.ms/jacdac
Creative Commons Attribution 4.0 International
66 stars 25 forks source link

Certain event handlers cause boot loop on UF2 ESP32 devices #1215

Open ross-inksmith opened 1 year ago

ross-inksmith commented 1 year ago

Describe the bug Certain Makecode event blocks cause bootloop on ESP32 device with UF2. This issue occurs with the rotary encoder, light sensor, slider/potentiometer, or any other sensor but not for button events (down/hold/up).

To Reproduce Demo code blocks in maker.makecode.com

  1. Download example .uf2 from the code above
  2. Copy the uf2 to ESP32 device, ours is a prototype device but similar to the MSR ESP32-S2 based IoT brain
  3. Issues arise at this point a. If the rotary encoder is connected to the brain, nothing gets logged to console, and the device enters a boot loop. b. If the rotary encoder isn't connected to a jd connector, the console will show the heartbeat pulse and "binding 1 servers". c. Connecting the module after b) will trigger the "rotated" console message under the event block and then put the device into a boot loop like in a)

Expected behavior Demo code blocks for Microbit The same blocks in the microbit editor (including photodiodes, sliders/pots, etc) will act normally. It will log "pulse" every 200ms and "rotate" every time the encoder rotates.

Additional context Just having the event block seems to be enough to trigger the boot loop, the blocks inside of it are irrelevant.

Getters don't cause this issue. This code and it's block equivalent works as expected.

forever(function () {
    console.log(modules.rotaryEncoder1.position())
    pause(200)
})

Comparing the packets sent in the jacdac dashboard, the button events (which do work) are a flag 8000 "CMD_EVENT_MASK"; while the encoder, slider, and light sensor are all emitting 1000 flagged "GET_REG" when their value changes.

This conversation started in an email with Tom Ball