Migrating projects with the custom fputc() function

Technical Note 220216

Arkitekturer:

Arm

Komponent:

compiler

Uppdaterad:

2022-03-01 16:16

Introduction

Some projects with a custom fputc() function generate no output when they are migrated to EWARM 9.20.1 or later version.

Discussion

This Technical Note applies to projects matching all these points:

  • Uses Full Library configuration, in other words the _DLIB_FILE_DESCRIPTOR = 1.
    and
  • Only uses the printf() function and/or putchar() function for output.
    and
  • Has implemented a custom fputc() function.

Other migrated projects are not affected.

Suggestions:

  1. Evaluate if the project needs Full library configuration. If not, switching to Normal library configuration could solve the problem.
  2. If Full library configuration is needed: Implement __write() instead of fputc().

Note: The recommended way to do retargeting is to implement __write(). This is described in the IAR C/C++ Development Guide, in the chapter The DLIB runtime environment, in the section Retargeting—Adapting for your target system, under the heading Standard streams for input and output.

Background:

EWARM 9.20.1 introduced an optimization in the run-time library.

  • The aim of that optimization is to avoid including (in the linked .out file) file descriptor (including malloc()).
  • In other words, the optimization shrinks linked output in 9.20.1 and later versions.

Example:

This link holds two example projects for retargeting printf() to UART1 when fputc() and __write() has been retargeted. The example (on the MCB2130 board) shows how to migrate from EWARM 9.10.2 to EWARM 9.20.2.

Conclusion

For migrated projects where this ‘no output’ issue occurs, the change from a custom fputc() function to a custom __write() function solves the issue.

A benefit is that the size of the linked .out file shrinks, when doing retargeting with a custom __write() function.

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

Det här innehållet finns tyvärr inte på svenska.

Vår webbplats finns främst på vårt koncernspråk engelska, förutom det innehåll för investerare som vi är lagstadgade att kommunicera på svenska. Vi rekommenderar att du besöker vår globala webbplats på engelska för att få en bättre upplevelse.

Vi stöder inte längre Internet Explorer. För att få bästa möjliga upplevelse av iar.com rekommenderar vi att du uppgraderar till en modern webbläsare som Chrome eller Edge.