2014-07-28 09:38 AM
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.2014-07-28 10:26 AM
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..2014-07-28 10:42 AM
IAR linker has an option switch --image_input for that. See integrated reference manual for more details.
2014-07-28 12:47 PM
> 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) / 8) + 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.2014-07-28 12:59 PM
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.2014-07-28 01:20 PM
Surely:
extern const char IMG_NO_SALE[]; or using underscores as prescribed.2014-07-28 01:43 PM
Facepalm!
Of course, that works great!Thanks!Jeff.