Decoding the .map(Linker Address Map) , .abs(ABS file ) and S19 file

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

Decoding the .map(Linker Address Map) , .abs(ABS file ) and S19 file

6,195 Views
Nycil
Contributor I

Hello,

Requirement: CRC generation of the data written into the ROM.

                                   When I compile my source codes, an S19 file is generated along with a .map and .abs file. The S19 file contains S-records, each record having information of the length of the record, and address and the corresponding data in those addresses.The .map file contains information about the starting addresses of various segments such as .init,.bss etc and their respective terminating addresses. I have no clue what is contained in the .abs file. I had read that .abs is similar to an ELF file. I need to how I can decipher the informartion contained in the .abs file.

                                   In the Linker file , I have specifed address ranges for different sections  of the code to be placed. Some of these address ranges are visible in the S19 file while others are not. The reason I assume, would be because those addresses which are not visible are not being used.

                                   In a tool we developed, we parse through the entire s19 file, take the data and generate CRC for the whole data which is appended in the last but one S-record along with the CRC and address in the ROM to which the calculated CRC would be put.

                                   We then flash the code into the micrcontroller. From my application in the microcontroller, I need to access the addresses which have been specified in the s19file. How do I go about doing this? Is there any way I could know which all addresses are represented in the S19 file.

I kindly request your help.

Thanks in Advance

Labels (1)
0 Kudos
Reply
9 Replies

2,924 Views
Lundin
Senior Contributor IV

Assuming this is for a S12 MCU.

 

.abs is the debugger file for hiwave.exe, containing the program plus source code visualisation stuff. It isn't needed for production programming.

 

The answer to your question somewhat depends on which addressing formats you use. If your program is "banked" (ie using flash pages), some flash programmers require "absolute"/"physical"  addresses (CW names such srecord files .phy), while some accept the ppage syntax "ppaaaa" where pp is the page and a the address. You need to investiage which format the s19 is in. The MCU itself is likely going to use the latter format in your program.

 

Everything that is shown as "used" in the map file will end up in the s-record file. However, the s-record file generated by CW will use a fixed number of bytes per row. So your script in the PC and the one in the MCU has to be smart enough to work around this.

 

No matter the format, you will need to allocate a const memory variable in the flash, preferably as high up as possible, 16 or 32 bit large depending on checksum size. Set the variable to some rubbish value like 0xFFFF or 0xFFFFFFFF. Then enforce linking of that variable, you need to use it in your program or list it below ENTRIES in the CW .prm file. This variable should now pop up as a s-record row in your s19 file. Then you can alter that row with a script, before programming the chip.

0 Kudos
Reply

2,925 Views
Nycil
Contributor I

Thanks Lundin. I have made a junk variable and enforced its linking , so that it now appears on the S19 record. But it has a checksum associated with it and if i alter the data in the address using my tool   , shouldnt It reflect on the checksum that is comes to towards the end of the Srecord.

My main issue still remains unsolved, which is, how will I get to know the addresses , present in the S19 file. This is mandatory as my PC tool will be generating a CRC for all the data in the data field of the individual S records. I have to use these addresses in the my application where my CRC is generated.

Thanks in Advance.

 

0 Kudos
Reply

2,925 Views
kef
Specialist I

I'm not sure I understand your requirements. But it seems you are trying to replace contents of some variable in flash with some external PC tools. You can do it. Say you have 16bit variable my_crc allocated somewhere in flash. You open map file and look for OBJECT-ALLOCATION SECTION section or for OBJECT LIST SORTED BY ADDRESS section. And after it's found, look for first instance of my_crc. Item on column to the right is address of variable. You take this address, scan S records file for specified address, replace contents of my_crc in S record and update S record checksum.

The problem is how to decide is map file specifying paged address, nonpaged address or maybe global address. Global addresses are specified with 'G at the end. Nonpaged addresses are specified with up to 4 hex digits. Paged addresses - with no 'G after the number but with more than 4 hex digits.

 

It may be simplier to not allocate crc variable in the code and access it from the code using something like this

 

