Closed Mynogs closed 3 years ago
With the spi readwrite function, multiples of four bytes must always be written/readed. Otherwise the heap will be damaged.
Here are five different tests:
local recv = device: readwrite (address >> 16, address >> 8, address, 4, 5) CORRUPT HEAP: Bad tail at 0x3ffbe101. Expected 0xbaad5678 got 0xba000000
local recv = device: readwrite (address >> 16, address >> 8, address, 4, 5, 6) CORRUPT HEAP: Bad tail at 0x3ffbe102. Expected 0xbaad5678 got 0xbaad0000
local recv = device: readwrite (address >> 16, address >> 8, address, 4, 5, 7) CORRUPT HEAP: Bad tail at 0x3ffbe103. Expected 0xbaad5678 got 0xbaad5600
local recv = device: readwrite (address >> 16, address >> 8, address, 4, 5, 7, 8) *** Works!
local recv = device: readwrite (address >> 16, address >> 8, address, 4, 5, 7, 8, 9) CORRUPT HEAP: Bad tail at 0x3ffd1741. Expected 0xbaad5678 got 0xba000000
When I send 5 bytes, 3 bytes in the heap are corrupted.
When I send 6 bytes, 2 bytes in the heap are corrupted.
When I send 7 bytes, 1 byte in the heap is corrupt.
If I send 8 bytes there is no problem.
When I send 9 bytes, 3 bytes in the heap are corrupted.
etc....
Best wishes
André
With the spi readwrite function, multiples of four bytes must always be written/readed. Otherwise the heap will be damaged.
Here are five different tests:
When I send 5 bytes, 3 bytes in the heap are corrupted.
When I send 6 bytes, 2 bytes in the heap are corrupted.
When I send 7 bytes, 1 byte in the heap is corrupt.
If I send 8 bytes there is no problem.
When I send 9 bytes, 3 bytes in the heap are corrupted.
etc....
Best wishes
André