PC版 SYSLAB blog  http://syslab.asablo.jp/blog/......

FRK-RX62N (16) printf (4) KPIT GNURX Newlib
2011-06-26


禺画像]
#include #include #include void charput(unsigned char output_char); unsigned char charget(void); #if NEWLIB _ssize_t _read_r( struct _reent *r, int file, void *ptr, size_t len) { int c; unsigned char *p; c=charget(); p = ptr; *p = c; return (1); } #else int _read(int file, char *ptr, int len) { *ptr=charget(); return (1); } #endif #if NEWLIB _ssize_t _write_r ( struct _reent *r, int file, const void *ptr, size_t len) { size_t todo; const unsigned char *p; todo = len; p = ptr; for( ; todo != 0; todo--) { charput(*p++); } return (size_t)len; /* Number of bytes written. */ } #else int _write(int file,char *ptr,int len) { int i; for(i=0;ist_mode = S_IFCHR; /* assigned to strong type with implicit */ /* signed/unsigned conversion. Required by */ /* newlib. */ return 0; } #endif #if NEWLIB int _isatty_r( struct _reent *r, int file) { return 1; } #else #if 0 int _isatty(int file); /* avoid warning */ int _isatty(int file) { return 1; } #endif #endif #if 0 static void _exit (int n) { label: goto label; /* endless loop */ } #endif #if 0 /* "malloc clue function" from newlib-lpc/Keil-Demo/"generic" */ /**** Locally used variables. ****/ // mt: "cleaner": extern char* end; extern char end[]; /* end is set in the linker command */ /* file and is the end of statically */ /* allocated data (thus start of heap). */ static char *heap_ptr; /* Points to current end of the heap. */ /************************** _sbrk_r ************************************* * Support function. Adjusts end of heap to provide more memory to * memory allocator. Simple and dumb with no sanity checks. * struct _reent *r -- re-entrancy structure, used by newlib to * support multiple threads of operation. * ptrdiff_t nbytes -- number of bytes to add. * Returns pointer to start of new heap area. * * Note: This implementation is not thread safe (despite taking a * _reent structure as a parameter). * Since _s_r is not used in the current implementation, * the following messages must be suppressed. */ void * _sbrk_r( struct _reent *_s_r, ptrdiff_t nbytes) { char *base; /* errno should be set to ENOMEM on error */ if (!heap_ptr) { /* Initialize if first time through. */ heap_ptr = end; } base = heap_ptr; /* Point to end of heap. */ heap_ptr += nbytes; /* Increase heap. */ return base; /* Return pointer to start of new heap area. */ } #endif

  NEWLIB の Defines を忘れずにね!
  これは WinARM の Newlib/StdIO-Interface and LPC ADC example の中にあるファイル。
7.KPIT GNURX [ELF] Toolchain の Library Generator は
  Library type が Pre-Built
  Select library が Newlib
  と設定する。
8.後はコンパイルして書き込むだけ。と言いたいところだが、ここからが大変だ。
RAM の部分のデータを ROM に戻してやらなければならない。
(私の場合)コンパイル後の mot ファイル 0x00000400 から 00000C9B までを Tiny Hexer で Import し、それをそのまま Export する。Export する Address は FFFAA980 。
テキストエディタでコンパイル後の mot ファイルを読み込み 0x00000400 から 00000C9B までを削除する。先ほど Export したテキストを FFFAA980 から貼り付ける。
こうしてできたファイルを FDT で書き込めばよい。
(上記のアドレスはマップファイルと mot ファイルを参照しながら決めてね!)


ふう〜


いろいろやったけど他の方法を思いつかなかった。非常に手間がかかる。


ということで前回の Optimized ライブラリ printf でも同じように手動変換しなければならないということだろう。
たまたま動いたということか?


参照:Renesas Application Notes[LINK] RX600 Series Adding Printf and Scanf Support (R01AN0509EU0100)
    WinARM[LINK] Newlib/StdIO-Interface and LPC ADC example
環境:High-performance Embedded Workshop Upgrade 4.09.00
    KPIT GNURX v11.01 Windows Tool Chain (ELF)

戻る
[RX]
[マイコン]

コメント(全0件)
コメントをする


記事を書く
powered by ASAHIネット