element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development DDR memory reservation
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 2 replies
  • Subscribers 329 subscribers
  • Views 1355 views
  • Users 0 members are here
Related

DDR memory reservation

Former Member
Former Member over 8 years ago

Hello everyone,

I'm working on Microzed board on an AMP architecture without using OpenAMP.

My CPU0 runs a Linux OS (kernel 4.4). My CPU1 runs a FreeRTOS. Each Application have to exchange data to the other one. so I'm using DDR as a shared memory and SGI as Inter processor interrupt system. My FreeRTOS application is located at 0x0F010000, and my Shared memory is located at 0x0F000000. 

I've developped a module driver to managed to the SGI's and the access to the shared memory (read, write, ...). And I get -EBUSY error while trying to get DDR ressources from 0x0F000000 to 0x0F00FFFF.

 

I've try different ways :

- I've Changed memory size in device tree 

memory {

  device_type = "memory";
  reg = <0x0 0x0F000000>;
};
 
but the /proc/meminfo still see 1Gbyte RAM size (see here under)
  MemTotal:        1031656 kB
  MemFree:         1011788 kB
  MemAvailable:    1009032 kB
   
  And modprobe mydev still returns an error.
   
  - I've added mem=240M in kernel boot command line (in device tree), but Linux Freeze at "Starting Kernel" step

- I've used memmap argument in kernel boot command line ==> it does not work and I've later that it is not supported on ARM.

- I've add a device tree node (reserved-memory) 

  reserved-memory {
     #address-cells = <1>;
    #size-cells = <1>;
    ranges;
     ddr_memp0: amp_memp@0f000000 {
      reg = <0x0f000000 0x010000>;
    };
     ddr_appcpu1: amp_appcpu1@0f010000 {
      reg = <0x0f010000 0x050000>;
    };    
  };

==> the /proc/meminfo still see 1Gbyte RAM size (see here under) and modprobe mydriver still returns the same error 

  MemTotal:        1031656 kB
  MemFree:         1011788 kB
  MemAvailable:    1009032 kB
   
  - I've try the free ressources located between 0x0F000000 and 0x0F060000 (see driver code here under) ==> But I got an error message explaining that the resources do not exist (Trying to free nonexistent resource <000000000f000000-000000000f00ffff>)
   
  Does someone can give me some working clues to secure my DDR shared and my freertos code and data memory ?
  Thanks for you help !!!
   
  ________________________________________________________________________________________
   
  I give here under the probe function of my driver 
   
  <code>
 
   static int ae_memp_probe(struct platform_device *pdev){
 
    
 
   void * pdata; /* platform data pointer */
 
   struct resource *res;
 
   u32 rq_irq, wr_irq, u32_mem_addr;
 
   long s32_mem_size;
 
   int rtn;
 
    
 
    
 
   printk(KERN_INFO "ae_memp_probe : Allocating ae_memp ressources\n");
 
   memp_reg_mgr = kzalloc(sizeof(struct ae_memp), GFP_KERNEL);
 
   if (!memp_reg_mgr){
 
     printk(KERN_ERR "ae_memp_probe : allocation failed\n");
 
   return rtn;
 
   }else{
 
     printk(KERN_INFO "ae_memp_probe : Getting platform data\n");
 
     pdata = dev_get_platdata(&pdev->dev);
 
     if (pdata == NULL ){
 
       printk(KERN_ERR "ae_memp_probe : platform data NULL pointer\n");
 
     }
 
    
 
     printk(KERN_INFO "ae_memp_probe : Getting Information from Device Tree\n");
 
    
 
     of_property_read_u32(pdev->dev.of_node, "mem_addr", &u32_mem_addr);
 
     if (!u32_mem_addr){
 
       printk(KERN_ALERT "ae_memp_probe : mem_addr not found\n");
 
       mem_addr = (char *)0x0F000000;
 
       u32_mem_addr=0x0F000000;
 
     } else {
 
       mem_addr=(char *)u32_mem_addr;
 
       printk(KERN_INFO "ae_memp_probe : read mem_addr=0x%lx\n", (unsigned long)mem_addr);
 
     }
 
    
 
     of_property_read_u32(pdev->dev.of_node, "mem_size",(u32*)&s32_mem_size);
 
     if (s32_mem_size <= 0 ){
 
       printk(KERN_ALERT "ae_memp_probe : s32_mem_size not found or bad value\n");
 
       s32_mem_size=100;
 
     } else {
 
       printk(KERN_INFO "ae_memp_probe : read s32_mem_size=%ld\n", s32_mem_size);
 
     }
 
    
 
     /* Freeing shared Memory region */
 
     release_region (u32_mem_addr, (unsigned long)s32_mem_size); /* does not work */
 
    
 
     printk(KERN_INFO "ae_memp_probe : Getting Platform ressources\n");
 
     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
     if (res == NULL){
 
       printk(KERN_ALERT "ae_memp_probe : Failed to get platform ressources\n");
 
       return -ECANCELED;
 
     }
 
    
 
     memp_reg_mgr->ram.mem_addr= devm_ioremap_resource(&pdev->dev, res);
 
     if (IS_ERR(memp_reg_mgr->ram.mem_addr)) {
 
       rtn = PTR_ERR(memp_reg_mgr->ram.mem_addr);
 
       return rtn;
 
     }
 
    
 
     printk(KERN_INFO "ae_memp_probe : Configuring IPI\n");
 
     clear_ipi_handler(memp_reg_mgr->irqmgr.rd_irq);
 
     rtn = set_ipi_handler(memp_reg_mgr->irqmgr.rd_irq, ae_memp_irqhandler, "ae_memp_irqhandler");
 
     if (rtn != 0){
 
       printk(KERN_ERR "ERREUR : ae_memp_probe - Echec de requete de l'IRQ\n");
 
       return rtn;
 
     }
 
    
 
     printk(KERN_INFO "ae_memp_probe success - Module Loaded\n");
 
    
 
     return 0;
 
   }
 
   return -ECANCELED;
 
   }
 
    
 
  
    static const struct of_device_id ae_memp_of_match[] = {
  
    { .compatible = "ae,ddr_memp_1.0.a", },
  
    {}
  
    };
  
    MODULE_DEVICE_TABLE(of, ae_memp_of_match);
  
     
  
    static struct platform_driver ae_memp_driver = {
  
    .probe = ae_memp_probe,
  
    .remove = ae_memp_remove,
  
    .driver = {
  
    .name = AE_MEMP_DEVICE,
  
    .of_match_table = ae_memp_of_match,
  
    },
  
    };
  
    module_platform_driver(ae_memp_driver);
 
  </code>

