I posted how to convert a binary file into a linkable object file in the earlier post, but I didn’t show you how to take it in a project.
This time, I will show you how to take such a converted linkable object in your project.
I think this post will be very short, and to take the object file in the project is very easy.
First, you need to prepare a linkable ELF format object file. See the previous post in detail.
Once you can successfully convert your binary file into ELF format object, you might as well copy it into your project workspace so that you can easily find and access to the file.
In case of MCUXpresso IDE
First case is to use MCUXpresso IDE. This is very easy.
All you have to do is to add the linkable object file in the file path of Linker Object as shown below picture.
Tool settings-MCU Linker- Miscellaneous-Other Objects
That should do it.
In case of IAR EWARM
you need to do a little in case of EWARM. It is better to check the symbol by using “objdump”.
Using the symbol name, you need to put the file name of the raw binary image(linkable object) in the file path. And, you need to put the symbol name as below picture.
In the “Section” area, you might want to put “text” or “readonly” as you renamed the section when you converted it into the linkable object.
That is all.
How to access the binary from C source
You can access to the binary from C source like this.
You can declare the table name as below as the start, end and size address of the binary file.
extern char _binary_filename_bin_start;
extern char _binary_filename_bin_end;
extern char _binary_filename_bin_size;
Actually, you can use the pointer to access to the binary.
This is all what you need to put the binary object in your project.