RX SmartConfigurator FIT e2studioプロジェクトをMinGWでbuildしてみる(もちろん実行出来ませんけれど)

こんにちは。NoMaYです。

別スレッド「RXシュミレータでの最小プログラムの作成について」でRXシミュレータの代わりにMinGWを使うと言う話が出ていましたので、とりあえず、ビルド出来るようにするにはどうすれば良いのだろうか試してみることにしました。

まずはMingGWのインストールから。今回、以下を参考にさせて頂きました。私は64bit版をインストールしてみました。[追記] 正確には、MinGW-W64にて、64bitターゲットアーキテクチャを選択したのですが、この選択は不適切でしたので、後日、32bitターゲットアーキテクチャを選択し直しました。

gccのインストール(Windows) - 電気通信大学
joho.g-edu.uec.ac.jp/joho/gcc_win/





続く。

Parents
  • こんにちは。NoMaYです。

    FITのBSPモジュールのソースの1つにr_rx_compiler.hというヘッダファイルがあるのですが、そのファイルに細工をして以下の画面コピーのレベルまでエラーやワーニングを減らしました。(あと、FreeRTOSポートレイヤのportmacro.hというヘッダファイルもですが、余り重要ではないです。) ここまで減らせば、まあ後は何とかなるだろう、というレベルかなと思います。細工の内容は、以下の画面コピーの後に書いてあります。次の作業では、流用元プロジェクトをGNURX版からCC-RX版へ戻します。

    続く。

    画面コピー






    細工の内容 (赤文字部分が追加箇所)

    r_rx_compiler.h

    /* ---------- Interrupt Function Creation ---------- */
    #if defined(__CCRX__)



    #elif defined(__GNUC__) && !defined(__WINNT__)

    /* Standard */
    #define R_BSP_PRAGMA_INTERRUPT(function_name, vector)                 extern void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector)));
    #define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector)          static void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector), used));

    #define R_BSP_PRAGMA_INTERRUPT_FUNCTION(function_name)                extern void function_name(void) __attribute__((interrupt));
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_FUNCTION(function_name)         static void function_name(void) __attribute__((interrupt, used));

    #define R_BSP_ATTRIB_INTERRUPT                                        extern /* only this one because __attribute__((interrupt)) prevents GNURX from generating vector */
    #define R_BSP_ATTRIB_STATIC_INTERRUPT                                 static /* only this one because __attribute__((interrupt, used)) prevents GNURX from generating vector */

    /* Fast */
    #define R_BSP_PRAGMA_FAST_INTERRUPT(function_name, vector)            extern void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector))) \
                                                                                                          __attribute__((fast_interrupt));
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT(function_name, vector)     static void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector), used)) \
                                                                                                          __attribute__((fast_interrupt, used));

    #define R_BSP_PRAGMA_FAST_INTERRUPT_FUNCTION(function_name)           extern void function_name(void) __attribute__((fast_interrupt));
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT_FUNCTION(function_name)    static void function_name(void) __attribute__((fast_interrupt, used));

    #define R_BSP_ATTRIB_FAST_INTERRUPT                                   extern /* __attribute__((interrupt(fast))) Not necessary,
                                                                                    but Don't forget a R_BSP_PRAGMA_FAST_INTERRUPT() declaration */
    #define R_BSP_ATTRIB_STATIC_FAST_INTERRUPT                            static /* __attribute__((interrupt(fast)), used) Not necessary,
                                                                                    but Don't forget a R_BSP_PRAGMA_STATIC_FAST_INTERRUPT() declaration */

    /* Default */
    #define R_BSP_PRAGMA_INTERRUPT_DEFAULT(function_name)                 extern void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, "$default")));
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_DEFAULT(function_name)          static void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, "$default"), used));

    #elif defined(__ICCRX__)



    #elif defined(__GNUC__) && defined(__WINNT__)

    /* Standard */
    #define R_BSP_PRAGMA_INTERRUPT(function_name, vector)                 extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector)          static void function_name(void) __attribute__((used));

    #define R_BSP_PRAGMA_INTERRUPT_FUNCTION(function_name)                extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_FUNCTION(function_name)         static void function_name(void) __attribute__((used));

    #define R_BSP_ATTRIB_INTERRUPT                                        extern
    #define R_BSP_ATTRIB_STATIC_INTERRUPT                                 static

    /* Fast */
    #define R_BSP_PRAGMA_FAST_INTERRUPT(function_name, vector)            extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT(function_name, vector)     static void function_name(void) __attribute__((used));

    #define R_BSP_PRAGMA_FAST_INTERRUPT_FUNCTION(function_name)           extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT_FUNCTION(function_name)    static void function_name(void) __attribute__((used));

    #define R_BSP_ATTRIB_FAST_INTERRUPT                                   extern
    #define R_BSP_ATTRIB_STATIC_FAST_INTERRUPT                            static

    /* Default */
    #define R_BSP_PRAGMA_INTERRUPT_DEFAULT(function_name)                 extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_DEFAULT(function_name)          static void function_name(void) __attribute__((used));

    #endif

     

    /* ---------- Inline Expansion of Assembly-Language Function (part2) ---------- */
    #if defined(__CDT_PARSER__)



    #else

    #if defined(__CCRX__)



    #elif defined(__GNUC__) && !defined(__WINNT__)

    #define _R_BSP_ASM(...)           #__VA_ARGS__
    #define R_BSP_ASM(...)            _R_BSP_ASM(__VA_ARGS__\n)
    #define R_BSP_ASM_LAB_NEXT(n)     ?+
    #define R_BSP_ASM_LAB_PREV(n)     ?-
    #define R_BSP_ASM_LAB(n_colon)    R_BSP_ASM(?:)
    #define R_BSP_ASM_BEGIN           __asm__ volatile (
    #define R_BSP_ASM_END             R_BSP_ASM(rts));

    #elif defined(__ICCRX__)



    #elif defined(__GNUC__) && defined(__WINNT__)

    #define _R_BSP_ASM(...)
    #define R_BSP_ASM(...)
    #define R_BSP_ASM_LAB_NEXT(n)
    #define R_BSP_ASM_LAB_PREV(n)
    #define R_BSP_ASM_LAB(n_colon)
    #define R_BSP_ASM_BEGIN
    #define R_BSP_ASM_END

    #define __asm( ... )
    #define asm( ... )

    #endif

    #endif /* defined(__CDT_PARSER__) */


    portmacro.h

    #if !defined(__WINNT__)
        #define _portASM( ... )              __asm volatile ( #__VA_ARGS__ "\n" );
        #define portASM( ... )               _portASM( __VA_ARGS__ )
        #define portASM_LAB_NEXT( name )     ?+
        #define portASM_LAB_PREV( name )     ?-
        #define portASM_LAB( name_colon )    _portASM( ?: )
        #define portASM_BEGIN
        #define portASM_END
    #elif defined(__WINNT__)
        #define _portASM( ... )
        #define portASM( ... )
        #define portASM_LAB_NEXT( name )
        #define portASM_LAB_PREV( name )
        #define portASM_LAB( name_colon )
        #define portASM_BEGIN
        #define portASM_END
        #define volatile( ... ) ( "" )
    #endif

     

