+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Member level 3
    Points: 1,330, Level: 8

    Join Date
    Aug 2012
    Location
    chengdu
    Posts
    59
    Helped
    4 / 4
    Points
    1,330
    Level
    8

    What is written into FLASH really when using MCS file?

    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.
    Click image for larger version. 

Name:	微信图片_20180514223528.jpg 
Views:	13 
Size:	82.3 KB 
ID:	146637

    •   AltAdvertisment

        
       

  2. #2
    Super Moderator
    Points: 29,367, Level: 41
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    6,783
    Helped
    1612 / 1612
    Points
    29,367
    Level
    41

    Re: What is written into FLASH really when using MCS file?

    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).


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  3. #3
    Member level 3
    Points: 1,330, Level: 8

    Join Date
    Aug 2012
    Location
    chengdu
    Posts
    59
    Helped
    4 / 4
    Points
    1,330
    Level
    8

    Re: What is written into FLASH really when using MCS file?

    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.



    •   AltAdvertisment

        
       

  4. #4
    Super Moderator
    Points: 247,995, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    43,137
    Helped
    13124 / 13124
    Points
    247,995
    Level
    100

    Re: What is written into FLASH really when using MCS file?

    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.



  5. #5
    Member level 3
    Points: 1,330, Level: 8

    Join Date
    Aug 2012
    Location
    chengdu
    Posts
    59
    Helped
    4 / 4
    Points
    1,330
    Level
    8

    Re: What is written into FLASH really when using MCS file?

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

    Click image for larger version. 

Name:	TIM截图20180521221102.png 
Views:	0 
Size:	104.9 KB 
ID:	146780
    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.



    •   AltAdvertisment

        
       

  6. #6
    Super Moderator
    Points: 247,995, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    43,137
    Helped
    13124 / 13124
    Points
    247,995
    Level
    100

    Re: What is written into FLASH really when using MCS file?

    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.



--[[ ]]--