cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Observer
Observer
418 Views
Registered: ‎07-24-2020

How to access PL DDR from PS in Petalinux

Hello,

I am trying to configure petalinux to access PL DDR instead of PS DDR. How can i make it work??

I created vivado block design and tested its working in vitis, However now I want my linux to write to PL DDR instead of PS DDR.

Any help would be highly appreciated.

Tags (1)
0 Kudos
10 Replies
Highlighted
Mentor
Mentor
377 Views
Registered: ‎01-28-2008

Hi @Prasanna_K 

  As far as the firmware design goes, the block design will have to instantiate the PL DDR and map it to a memory range accessible from the PS, likely using one of the master AXI ports.

  Then Linux running from the PS will have access to the PL DDR; you can read and write to any PL DDR location using for example /dev/mem. However, this will be very slow. You'll need a DMA to move data at a faster rate. Typically you'd use a ZDMA channel to accomplish this. This post in the wiki has more info Zynqmp+DMA and Linux+DMA+From+User+Space 

  Linux DMA is a contested subject due mainly to requiring a kernel driver to properly implement it. There's various workarounds floating around.

 

Best luck,

-Pat

 

https://tuxengineering.com/blog
0 Kudos
Highlighted
Moderator
Moderator
370 Views
Registered: ‎02-07-2018

HI @Prasanna_K 

You just need to add pl memory as a part of memory node in system-user.dtsi file,  so that you will be able to access pl memory from Linux. by default memory node only having PS memory.

I have added this below node for your reference, you need to add PS &  PL address ranges , you can see same from your address editor of your vivado design.

/include/ "system-conf.dtsi"
/ {
/* PS DDR Range <0x00 0x00 0x00 0x7ff00000> */
/* PL DDR Range <0x04 0x00 0x01 0x00>  */
memory {
device_type = "memory";
reg = <0x00 0x00 0x00 0x7ff00000>, <0x04 0x00 0x01 0x00>;
};
};

 

Thanks & regards

Aravind

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
---------------------------------------------------------------------------------------------

 

Highlighted
Observer
Observer
347 Views
Registered: ‎07-24-2020

Hi @aravindb @patocarr ,

Thanks for your response!!

@aravindb I tried what you suggested now, but not sure if I missed something,

Let me describe my design clearly, I have a address translation device in my PL and I want all the memory request has to passed through the PL and PL will access the DDR for read/store.

I am currently working on Zedboard,

whose DDR address is from 0x00000000 to 0x3FFFFFFF and 

my PL address range is from 0x40000000 to 0x7FFFFFFF.

I tested working of this design in Vitis, and confirmed that if I write anything in the address range from 0x40000000 to 0x7FFFFFFF, it is will go through my PL and it writes to DDR in the backend(Exactly how I wanted).

Now I am trying to boot petalinux and wants petalinux to write to address only to my PL address range,

Here's the steps I followed,

petalinux-create -t project -s avnet-digilent-zedboard-v2020.1-final.bsp

petalinux-config --get-hw-description=<path to my xsa>

When I executed petalinux-config command, I could not change kernel base address and System memory base address to 0x40000000 under Subsystem AUTO Hardware Setting, It says "You have made an invalid entry." so I kept them as it is i.e. kernel base address 0x0.

However, I modified system-user.dtsi file as mentioned by @aravindb , and it looks like this,

/include/ "system-conf.dtsi"
/ {
/* PS DDR Range <0x00 0x00 0x00 0x7ff00000> */
/* PL DDR Range <0x04 0x00 0x01 0x00>  */
memory {
device_type = "memory";
reg = <0x40000000 0x3fffffff>;
};

};

Built the project using the below command,

petalinux-build

petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga /<path to bit stream>design_1_wrapper.bit --u-boot

I copied BOOT.BIN boot.scr image.ub system.dtb files from /image/linux directory to SD card and tried to boot on the board, below is the error what I get,

U-Boot 2020.01 (Sep 16 2020 - 09:17:15 +0000)

CPU: Zynq 7z020
Silicon: v3.1
Model: Zynq Zed Development Board
DRAM: ECC disabled 1024 MiB
Flash: 0 Bytes
NAND: 0 MiB
MMC: mmc@e0100000: 0
Loading Environment from SPI Flash... SF: Detected s25fl256s1 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
*** Warning - bad CRC, using default environment

