- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Mike, I was able to manage my memory.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page