Skip to content

Commit 84e8841

Browse files
committed
Introduce a memory barrier between writing the DMA address and the command.
Without a memory barrier gcc is free to reorder volatile stores. In my case the LED strip lit up with uninitialized memory for the first draw and then fixed itself with the next one. With this change it was immediately fixed.
1 parent d4c2aa3 commit 84e8841

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/ledscape/ledscape.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ ledscape_strip_draw(
350350
= leds->pru->ddr_addr + leds->frame_size * frame;
351351
// frame = (frame + 1) & 1;
352352

353+
__asm__ __volatile__("":::"memory");
354+
353355
// Send the start command
354356
leds->ws281x->command = 1;
355357
}

0 commit comments

Comments
 (0)