Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store firmware file into header file (.h)

I have got a firmware (.raw) file which has to be written in serial flash. One way is to create a header file out of it i.e. a string array with the file content and then in code read this buffer and write it in serial flash.

In linux do we have any tool/command to create a header file with proper formatting. I am finding it toough to do it manually. The size of raw file is around 5mb.

like image 537
khanak gupta Avatar asked Mar 31 '15 11:03

khanak gupta


People also ask

What is .h in header file?

Advertisements. A header file is a file with extension . h which contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that comes with your compiler.

What do you put in .h files?

Header files ( . h ) are designed to provide the information that will be needed in multiple files. Things like class declarations, function prototypes, and enumerations typically go in header files. In a word, "definitions".

Can you include header files in header files?

Yes, this will work. Note, however, that if you include a lot of headers in this file and don't need all of them in each of your source files, it will likely increase your compilation time.


1 Answers

In linux you can use xxd command for this functionality.

Usage: xxd -i fname > abc.h

This will create a new header file with proper formatting.

like image 153
Anshul Avatar answered Sep 23 '22 17:09

Anshul