Go to Post Thinking (or the lack of it) will be our downfall. - sirbleedsalot [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-03-2006, 17:18
RbtGal1351's Avatar
RbtGal1351 RbtGal1351 is offline
~La Reina de los Robots~
AKA: Stephanie
FRC #1351 (TKO)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 166
RbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to behold
Send a message via AIM to RbtGal1351 Send a message via MSN to RbtGal1351
Exclamation Please help: Memory allocation problem dealing with sections

Hi,

I'm having a memory allocation problem. (I think.)
I was working with the 2005 RC, but this doesn't work when compiled for the 2006 RC either.
Code:
    MPLINK 3.90, Linker
    Copyright (c) 2004 Microchip Technology Inc.
    Error - section '.idata_autonomous.o' can not fit the section. Section '.idata_autonomous.o' length=0x00000123
    Errors    : 1
    BUILD FAILED: Mon Mar 13 00:43:55 2006
I have a big script of autonomous stuff, but its 8 bytes per, x 34 long, which is 272 bytes.
I have 2000 bytes to use. (according to microchip: http://www.microchip.com/stellent/id...ame =en010319)

The other big memory usage is 64 bytes of look up table for driving.


my guess is for each .o you can only use 256 k. and its in "sections".
Suggestions? Help please!

Thanks so much!
I'd like to use this code for SVR in less than three days...
~Stephanie
__________________
2004 Founding member and Arm leader, 2005 Lead programmer, 2006 Controls leader, 2007 Project Manager/President
Thanks for making FIRST such a great experience for me. I'm no longer on 1351, and I'm not currently planning to mentor team 97, but FIRST has meant so much in getting me to where I am now, in life and at MIT, class of 2011.
I met Billfred! He recognized me!
SVR 04: 11th seed - Highest Rookie Seed - Semifinalists w/ 1120 and 568 - GM Industrial Design Award
SVR 05: Semifinalists w/ 8 and 766
SVR 06: 6th seed - Quarterfinalists w/ 368 and 1072
Davis 06: 1st seed - Quarterfinalists w/ 649 and 100 - KPCB Entrepreneurship Award
SVR 07: 36th seed
David 07: 4th seed - Semifinalists w/ 1280 and 692 - Johnson and Johnson Sportsmanship Award
  #2   Spotlight this post!  
Unread 13-03-2006, 17:26
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Please help: Memory allocation problem dealing with sections

Quote:
Originally Posted by RbtGal1351
Hi,

I'm having a memory allocation problem. (I think.)
I was working with the 2005 RC, but this doesn't work when compiled for the 2006 RC either.
Code:
    MPLINK 3.90, Linker
    Copyright (c) 2004 Microchip Technology Inc.
    Error - section '.idata_autonomous.o' can not fit the section. Section '.idata_autonomous.o' length=0x00000123
    Errors    : 1
    BUILD FAILED: Mon Mar 13 00:43:55 2006
I have a big script of autonomous stuff, but its 8 bytes per, x 34 long, which is 272 bytes.
I have 2000 bytes to use. (according to microchip: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName =en010319)

The other big memory usage is 64 bytes of look up table for driving.


my guess is for each .o you can only use 256 k. and its in "sections".
Suggestions? Help please!

Thanks so much!
I'd like to use this code for SVR in less than three days...
~Stephanie
I don't think you can have any single variable or array over 256 bytes in size, that could be your problem, can you condense the script array at all?
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #3   Spotlight this post!  
Unread 13-03-2006, 17:36
RbtGal1351's Avatar
RbtGal1351 RbtGal1351 is offline
~La Reina de los Robots~
AKA: Stephanie
FRC #1351 (TKO)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 166
RbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to behold
Send a message via AIM to RbtGal1351 Send a message via MSN to RbtGal1351
Re: Please help: Memory allocation problem dealing with sections

Well I just got the same error message after shortening the array and adding the same number of single unsigned char variables.

So I think that the 256k (or about) limit is for the file, not a single variable.

On second thought, it could just be both.
__________________
2004 Founding member and Arm leader, 2005 Lead programmer, 2006 Controls leader, 2007 Project Manager/President
Thanks for making FIRST such a great experience for me. I'm no longer on 1351, and I'm not currently planning to mentor team 97, but FIRST has meant so much in getting me to where I am now, in life and at MIT, class of 2011.
I met Billfred! He recognized me!
SVR 04: 11th seed - Highest Rookie Seed - Semifinalists w/ 1120 and 568 - GM Industrial Design Award
SVR 05: Semifinalists w/ 8 and 766
SVR 06: 6th seed - Quarterfinalists w/ 368 and 1072
Davis 06: 1st seed - Quarterfinalists w/ 649 and 100 - KPCB Entrepreneurship Award
SVR 07: 36th seed
David 07: 4th seed - Semifinalists w/ 1280 and 692 - Johnson and Johnson Sportsmanship Award
  #4   Spotlight this post!  
Unread 13-03-2006, 18:13
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: Please help: Memory allocation problem dealing with sections

Try this, if the script is set at compile time, and not changed:

Instead of
Code:
unsigned char someArray[]....
use

Code:
rom const unsigned char someArray[]...
And you shouldn't have that problem anymore.. if that doesn't help, search for "lookup tables"
  #5   Spotlight this post!  
Unread 13-03-2006, 18:18
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Please help: Memory allocation problem dealing with sections

Stephanie,

There are a couple of things you can do to fix this problem. As Matt mentioned, you can't have a single array greater than 256 bytes in data memory. In fact, unless to tell the compiler otherwise, you can't have more than 256 bytes of static variables defined in any file. From your error, it looks like you are initializing the variable list. If you do not need to write to these variables (read-only) then you can define them as "rom". This places them in program (flash) memory with your code as shown below. You can access them identically to a data variable except you no longer have the 256 byte limit. (Note that if you use pointers, you need to define the pointer as rom as well)

// Data Memory (this generates the error):
static unsigned char myvariable[8,34];

// Program Memory (this will work):
rom unsigned char myvariable[8,34];

If you need to write to these variables, then you will have to make sure that no variable array is greater than 256 bytes. So you could either shorten the array, or split it into multiple arrays. Then you need to tell the compiler to place them into different sections similar to the following. In this example, the array is split into 2 parts of [4,34].

// file global variable split into 2 sections
#pragma udata vararray1
unsigned char myvariable1[4,34];
#pragma udata vararray2
unsigned char myvariable2[4,34];
#pragma udata

The #pragma statement tells the compiler to split the variables into two sections ("udata" indicate an uninitialized data array, "vararray1" is just a unique name for the section - use "idata" instead of "udata" if you are initializing the array with values). These sections can then be placed into different 256 byte memory banks. The "rom" qualifier is the way to go if you don't need to write to the variables as it is an easy change and should require modification to your program as long as you do not use pointers (otherwise define the pointer as rom as well like: rom unsigned char *varpointer)

Mike

Last edited by Mike Bortfeldt : 13-03-2006 at 18:55. Reason: udata/idata correction
  #6   Spotlight this post!  
Unread 13-03-2006, 19:03
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Please help: Memory allocation problem dealing with sections

Can't you have data bigger than 256 bytes if you edit the linker script to create some sections that are bigger? You might need
some pragma statements to allocate your data into a specific
memory location.

I think the compiler can generate code to address larger sections of data, it is just that it needs to know that the data structure does this, so it can do the right sort of addressing.

It seems to me that the linker script sets the sections to be 256 bytes since that will work for most people and it produces the quickest code since the data offsets fit into the instructions without the need to manipulate extra registers.
  #7   Spotlight this post!  
Unread 13-03-2006, 19:26
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Please help: Memory allocation problem dealing with sections

Good point about the linker script. You can change one of the DATABANK statements to make a larger section. For example, change:

DATABANK NAME=gpr9 START=0x900 END=0x9FF

to:

DATABANK NAME=gpr9 START=0x900 END=0AFF

Then delete the gpr10 DATABANK line. This would give you a 512 byte block for your data. It's not as efficient to use, but it should work (I just wrote a test program and it ran fine). You may have to do a "build all", but the compiler was smart enough in my simple test case to find the correct memory bank without it.

Mike
  #8   Spotlight this post!  
Unread 13-03-2006, 22:24
RbtGal1351's Avatar
RbtGal1351 RbtGal1351 is offline
~La Reina de los Robots~
AKA: Stephanie
FRC #1351 (TKO)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 166
RbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to behold
Send a message via AIM to RbtGal1351 Send a message via MSN to RbtGal1351
Re: Please help: Memory allocation problem dealing with sections

Oh my gosh, thank you so much Matt Krass, devicenull, Mike Bortfeldt, and ericand!!
It works now; I've changed the array to a rom const.


Questions, though... (I want to know what this does more specifically, seeing as it is now an integral part of the software.)

1) What is the memory usage limit on each file or variable in rom?

2) According to Microchip's data sheet , there are three types of memory:
• Program Memory
• Data RAM
• Data EEPROM
Which does the "rom const" access? EEPROM?

