atomvm / AtomVM

Tiny Erlang VM
https://www.atomvm.net
Apache License 2.0
1.49k stars 106 forks source link

i2c:write_bytes panic on ESP32 #1324

Open ray-delossantos opened 1 month ago

ray-delossantos commented 1 month ago

Using an ESP32 board

When running this function


i2c_write_bytes_with_result(I2C, Bytes) -> 
    case i2c:write_bytes(I2C, <<0, 128>>) of
        ok -> {ok, nil};
        error -> {error, nil};
        {error, _} = E -> E
    end.

It throws the error below.

# sudo cu -s 115200 -l /dev/tty.usbserial-0001

I (969) i2c_driver: I2C driver installed using I2C port 0
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x400da301  PS      : 0x00060030  A0      : 0x801395a3  A1      : 0x3ffba930
A2      : 0x00000002  A3      : 0x3ffcc16c  A4      : 0x3ffcc21c  A5      : 0x00000064
A6      : 0x03ffcc67  A7      : 0x3ffcc300  A8      : 0xfffffffc  A9      : 0x00000003
A10     : 0x00000033  A11     : 0x0000006c  A12     : 0x3ffbbd18  A13     : 0x00000167
A14     : 0x0000000b  A15     : 0x00000000  SAR     : 0x0000000a  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000068  LBEG    : 0x4008336d  LEND    : 0x40083375  LCOUNT  : 0x00000027

Backtrace: 0x400da2fe:0x3ffba930 0x401395a0:0x3ffba990 0x401396b6:0x3ffba9c0 0x400f3977:0x3ffba9e0 0x4011485a:0x3ffbaa90 0x400d90e7:0x3ffbaab0 0x401dca17:0x3ffbaaf0

What I may be doing wrong?

Note: If I use the i2c:write_byte and send the exact same bytes one by one it works as expected.

bettio commented 1 month ago

Thanks for reporting this issue, we need to reproduce first, and investigate this. Since we were close to a release, we left this as a known issue and it is a good candidate for a v0.6.6 maintenance release.

ray-delossantos commented 1 month ago

Thanks for the update. If it helps I may be able to test that part of the release when ready.