Is it possible to change a CW6.3 project from minimal C startup to ANSI C startup?

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

Is it possible to change a CW6.3 project from minimal C startup to ANSI C startup?

Jump to solution
2,447 Views
tminnich
Contributor I

Is it possible to change a CW6.3 project from minimal startup to ANSI startup? I have been looking for ways to change options to change a project from minimal C startup code to ANSI C startup code, without any luck thus far. What is the best way to change  a  project from a minimal C startup to an ANSI C startup?

 

 

Regards Tom M.

Labels (1)
0 Kudos
1 Solution
1,429 Views
CompilerGuru
NXP Employee
NXP Employee

Init is just not written for the copy down information to be banked.

 

Out of the prm file:

 

 

/*  ROM                      =  READ_ONLY    0x3000 TO 0x7FFF;    */
    ROM                      =  READ_ONLY    0x3000 TO 0xFFAD;    
/*    ROM1                     =  READ_ONLY    0xC000 TO 0xFFAD;  */

 

 

/*  ROM                      =  READ_ONLY    0x3000 TO 0x7FFF;    */    ROM                      =  READ_ONLY    0x3000 TO 0xFFAD;/*    ROM1                     =  READ_ONLY    0xC000 TO 0xFFAD;  */...    NON_BANKED,                         /* runtime routines which must not be banked */    DEFAULT_ROM,    COPY                                /* copy down information: how to initialize variables */                                        INTO  ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */

 

The problem is that code/constants (including copy down) is placed at the page window from 0x8000..0xBFFF.

It appears that the ROM/ROM1 area have been defined properly once but this has been changed to a single ROM block, keeping the old setup in comments. Well this only works if PPAGE is never ever touched and set to 0 at startup, I so I'm tempted to say that this does not work....

In the small and tiny memory models, the code (and constants) must be allocated non banked, and non banked excludes the 0x8000..0xBFFF area as well. Basically the 0x8000..0xBFFF area is banked with PPAGE == 0, it must not be used for non banked code (or constants).

I would recommend to restore the old setup (maybe to add -OnB=b as suggested by the comment and then to list both ROM and ROM1).

 

Daniel

 

 

View solution in original post

0 Kudos
18 Replies
1,429 Views
CompilerGuru
NXP Employee
NXP Employee

I thought the only difference in the generated project is that for minimal startup code, the wizard adds -D__ONLY_INIT_SP to the compiler command line.

 

Therefore removing this option should be all you need.

Note that the project internally still knows that it was created as minimal startup code project, especially when switching from one derivative to another the change wizard might (did not test it) readd the option. There is no UI to change the internal setting for this.

 

Daniel

0 Kudos
1,429 Views
tminnich
Contributor I

I tried removing the -D for the SP only initialization, but in the debugger the result is not a good one. I suspect the Linker is not creating the copydown information for the startup segment. I always try to do my homework before bugging people on the forum. :smileyhappy: Out of curiosity I will try retargeting away from the MCU and back again to see if I am offered the startup simple or ANSI choice again.

 

Thanks Tom M.

0 Kudos
1,429 Views
J2MEJediMaster
Specialist I

Easiest route might be:

 

1) In CodeWarrior, use the New Project wizard to make a project that uses the ANSI C startup option.

2) Drag your source files into the new project's folder, and then add them to the project

3) Check and modify the build settings in the new project so that they match those of the old project

 

This assumes that what you're really trying to accomplish is to carry over the source files that you made, and are not relying on any modifications you made to the startup file.

 

---Tom

0 Kudos
1,429 Views
tminnich
Contributor I

I suspect that copying the sources over to a new empty project (with an ANSI startup) will be the way to get this done. I will try the retargeting approach first and report back.

 

Regards Tom M.

0 Kudos
1,429 Views
tminnich
Contributor I

Retargeting from one MCU type to another and then targeting back to the original MCU type will not get to an ANSI C startup, This is with the define for SP only initialization removed. The expected data is not in the startup segment , I checked with the debugger. So it looks like copying the files to a new empty project (with an ANSI C startup) is the only choice.

 

Regards Tom M.