In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Net:
ZYNQ GEM: e000b000, mdio bus e000b000, phyaddr 0, interface rgmii-id

Warning: ethernet@e000b000 using MAC address from DT
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
2010 bytes read in 49 ms (40 KiB/s)
## Executing script at 43000000
** Reading file would overwrite reserved memory **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
SCRIPT FAILED: continuing...
## Executing script at 43000000
** Reading file would overwrite reserved memory **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
SCRIPT FAILED: continuing...
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
2010 bytes read in 49 ms (40 KiB/s)
## Executing script at 43000000
** Reading file would overwrite reserved memory **
Wrong Image Format for bootm command
ERROR: can't get kernel image!
SCRIPT FAILED: continuing...
MMC Device 1 not found
no mmc device at slot 1
SF: Detected s25fl256s1 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
device 0 offset 0xfc0000, size 0x40000
SF: 262144 bytes @ 0xfc0000 Read: OK
## Executing script at 43000000
Wrong image format for "source" command
SCRIPT FAILED: continuing...


no devices available
SCRIPT FAILED: continuing...
## Executing script at 43000000
Wrong image format for "source" command
SCRIPT FAILED: continuing...
starting USB...
Bus usb@e0002000: USB EHCI 1.00
scanning bus usb@e0002000 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found

Device 0: unknown device

Device 1: unknown device
ethernet@e000b000 Waiting for PHY auto negotiation to complete................

_------------------------------------------------------------------------

How do I fix this, or did I miss something ??

Regards,

Prasanna

 

0 Kudos
Highlighted
Observer
Observer
304 Views
Registered: ‎07-24-2020

Hi @aravindb ,

I think I am able to load the fsbl and get to autoboot mode, where i can see my PL address mentioned as the DRAM bank.

 

---------------------------------

Zynq> bd
arch_number = 0x00000000
boot_params = 0x00000000
DRAM bank = 0x00000000
-> start = 0x40000000
-> size = 0x10000000
baudrate = 115200 bps
TLB addr = 0x4fff0000
relocaddr = 0x4ff2f000
reloc off = 0x4bf2f000
irq_sp = 0x4eb09130
sp start = 0x4eb09120
ARM frequency = 666 MHz
DSP frequency = 0 MHz
DDR frequency = 533 MHz
Early malloc usage: 5f8 / 800
fdt_blob = 0x4eb09148

---------------------------------

When I executed bootm command manually,  I get the below log, In that load address and entry point is still pointing to PS DDR range(which is invalid). How to make the linux load address/entry point lies in the range of 0x4000_0000??

 

Zynq> fatload mmc 0 0x41000000 image.ub

Zynq> bootm 0x41000000

OS: Linux
Load Address: 0x00200000
Entry Point: 0x00200000

---------------------------------

 

Log:

------------------------------------------------------------------------

Zynq>
## Loading kernel from FIT Image at 41000000 ...
Using 'conf@system-top.dtb' configuration
Verifying Hash Integrity ... OK
Trying 'kernel@1' kernel subimage
Description: Linux kernel
Type: Kernel Image
Compression: uncompressed
Data Start: 0x410000f8
Data Size: 4325968 Bytes = 4.1 MiB
Architecture: ARM
OS: Linux
Load Address: 0x00200000
Entry Point: 0x00200000
Hash algo: sha256
Hash value: 87bbd46051da5f5983cccd508134478436feeee3f9b8ee22339b8ce8168b700f
Verifying Hash Integrity ... sha256+ OK
## Loading ramdisk from FIT Image at 41000000 ...
Using 'conf@system-top.dtb' configuration
Verifying Hash Integrity ... OK
Trying 'ramdisk@1' ramdisk subimage
Description: petalinux-image-minimal
Type: RAMDisk Image
Compression: uncompressed
Data Start: 0x41425288
Data Size: 7157387 Bytes = 6.8 MiB
Architecture: ARM
OS: Linux
Load Address: unavailable
Entry Point: unavailable
Hash algo: sha256
Hash value: d45fd3aed8ad93e13cd9a274cef373444f4f9108fb52be32e9f0f401c89c9798
Verifying Hash Integrity ... sha256+ OK
## Loading fdt from FIT Image at 41000000 ...
Using 'conf@system-top.dtb' configuration
Verifying Hash Integrity ... OK
Trying 'fdt@system-top.dtb' fdt subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x41420454
Data Size: 19816 Bytes = 19.4 KiB
Architecture: ARM
Hash algo: sha256
Hash value: 1ee07ec62f91da104048cf5a9c068d2d7da4ae24a5efaad65d8bd7bae04e4c97
Verifying Hash Integrity ... sha256+ OK
Booting using the fdt blob at 0x41420454
Loading Kernel Image
ERROR: Failed to allocate 0x6d368b bytes below 0x20000000.
ramdisk - allocation error
bootm - boot application image from memory

Usage:
bootm [addr [arg ...]]
- boot application image stored in memory
passing arguments 'arg ...'; when booting a Linux kernel,
'arg' can be the address of an initrd image
When booting a Linux kernel which requires a flat device-tree
a third argument is required which is the address of the
device-tree blob. To boot that kernel without an initrd image,
use a '-' for the second argument. If you do not pass a third
a bd_info struct will be passed instead

For the new multi component uImage format (FIT) addresses
must be extended to include component or configuration unit name:
addr:<subimg_uname> - direct component image specification
addr#<conf_uname> - configuration specification
Use iminfo command to get the list of existing component
images and configurations.

Sub-commands to do part of the bootm sequence. The sub-commands must be
issued in the order below (it's ok to not issue all sub-commands):
start [addr [arg ...]]
loados - load OS image
ramdisk - relocate initrd, set env initrd_start/initrd_end
fdt - relocate flat device tree
cmdline - OS specific command line processing/setup
bdt - OS specific bd_t processing
prep - OS specific prep before relocation or go
go - start OS

-------------------------------------------------------------

Regards,

Prasanna

0 Kudos
Highlighted
Moderator
Moderator
288 Views
Registered: ‎04-24-2017

Hi @Prasanna_K ,

I'm clear on your question here. PetaLinux is a build tool which uses Yocto backend.

Do you want to access PL DRR from Linux user space application or kernel space? Or you want to boot Linux from PL DDR?

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Highlighted
Observer
Observer
278 Views
Registered: ‎07-24-2020

Hi @sandeepg ,

Thanks for your response,

I am using PS DDR only in the backend of my logic.

My motive is to make all the memory request to be passed through my IP and my IP in the backend will access memory and serve read and store request for the PS.

Prasanna_K_0-1600453256407.png

In Vitis, I confirmed that, if i write anything in the PL address range, it writes into DDR address in the backend and i can read back as well.

Now I want linux to see PL as the memory and write everything into its address range. Linux should not use DDR directly at all, it should read/write only in to the PL.

Hope I have explained my design, But with memory being changed, linux is not booting up. I have been stuck here  and not able to get this working. I need to access DDR from the kernel space. 

Regards,

Prasanna 

0 Kudos
Highlighted
Voyager
Voyager
264 Views
Registered: ‎10-21-2015

Hi,

Could you show the Address Editor in vivado?

I guess your pl ip has axi lite slave interface

If so, you should handle it as ip(like axi gpio) not memory

You can access your ip using uio driver

Refer to https://forums.xilinx.com/t5/Embedded-Linux/Custom-Hardware-with-UIO/m-p/804680/highlight/true#M22475 

0 Kudos
Highlighted
Observer
Observer
173 Views
Registered: ‎07-24-2020

Hi @hokim 

Thanks for your response,

Please find attached address editor details in vivado,

Prasanna_K_0-1600672990048.png

@hokim , If I use my IP as uio driver, then all the os request to memory will not pass through my IP right? 

Regards,

Prasanna

 

0 Kudos
Highlighted
Observer
Observer
155 Views
Registered: ‎07-24-2020

Hi @sandeepg 

I need to access DDR from the kernel space. 

Regards,

Prasanna

0 Kudos
Highlighted
Observer
Observer
19 Views
Registered: ‎07-24-2020

Hi @sandeepg 

Any update on this?

Regards,

Prasanna

0 Kudos