NuttX のビルド でファームウェアのバイナリがビルドできましたので、実機に書き込んで動作させてみます。
xubuntu64:~/src/NuttX/nuttx$ ls -ln nuttx* -rwxrwxr-x 1 1000 1000 1959884 3月 7 14:06 nuttx -rwxrwxr-x 1 1000 1000 116948 3月 7 14:06 nuttx.bin -rw-rw-r-- 1 1000 1000 329007 3月 7 14:06 nuttx.hex xubuntu64:~/src/NuttX/nuttx
Debugger(ST-Link/V2) と USB-Serial ケーブルを接続しておきます。
USB-Serial のポート名を確認し、ターミナルエミュレータで接続しておきます。
ryzen7:~$ dmesg |tail -5 [83629.247281] usb 1-4.4: Manufacturer: FTDI [83629.247283] usb 1-4.4: SerialNumber: FT9ZOTM2 [83629.272759] ftdi_sio 1-4.4:1.0: FTDI USB Serial Device converter detected [83629.272793] usb 1-4.4: Detected FT232RL [83629.282853] usb 1-4.4: FTDI USB Serial Device converter now attached to ttyUSB6
設定は下記の通りです。
項目 | 値 |
---|---|
ボーレート | 115.2kbps |
Bits | 8bit |
Stop | 1bit |
Parity | None |
Flow | None |
XG-50 に OpenOCD で接続します。
設定ファイルはソースに同梱している openocd.cfg1)を使用します。
develop:~/src/NuttX_XG50/nuttx$ sudo openocd -f openocd.cfg Open On-Chip Debugger 0.10.0-00012-gc3826e5-dirty (2017-10-19-10:56) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD adapter speed: 500 kHz adapter_nsrst_delay: 100 srst_only separate srst_nogate srst_open_drain connect_assert_srst Info : Unable to match requested speed 500 kHz, using 480 kHz Info : Unable to match requested speed 500 kHz, using 480 kHz Info : clock speed 480 kHz Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748 Info : using stlink api v2 Info : Target voltage: 3.289941 Info : stm32l4x.cpu: hardware has 6 breakpoints, 4 watchpoints srst_only separate srst_nogate srst_open_drain connect_deassert_srst
OpenOCD 経由で、XG-50 に gdb で接続します。OpenOCD を実行しているのと別のターミナルから接続します。
develop:~/src/NuttX_XG50/nuttx$ arm-none-eabi-gdb nuttx GNU gdb (7.10-1ubuntu3+9) 7.10 Copyright (C) 2015 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. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from nuttx...done. 0x00000000 in ?? () (gdb)
接続できました。
.gdbinit で各種設定をしていますが、下記のようなエラーがでて接続できない場合があります。
develop:~/src/NuttX_XG50/nuttx$ arm-none-eabi-gdb nuttx GNU gdb (7.10-1ubuntu3+9) 7.10 Copyright (C) 2015 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. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from nuttx...done. warning: File "/home/kikuchi/src/NuttX_XG50/nuttx/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". To enable execution of this file add add-auto-load-safe-path /home/kikuchi/src/NuttX_XG50/nuttx/.gdbinit line to your configuration file "/home/kikuchi/.gdbinit". To completely disable this security protection add set auto-load safe-path / line to your configuration file "/home/kikuchi/.gdbinit". For more information about this security protection see the "Auto-loading safe path" section in the GDB manual. E.g., run from the shell: info "(gdb)Auto-loading safe path" (gdb)
表示されているとおり、下記内容で ~/.gdbinit を作成します。
set auto-load safe-path /
接続ができたら、XG-50 をリセットし、ファームウェアのバイナリを書き込みます。
(gdb) reset_halt Unable to match requested speed 500 kHz, using 480 kHz Unable to match requested speed 500 kHz, using 480 kHz adapter speed: 480 kHz srst_only separate srst_nogate srst_open_drain connect_deassert_srst target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08000188 msp: 0x2000657c
(gdb) flashwrite nuttx auto erase enabled target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x20000050 msp: 0x2000657c block write succeeded wrote 118784 bytes from file nuttx in 5.169585s (22.439 KiB/s)
これでファームウェアバイナリが XG-50 に書き込みできましたので、早速実行してみます。
c コマンドで実行開始します。
(gdb) c Continuing.
コンソールに NuttShell のプロンプトが出るのが確認できます。