【问题标题】:Cannot reserve memory on Petalinux2020.2?无法在 Petalinux2020.2 上预留内存?
【发布时间】:2021-04-01 17:12:39
【问题描述】:

我正在使用 petalinux2020.2 和 RFSOC、zcu111 板构建一个项目,对于我的应用程序,我需要从 petalinux 保留一段内存以用于 DMA,在 FPGA 的可编程逻辑上实现。 我尝试关注this tutorial,但在启动时出现错误。

以内核恐慌终止,如下所示: 我尝试使用 petalinux-config 命令修改内存大小,将内存大小设置为 0x70000000,但没有帮助。

设备树的条目如下所示:

/include/ "system-conf.dtsi"
/{
    reserved-memory {
        #address-cells = <2>;
        #size-cells = <2>;
        ranges;
 
        reserved: buffer@0 {
            no-map;
            reg = <0x0 0x70000000 0x0 0x10000000>;
        };
    };
    reserved-driver@0 {
        compatible = "xlnx,reserved-memory";
        memory-region = <&reserved>;
    };
};

我怎样才能做到这一点?

【问题讨论】:

  • 0x10000000 是 256MB,看起来您正在尝试覆盖您的 ramdisk。这就是你想要的吗?
  • 是的,我试图为 DMA 保留该范围内的内存。基本上我有一个 IP-Core,它会在启用时通过 DMA 写入这些位置。该位置由自定义内核模块映射,以便用户应用程序可以读取我的 DMA 设备生成的数据。

标签: linux embedded-linux xilinx device-tree petalinux


【解决方案1】:

我在 Zynq-7020 板上运行 PetaLinux 2018.1,并且可以成功地为我的 DMA 操作预留内存。虽然不是您的确切设置,但它应该足够相似。您需要调整内存地址以适应您的系统。

我正在使用 DMA API“shared-dma-pool”属性。这样我的设备驱动程序将使用我的保留空间而不是默认的 CMA 池。

另外,请注意,在我将 vmalloc=512M 语句添加到 bootargs 之前,我在保留内存时遇到了问题。虽然我只为 DMA 预留了 256MB,但I needed to vmalloc a larger value(在我的情况下是双倍的)让事情正常进行。

我的设备树条目:

/include/ "system-conf.dtsi"
/ {
    chosen {
    bootargs = "console=ttyPS0,115200 earlyprintk vmalloc=512M";
    stdout-path = "serial0:115200n8";
    };

reserved-memory {
        #address-cells = <1>;
        #size-cells = <1>;
        ranges;
 
            dma_reserved: buffer@30000000 {
        compatible = "shared-dma-pool";
            no-map;
        reg = <0x30000000 0x10000000>;
            };
    };

    //Required properties: 
    // - dmas: a list of <[DMA device phandle] [Channel ID]> pairs, 
    //         where Channel ID is (if both channels are enabled):
    //      '0' for write/tx channel
    //      '1' for read/rx channel 
    //     If only one channel is enabled, either tx or rx: 
    //      Channel ID is '0'. 
    // - dma-names: a list of DMA channel names, one per "dmas" entry 
    dma_proxy@0 {
        compatible ="xlnx,dma_proxy";
        dmas = <&axi_dma_0 0;
        dma-names = "dma1";
    memory-region = <&dma_reserved>;
    };
}

显示保留内存的控制台:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-26
    • 1970-01-01
    • 2012-05-14
    • 1970-01-01
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多