Amazon AWSのFreeRTOS Kernel Developer GuideのサンプルコードをRenesas RX SimulatorのDebug Consoleで試せるようにしてみた

こんにちは。NoMaYです。

別スレッドで、AWSドキュメントサイト内にFreeRTOS kernelの開発者ガイドの日本語版が載っていることに気付いたのですが、その中に含まれているCコード例をルネサスRXシミュレータで試せたら面白そうだと思い、やってみました。まずはCC-RX(CS+/e2 studio)版です。後日GNURX(e2 studio)版もやろうと思います。以下、プロジェクトのファイル一式です。(CS+ V8.01+CC-RX V2.03でビルド)(e2 studio用.project/.cproject等を同梱(zipファイルをe2 studioに直接インポート可能))

sim_rx65n_freertos_ccrx_c_csplus_20190526.zip

やったこと(主なもの)

(1) FreeRTOS kernelがルネサスRXシミュレータの未対応機能を使っていたので無理矢理に対応機能のみ使うように小細工
(2) Full DemoからルネサスRXシミュレータの未対応機能を使っている項目を除外
(3) ルネサスRXシミュレータではBSPモジュール内で無限ループしてしまう点を回避
(4) 開発者ガイドのCコード例で使われているvPrintString()をDebug Consoleへ出力するように作成
(5) Full Demo/Simple Blinky Demo/Cコード例でvAssertCalled()呼び出し時にDebug Consoleへメッセージを出力
(6) Full Demo/Simple Blinky DemoでLEDのOn/OffのタイミングでDebug ConsoleへOn/Offのメッセージを出力
(7) 開発者ガイドのCコード例が動くようにルネサスRXシミュレータの起動設定を変更(私の個人的な好みを含む)
(8) 開発者ガイドのCコード例をビルドする時には不要なデモソースをビルドから除外したプロジェクトを作成(CS+のみ)
(9) 開発者ガイドのCコード例をビルドするプロジェクトではコンパイル時の最適化レベルを0に変更(CS+のみ)

以下、FreeRTOS kernelの開発者ガイドのCコード例をルネサスRXシミュレータで動かした時の画面コピーです。(上記の(8)のプロジェクトです。)

FreeRTOS kernelの開発者ガイドではFreeRTOS Windowsシミュレータで実行
docs.aws.amazon.com/ja_jp/freertos-kernel/latest/dg/task-management.html


ルネサスRXシミュレータで実行


ビルドした時のビルド設定とビルド結果


zipファイルには、開発者ガイドのCコード例をビルドするプロジェクト(CS+のみ)の他に、別スレッドに投稿した、RX65N TBボードで動く(といってもデバッグ中ではありますが)Full Demo/Simple Blinky Demoをビルドするプロジェクトも含まれています。(上記の(2)で除外している項目はありますが。) 以下、それらの画面コピーです。

CS+


e2 studio

Parents
  • こんにちは。NoMaYです。#3連投の2つ目です。

    CS+のPrintf Action Event機能も、e2 studioのDynamic Printf機能も、GUIから設定出来ますが、今回は以下のようにして、自動的に設定されるようにしました。

    CS+: ダウンロード後のフック関数のPythonスクリプトを記述

    sim_rl78_freertos_dev_guide_debug.py / sim_rl78_freertos_full_demo.py

    ...略...
    def AfterDownload():
        ThrowExceptSave = common.ThrowExcept
        ViewOutputSave  = common.ViewOutput
        common.ThrowExcept = False
        common.ViewOutput  = False
        if debugger.DebugTool.GetType() == DebugTool.Simulator:
            for ae in debugger.ActionEvent.Information():
                if ae.Address == "sim_debugger_console.c#1":
                    break;
            else:
                ae = ActionEventCondition()
                ae.Address = "sim_debugger_console.c#1"
                ae.Output = "char *"
                ae.Expression = "message"
                ae.ActionEventType = ActionEventType.Printf
                ae_number = debugger.ActionEvent.Set(ae)
        common.ThrowExcept = ThrowExceptSave
        common.ViewOutput  = ViewOutputSave
        return

    e2 studio: デバッグ構成の[Starup]の[コマンドを実行]にGDBコマンドを記述

    dprintf sim_debugger_console.c:1,"%s",message
    clear sim_debugger_console.c:1
    dprintf sim_debugger_console.c:1,"%s",message

    また、上記での自動設定(において重複設定してしまうことの回避)がやりやすくなるよう、イベントを設定するソースを以下のようにしました。

    src/sim_debugger_console.c

    void sim_debugger_console(const char *message); void sim_debugger_console(const char *message) { (void) message; }
    /* This is a stub function to output a string to the debugger console
    using an Action Event of the CS+ or a Dynamic Printf of the e2 studio
    for the Renesas RL78 Simulator. */

    上記の関数は以下で呼び出されます。

    src/frtos_startup/freertos_start.c

    /******************************************************************************
    * Function Name: vPrintString
    * Description  : This function is used to write a string to a debug console.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vPrintString(const char *pcMessage)
    {
        /* Write the string to a debug console, using a critical section
        as a crude method of mutual exclusion. */

        extern void sim_debugger_console( const char *message );

        taskENTER_CRITICAL();
        {
            sim_debugger_console( pcMessage );
        }
        taskEXIT_CRITICAL();

    } /* End of function vPrintString() */

    Simulator GUIのパネルのLEDとButtonは以下の画面コピーの通りに設定にしました。また、この設定はCS+ではSimulator GUI起動時に自動的に再設定されたのですが、e2 studioでは再設定されませんでしたので、この設定を保存したファイルsim_rl78_visual_parts_panel.pnlをzipファイルに同梱しました。なお、LEDとButtonを接続する端子はGR-KURUMIで扱える端子を選択してみました。









    あと、以下は、Renesas RL78 Simulatorの起動設定の画面コピーです。

    CS+





    e2 studio