0 Kudos
1,429 Views
CompilerGuru
NXP Employee
NXP Employee

Did "copying the files to a new empty project" work?

I would suggest to diff the new files from the wizard with the old files, I really think that the added -D option is the only

difference of a stock wizard generated project, therefore if the copying works I would guess something else was changes in the original configuration, maybe with the disabled copy down in mind.

BTW I assume this is for a S08/RS08/HC08. If this thread is for a CF, then the generated project may be different, not sure.

 

0 Kudos
1,429 Views
tminnich
Contributor I

The project is a 9S08QE128 project. Copying to a new project did not work. Starting the debugger the startup code runs immediately but does no stop at the jump to main (as I have been used to) . Halting shows that we are still in the copydown process although the code has been running 10 seconds or longer. This was the same experience as removing the -D for SP only initialization.  I am sure this will begin to start making sense, hopefully soon.:smileyindifferent:

 

regards Tom M.

 

an excerpt from the map file

 

*********************************************************************************************
STARTUP SECTION
---------------------------------------------------------------------------------------------
Entry point: 0x3094 (_Startup)
_startupData is allocated at 0x309F and uses 6 Bytes
extern struct _tagStartup {
  unsigned nofZeroOut     2
  _Range   pZeroOut       0x80     128
                          0x100     476
  _Copy    *toCopyDownBeg 0xA207
} _startupData;

 

 these are some of the records having to do with a hoped for initialization

of a const byte * array;

 

 

STRING.S1232080AC0028A39D9D.2 3171 4B 75 1 .rodata1

STRING.S12320A01B088D1A088D.3 31BC 4B 75 1 .rodata1

STRING.S12320C0E603E7026F03.4 3207 4B 75 1 .rodata1

STRING.S12320E018254D2AFAC6.5 3252 4B 75 1 .rodata1

STRING.S12321000B878A887E7D.6 329D 4B 75 1 .rodata1

STRING.S1232120F301230520B9.7 32E8 4B 75 1 .rodata1

STRING.S12321408DA7FA4520A9.8 3333 4B 75 1 .rodata1

STRING.S123216004878A88FE9F.9 337E 4B 75 1 .rodata1

STRING.S12321808BA7FB450448.10 33C9 4B 75 1 .rodata1

STRING.S12321A010898B9EFE0D.11 3414 4B 75 1 .rodata1

STRING.S12321C08B9EFE0A898B.12 345F 4B 75 1 .rodata1

STRING.S12321E00195AF009EFE.13 34AA 4B 75 1 .rodata1

STRING.S1232200018D878C9765.14 34F5 4B 75 1 .rodata1

STRING.S1232220A0419EE701AB.15 3540 4B 75 1 .rodata1

STRING.S12322400A95AF079EFF.16 358B 4B 75 1 .rodata1

STRING.S1232260B77B869E6F02.17 35D6 4B 75 1 .rodata1

STRING.S12322800025E8A7048D.18 3621 4B 75 1 .rodata1

STRING.S12322A061A825EC4F9E.19 366C 4B 75 1 .rodata1

STRING.S12322C021419EFE0989.20 36B7 4B 75 1 .rodata1

STRING.S12322E00A8745022089.21 3702 4B 75 1 .rodata1

STRING.S123230001092074C718.22 374D 4B 75 1 .rodata1

STRING.S12323204D237A239423.23 3798 4B 75 1 .rodata1

STRING.S12323400022029EE701.24 37E3 4B 75 1 .rodata1

STRING.S1232360D60121AC0022.25 382E 4B 75 1 .rodata1

STRING.S123238001068CD60121.26 3879 4B 75 1 .rodata1

STRING.S12323A0895CCF010688.27 38C4 4B 75 1 .rodata1

STRING.S12323C0019EEB029EE7.28 390F 4B 75 1 .rodata1

0 Kudos
1,429 Views
tminnich
Contributor I

Here is the PRM file if that could have any influence on the problem.

0 Kudos
1,429 Views
tminnich
Contributor I

For some reason  _startupData.toCopyDownBeg:toCopyDownBegOffs points to the end of the everything in rom and not valid startup data.

 

Regards Tom M

