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.

Hex2000 create raw binary image for Flash API usage



Hi,

I want to write create a custom firmware update function to write a binary image into the Flash of a F2806x processor.
I transfer the binary image from a different processor to the F2806x via the McBSP (SPI mode) and the DMA controller say 1024 bytes at a time.  

These 1024 bytes are stored in a Buffer at the F2806x side.
Using the Flash API i want to write these bytes to the corresponding address in FLASH  where the binary must end up ( start at 0x3D8000 ),
this offset is known  in the firmware update application.

uint16_t* pointer = &Buffer

so: Flash_Program( 0x3D8000, &Buffer, 512 )
next write is then Flash_Program ( 0x3D8000 + 512, pointer + 512, 512 )

What i would like to have is a binary that contains the Flash Content of the application, which is located at Flash Address 0X3D8000 and has length 0xBFFE
( FLASH_ASW_ENTRY + FLASH_ASW ) I then add two bytes (using a costum checksum tool)  so the total size of the binary ends up being 0xC000 or in 8 bit 
address space a length of 0x18000.

To create an *.out file i use the following linker command file settings

MEMORY
{
PAGE 0 :
FLASH_ASW_ENTRY (R) : origin = 0x3D8000, length = 0x000002 /* Application code entry */
FLASH_ASW (R) : origin = 0x3D8002, length = 0x00BFFC               /* Application */
FLASH_ASW_CS (R) : origin = 0x3E3FFE, length = 0x000002        /* Application checksum */

etc.....

}

