LoginSignup
14
5

More than 5 years have passed since last update.

WSLでマイコンシミュレータ環境(athrill)をつくる

Last updated at Posted at 2018-09-10

概要

ここ数年で Windows/ubuntu環境(WSL)を容易に使えるようになりましたが、最近、組込み向けマイコンシミュレータ環境(athrill)もPC上で簡単に構築できるようになったようです。

そこで、WSLを使ってathrill(アスリル)環境を簡単に使えるようにできたので、ご紹介します!

必要なもの

  • WSL (ubuntu 16.04)
  • VS Code
  • Athrill本体
  • V850 クロスコンパイラ

1. 各種ダウンロード

WSLのインストール

  1. [プログラムと機能]から[windowsの機能の有効化または無効化]を開き[Windows Subsystem for Linux]にチェック。再起動。
  2. Microsoft storeから「Ubuntu」で検索し、Ubuntu 16.04インストール。

VS Codeのインストール

以下からダウンロード

Visual Studio Code - Code Editing. Redefined

Athrillのダウンロード

ここの手順はWSL上で行う。
1. cd /mnt/c/ でWSL上からCドライブ直下に移動する。
2. mkdir project projectフォルダを作成。
3. Athrillをprojectフォルダにクローンする。

  $ cd ~/project
  $ git clone https://github.com/tmori/athrill.git

V850クロスコンパイラのダウンロード

  1. https://gcc-renesas.com/ja/v850/v850-download-toolchains/ のインストール
    • GNUV850 v14.01 Windows Toolchain (ELF)を選択。
  • アカウントの作成が必須となります。

  • インストーラーの途中で求められる"Activate Code"は公式サイト左上からアクセスできるレガシーコードを使用すること。


2. 環境設定

WSL側の手順

1. dash → bashに変更

$ ls -l /bin/shで dashが表示される場合、以下のコマンドでbashに変更する。
- $ sudo dpkg-reconfigure dash→NOを選択。

参考:

https://qiita.com/tashua314/items/86c87ababa42064ce5ed

2. Athrillフォルダへのショートカットリンクを作成

$ ln -s /mnt/c/project/athrill ~/athrill

3. Athrillのbinのパスを通す

.bashrc末尾に以下を追加する。

  export PATH=/mnt/c/project/athrill/bin/linux/:${PATH}
  export PATH=${HOME}/bin/:${PATH}

V850クロスコンパイラ

  1. 空白文字を含むフォルダを避けるため、Windows上からC:/Program Files(x86)/KPITC:/KPITに移動。
    ===以下WSL上で作業===

  2. $ mkdir ~/binでbinフォルダを作成。

  3. binフォルダ内にget_cmd.shを以下の内容で作成。

    #!/bin/sh
    
    echo "${1}" | awk -F\.exe '{print $1}' | awk -F\/ '{print $NF}'
    
  4. $ ls /mnt/c/KPIT/GNUV850v14.01-ELF/v850-elf/bin/*.exe > list.txtでテキストに書き出す。

  5. binファイル内で以下のコマンドを実行することで、シンボリックリンクを作成する。

    $ for i in `cat list.txt`; do ln -s $i `sh get_cmd.sh $i`; done

VSCodeの設定

  1. 起動し、左下歯車マーク→Settingから設定画面を開き、上部検索欄に「terminal.integrated.shell.windows」と入力。

  2. パスに以下を設定する。

   C:\\WINDOWS\\System32\\bash.exe

(以下、直接ユーザ設定ファイルを編集する場合のサンプル)

   {
    "team.showWelcomeMessage": false,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe",
    "terminal.integrated.rendererType": "dom",
    "git.ignoreMissingGitWarning": true,
    "window.zoomLevel": 5,
   }

Makeする

$ sudo apt update
$ sudo apt install make gcc

$ cd /athrill/trunk/src/build/target/linux_v850e2m
$ make clean
$ make

動作確認

athrill2をオプションなしで実行し、以下のような表示がでればインストールの完了です。良いAthrillライフを!

$ athrill2
Usage:athrill -m <memory config file> [OPTION]... <load_file>
 -i                             : execute on the interaction mode. if -i is not set, execute on the background mode.
 -r                             : execute on the remote mode. this option is valid on the interaction mode.
 -t<timeout>                    : set program end time using <timeout> clocks. this option is valid on the background mode.
 -m<memory config file>         : set athrill memory configuration. rom, ram region is configured on your system.
 -d<device config file>         : set device parameter.
14
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
5