Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

allocate memory at fixed location

Altera_Forum
Honored Contributor II
1,255 Views

I want to assign a 2K memory at a fixed location. I am using eCos for my system. With OsAlloc(), I don't have option to have desired start location but will give me any random location which will not be of my interest. Can anybody here help me, how can I allocate memory of 2K at location 0x2000H.

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
544 Views

I have no idea what your memory map looks like (is 0x2000 part of the heap or something else?), but if you want to create a fixed region of memory, you probably need to alter your linker file. 

 

Looking at an old eCos project of mine, in the ecos50_install directory that eCos generated there's a file at lib/target.ld. In it there is a block named "MEMORY" and a block named "SECTIONS". The latter lists out the various code sections and where they are placed in memory. 

 

You'll need to add an entry to "SECTIONS" for your 2k table, and you may need to break the entry for your RAM in "MEMORY" into two parts: one for your table and the other for the rest of RAM. Read the GCC docs on how to specify sections for variable storage (should be the __attribute__ keyword) in your C or C++ code, and how to modify your linker file to add the new section (and memory, if needed). 

 

BTW, the ".entry" section, which is a 32-byte block at a fixed memory address, is handled in a similar manner to what you're trying to do here. It might be a useful example.
0 Kudos
Altera_Forum
Honored Contributor II
544 Views

Thanks Mike. I think I am going in right direction after reading your reply. This target.ld file is generated by ecos and if I am not wrong, I will need to modify the "XXXXXX.ldi" file for defining that 2K buffer in MEMORY and SECTIONS block. Well, after such define, which RAM section will act as default. Will I have to write after each and every function the __attribute__ to define its section. suppose I have two ram area defined RAM1, RAM2. which one will act as the default for other functions which are not attributed. Also, one more thing, what will be the starting address for the array defined using the __attribute__ method. Will it be the first location in that section? Thanks once again for your help.

0 Kudos
Altera_Forum
Honored Contributor II
544 Views

Thanks Mike, I was able to manage my memory.

0 Kudos
Reply