Reply
  • こんにちは。NoMaYです。

    FITのBSPモジュールのソースの1つにr_rx_compiler.hというヘッダファイルがあるのですが、そのファイルに細工をして以下の画面コピーのレベルまでエラーやワーニングを減らしました。(あと、FreeRTOSポートレイヤのportmacro.hというヘッダファイルもですが、余り重要ではないです。) ここまで減らせば、まあ後は何とかなるだろう、というレベルかなと思います。細工の内容は、以下の画面コピーの後に書いてあります。次の作業では、流用元プロジェクトをGNURX版からCC-RX版へ戻します。

    続く。

    画面コピー






    細工の内容 (赤文字部分が追加箇所)

    r_rx_compiler.h

    /* ---------- Interrupt Function Creation ---------- */
    #if defined(__CCRX__)



    #elif defined(__GNUC__) && !defined(__WINNT__)

    /* Standard */
    #define R_BSP_PRAGMA_INTERRUPT(function_name, vector)                 extern void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector)));
    #define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector)          static void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector), used));

    #define R_BSP_PRAGMA_INTERRUPT_FUNCTION(function_name)                extern void function_name(void) __attribute__((interrupt));
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_FUNCTION(function_name)         static void function_name(void) __attribute__((interrupt, used));

    #define R_BSP_ATTRIB_INTERRUPT                                        extern /* only this one because __attribute__((interrupt)) prevents GNURX from generating vector */
    #define R_BSP_ATTRIB_STATIC_INTERRUPT                                 static /* only this one because __attribute__((interrupt, used)) prevents GNURX from generating vector */

    /* Fast */
    #define R_BSP_PRAGMA_FAST_INTERRUPT(function_name, vector)            extern void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector))) \
                                                                                                          __attribute__((fast_interrupt));
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT(function_name, vector)     static void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, vector), used)) \
                                                                                                          __attribute__((fast_interrupt, used));

    #define R_BSP_PRAGMA_FAST_INTERRUPT_FUNCTION(function_name)           extern void function_name(void) __attribute__((fast_interrupt));
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT_FUNCTION(function_name)    static void function_name(void) __attribute__((fast_interrupt, used));

    #define R_BSP_ATTRIB_FAST_INTERRUPT                                   extern /* __attribute__((interrupt(fast))) Not necessary,
                                                                                    but Don't forget a R_BSP_PRAGMA_FAST_INTERRUPT() declaration */
    #define R_BSP_ATTRIB_STATIC_FAST_INTERRUPT                            static /* __attribute__((interrupt(fast)), used) Not necessary,
                                                                                    but Don't forget a R_BSP_PRAGMA_STATIC_FAST_INTERRUPT() declaration */

    /* Default */
    #define R_BSP_PRAGMA_INTERRUPT_DEFAULT(function_name)                 extern void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, "$default")));
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_DEFAULT(function_name)          static void function_name(void) __attribute__((interrupt(R_BSP_SECNAME_INTVECTTBL, "$default"), used));

    #elif defined(__ICCRX__)



    #elif defined(__GNUC__) && defined(__WINNT__)

    /* Standard */
    #define R_BSP_PRAGMA_INTERRUPT(function_name, vector)                 extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_INTERRUPT(function_name, vector)          static void function_name(void) __attribute__((used));

    #define R_BSP_PRAGMA_INTERRUPT_FUNCTION(function_name)                extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_FUNCTION(function_name)         static void function_name(void) __attribute__((used));

    #define R_BSP_ATTRIB_INTERRUPT                                        extern
    #define R_BSP_ATTRIB_STATIC_INTERRUPT                                 static

    /* Fast */
    #define R_BSP_PRAGMA_FAST_INTERRUPT(function_name, vector)            extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT(function_name, vector)     static void function_name(void) __attribute__((used));

    #define R_BSP_PRAGMA_FAST_INTERRUPT_FUNCTION(function_name)           extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_FAST_INTERRUPT_FUNCTION(function_name)    static void function_name(void) __attribute__((used));

    #define R_BSP_ATTRIB_FAST_INTERRUPT                                   extern
    #define R_BSP_ATTRIB_STATIC_FAST_INTERRUPT                            static

    /* Default */
    #define R_BSP_PRAGMA_INTERRUPT_DEFAULT(function_name)                 extern void function_name(void);
    #define R_BSP_PRAGMA_STATIC_INTERRUPT_DEFAULT(function_name)          static void function_name(void) __attribute__((used));

    #endif

     

    /* ---------- Inline Expansion of Assembly-Language Function (part2) ---------- */
    #if defined(__CDT_PARSER__)



    #else

    #if defined(__CCRX__)



    #elif defined(__GNUC__) && !defined(__WINNT__)

    #define _R_BSP_ASM(...)           #__VA_ARGS__
    #define R_BSP_ASM(...)            _R_BSP_ASM(__VA_ARGS__\n)
    #define R_BSP_ASM_LAB_NEXT(n)     ?+
    #define R_BSP_ASM_LAB_PREV(n)     ?-
    #define R_BSP_ASM_LAB(n_colon)    R_BSP_ASM(?:)
    #define R_BSP_ASM_BEGIN           __asm__ volatile (
    #define R_BSP_ASM_END             R_BSP_ASM(rts));

    #elif defined(__ICCRX__)



    #elif defined(__GNUC__) && defined(__WINNT__)

    #define _R_BSP_ASM(...)
    #define R_BSP_ASM(...)
    #define R_BSP_ASM_LAB_NEXT(n)
    #define R_BSP_ASM_LAB_PREV(n)
    #define R_BSP_ASM_LAB(n_colon)
    #define R_BSP_ASM_BEGIN
    #define R_BSP_ASM_END

    #define __asm( ... )
    #define asm( ... )

    #endif

    #endif /* defined(__CDT_PARSER__) */


    portmacro.h

    #if !defined(__WINNT__)
        #define _portASM( ... )              __asm volatile ( #__VA_ARGS__ "\n" );
        #define portASM( ... )               _portASM( __VA_ARGS__ )
        #define portASM_LAB_NEXT( name )     ?+
        #define portASM_LAB_PREV( name )     ?-
        #define portASM_LAB( name_colon )    _portASM( ?: )
        #define portASM_BEGIN
        #define portASM_END
    #elif defined(__WINNT__)
        #define _portASM( ... )
        #define portASM( ... )
        #define portASM_LAB_NEXT( name )
        #define portASM_LAB_PREV( name )
        #define portASM_LAB( name_colon )
        #define portASM_BEGIN
        #define portASM_END
        #define volatile( ... ) ( "" )
    #endif

     

