コグノスケ


link 未来から過去へ表示  link 過去から未来へ表示(*)

link もっと前
2023年12月31日 >>> 2023年12月31日
link もっと後

2023年12月31日

VSCodeでRISC-Vボードをデバッグその3 - Linuxマシン側の準備(Akaria BSP)

目次: Linux

前回はLinuxマシンだけを使って、OpenOCDとGDBでRISC-Vボードをデバッグする方法を紹介しました。

今回はそのおまけです。VSCodeのデバッグの話を見たい方はその4をご覧ください。

デバッグ対象: Akaria NS31 on Arty 7

デバッグ対象は何でも良いと書きました。その例として、別のソフトウェア、別のボードを使うパターン(Akaria BSP + NS31 on Arty 7)を紹介します。

FPGAへの書き込み方は以前の日記(2023年4月24日の日記参照)でご紹介しました。そちらをご覧ください。

ツールチェーンのインストールをします。ディレクトリはどこでも良いですが、ここでは~/workで作業しているものとします。

RISC-V用ツールチェーンのインストール
$ cd ~/work
$ wget https://github.com/nsitexe/akaria-riscv-toolchain/releases/download/nsitexe-20231117/riscv64-unknown-elf_ubuntu22.tar.gz
$ tar xf riscv64-unknown-elf_ubuntu22.tar.gz
$ export PATH=~/work/riscv64-unknown-elf/bin:$PATH

$ riscv64-unknown-elf-gdb --version

GNU gdb (GDB) 13.0.50.20220805-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

次にAkaria BSPのビルドをします。

Akaria BSPのビルド
$ git clone https://github.com/nsitexe/akaria-bmetal
$ cd akaria-bmetal/
$ rm -r build
$ cmake -B build -G Ninja -DARCH=riscv \
    -DCROSS_COMPILE=riscv64-unknown-elf- \
    -DCC=gcc \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_INSTALL_PREFIX=test/sysroot/ \
    -DDEFCONF=riscv_nsitexe_ns31_arty

CMake Warning (dev) at CMakeLists.txt:3 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/lib/ccache/cc
---- CC is 'gcc'
---- Compiler is 'riscv64-unknown-elf-gcc'
---- CCASM is 'gcc'
---- Assembler is 'riscv64-unknown-elf-gcc'
---- DEFCONF is 'riscv_nsitexe_ns31_arty'
---- CONF dir is '/home/katsuhiro/work/akaria-bmetal/config'
---- ARCH dir is '/home/katsuhiro/work/akaria-bmetal/arch/riscv'
---- SOC dir is '/home/katsuhiro/work/akaria-bmetal/arch/riscv/nsitexe_ns31'
---- BOARD dir is '/home/katsuhiro/work/akaria-bmetal/board/riscv/nsitexe_ns31_arty'
---- arch  is riscv
---- march is 'rv32imafc_zicsr_zifencei'
---- mabi  is 'ilp32f'
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.4") found components: doxygen dot
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/katsuhiro/work/akaria-bmetal/build


$ ninja -C build install

ninja: Entering directory `build'
[46/47] Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/bin/add_auxdata
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/lib/libbmetal_crt.a
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/include/bmetal
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/include/bmetal/bmetal.h
-- Up-to-date: /home/katsuhiro/work/akaria-bmetal/test/sysroot/include/bmetal
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/include/bmetal/generated
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/include/bmetal/generated/autoconf.h
-- Installing: /home/katsuhiro/work/akaria-bmetal/test/sysroot/include/bmetal/generated/linker_gen.ld

テストアプリをビルドします。

Akaria BSPテストアプリのビルド
$ cd ~/work/akaria-bmetal/test
$ make USE_NEWLIB=y

ビルドできました。1つ目の端末にてOpenOCDを起動します。

OpenOCDの起動
$ sudo openocd -c 'bindto 0.0.0.0' -f tcl/interface/jlink.cfg -f ./openocd-ns31.cfg

JTAGインタフェース用の設定ファイルtcl/interface/jlink.cfgはその2(2023年12月30日の日記参照)にてご紹介しています。SEGGER J-Link以外のインタフェースをご利用の場合は適宜変更をお願いします。

NS31 on Arty 7用の設定ファイルopenocd-ns31.cfgは以前の日記(2023年4月7日の日記参照)にてご紹介しています。

2つ目の端末にてGDBを使ってロード&実行します。

GDBによるロード&実行
$ riscv64-unknown-elf-gdb hello

(gdb) target remote :3333
(gdb) monitor reset halt
(gdb) load
(gdb) continue

UARTから出力されていることを確認します。

NS31 on Arty 7のUART出力
$ pyserial-miniterm /dev/ttyUSB1 9600 --raw

--- Miniterm on /dev/ttyUSB1  9600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
hello world!
good bye world!

Zephyr + HiFive1のときとロード&実行方法は一緒です。最初はとっつきにくいかもしれませんが、OpenOCDとGDBの組み合わせであれば他のソフトウェア、他のボードでもほぼ一緒の使い勝手で便利です。

編集者:すずき(2024/01/05 16:54)

コメント一覧

  • コメントはありません。
open/close この記事にコメントする



link もっと前
2023年12月31日 >>> 2023年12月31日
link もっと後

管理用メニュー

link 記事を新規作成

<2023>
<<<12>>>
-----12
3456789
10111213141516
17181920212223
24252627282930
31------

最近のコメント5件

  • link 24年6月17日
    すずきさん (06/23 00:12)
    「ありがとうございます。バルコニーではない...」
  • link 24年6月17日
    hdkさん (06/22 22:08)
    「GPSの最初の同期を取る時は見晴らしのい...」
  • link 24年5月16日
    すずきさん (05/21 11:41)
    「あー、確かにdpkg-reconfigu...」
  • link 24年5月16日
    hdkさん (05/21 08:55)
    「システム全体のlocale設定はDebi...」
  • link 24年5月17日
    すずきさん (05/20 13:16)
    「そうですねえ、普通はStandardなの...」

最近の記事3件

  • link 22年3月18日
    すずき (06/22 17:32)
    「[射的 - まとめリンク] 目次: 射的一覧が欲しくなったので作りました。ガスガン その1ガスガン その2ガスガンが増えました...」
  • link 23年11月25日
    すずき (06/22 17:31)
    「[JTSA Limited大会参加2023] 目次: 射的JTSA Limitedの大会に参加しました。いつも使っているエアガ...」
  • link 24年5月26日
    すずき (06/22 17:16)
    「[JTSA Unlimited大会参加2024] 目次: 射的JTSA Unlimitedの大会に参加しました。去年は選手登録...」
link もっとみる

こんてんつ

open/close wiki
open/close Linux JM
open/close Java API

過去の日記

open/close 2002年
open/close 2003年
open/close 2004年
open/close 2005年
open/close 2006年
open/close 2007年
open/close 2008年
open/close 2009年
open/close 2010年
open/close 2011年
open/close 2012年
open/close 2013年
open/close 2014年
open/close 2015年
open/close 2016年
open/close 2017年
open/close 2018年
open/close 2019年
open/close 2020年
open/close 2021年
open/close 2022年
open/close 2023年
open/close 2024年
open/close 過去日記について

その他の情報

open/close アクセス統計
open/close サーバ一覧
open/close サイトの情報

合計:  counter total
本日:  counter today

link About www.katsuster.net
RDFファイル RSS 1.0

最終更新: 06/23 00:12