Closed cinlyooi-intel closed 5 years ago
does not fail on qemu_nios2
I've reproduced on Max10 HW, but this is still mysterious. I think this has something to do with unaligned memory access to the ring buffer storage area, still digging
Seems that on the real Max10 board, trying to array reference an unaligned pointer implictly changes stuff. The rb_data[] array passed to ring_buf_item_put() is not 4-byte aligned.
In emulation, and presumably on other hardware, we see:
RB PUT TO ADDR 0x00400e47
data[i] is 44434241
But on the Max10 board, the unaligned pointer is treated differently:
RB PUT TO ADDR 0x00400e33
data[i] is 41000000
We expect data[i] to be 0x44434241, which is what "ABCD" would look like if cast to a u32_t. It seems that the CPU is instead doing something which causes the array beginning to be treated as 0x00400e30 instead.
I don't know if this is an undefined behavior problem with the test, or some bug on Max10.
I'm gonna go with this being undefined behavior.
verified that the tests/lib/ringbuffer test cases are passed with the latest commit 9926f94
Describe the bug (memcmp((char )getdata, rb_data, getsize sizeof(u32_t)) == 0
Seen on Altera Max10
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots or console output
Environment (please complete the following information):
Additional context Add any other context about the problem here.