3) Is there more info about the "rom const" somewhere that I should know about? I can't find it in Microchip's data sheet or anywhere on IFI Robotics.

Thanks so much!!
~Stephanie
__________________
2004 Founding member and Arm leader, 2005 Lead programmer, 2006 Controls leader, 2007 Project Manager/President
Thanks for making FIRST such a great experience for me. I'm no longer on 1351, and I'm not currently planning to mentor team 97, but FIRST has meant so much in getting me to where I am now, in life and at MIT, class of 2011.
I met Billfred! He recognized me!
SVR 04: 11th seed - Highest Rookie Seed - Semifinalists w/ 1120 and 568 - GM Industrial Design Award
SVR 05: Semifinalists w/ 8 and 766
SVR 06: 6th seed - Quarterfinalists w/ 368 and 1072
Davis 06: 1st seed - Quarterfinalists w/ 649 and 100 - KPCB Entrepreneurship Award
SVR 07: 36th seed
David 07: 4th seed - Semifinalists w/ 1280 and 692 - Johnson and Johnson Sportsmanship Award
  #9   Spotlight this post!  
Unread 14-03-2006, 10:57
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: Please help: Memory allocation problem dealing with sections

Stephanie,

More information on the "rom" qualifier can be found in the MPLAB C18 C Compiler User's Guide. (In the older version of this document it was in section 2.4.3, but that might have changed in version 3.0 that is available on Microchip's website.) In short, "rom" indicates program memory and as for a size limitation, I would guess it would either be limited to the size of either a signed or an unsigned short (32k or 64k), although I don't have any specific information to back that up.

Mike
  #10   Spotlight this post!  
Unread 14-03-2006, 11:02
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Please help: Memory allocation problem dealing with sections

The "rom const" directive is in the C18 manual. What it says is that the data that it refers to, (whatever its type - char, int, struct, array...) is not going to change (the const part). Further it says that you want this data to be stored in the program memory (the rom part).

The compiler will look at the directive and allocate the space for the data along with the program in the program memory which is much much bigger than the RAM. The compiler will make sure that the addressing modes in the generated machine code for accessing that data are appropriate for pulling data out of the program space.

Take a look at the .map file with the data declared as "rom const" and again with
the data declared without the "rom const" and see what section and what address the data is being stored at. I think that will help you understand what is going on.
  #11   Spotlight this post!  
Unread 14-03-2006, 14:58
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Please help: Memory allocation problem dealing with sections

That problem went away when we used the latest IFILoader program....also
check here http://www.ifirobotics.com/docs/memory_problem_8722.pdf

Jon Mittelman
Team 236
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi