CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

#org and getenv("program_memory")

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

#org and getenv("program_memory")
PostPosted: Mon Jul 06, 2009 5:53 pm     Reply with quote

OK, so I have a bootloader that works great IF I manually assign the range for the Main.

like a lot of people here, I've used the CCS example (which I wish was a little better commented to explain all the #org statements to control the code placement... and WHY) with pretty good success.

I'm still stuck defining the range END with a hard number instead of using the GETENV("PROGRAM_MEMORY") command because it complains...

So to better understand (and yes, I RTFM'd), I thought I would ask the group here.

I'm currently using an 18F97J60. It has 0x1FFF8 of memory. (as reported by CCS) and MPLAB shows me a ROM window that does go from 0x00000 to 0x1FFF6.

So that makes sense. I'm not using ICD mode. So I should have ALL my memory. But it doesn't work.

Code:

--- Info 300 "bootloader.c" Line 40(1,2): More info:   Segment at 00000-000FE (0000 used)
--- Info 300 "bootloader.c" Line 40(1,2): More info:   Segment at 00100-00108 (0000 used)  Priv
--- Info 300 "bootloader.c" Line 40(1,2): More info:   Segment at 0010A-007FE (0000 used)  Priv
--- Info 300 "bootloader.c" Line 40(1,2): More info:   Segment at 00800-0FFFE (0000 used)
--- Info 300 "bootloader.c" Line 40(1,2): More info:   Segment at 10000-1FFF6 (0000 used)
--- Info 300 "bootloader.c" Line 40(1,2): More info:   Attempted to create: 00800-1FFF6  for #org
*** Error 126 "bootloader.c" Line 40(1,2): Invalid ORG range
      1 Errors,  0 Warnings.


If I put in an application end address of 0xFFFF, no problem (hard coded).
But if I used an end address of 0x10000, kablooey.

Now, the .H file for this device says 65535x16 (which would be 0xFFFF)... I don't think I'm supposed to divide by 2!

Is this a bug or am I doing something wrong?

Thanks!

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 06, 2009 7:07 pm     Reply with quote

See my post about 2/3 of the way down this thread, where I explain
how #org only works for a maximum of 64KB. If you want to #org a
larger range than that, then you need to use two #org statements:
http://www.ccsinfo.com/forum/viewtopic.php?t=31941
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Jul 06, 2009 7:43 pm     Reply with quote

Innnteressstttiiinnnggg...

Thanks.. Sorry for the Dup Post (sometimes search doesn't help - so I went with a subject line that hopefully rings up the next time someone searches)

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Jul 06, 2009 8:00 pm     Reply with quote

Ok, I tried that...

My dual #org is for app memory...

so I have:

Code:

// ==============================================================
// This places bogus application at 800
// that gets overwritten when the real application is loaded into memory.
//
// #org APP_ADDR,APP_END // 0x800 to end of memory
#org APP_ADDR, 0x0FFFF
#org 0x10000, ROMSIZE
void application(void) {
   fprintf(COMM, "No Application to Run\r\n");
}


and I get


Executing: "C:\Program files\Picc\CCSC.exe" +FH "bootloader.c" +DF +LY +T +A +M -Z +Y=9 +EA
*** Error 71 "bootloader.c" Line 109(1,2): Out of ROM, A segment or the program is too large @const554
Seg 0001E-000FE, 0032 left, need 003A
Seg 00100-00108, 000A left, need 003A
Seg 0010A-007FE, 06F6 left, need 003A
Seg 00800-0FFFE, F800 left, need 003A
Seg 10000-1FFF6, FFF8 left, need 003A
Seg 00000-00006, 0004 left, need 003A
Seg 00008-0001C, 0016 left, need 003A

1 Errors, 0 Warnings.


where just using #org APP_ADDR, APP_END worked just fine.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 07, 2009 12:54 am     Reply with quote

The example in the link is using #org to reserve a ROM address range
for the application program. That requires putting braces {} after
the #rom range values. You don't have that.
http://www.ccsinfo.com/forum/viewtopic.php?t=31941&start=5
The link is about the Codeloader bootloader. I don't know if this applies
to your bootloader. You need to decide if it does.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Jul 07, 2009 1:00 am     Reply with quote

all {} does is reserve the area with nothing. I shouldn't need to do that if I just want to write to that block area.

Although I did try it with and without the {}'s with similar (I think same) results.

I'll toast by brain on it some more tomorrow. yay.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group