How can i use ROM Library ?

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

How can i use ROM Library ?

728 Views
pamis
Contributor II

Hi,

   I am cutting our software project in two small projects.  One is Application project,the other is Bootloader. So I decided to use ROM libraries as this technic allowed me to include bootloader within my application without paying attention to bootloader. But always failed, can't even create a simple ROM libraries example. Who can provide examples for using ROM Library, or find our mistake ? 

   Hi, Erich Styger‌! I know you are professional, so specially mention you.

Detailed description is s follows:

IDE: CodeWarrior IDE version 5.9.0

Chip: MC9S12VR48

ROM Library project:

#include "rl.h"
#include <startup.h>

struct _tagStartup _startupData;
static char RL_counter;

char Add(char a) {
RL_counter += a;
   return RL_counter;
}

char RL_Count(void) {
   return Add(5);
}

   

// Turn on "Link as ROM library" in SmartLinker Option Settings

NAMES END

SEGMENTS
MY_RAM = READ_WRITE 0x3800 TO 0x38FF;
MY_ROM = READ_ONLY 0xE000 TO 0xEFFF;
END
PLACEMENT
DEFAULT_ROM, ROM_VAR, STRINGS INTO MY_ROM;
DEFAULT_RAM INTO MY_RAM;
END

      

Applicaiton project:  

#include "rl.h"

static unsigned char b;

void main(void) {
   b = RL_Count();
}

NAMES END

SEGMENTS
RAM = READ_WRITE 0x3900 TO 0x3FFF;
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF;
END

PLACEMENT
_PRESTART,STARTUP,ROM_VAR,STRINGS,VIRTUAL_TABLE_SEGMENT,DEFAULT_ROM, NON_BANKED,COPY
INTO ROM_4000;
SSTACK,DEFAULT_RAM
INTO RAM;
END

ENTRIES
RL_Count
END

STACKSIZE 0x100

VECTOR 0 _Startup

*********************************************************************************************
OBJECT-ALLOCATION SECTION
Name Module Addr hSize dSize Ref Section RLIB
---------------------------------------------------------------------------------------------
MODULE: -- romlib.lib --
- PROCEDURES:
RL_Count E028 5 5 1 @
- VARIABLES:

*********************************************************************************************
OBJECT LIST SORTED BY ADDRESS
Name Addr hSize dSize Ref Section RLIB
---------------------------------------------------------------------------------------------

None RL_Count description

*********************************************************************************************
DEPENDENCY TREE
*********************************************************************************************
main and _Startup Group
|
+- main
| |
| +- RL_Count
|
+- _Startup
|
+- Init
|
+- main (see above)

Question:

1. In the map file, Only “OBJECT-ALLOCATION SECTION” mention RL_Count, but “OBJECT LIST SORTED BY ADDRESS” does not. There is no corresponding information in the S-record file. So how can i download application and bootloader to debug ?

2. DEPENDENCY TREE does not include Add, Do all the functions need to be in “ENTRIES END” ?

3. How to make Bootloader and Application variables use common RAM segment but not conflict ?

Thanks all.

BlackNight

0 Kudos
1 Reply

543 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

ROM library is rarely used by users in recent years.I checked there is no demo code on this related, But I found an old technical note about Using ROM Libraries in my storage. see attached.
why do you use ROM library?if you want to use it to implement bootloader+app, using HEXFILE command is easier.
In 8/16bit Codewarrior Linker Parameter file, you can add an "HEXFILE" command. This allows you to link, together with the code of the current application, with an external s-record. Both the s-record from your project and the s-record linked with the HEXFILE command will be downloaded into your target!  
 
This is useful if you wish to program your device with two applications in one single programming time. This becomes very handy for example when you want to include in your device memory, a bootloader to be used in the future. One single programming effort will burn two s-records.
 
HEXFILE usage can be found on the Build_Tools_Utilities manual, search the document with keyword “HEXFILE”, you
can see a section detail this issue.
 
 
For example in application prm file, add below. The boot code will be inserted to
application s19 file
HEXFILE    boot.s19
 
(boot.s19 is located in the current project folder root path)


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos