Use malloc in CodeWarrior for HC08 : "out of allocation space in segment.."

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use malloc in CodeWarrior for HC08 : "out of allocation space in segment.."

Jump to solution
5,957 Views
ppoi
Contributor I
I followed the instruction of the FAQ-27441 "Can I use malloc in CodeWarrior for HC(S)08?".
However I have an error of link "out of allocation space in segment HEAP_SEGMENT at adress 341".
Could you provide me a simple project without error. I need really to dynamically allocate memory in my project...


here the modifications brings to the project,

//----------------------------------------------------------------------
Modification of the file "libdefs.h"

#define LIBDEF_HEAPSIZE 20 // by default 2000

//----------------------------------------------------------------------

Here my file ".prm" :

SECTIONS
    ...
    RAM1 = READ_WRITE       0x0050 TO 0x0340;
    DG_HEAP  = READ_WRITE   0x0341 TO 0x044F;
       RAM2 = READ_WRITE       0x0A00 TO 0x0BFF;

PLACEMENT
    ...
    HEAP_SEGMENT                  INTO  DG_HEAP;
    SSTACK                        INTO  STK_AREA;

END

//----------------------------------------------------------------------

Development tool:

Version of CodeWarrior IDE 4.1 "Build 0669"
µc MC68HC908AZ60A
Labels (1)
Tags (1)
0 Kudos
1 Solution
1,501 Views
BlackNight
NXP Employee
NXP Employee

Hello,
ok, it is always better to do it with an example than just suggesting things out of my mind :smileyhappy:.
As I'm having a newer CodeWarrior (and the project got converted), I just have made some screen-shots so you can do the modifications on your end. Please see attached document.
In essence: you need to add as well the heap.c locally to your project (sorry, I have missed that heap_ is defined in there).
See as well the instructions and hints in the document (which hopefully will work for you too, it did for me).

Regards,
BK

 

instructions.doc

Message Edited by t.dowe on 2009-09-03 05:56 PM

View solution in original post

0 Kudos
10 Replies
1,501 Views
ppoi
Contributor I
It's good, everything works well

thank you very much BlackNight

:smileyhappy:


0 Kudos
1,501 Views
ppoi
Contributor I
My CodeWarrior is too old for the utilization of 'Pack&Go'

My project,

TestHeap.zip
Message Edited by t.dowe on 2009-09-03 05:57 PM
0 Kudos
1,502 Views
BlackNight
NXP Employee
NXP Employee

Hello,
ok, it is always better to do it with an example than just suggesting things out of my mind :smileyhappy:.
As I'm having a newer CodeWarrior (and the project got converted), I just have made some screen-shots so you can do the modifications on your end. Please see attached document.
In essence: you need to add as well the heap.c locally to your project (sorry, I have missed that heap_ is defined in there).
See as well the instructions and hints in the document (which hopefully will work for you too, it did for me).

Regards,
BK

 

instructions.doc

Message Edited by t.dowe on 2009-09-03 05:56 PM
0 Kudos
1,501 Views
ppoi
Contributor I
hello,

I carried out handling of BlackNight
I you joint of the images of my project (see .zip)
Can you look at the project ?
thank you to tell me my errors

I desperate because I followed the instructions...

MyProject.zip
Message Edited by t.dowe on 2009-09-03 05:57 PM
0 Kudos
1,501 Views
BlackNight
NXP Employee
NXP Employee
Hello,
from the picture you have attached it looks like you have a LIBDEF_HEAPSIZE defined to 20?
I guess this is your problem?

Otherwise can you zip your project (you can use the 'Pack&Go' wizard in the CW Help menu for this.

BK
0 Kudos
1,500 Views
ppoi
Contributor I
Hi,

In the project “hc08_lib.mcp”,
1) I have modify only the file “libdefs.h”
2) The configuration of the project is as follows,
   Target setting -> Target Name : all Libraries
   Linker : None
   Pre-Linker : None
   Post-Linker : None
3) Make (F7) -> It's ok
4) From {Install}\lib\HC08c\hc08_lib_Data -> new files ".o"

In my project,
1) The libs is “ansi.lib” (only)
2) I see from {Install}\lib\HC08c\lib
   There are the files "ansi.lib", "ansi.lst", "ansif.lib"...
   the dates of the files are 2000
3) The configuration of the project is as follows,
   Target setting -> Target Name : LAUTERBACH
   Linker : Linker for HC08
   Pre-Linker : None
   Post-Linker : None
4) Target -> Access Path : "{compiler}\lib\HC08c\lib"

I think that I must generate the new file “ansi.lib”.     
I don't know the procedure...

There is also in the repertory "{Install}\lib\HC08c\lib.e20" the file “ansi.lib” ?


thank you for the assistance

0 Kudos
1,500 Views
BlackNight
NXP Employee
NXP Employee
Hello,
instead of compiling the whole ansi library, you could simply add malloc.c and libdefs.h (modified) into your project. Make sure that it compiles the malloc.h with the right libdefs (increased heap size).
If malloc.o is linked (first) in your link order, you should get what you want.

BK
0 Kudos
1,501 Views
ppoi
Contributor I
Version of “codewarrior” : 1993-2000, yes it is really old...

I followed the procedure of the FAQ-27441,

1) Open project hc08_lib.mcp from {Install}\lib\hc08c directory.
2) Edit file libdefs.h (from {Install}lib\hc08c\include directory.
3) Change the LIBDEF_HEAPSIZE to something smaller.
4) Save the changes.
5) Rebuild the libraries (or at least the one you need). => Push F7, I see the new files "ObjetCode" in the repertory "hc08_lib_Data"

How to generate the file “ansi.lib”? it is my error, I think


0 Kudos
1,501 Views
CrasyCat
Specialist III
Hello
 
What is the current build target name displayed in the .mcp window combo box?
If you open the Target setting dialog for the ANSI library project and look at eh librarian for HC08 panel, what is the name of the .lib file there?
Which library file are you linking to your application?
 
When you pressed F7, did something happen in CodeWarrior?
 
The procedure described in the FAQ has been validated with CW for HC08 V3.1 and later.
 
CrasyCat
0 Kudos
1,501 Views
CrasyCat
Specialist III
Hello
 
The version number you are providing does not help a lot. Anyway, from the IDE version number it looks like you are using a VERY OLD version of CodeWarrior.
 
It might be a good idea to upgrade to something more recent.
 
Then after you have changed the LIBDEF_HEAPSIZE, did you rebuild  the ANSI libraries?
All of them? Only one? Did you rebuild the one that is linked to your project?
 
CrasyCat
0 Kudos