사용자 정의 fputc() 함수로 프로젝트 마이그레이션

기술노트 220216

아키텍처:

Arm

컴포넌트:

compiler

업데이트:

2022-07-05 오전 12:10

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.

죄송하지만, 당사 사이트에서는 Internet Explorer를 지원하지 않습니다.보다 편안한 사이트를 위해 Chrome, Edge, Firefox 등과 같은 최신 브라우저를 사용해 주시길 부탁드립니다.