0 Kudos
1,429 Views
tminnich
Contributor I

The linear address register LAP is equal to 0 and the startup section is in the banked range!!

 

The bank is pointing at the wrong area!

 

That probably means it is sufficient to use -D__ONLY_INT_SP for the compiler option

 

and that copying files into the blank project (with ANSI C startup selected is unnecessary.

 

Regards Tom M.

0 Kudos
1,429 Views
tminnich
Contributor I

FALSE alarm PPAGE = 2 , I am not sure what the problem is.

 

:smileysad:

 

Tom M.

0 Kudos
1,429 Views
tminnich
Contributor I

The copydown is not finishing,  when I halt with the BDM, flash locations are shown as all FFs. Next week's project is to make the call to  Init() after a SP initialize only startup has completed. (Comment Init() out in startup and run it after the debugger completes an empty startup). Then I can use the debugger to find out what is going on.

 

Regards Tom M.

0 Kudos
1,429 Views
J2MEJediMaster
Specialist I

Time to try a different tack: You say the copydown operation is taking a long time. Is the watchdog timer disabled during the copydown process?

 

---Tom

0 Kudos
1,429 Views
tminnich
Contributor I

The watchdog is enabled, but the _DO_FEED_COP_ #define is set in the compiler settings.

 

Regards Tom M.

0 Kudos
1,429 Views
tminnich
Contributor I

I am verifying the following theory:

  Init() did not work because PPAGE was set to 2 when it really should be zero. (because we are in banked mode). I discovered this with the BDM, the copydown data is at 0A223'P. That is to say the copydown is in the zero page!  When the MCU resets it puts PPAGE at 2, the tools  did not put PPAGE to zero before executing Init(), and then when init looks for copydown in the wrong place things go downhill fast.

 

Regards Tom M.

0 Kudos
1,430 Views
CompilerGuru
NXP Employee
NXP Employee

Init is just not written for the copy down information to be banked.

 

Out of the prm file:

 

 

/*  ROM                      =  READ_ONLY    0x3000 TO 0x7FFF;    */
    ROM                      =  READ_ONLY    0x3000 TO 0xFFAD;    
/*    ROM1                     =  READ_ONLY    0xC000 TO 0xFFAD;  */

 

 

/*  ROM                      =  READ_ONLY    0x3000 TO 0x7FFF;    */    ROM                      =  READ_ONLY    0x3000 TO 0xFFAD;/*    ROM1                     =  READ_ONLY    0xC000 TO 0xFFAD;  */...    NON_BANKED,                         /* runtime routines which must not be banked */    DEFAULT_ROM,    COPY                                /* copy down information: how to initialize variables */                                        INTO  ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */

 

The problem is that code/constants (including copy down) is placed at the page window from 0x8000..0xBFFF.

It appears that the ROM/ROM1 area have been defined properly once but this has been changed to a single ROM block, keeping the old setup in comments. Well this only works if PPAGE is never ever touched and set to 0 at startup, I so I'm tempted to say that this does not work....

In the small and tiny memory models, the code (and constants) must be allocated non banked, and non banked excludes the 0x8000..0xBFFF area as well. Basically the 0x8000..0xBFFF area is banked with PPAGE == 0, it must not be used for non banked code (or constants).

I would recommend to restore the old setup (maybe to add -OnB=b as suggested by the comment and then to list both ROM and ROM1).

 

Daniel

 

 

0 Kudos
1,429 Views
tminnich
Contributor I

Daniel:

 Setting PPAGE to zero at the beginning of Init() works in the current revisions of my code. I view setting PPAGE to zero as a hack and not a "best practices" fix. What I would really like to do is fix my .prm file ( or do whatever else in needed ) to make sure that C startup code always works regardless of the code size of my banked memory mode application. I will be going over your reply in detail to see if you have given me that fix. Is it possible to redo Init() so that it is aware of the Banked mode memory model in subsequent releases of CW. (maybe it is fixed in the new Eclipse based beta?)

 

Thanks Tom M.

0 Kudos
1,429 Views
tminnich
Contributor I

 What does -OnB=b do?

 

Regards Tom M.

0 Kudos