Red Pitaya Linux modification --reserved memory for dma

Applications, development tools, FPGA, C, WEB
Post Reply
alex123go
Posts: 14
Joined: Mon May 04, 2020 4:46 pm

Red Pitaya Linux modification --reserved memory for dma

Post by alex123go » Fri Jun 12, 2020 10:31 pm

Hello everyone,

I'm running custom HDL applications on the Red Pitaya and I'm currently using 0.94 ecosystem (though I could probably change if needed). I'd like to reduce the memory allocation to linux (therefore, increase the dma-reserve portion).

The goal of this modification is to make a high speed acquisition card (ADC -> Datamover -> DDR3 and when the acquisition is done, read DDR3 and save to sd card or send via ethernet). Therefore, I'd like to reduce the linux RAM size as much as possible (around 100 MB) and use the remaining (around 412 MB ~ 256 MSamples at 125 MHz).

First, quick question which might make the next one unnecessary:
Can I assume that if I allocate memory in a C program with the following pseudo code, it's not used by linux. So if I change 0x1E000000UL to a lower address like 0x10000000UL (and corresponfing MAP_SIZE and MAP_MASK), will I be sure all my data in the DDR3 won't be modified by linux?

Code: Select all

#define MAP_SIZE_DMA (1UL<<25) //DMA from FPGA_MEMORY_START_DMA to 0x1FFFFFFFUL (for 1E000000 to 1FFFFFFF => 2^25-1 = 32MB)
#define MAP_MASK_DMA (MAP_SIZE_DMA - 1)
uint32_t FPGA_MEMORY_START_DMA = 0x1E000000UL;

void* map_base_dma = (void*)(-1);
fd_dev_mem = open("/dev/mem", O_RDWR | O_SYNC);

map_base_dma = mmap(0, MAP_SIZE_DMA, PROT_READ | PROT_WRITE, MAP_SHARED, fd_dev_mem, FPGA_MEMORY_START_DMA & ~MAP_MASK_DMA);
If not, here's my real question:

How should I proceed to modify dma-reserved memory? I've tried several path, but not sure which one to follow. I recently started having an okay understanding of the FPGA side, but frankly, I'm lost with everything on the processing side (and mostly booting). Every bit of advice is welcome.

Here's what I've tried so far:

- Currently, I can decompile the devicetree ( dtc -I dtb -O dts /boot/devicetree.dtb) and see this line
memory {
device_type = "memory";
reg = <0x0 0x1c000000>;
};
which fit approximately with what i get from "vmstat -s" (468 MB of RAM)
479256 K total memory
If I manually change the value in the devicetree, run

Code: Select all

dtc -I dts -O dtb devicetree.dtb devicetree.dts
and reboot, I get "Invalid FAT entry" in the boot section

If I manually change the devicetree.dtb via windows (by inserting the sd card in the sd reader), nothing happen but I can see the dtb file has been modified (if I decompile it with the dtc command).

- Also, if I look at everything in the boot section I see these lines:
## Executing script at 02000000
Set devicetree and ramdisk high loading address to 512MB-64MB
[...]
Machine model: xlnx,zynq-7000
cma: Reserved 16 MiB at 0x1d000000
Memory policy: Data cache writealloc
[...]
Memory: 462656K/491520K available (5444K kernel code, 336K rwdata, 1776K rodata, 216K init, 238K bss, 28864K reserved, 0K highmem)
[...]
DMA: preallocated 256 KiB pool for atomic coherent allocations
- I also looked at u-boot.src (and u-boot.src.buildroot and u-boot.src.debian) and there is the following lines:
setenv high 0x1c000000
setenv fdt_high ${high}
setenv initrd_high ${high}
To summarize, I see contradictory information (u-boot and devicetree vs text in boot section) and I don't know how to boot with a modified devicetree (or even if I should). Do you have any suggestion for me?

Thank you very much for your help.

Alex

33dnp
Posts: 2
Joined: Fri Jul 17, 2020 6:00 am

Re: Red Pitaya Linux modification --reserved memory for dma

Post by 33dnp » Fri Jul 17, 2020 6:11 am

You can modify u-boot with a patch.
If you check file
https://github.com/RedPitaya/RedPitaya/ ... kefile.x86 line 183
you can see patch for build u-boot

file of patch stored
https://github.com/RedPitaya/RedPitaya/ ... oot.script

alex123go
Posts: 14
Joined: Mon May 04, 2020 4:46 pm

Re: Red Pitaya Linux modification --reserved memory for dma

Post by alex123go » Wed Aug 05, 2020 7:54 pm

Thanks for your answer.

In the meantime, I was trying different things and discovered Pavel's repo to compile Alpine Linux, which, in my opinion, was better documented. I successfully compiled Alpine Linux with increased reserved memory for DMA (384MB of reserved memory, which allows to save up to 1.6 sec of data at 125MHz in the RAM)

Therefore, it's unnecessary to modify the original RP ecosystem.

However, thanks for your help.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: Bing [Bot] and 3 guests