Using a const char array to access a binary image

Technical Note 71111

Targets:
ARM

Component:
Linker

Updated:
11/22/2018 4:47 PM

Introduction

A common method of accessing the contents of a binary file stored in flash is to dereference a char pointer. This technical note describes how to access the stored contents directly through a linker symbol.

Discussion

Use the linker option --image_input to include a binary file and assign a linker symbol that is associated with the address in flash where the contents are stored.

In your source code, use the associated linker symbol directly to access the binary image, for example:

 

extern const char test_bin_symbol[];

for (int i=0; i < 10; i++)
{
printf("%c\n", test_bin_symbol[i]);
}

Conclusion

You can access the stored contents of a binary file through a linker symbol defined by the linker option --image_input.

The example contains a project and screenshots showing linker options.

 

All Product names are trademarks or registered trademarks of their respective owners.

Related Tech Notes

© IAR Systems 1995-2019 - All rights reserved.

We use cookies on this website to provide you with a better experience. You need to accept cookies to continue using this site. Cookies