SECTIONS
{
.branch_entry_point : > FLASH_ASW_ENTRY, PAGE = 0
.copy_sections : > FLASH_ASW, PAGE = 0
.text : > FLASH_ASW, PAGE = 0
.cinit : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM, PAGE = 0
, LOAD_START(_CInit_LoadStart)
, RUN_START(_CInit_RunStart)
, SIZE(_CInit_Size)
.const : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM, PAGE = 0
, LOAD_START(_Const_LoadStart)
, RUN_START(_Const_RunStart)
, SIZE(_Const_Size)
.econst : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM, PAGE = 0
, LOAD_START(_EConst_LoadStart)
, RUN_START(_EConst_RunStart)
, SIZE(_EConst_Size)
.pinit : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM, PAGE = 0
, LOAD_START(_PInit_LoadStart)
, RUN_START(_PInit_RunStart)
, SIZE(_PInit_Size)
.switch : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM, PAGE = 0
, LOAD_START(_Switch_LoadStart)
, RUN_START(_Switch_RunStart)
, SIZE(_Switch_Size)

RamFunction : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM, PAGE = 0
, LOAD_START(_RamFunction_LoadStart)
, RUN_START(_RamFunction_RunStart)
, SIZE(_RamFunction_Size)

.const_cla : LOAD = FLASH_ASW, PAGE = 0
, RUN = LRAM_CLA, PAGE = 0
, LOAD_START(_ConstCla_LoadStart)
, RUN_START(_ConstCla_RunStart)
, SIZE(_ConstCla_Size)

Cla1Prog : LOAD = FLASH_ASW, PAGE = 0
RUN = LRAM_CLA, PAGE = 0
LOAD_START(_Cla1funcs_LoadStart),
RUN_START(_Cla1funcs_RunStart),
RUN_END(_Cla1funcs_RunEnd),
SIZE(_Cla1funcs_Size)

etc...

I expect a binary with the size of 0xC0000 - 0x02 ( application without checksum) in 16 bit address space. (in 8 bit address space 0x18000). 

QUESTION:

How can i instruct Hex2000 tool to create such a raw binary file that i can copy and use directly in the Flash API.

hex2000 -o outputfile.bin --map=outputfile.map release_hex.cmd inputfile.out

release_hex.cmd:

--image
--zero
--issue_remarks
--binary

ROMS
{
APPLICATION_BINARY: org = 0x0, len = 0xBFFE, romwidth = 8,
memwidth = 8, fill = 0xFF
files = { output.8b}
}

SECTIONS
{
.branch_entry_point :
.copy_sections :
.text :
.cinit :
.const :
.econst :
.pinit :
.switch :
RamFunction :
.const_cla :
Cla1Prog :
}

But in the ROM stage i get errors because address do not match the sections do not match the ROM origin,
Should i multiply every address in the hex command file by 2? --> --binary is 8 bit and linker command is 16 bit?

Translating to Binary format...
"output/release/f28x_application.out" ==> .branch_entry_point
warning: section output/release/f28x_application.out(.branch_entry_point) at
07b0000h falls in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> RamFunction
warning: section output/release/f28x_application.out(RamFunction) at 07b0004h
falls in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> .text
warning: section output/release/f28x_application.out(.text) at 07b8278h falls
in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> Cla1Prog
warning: section output/release/f28x_application.out(Cla1Prog) at 07bf980h
falls in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> .econst
warning: section output/release/f28x_application.out(.econst) at 07c0424h falls
in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> .cinit
warning: section output/release/f28x_application.out(.cinit) at 07c0d84h falls
in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> .copy_sections
warning: section output/release/f28x_application.out(.copy_sections) at
07c0e36h falls in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> .switch
warning: section output/release/f28x_application.out(.switch) at 07c0ed0h falls
in unconfigured memory (skipped)
"output/release/f28x_application.out" ==> .pinit
warning: section output/release/f28x_application.out(.pinit) at 07c0f68h falls
in unconfigured memory (skipped)

Should i try this? Because it then complains that the paddr for the sections is not specified?

ROMS
{
APPLICATION_BINARY: org = 0x7B000, len = 0x18000, romwidth = 16,
memwidth = 16, fill = 0xFFFF
files = { output.16b}
}

 Hope you could help me out, i want a nice way to configure this conversion so i don't need 
any other tools / toolchain in the future. 
I do not want a hex or text file that describes the address range and requires parsing of the file.  

I tried reading the spru13e.pdf but could not figure out the correct conversion procedure / command file.

Regards,

Rob

  • Solved my problem, but could not accomplish the goal without making a hex2000 tool command file.
    which contains the following:

    FIX: Because a binary assumes 8 bit addressing i needed to convert the linker addresses to 8 bit addressing (multiply by 2)

    --issue_remarks
    --binary /* Note all addresses in 8 bit memwidth */
    --zero /* Start from zero in output file */
    --image

    ROMS

    {
    /* multiply the linker addressing of Flash sections by 2 (16 bit to 8 bit addressing ) */
    /* when using --binary option all addresses are converted to binary (byte addressing) */
    APPLICATION_BINARY:
    org = 0x007B0000, /* 0x3D8000 in linker */
    len = 0x00017FFC, /* 0xBFFE in linker */
    romwidth = 16, /* no influence because romwidth > 8 */
    fill = 0xFFFF
    }

    SECTIONS
    {
    .branch_entry_point :
    .copy_sections :
    .text :
    .cinit :
    .const :
    .econst :
    .pinit :
    .switch :
    RamFunction
    .const_cla :
    Cla1Prog :
    }

     My Makefile contains the following lines:

    FILE_REL: binary name ( "release_r03.bin" )
    OUTFILE_REL: is the compiled *.out file of your application
    CG_TOOL_HEX: path to hex2000 tooling 

    @echo "*** Creating Binary Image: $(FILE_REL)"
    $(CG_TOOL_HEX) -o $(FILE_REL) -order=LS --map=$(FILE_REL).map $(HEX_CMD_REL) $(OUTFILE_REL)

  • HI,

    The above thread is indeed very useful.

    I have used the above configuration and it seems HEX2000 can eliminate the need of third party HEX2BIN utilities.

    However, can the Hex2000 append checksum(big,little endian) at the end of binary file? Is there any command line option?

    Regards

    Prashant

  • Hi Rob
    Can You tell me more specific how to generate that hex2000 tool command file and makefile? When i'm trying to modify my makefile it is not changing anything.