Reply
  • こんにちは。NoMaYです。#3連投の2つ目です。

    CS+のPrintf Action Event機能も、e2 studioのDynamic Printf機能も、GUIから設定出来ますが、今回は以下のようにして、自動的に設定されるようにしました。

    CS+: ダウンロード後のフック関数のPythonスクリプトを記述

    sim_rl78_freertos_dev_guide_debug.py / sim_rl78_freertos_full_demo.py

    ...略...
    def AfterDownload():
        ThrowExceptSave = common.ThrowExcept
        ViewOutputSave  = common.ViewOutput
        common.ThrowExcept = False
        common.ViewOutput  = False
        if debugger.DebugTool.GetType() == DebugTool.Simulator:
            for ae in debugger.ActionEvent.Information():
                if ae.Address == "sim_debugger_console.c#1":
                    break;
            else:
                ae = ActionEventCondition()
                ae.Address = "sim_debugger_console.c#1"
                ae.Output = "char *"
                ae.Expression = "message"
                ae.ActionEventType = ActionEventType.Printf
                ae_number = debugger.ActionEvent.Set(ae)
        common.ThrowExcept = ThrowExceptSave
        common.ViewOutput  = ViewOutputSave
        return

    e2 studio: デバッグ構成の[Starup]の[コマンドを実行]にGDBコマンドを記述

    dprintf sim_debugger_console.c:1,"%s",message
    clear sim_debugger_console.c:1
    dprintf sim_debugger_console.c:1,"%s",message

    また、上記での自動設定(において重複設定してしまうことの回避)がやりやすくなるよう、イベントを設定するソースを以下のようにしました。

    src/sim_debugger_console.c

    void sim_debugger_console(const char *message); void sim_debugger_console(const char *message) { (void) message; }
    /* This is a stub function to output a string to the debugger console
    using an Action Event of the CS+ or a Dynamic Printf of the e2 studio
    for the Renesas RL78 Simulator. */

    上記の関数は以下で呼び出されます。

    src/frtos_startup/freertos_start.c

    /******************************************************************************
    * Function Name: vPrintString
    * Description  : This function is used to write a string to a debug console.
    * Arguments    : None.
    * Return Value : None.
    ******************************************************************************/
    void vPrintString(const char *pcMessage)
    {
        /* Write the string to a debug console, using a critical section
        as a crude method of mutual exclusion. */

        extern void sim_debugger_console( const char *message );

        taskENTER_CRITICAL();
        {
            sim_debugger_console( pcMessage );
        }
        taskEXIT_CRITICAL();

    } /* End of function vPrintString() */

    Simulator GUIのパネルのLEDとButtonは以下の画面コピーの通りに設定にしました。また、この設定はCS+ではSimulator GUI起動時に自動的に再設定されたのですが、e2 studioでは再設定されませんでしたので、この設定を保存したファイルsim_rl78_visual_parts_panel.pnlをzipファイルに同梱しました。なお、LEDとButtonを接続する端子はGR-KURUMIで扱える端子を選択してみました。









    あと、以下は、Renesas RL78 Simulatorの起動設定の画面コピーです。

    CS+





    e2 studio


Children
No Data