Children
  • NoMaYさん

    シェルティです、こんにちは。

    ありがとうございます。BSPの開発チームに検討依頼出しました。いつも開発にご協力いただき感謝です。

    以上です

  • NoMaYさん、こんにちは。

    自分もlongのサイズは意識していませんでした(汗)

    ビルドができるようになれば、全体を実行することはできなくても
    CUnit(C++ならGoogleTestでも)での単体テストならできそうですね。

    CGの場合は以下のような細工になります。
    (自分はデバッグしやすいようにもうちょっと細工していますが)

    iodefine.h
    #define DI() asm("di") // ここは変更なし
    ...(略)...

    #if !defined(__WINNT__) // 実機用、従来の定義
    #define P0 (*(volatile union un_p0 *)0xFFF00).p0
    #define P0_bit (*(volatile union un_p0 *)0xFFF00).BIT
    #define P1 (*(volatile union un_p1 *)0xFFF01).p1
    #define P1_bit (*(volatile union un_p1 *)0xFFF01).BIT
    ...(略)...
    #else                               // MinGW用
    extern unsigned char sfr_buf[256];
    #define P0 (*(volatile union un_p0 *)(sfr_buf + 0x00000)).p0
    #define P0_bit (*(volatile union un_p0 *)(sfr_buf + 0x00000)).BIT
    #define P1 (*(volatile union un_p1 *)(sfr_buf + 0x00001)).p1
    #define P1_bit (*(volatile union un_p1 *)(sfr_buf + 0x00001)).BIT
    ...(略)...
    #endif

    適当な.cをつくって
    unsigned char sfr_buf[256];

    void asm(char *code) // gcc -fno-asm
    {
        if (strcmp(code, "di") == 0)
        {
            ...(略)...