Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is written into FLASH really when using MCS file?

Status
Not open for further replies.

naught

Member level 3
Joined
Aug 25, 2012
Messages
59
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Location
chengdu
Activity points
1,739
I'm doing a project of remote programming the FPGA, basically I have to write MCS file into flash without using JTAG.

Now I've known that MCS file has its own structure, like head, address, type, checksum, and also contains a ASCII representation of the original bitstream contents(two ASCII characters in MCS file to represent one byte in bitstream rawdata)

I have 2 questions.
1. Do I strip away all these head, address, type , length and checksum information, and ONLY transferring the raw data into FLASH? or Do I have to transfer MCS as a whole without any modification?

2. If I only transfer the raw data, do I have to convert them back into hex form, like taking two ASCII characters as one hex byte, before writing the flash?


I'm not sure whether the following is right or not.
微信图片_20180514223528.jpg
 

The entire statement:
Only the bold text is actual data that will go into the PROM or flash. Also note that each character takes 9-bits in the file, but only represents 4-bits of data. That explains why the file is so much larger.
says it all.

The file is in ASCII, i.e. 8-bit characters representing the hex values 0-F (the 4-bits).

The first 32-bits after the :, i.e. the 8 characters are the address location of the first byte of data. The last two characters is the checksum (which you should compute to verify the data you are planning to write is correct).
 
  • Like
Reactions: naught

    naught

    Points: 2
    Helpful Answer Positive Rating
thanks for the comfirmation.
Now I'm combining every 2 ascii characters in the raw data section into one hex byte, then write it to FLASH.
 

Now I'm combining every 2 ascii characters in the raw data section into one hex byte, then write it to FLASH.

That's correct for the example Intel hex file which contains continuous data starting at address 0. But Intel hex data isn't necessarily continuous and can have embedded sector address records like the first line and also varying start addresses for each line. In generally, it has to be decoded with a hex2bin converter, filling the unused bytes e.g. with 0xff.
 

basically I'm getting rid of the start colon mark, address, length infomation, type, and check sum in each line of the MCS file.

TIM截图20180521221102.png
Take the format above for example,
even though there're data in the first line...I don't write any of it into Flash, because its "type" is not data.
Neither do I write anything of the last line(which is not shown in the picture) of the MCS file into Flash, because its "type" is END.

Except those two lines, all other lines consists of the colon mark, address, length information, type, DATA, and check sum. All of these DATA must be written into Flash.
 

As said, it may be O.K. in this case. You should check if the hex file is using continuous addresses up to the end (the 0000, 0010, 0020 field). If it's more than 64k data, there must be another sector address record. You can make things easier if you learn how to decode Intel hex.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top