_______________________________________________________________________________

My device tree :

/ {
  cpus {
    cpu@0 {
      operating-points = <666666 1000000 333333 1000000>;
    };
  };
  chosen {
    bootargs = "console=ttyPS0,115200 root=/dev/ram ramdisk_size=65535 maxcpus=1 ip=192.168.1.192 clk_ignore_unused rw earlyprintk";
  };
  aliases {
    ethernet0 = &gem0;
    serial0 = &uart1;
    spi0 = &qspi;
    spi1 = &spi0;
  };
  memory {
    device_type = "memory";
    reg = <0x0 0x40000000>;
  };
 
  reserved-memory {
    #address-cells = <1>;
   #size-cells = <1>;
   ranges;
    ddr_memp0: amp_memp@0f000000 {
     reg = <0x0f000000 0x010000>;
    };
    ddr_appcpu1: amp_appcpu1@0f010000 {
     reg = <0x0f010000 0x050000>;
    };    
  };
 
  memp0: ae_memp@0f000000 {
    compatible = "ae,ddr_memp_1.0.a";
    reg = <0x0f000000 0x010000>;   
    memory-region = <&ddr_memp0>; 
    rd_irq= <2>;
    wr_irq= <1>;
    mem_addr=<0x0F000000>;
    mem_size=<0x010000>;
  };
};
  • Sign in to reply
  • Cancel
  • jafoste4
    0 jafoste4 over 8 years ago

    Hello,

    Try taking a look at this post I found over at the Xilinx Forum. It seems quite similar to yours

    https://forums.xilinx.com/t5/Embedded-Processor-System-Design/RPMsg-Zynq-AMP-Linux-RTOS/td-p/696377

    Also take a look at our ZynqSW Speedway, specifically lab 9 were we communicate between two baremetal applications using CPU0 and CPU1. 

    http://zedboard.com/course/developing-zynq%C2%AE-7000-all-programmable-soc-software-vivado-20133-201441-20152-and-20162

    --Josh

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 8 years ago

    Hello JFoster,

     

    Thank for your reply but theses links did not help me a lot.

     

    I've finally found one way to solve my problem.

     

    In The device tree, instead of configuring the memory node with 

    memory {
        device_type = "memory";
        reg=<0 0x40000000>;
    };

    I'm using the directive 

    memory {
        device_type = "memory";
        linux,usable-memory =<0x0 0x0F000000>, <0x0F060000 0x30FA0000>;
    };

    in order to allow linux to use DDR memory from 0 to 0x0EFFFFFF and from 0x0F0600000 to 3FFFFFFF.

     

    In that case, Linux Kernel does not allocate memory from 0x0F000000 to 0x0F060000. which is now totally free for may shared memory processor communication.

    The use of " platform_get_resource(pdev, IORESOURCE_MEM, 0);" does not return an error anymore.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube