4 years ago.

Append a binary file to the compiled output

Is there a way to import a binary file and append it to the compiler output?

For instance :
I am using Adam Green's FlashFileSystem to read the contents of a static file appended to a compiled mbed file.
Adam wrote a tool (fsbld) to convert a folder on your computer to a binary file that can be appended to the mbed binary.
Currently, we need to copy both binaries into one new binary file and send it to the mbed board.
Even though this is very simple, it would be great to have the ability to import the binary (created with fsbld) into the mbed compiler and tell the compiler to append this binary to the compiled output. Let's call this the #append directive.
This allows us to create a project where all files are immediately available, so the user doesn't need to download the additional binary and fiddle with a command prompt to join both files. Only when the user wants to replace the appended file, he would need to open a command prompt to 'fsbld' a new binary.

Another solution might be to create a modified version of fsbld that outputs a header files which defines a global byte array and initializes it with the contents of the file system. FlashFileSystem could then be modified to include this generated header file and use the global byte array instead of searching FLASH for an appended image.

Just a though anyway.


posted by Adam Green 30 Mar 2015

I modified fsbld - We no longer need to append the binary to the compiled file as it now also spits out a header file we can import/include into the compiler.

posted by Frank Vannieuwkerke 02 Apr 2015
Comment on this question

1 Answer

4 years ago.

This is an intriguing solution and I'm trying to understand a use case. One use case I can think of could be embedding (appending) the html, css and javascript files into the compiled mbed bin file for a web server application. Would this be a use case? I would find this functionality very useful if this is true.

Exactly, you create a folder on your computer containing all additional files and run fsbld to create the binary. Next, you append this binary to the compiled mbed bin and program your device with it. Your mbed code uses FlashFileSystem to access these files. More info is available at Adam's page.

posted by Frank Vannieuwkerke 31 Mar 2015

To post an answer, please log in.