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.

CCS: adding a binary file of data to an executable

Other Parts Discussed in Thread: SEGGER

Hi,

I have to boot an fpga from my Tiva. I have done this before by having an external serial flash device. Now I would like to "bind" the fpga data to the Tiva code and have a pointer to the data which I can use from within the code. I can't figure out how to get CCS to do this. Can anyone help please?

Thanks, Richard

  • Hi,

    Two suggestions, could be also others:

    1. Make your own tool: read each byte and emit a hexa text, as in pnmtoc tool (to be found in Tiva/tools, as executable and source), which can output either a .h or .c file, then add it to your project;
    2. Reserve a region of flash at top of your flash, and use LMFlash to write directly that file at dedicated address, usually start of page. LMFlash can do that without erasing other pages. Weight yourself pros/cons of this method and the previous one.

     

  • Petrei said:
    Make your own tool: read each byte and emit a hexa text, as in pnmtoc tool (to be found in Tiva/tools, as executable and source), which can output either a .h or .c file, then add it to your project;

    This has been my usual method in the past. Simple to do and you may even find freeware/open source tools to do it. You end up with source looking something like

    const uint8_t external_data[] = {0x1u, 0x45u, 0x97u, ....};

    Method 2 should work as well and as Petrei mentions has some pros and cons

    Robert

  • And as it turns out Segger's Flash utility includes support for this, it will produce C code from a given binary.

    Robert
  • Thanks for your replies.
    Gosh, I was expecting there to be a straight-forward compiler "resource import" that would achieve this!
    Anyway, on your advice I have found a simple DOS utility called bin2h.exe which creates a header file for inclusion. This works fine, it's just that now I have to remember to manually run this extra step each time the fpga file changes.
    Best regards,
    Richard
  • I don't know what you've got for a build system (that would require someone with CCS experience) but you should be able to create a dependency such that the header file gets rebuilt anytime the FPGA file is updated. Ideally it would also check the FPGA source and rebuild the FPGA binary by running the FPGA compiler if necessary.

    Robert
  • Hi Robert,
    Yes CCS has "Pre-Build Steps" where I could run bin2h every time I build. Not very elegant - maybe there's a better way, but it'll do for now!
    Richard
  • That's an option but I was referring to a dependency. I'm used to writing something like this

    FPGA.h: fpga.bin
    bin2h fpga.bin FPGA.h

    or

    FPGA.h: fpga.src
    fpga_compile fpga.src -l -r -ofpga.bin
    bin2h fpga.bin FPGA.h

    Where the first would regenerate FPGA.h whenever then binary changed, and the second would regenerate from the source whenever it changed. The build system must be doing something like that for the C source unless it is recompiling everything all the time.

    Robert

    My system is a little simpler and more complicated simultaneously but this is the idea. Any halfways decent build environment will give you a way to do this.
  • Thanks Robert, I'll look for dependencies in CCS.
    CCS is an Eclipse-based environment which generates it's own makefile and is not really very intuitive I find.
    Richard
  • That's why I use a programmers editor. rather than an IDE

    Eclipse was built for Java and I find it unwieldy when I've used it. They do have a build system which is supposed to be an improvement on make but I've not yet learned it.

    Robert