Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5021

Bare metal, Assembly language • RPi 1/Zero DMA with SRC_INC set to 0

$
0
0
The DMA Controller Overview in section 4.1 of the docs for the BCM2835 states:
The DMA can deal with byte aligned transfers and will minimise bus traffic by buffering and
packing misaligned accesses.
But as far as i can tell, if you specify SRC_INC as 0, the source data needs to be 16 byte aligned. Also, when you do this SRC_WIDTH will be ignored and it seems to always do 128 bit transfers. (I can't also find what misaligned accesses are in the docs...)

This is my test:
Image

The topmost block is transferring this (array of white colours):

Code:

u32 aAlignedW128[] __attribute__((aligned(16))) = {0xffffffff,0xffffffff,0xffffffff,0xffffffff};
with SRC_WIDTH & DST_WIDTH set to 1, all looks good.

The next block down, is attemping to transfer the first 32 bits of this (3 white 1 black colour values):

Code:

u32 aAlignedW128_marker[] __attribute__((aligned(16))) = {0xffffffff,0xffffffff,0xffffffff,0x00000000};
with SRC_WIDTH & DST_WIDTH set to 0, but it looks like it's copying past the first elements right to the last black element. past 32 bits, looks more like 128!

The next one is the same as before, but using a white,red,green,blue,black pattern:

Code:

u32 aAlignedW32[] __attribute__((aligned(16))) = {0xffffffff,0xf000f000,0x0ff00ff0,0x00f0000f,0x00000000};
it's copying up to and including the blue element, which again suggests this is not read/writing just 32 bits

After that i am trying to copy some unaligned values from this:

Code:

u32 aUnalignedW128[] = {0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000};
The output here varies, but unless this array happens to be 16 byte aligned, the output is always wrong regardless of the SRC/DST_WIDTH value.

At a guess the misaligned packing mentioned in the docs is filled with junk? and maybe it always transferring 128 is just an error in the docs. But maybe someone here can set me straight.

I made this thread as i asked about this issues earlier in the year (but the thread ended up being about other issues)
viewtopic.php?t=373842
Other people seems to have hit this issues too:
viewtopic.php?p=916205
viewtopic.php?p=1915115
So just documenting what i have found
Screenshot 2024-12-28 at 22.14.30.jpg

Statistics: Posted by welford — Sat Dec 28, 2024 10:53 pm



Viewing all articles
Browse latest Browse all 5021

Trending Articles