cancel
Showing results for 
Search instead for 
Did you mean: 

IAR Embedded Workbench - Embed BMP File into Application Binary

jwormsley
Associate III
Posted on July 28, 2014 at 18:38

Does anyone know how to embed BMP images (or other files) into the application image in IAR?  I'd like to embed a series of BMP images, then have my code be able to read the BMP and send it to another device for display.

I could always write a utility to read the BMP files and output code to create constant char arrays with the contents, but I was hoping for a more direct method.

Thanks,

  Jeff.
6 REPLIES 6
Posted on July 28, 2014 at 19:26

The most common way tends to be to create .C/.H files. And it's technically feasible to instantiate an ELF object file, basically wrapping the binary data, and giving it a name/section.

Rather than recreate the wheel

STemWin_Library_V1.1.2\Libraries\STemWinLibrary522\Software\BmpCvt.exe

Likely to be plenty of other examples..
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
stm322399
Senior
Posted on July 28, 2014 at 19:42

IAR linker has an option switch --image_input for that. See integrated reference manual for more details.

jwormsley
Associate III
Posted on July 28, 2014 at 21:47

> IAR linker has an option switch --image_input for that. See integrated reference manual for more details.

Yes, I see this.  But how do I then reference these in my code?

For example, if I put the following in my linker options:

--image_input $PROJ_DIR$\..\Images\no_sale.bmp,IMG_NO_SALE,IMAGES,8

I can see that it was added to the application image by looking at the map file:

#        --image_input

#        C:\IAR\EMV\Application\Project\..\Images\no_sale.bmp,IMG_NO_SALE,IMAGES,8

...

''A3'':  place at 0x08010200 { ro section IMAGES }; ...

''A3'':                                         0x87e

  IMAGES               const    0x08010200    0x43e  no_sale.bmp [2]

...

IMG_NO_SALE             0x08010200   0x43e  Data  Gb  no_sale.bmp [2]

However, I cannot figure out how I am supposed to reference IMG_NO_SALE in my code to get the equivalent of a ''const * char Image[] = {....};'' structure.  For instance, if I try to do the following:

{

  char RawData[((128 * 64) / 😎 + sizeof(TBMPHeader)]; // Max Image Size

  memcpy(RawData, IMG_NO_SALE, sizeof(RawData));

...

I get a compilation error:

bezel8.c

Error[Pe020]: identifier ''IMG_NO_SALE'' is undefined C:\IAR\EMV\Application\src\bezel8.c 3077 Error while running C/C++ Compiler

Done. 1 error(s), 0 warning(s)

If I cheat and add ''#define IMG_NO_SALE             (const void *)0x08010200'' using what I saw in the .map file, then I can access the data, but that doesn't seem like it should be the proper way to handle this.

Jeff.

jwormsley
Associate III
Posted on July 28, 2014 at 21:59

I also asked IAR about this, and they brought up a point I hadn't considered.  Using the linker tools means all this is done -after- the pre-processor has finished, so there probably isn't any way my code could ever know the identifiers given in the linker options.

Looks like the converter may be my best bet.

Jeff.
Posted on July 28, 2014 at 22:20

Surely:

extern const char IMG_NO_SALE[];

or using underscores as prescribed.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jwormsley
Associate III
Posted on July 28, 2014 at 22:43

Facepalm!

Of course, that works great!

Thanks!

Jeff.