Using a const char array to access a binary image

Technical Note 71111

Architectures:

ARM

Component:

linker

Updated:

2018/11/22 17:16

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.

很抱歉,该页面尚未翻译成中文。

如果您有任何问题,请联系我们的中国团队

We do no longer support Internet Explorer. To get the best experience of iar.com, we recommend upgrading to a modern browser such as Chrome or Edge.