xg_series_devel:boot_firmware:start

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
xg_series_devel:boot_firmware:start [2018/03/08 09:28]
admin
xg_series_devel:boot_firmware:start [2018/03/10 05:42] (現在)
admin [OpenOCD の接続]
ライン 1: ライン 1:
 +====== ファームウェアの書き込みと動作 ======
  
 +[[xg_series_devel:​clone_sources:​start]] でファームウェアのバイナリがビルドできましたので、実機に書き込んで動作させてみます。
 +
 +<​code>​
 +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
 +</​code>​
 +
 +\\
 +
 +===== ST-Link/V2 とコンソールケーブルの接続 =====
 +
 +Debugger(ST-Link/​V2) と USB-Serial ケーブルを接続しておきます。
 +
 +{{:​xg_series_devel:​boot_firmware:​xg-50_002.jpg?​640|ST-Link/​V2 and USB-Serial}}
 +
 +\\
 +
 +USB-Serial のポート名を確認し、ターミナルエミュレータで接続しておきます。
 +
 +<​code>​
 +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
 +</​code>​
 +
 +\\
 +
 +設定は下記の通りです。
 +
 +^  項目 ​ ^  値  |
 +|  ボーレート ​ |  115.2kbps ​ |
 +|  Bits  |  8bit  |
 +|  Stop  |  1bit  |
 +|  Parity ​ |  None  |
 +|  Flow  |  None  |
 +
 +\\
 +
 +{{:​xg_series_devel:​boot_firmware:​putty_window_01.png?​600|Putty}}
 +
 +\\
 +
 +===== OpenOCD の接続 =====
 +
 +XG-50 に OpenOCD で接続します。\\
 +設定ファイルはソースに同梱している **openocd.cfg**((WFI を有効にしてあるファームウェアが書込済みであっても接続可能になっています))を使用します。
 +
 +<​code>​
 +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
 +</​code>​
 +
 +\\
 +
 +===== gdb の接続 =====
 +
 +OpenOCD 経由で、XG-50 に gdb で接続します。OpenOCD を実行しているのと**別の**ターミナルから接続します。
 +
 +<​code>​
 +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) 
 +</​code>​
 +
 +接続できました。
 +
 +\\
 +
 +==== gdb 接続でエラーになる場合 ====
 +
 +.gdbinit で各種設定をしていますが、下記のようなエラーがでて接続できない場合があります。
 +
 +<​code>​
 +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) 
 +</​code>​
 +
 +表示されているとおり、下記内容で **~/​.gdbinit** を作成します。
 +
 +<file config .gdbinit>​
 +set auto-load safe-path /
 +</​file>​
 +
 +\\
 +
 +===== ファームウェアバイナリの書き込み =====
 +
 +接続ができたら、XG-50 をリセットし、ファームウェアのバイナリを書き込みます。
 +
 +==== リセット ====
 +
 +<​code>​
 +(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
 +</​code>​
 +
 +==== 書き込み ====
 +
 +<​code>​
 +(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)
 +</​code>​
 +
 +\\
 +
 +===== 実行 =====
 +
 +これでファームウェアバイナリが XG-50 に書き込みできましたので、早速実行してみます。\\
 +**c** コマンドで実行開始します。
 +
 +<​code>​
 +(gdb) c
 +Continuing.
 +</​code>​
 +
 +\\
 +
 +コンソールに NuttShell のプロンプトが出るのが確認できます。
 +
 +{{:​xg_series_devel:​boot_firmware:​putty_nuttshell_01.png?​600|NuttShell}}
 +
 +{{:​xg_series_devel:​boot_firmware:​putty_nuttshell_02.png?​600|各種コマンドを実行}}
 +
 +\\
xg_series_devel/boot_firmware/start.1520468914.txt.bz2 · 最終更新: 2018/03/08 09:28 by admin