#define my_crc ( *(volatile short*)0xE000 ) // where 0xE000 is nonbanked address of crc constant in the flash

 

 {

   short crc = my_crc;

}

 

Then you would need to explude 0xE000-0xE001 from the memory segments in *.prm file. And just add crc to your S-records.

0 Kudos
Reply

2,925 Views
Nycil
Contributor I

Thanks Kef. 

I will reframe my requirements.

 

1. PC tool developed parses through the S19 File. The S19 file contains address and corresponding addresses.

Here is an Example for  the S19 file I have

 

S00600004844521B
/*Start of segment 1*/

S123728001876C852005C6127B1250EC851BF2010A0A3B188734198D35E68A874A491B0076
S10872A01B866C853D16    /*End of Segment 1*/

/*Start of segment 2*/

S123772003757B18150103757B1816010375AB0000030D100000FFFFFFE70000FFFFFFFFDF
S10B7740000000004316E52ED1   /*End of Segment 2*/

S208D08000AABBCCDD99 /*THE CRC RECORD*//* Address which is supposed to contain the CRC my PC tool generates*/

S9034000BC

 

In my linker file, I can specify the start address and the end address.

for eg :  Segment 1 belongs to the address range 7280 to 72FF

              Segment 2 belongs to the address range 7720 to 7260

The start address can be known to the application from the linker file as it specified by me, but the end address in the s19 file cannot be known to the application as it doesnot  correspond to the end address speciifed in the linker. The data doesnot  use up the whole range. 

 

My PC tool extracts the data from each data field of the indivitual S-Record and generates the CRC. This CRC is placed in the S19 file by editing the CRC record, shown above.

 

So my application needs to know the starting and end addresses of each segment.

I have tried and made it as lucid as possible.

Thanks in Advance.

 

Thanks you Kef and Lundin

 

 

0 Kudos
Reply

2,925 Views
kef
Specialist I

SECTION-ALLOCATION SECTION in the map file seems to contain what you are looking for. Each item with Type set to R (read only) represents the piece of code or const data in the flash. Starting and ending addresses are specified from and to.

 

It may be easier to checksum all the flash, assuming that all locations not used in S-records contain all ones (erased flash state).

0 Kudos
Reply

2,925 Views
Nycil
Contributor I

Very True Kef. But to parse the MAP , does it have a specific Format , through which I could parse the MAP file.? If So it would be easier to parse the file. Can u comment on it.

0 Kudos
Reply

2,925 Views
CrasyCat
Specialist III

Hello

 

The .map file is a text file, which is generated by the linker for information purpose.

Its format might change in a future release of the tool chain.

 

If you need to start from a standard file format I would recommend using information from the .abs Program Header Table or Section Header Table.

 

.abs file is a standard ELF binary file.

You should be able to find information on the file format on the web.

 

For example in section 4 in following document:  http://www.sco.com/developers/devspecs/gabi41.pdf

 

Crasycat

0 Kudos
Reply

2,925 Views
Nycil
Contributor I

I made a file parser for the .abs file. It shows its an ELF file with the magic numbers same as required. But when I am parsing the file according to the format that is available on the pdf which illustrates the format of the ELF. When I try to find the type of ELF file , it not among the kinds listed in pdf. The section headers are all worng. I am wondering even though the .abs file is an ELF file, does it follow the format as described in the pdf.

 

Thanks CrasyCat for your valuable info. 

Looking forward for an answer to the above query.

 

 

0 Kudos
Reply

2,925 Views
CompilerGuru
NXP Employee
NXP Employee

> When I try to find the type of ELF file , it not among the kinds listed in pdf. 

Can you be more specific?

Not sure what you refer to with "type". What value did you expect at which file offset, what did you see?

Maybe show a hex dump of the block.

 

Did you try out a stand elf reader? Linux, which is using ELF by default these days has multiple different ones (readelf, objdump, sure there are others).

The decoder.exe program in the CW installation can also be used to dump the internal file structure.

 

Daniel

 

PS: Note that the file is encoded in big endian, with a x86 processor you have to byte swap 16, 32 or 64 bit entities.

With the wrong endianess, the first 16 bytes look good as they are defined as byte array.

0 Kudos
Reply