This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28069: Copying .hex to the internal flash

Part Number: TMS320F28069
Other Parts Discussed in Thread: UNIFLASH

I'm looking at the .hex file and I'm trying to figure out what massaging I have to do to each line before copying it to internal flash. The code that I want to write into the internal flash was compiled to be loaded into FLASHB.

I see some pre-amble and the address at the beginning of each line. And it seems there is some CRC/Checksum. How do I strip it out and use the actual code to program into internal flash?

%4E6138003E0000873E873E873E873E873E873E873E873E873E873E873E873E873E003E0A3E143E
%4E6158003E00201E3E283E323E3C3E463E503E5A3E643E6E3E783E823E8C3E963EA03EAA3EB43E
%4E6288003E0040BE3EC83E913ED23EDC3EE63EF03EFA3E043E0E3E183E223E2C3E363E403E4A3E
%4E6348003E0060543E5E3E683E723E7C3E863E903E9A3EA43EAE3EB83E913E913E913EC23ECC3E
%4E60F8003E0080D63EE03E913EEA3EF43E913E913EFE3E083E123E1C3E123E303E3A3E913E913E
%4E6038003E00A0443E4E3E583E623E6C3E763E913E913E803E8A3E913E913E913E913E913E913E
%4E64C8003E00C0943E9E3EA83EB23EBC3EC63E913E913E913E913ED03EDA3EE43EEE3EF83E023E
%4E6F18003E00E00C3E163E203E2A3E343E3E3E483E523E5C3E913E913E913E913E913E663E703E
%4E6998003E010046525F4F4B0046525F4E4F545F5245414459000046525F4E4F5F46494C450000
%4E6A18003E012046525F4E4F5F50415448000046525F494E56414C49445F4E414D450046525F49
%4E6808003E01404E56414C49445F4452495645000046525F44454E4945440046525F4558495354
%4E6728003E0160000046525F52575F4552524F520046525F57524954455F50524F544543544544
%4E69D8003E0180000046525F4E4F545F454E41424C4544000046525F4E4F5F46494C4553595354
%4E6998003E01A0454D000046525F494E56414C49445F4F424A4543540046525F4D4B46535F4142
%4E6618003E01C04F5254454400554E4B4E4F574E204552524F5220434F44450000303132333435
%4E6698003E01E03637383961626364656600002E2E2F75617274737464696F2E63000008200800
%4E68B8003E02000D0A000020004552524F5200463EA03E0000163E00006F3E8B3EEF3EFF3E263E
%4E6248003E0220973ED13E4A3E0000008F46F3D426000000220000001446415400464154333200
%4E6A88003E02402E2E2F7573622E630000FFFF00000000473E0800F33E7F3E0000523E4A3EDA3E
%4E60F8003E80000444422500044342431F80038406024142420E18010342004001A4C441A60903
%4E67C8003E802042004201A4C40742420EEB3EC68206064644420A1F80BF040D1F8004094401A6
%4E69E8003E8040F402A6F6018606044242440F1F80BF04151F8004111F80BF040CC401A6F40BA6

  • Parag,

    Easy method:-
    If you have the COFF file instead of hex file. You can use On-chip flash programming tool in CCS to program flash and down the flash contents.

    Alternative method1:-
    Use Uniflash to program the hex file and download the contents of flash.

    Alternative method2:-
    Write a script to strip address / data / CRC contents. More difficult method.

    Regards,
    Manoj
  • Thanks for the suggestion Manoj. 

    1) Can I use the COFF file and use the flash_write functionality to write the code from within a secondary bootloader?

    2) Uniflash will not work since I need this to work from an embedded routine. I have to be able to program the internal flash using the bootloader functionality

    3) Can you provide the pseudo-code to do exactly that? I want to be able to strip the address, data and CRC and write directly to internal flash. Do I skip addresses? or is the data written sequentially?

  • Parag,

    Use the below procedure to get HEX data from the COFF file:-

    a) Program flash with the COFF using on-chip flash programmer
    b) Download the flash contents in .dat format using Memory Browser -> Save Memory -> Provide start address, 16 bit hex format, length of data

    1) No, flash_write function expects the hex code in an array. You can't use COFF file when you use flash_write function

    2) I suggested the uniflash to just get the hex file. Once you have the hex file, you need to load the hex file contents in a RAM array and then use that to program flash using flash_write API function.

    3) No, I don't have a ready made script that I can share. Frankly, I wouldnt write this script as I can easily hex contents using the method I described above.

    Regards,
    Manoj
  • So to clarify: I can take the hex and copy it to an internal RAM buffer and copy it AS IS to the internal flash and it will work.
    I will try and then mark this as resolved.
  • Is this resolved?
  • Sorry to keep this going, but this is still not resolved.

    I took the hex file AS IS, and converted it to an unsigned char array. I added that array to my secondary bootloader and attempted to run the Flash_Program() and Flash_Verify() routines to take the code from the RAM and copy it to internal flash. 

    Both the APIs return success, however, resetting the processor does not yield the expected results. The .hex image that I am copying is simply a blink routine to toggle a few LEDs on the development board. When I load the hex from CCS (I guess it's not hex, but I'm essentially debugging the image to the processor), I can see the expected behavior.

    The Flash_Verify returns success.

    My confusion lies in that I did NOTHING to the hex. I took the output and added ',' and 0x to make each element an unsigned char.  Manoj stated that I have to do nothing to prepare the array. Has anyone got this to work without stripping the delimiter, the number of bytes in each hex row, the start address of the data, and then the data CRC?

    Why am I struggling with this?

  • Also, accessing the memory directly doesn't show any copied data (all 0xFFFF). Is that expected? I'm assuming that it is expected otherwise there would be no need for a specific Flash_Verify() routine.
  • Parag,

    Is there any reason why you don't want use my suggestion mentioned on Mon, Jul 9 2018 5:55 PM?

    Regards,
    Manoj
  • Manoh, I tried your suggestion; taking the hex file output as is, and programming using Flash_Program(). I didn't work. Is my hex output correctly? Do I have to tweak some hex output setting? Is it a intel hex record, because the hex output I'm getting is quite different from typical Intel hex.

  • Parag,

    When you dump the content of flash memory say sector H. It would look as shown below (this is the hex file I'm talking about)...

    Once you have this file, you can load his file in RAM buffer in two different ways..

    1) Change the start address 0x3D8000 to RAM buffer address and load the .dat file into RAM buffer using CCS memory load option

    2) Assign the hex code to memory section ,save that file as .asm file, include that .asm file into your project and assign that section to RAM buffer in the linker command file (.cmd)

    .global _HEXDATA

       .sect   "hexdata"

    __HEXDATA
        .word 0x5807
        .word 0xD368
        .word 0x5545
        .word 0xD070
          ...

    Changes to linker command file assuming I have hex data of 0x2000 length

    MEMORY

    {

    PAGE1:

    .....

    PRAML0    : origin = 0x008000, length = 0x002000

    .....

    }

    SECTIONS

    {

       ....

       hexdata :> PRAML0, PAGE = 1

       ....

    }

    3) Once you have the hex data in RAM buffer, you can have Flash_Program() to program flash.

    Hope this helps.

    Regards,

    Manoj

     

     

  • Is this issue resolved? Can I close this thread?

    -Manoj