Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
314 changes: 178 additions & 136 deletions source/ide/projectrun.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Nuclei Studio 调试运行工程
==========================

在进行工程调试前,可以先检验一下当前的硬件环境是否正确无误,可以参考 :ref:`Nuclei Studio调试工程前的硬件检测 <faq_27>` 。
在进行工程调试前,可以先检验一下当前的硬件环境是否正确无误,可以参考 :ref:`Nuclei Studio调试工程前的硬件检测 <faq_27>` 。

.. _ide_projectrun_1:

Expand Down Expand Up @@ -566,113 +566,143 @@ Dlink连接后,在串口工具下,可以看到两个COM口,一个COM串用

并可以查看到串口中有正确的内容输出,与预期一致,则Dlink可以正常调试,其他操作步骤与OpenOCD大体一致。

|image59|


.. _ide_connect_to_target:

Connect to Running Target
---------------------------

为了满足用户直接连接到开发板的需求,Nuclei Studio 新增了 ``Connect to Running Target`` 功能。该功能支持直接连接正在运行的硬件目标板,用户可以进行如读取开发板相关信息等操作,极大方便了开发的效率。

在Nuclei Studio中 ``Connect to Running Target`` 仅支持OpenOCD和Jlink两种方式。下面以OpenOCD的方式来展示 ``Connect to Running Target`` 的使用。

使用 ``Connect to Running Target`` 功能非常简单。连接好开发板,并创建一个demo工程,当工程编译好后选中工程,在鼠标右键弹出的菜单,或者在IDE的工具菜单中找到 ``Connect to Running Target`` 菜单并点击。

|image75|

在console窗口中可以看到,gdb尝试连接到开发板中。

|image76|

当IDE连接上开发板后,用户可以通过IDE的 ``Debugger Console`` 工具来发送gdb命令来查看开发板当前的一些信息。

|image77|

.. _ide_flash_programming:

Flash Programming
------------------

为了满足用户将编译好的二进制文件直接下载到硬件开发板的需求,Nuclei Studio 新增了 Flash Programming 功能。该功能允许用户快速、便捷地将编译好的二进制文件直接下载到硬件开发板中,极大提升了开发和调试的效率;简化操作流程,用户只需点击一次即可完成二进制文件的下载。工程编译好后,找到Flash Programming,并点击,即可完成二进制文件的下载。

|image64|

用户也可以修改其相关的配置信息,在Launch Bar中点击配置按钮,打开配置页面,然后选中Flash Programming选项卡。

|image65|

**Load Program Image**

Load的文件,默认的elf格式的文件,也可以支持 ``*.bin、*.hex、*.s19、*.srec、*.symbolsrec`` 等各种格式

|image66|

**Flash Programming Options**

Flash Programming的选项有以下三个

- Verify Image:在烧录完成后,会校验烧录的镜像文件与当前连接的目标设备上下载进去的文件是否一致,确保烧录成功。

- Reset and Run:烧录完成后,让CPU复位并运行,需要注意如果勾选了 Load in RAM, 则只会运行不会复位(如程序烧录在RAM中,复位将会使程序丢失)。

- Load in Ram:勾选这个表示固件需要下载到内存中,而不是Flash等非易失性存储器上,选中后,必须指定Program Address。

.. note::

Load in Ram勾选和不勾选固件下载方式不一样,所使用的OpenOCD命令也不同,后续文档中有详细介绍,请仔细阅读并根据实际情况准确选择。

上述参数的使用,与工程的Download模式匹配,Nuclei Studio中默认支持 ``DDR/ILM/SRAM/FLASH/FLASHXIP`` 。

当工程Download模式是 ``DDR/ILM/SRAM`` 时,``Load in Ram`` 必须选中,同时 ``Program Address`` 地址也不能为空,这里的 ``Program Address`` 地址是程序烧写入Ram时的第一个地址。

一般 ``Program Address`` 可以在 ``*.map`` 文件中找到,或者执行 riscv64-unknown-elf-readelf -h /path/to/your.elf后查看Entry point address,本文档仅介绍从 ``*.map`` 文件中查找 ``Program Address`` 。

打开 ``*.map`` 文件,搜索 ``Linker script and memory map`` ,然后找到 ``.init`` 后面的这个地址就是 ``Program Address`` 。

|image72|

当选中 ``Load in Ram`` 时, 同时选中 ``Verify Image`` ,命令行中将多一行命令 ``-c "verify_image Debug/test.elf"`` ,此时是通过 ``verify_image`` 命令来实现镜像文件的检查。

当选中 ``Load in Ram`` 时, 同时选中 ``Reset and Run`` 、命令行中将多一行命令 ``-c "resume 0x80000000; shutdown"`` ,此时是通过 ``resume`` 命令来实现load后可能强制系统复位。

.. code-block:: console

-c "set BOOT_HARTID 0;"
-f "nuclei_sdk/SoC/evalsoc/Board/nuclei_fpga_eval/openocd_evalsoc.cfg"
-c 'echo "Start to program Debug/test.elf to 0x80000000"'
-c "load_image Debug/test.elf"
-c "verify_image Debug/test.elf"
-c "resume 0x80000000; shutdown"

|image73|

当工程Download模式是 ``FLASH/FLASHXIP`` 时,则不勾选 ``Load in Ram``,并且 ``Program Address`` 为必须为空。

当选中 ``Verify Image`` ,命令行中将多一行命令 ``verify`` ,此时是通过 ``verify`` 命令来实现镜像文件的检查。

当选中 ``Reset and Run`` ,命令行中将多一行命令 ``reset`` ,此时是通过 ``reset`` 命令来实现load后可能强制系统复位。

.. code-block:: console

-c "set BOOT_HARTID 0;"
-f "nuclei_sdk/SoC/evalsoc/Board/nuclei_fpga_eval/openocd_evalsoc.cfg"
-c 'echo "Start to program Debug/test.elf"'
-c "program Debug/test.elf verify reset exit"

|image74|

**OpenOCD Flash Programming Command line**

Flash Programming中的参数最终将通过OpenOCD执行。默认情况下, ``Customize openocd flash programming command line`` 选项是未选中的。当您勾选 ``Customize openocd flash programming command line`` 时,所有其他相关选项将失效。此时,您可以直接在下方的输入框中输入自定义命令。

如果您对OpenOCD命令有足够的了解,可以尝试自定义命令以满足特定需求。然而,如果您不熟悉OpenOCD命令行操作,建议不要勾选此选项,以免导致配置错误。

|image70|

根据需求配置好参数后,点击Flash Programming就可以下载二进制代码到硬件中,下载成功的结果如下图。

|image59|


.. _ide_connect_to_target:

Connect to Running Target
---------------------------

为了满足用户直接连接到开发板的需求,Nuclei Studio 新增了 ``Connect to Running Target`` 功能。该功能支持直接连接正在运行的硬件目标板,用户可以进行如读取开发板相关信息等操作,极大方便了开发的效率。

在Nuclei Studio中 ``Connect to Running Target`` 仅支持OpenOCD和Jlink两种方式。下面以OpenOCD的方式来展示 ``Connect to Running Target`` 的使用。

使用 ``Connect to Running Target`` 功能非常简单。连接好开发板,并创建一个demo工程,当工程编译好后选中工程,在鼠标右键弹出的菜单,或者在IDE的工具菜单中找到 ``Connect to Running Target`` 菜单并点击。

|image75|

在console窗口中可以看到,gdb尝试连接到开发板中。

|image76|

当IDE连接上开发板后,用户可以通过IDE的 ``Debugger Console`` 工具来发送gdb命令来查看开发板当前的一些信息。

|image77|

查看Nuclei CPU Information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Connect to Running Target 后,用户可以通过IDE的 ``Debugger Console`` 工具来发送命令 ``info reg misa`` 来查看当前 CPU 的 misa 信息。misa 会直接在 ``Debugger Console`` 中显示。

|image78|


用户也可以通过IDE的 ``Debugger Console`` 工具来发送命令 ``monitor nuclei cpuinfo`` 查看当前 Nuclei CPU Information ,因为 eclipse 的机制,Nuclei CPU Information 可能不会在 ``Debugger Console`` 中显示,但可以在 ``gdb trace`` 中查看到。

首先,打开 ``gdb trace`` 功能。在Nuclei Studio 中打开菜单 ``Windows -> Preferences``。

|image79|

搜索 ``gdb``,在 gdb 配置页中找到并勾选 ``Show the GDB trace console with character limit`` 。

|image80|

通过IDE的 ``Debugger Console`` 工具来发送命令 ``monitor nuclei cpuinfo`` 。

|image81|

然后在 ``Console`` 窗口中找到 ``gdb trace`` 视图并打开。

|image82|

在 ``gdb trace`` 视图中可以查看到 Nuclei CPU Information。

|image83|

.. _ide_flash_programming:

Flash Programming
------------------

为了满足用户将编译好的二进制文件直接下载到硬件开发板的需求,Nuclei Studio 新增了 Flash Programming 功能。该功能允许用户快速、便捷地将编译好的二进制文件直接下载到硬件开发板中,极大提升了开发和调试的效率;简化操作流程,用户只需点击一次即可完成二进制文件的下载。工程编译好后,找到Flash Programming,并点击,即可完成二进制文件的下载。

|image64|

用户也可以修改其相关的配置信息,在Launch Bar中点击配置按钮,打开配置页面,然后选中Flash Programming选项卡。

|image65|

**Load Program Image**

Load的文件,默认的elf格式的文件,也可以支持 ``*.bin、*.hex、*.s19、*.srec、*.symbolsrec`` 等各种格式

|image66|

**Flash Programming Options**

Flash Programming的选项有以下三个

- Verify Image:在烧录完成后,会校验烧录的镜像文件与当前连接的目标设备上下载进去的文件是否一致,确保烧录成功。

- Reset and Run:烧录完成后,让CPU复位并运行,需要注意如果勾选了 Load in RAM, 则只会运行不会复位(如程序烧录在RAM中,复位将会使程序丢失)。

- Load in Ram:勾选这个表示固件需要下载到内存中,而不是Flash等非易失性存储器上,选中后,必须指定Program Address。

.. note::

Load in Ram勾选和不勾选固件下载方式不一样,所使用的OpenOCD命令也不同,后续文档中有详细介绍,请仔细阅读并根据实际情况准确选择。

上述参数的使用,与工程的Download模式匹配,Nuclei Studio中默认支持 ``DDR/ILM/SRAM/FLASH/FLASHXIP`` 。

当工程Download模式是 ``DDR/ILM/SRAM`` 时,``Load in Ram`` 必须选中,同时 ``Program Address`` 地址也不能为空,这里的 ``Program Address`` 地址是程序烧写入Ram时的第一个地址。

一般 ``Program Address`` 可以在 ``*.map`` 文件中找到,或者执行 riscv64-unknown-elf-readelf -h /path/to/your.elf后查看Entry point address,本文档仅介绍从 ``*.map`` 文件中查找 ``Program Address`` 。

打开 ``*.map`` 文件,搜索 ``Linker script and memory map`` ,然后找到 ``.init`` 后面的这个地址就是 ``Program Address`` 。

|image72|

当选中 ``Load in Ram`` 时, 同时选中 ``Verify Image`` ,命令行中将多一行命令 ``-c "verify_image Debug/test.elf"`` ,此时是通过 ``verify_image`` 命令来实现镜像文件的检查。

当选中 ``Load in Ram`` 时, 同时选中 ``Reset and Run`` 、命令行中将多一行命令 ``-c "resume 0x80000000; shutdown"`` ,此时是通过 ``resume`` 命令来实现load后可能强制系统复位。

.. code-block:: console

-c "set BOOT_HARTID 0;"
-f "nuclei_sdk/SoC/evalsoc/Board/nuclei_fpga_eval/openocd_evalsoc.cfg"
-c 'echo "Start to program Debug/test.elf to 0x80000000"'
-c "load_image Debug/test.elf"
-c "verify_image Debug/test.elf"
-c "resume 0x80000000; shutdown"

|image73|

当工程Download模式是 ``FLASH/FLASHXIP`` 时,则不勾选 ``Load in Ram``,并且 ``Program Address`` 为必须为空。

当选中 ``Verify Image`` ,命令行中将多一行命令 ``verify`` ,此时是通过 ``verify`` 命令来实现镜像文件的检查。

当选中 ``Reset and Run`` ,命令行中将多一行命令 ``reset`` ,此时是通过 ``reset`` 命令来实现load后可能强制系统复位。

.. code-block:: console

-c "set BOOT_HARTID 0;"
-f "nuclei_sdk/SoC/evalsoc/Board/nuclei_fpga_eval/openocd_evalsoc.cfg"
-c 'echo "Start to program Debug/test.elf"'
-c "program Debug/test.elf verify reset exit"

|image74|

**OpenOCD Flash Programming Command line**

Flash Programming中的参数最终将通过OpenOCD执行。默认情况下, ``Customize openocd flash programming command line`` 选项是未选中的。当您勾选 ``Customize openocd flash programming command line`` 时,所有其他相关选项将失效。此时,您可以直接在下方的输入框中输入自定义命令。

如果您对OpenOCD命令有足够的了解,可以尝试自定义命令以满足特定需求。然而,如果您不熟悉OpenOCD命令行操作,建议不要勾选此选项,以免导致配置错误。

|image70|

根据需求配置好参数后,点击Flash Programming就可以下载二进制代码到硬件中,下载成功的结果如下图。

|image71|

.. |image1| image:: /asserts/nucleistudio/projectrun/image2.png
Expand Down Expand Up @@ -800,31 +830,43 @@ Flash Programming中的参数最终将通过OpenOCD执行。默认情况下, `
.. |image62| image:: /asserts/nucleistudio/projectrun/image62.png

.. |image63| image:: /asserts/nucleistudio/projectrun/image63.png

.. |image64| image:: /asserts/nucleistudio/projectrun/image64.png

.. |image65| image:: /asserts/nucleistudio/projectrun/image65.png

.. |image66| image:: /asserts/nucleistudio/projectrun/image66.png

.. |image67| image:: /asserts/nucleistudio/projectrun/image67.png

.. |image68| image:: /asserts/nucleistudio/projectrun/image68.png

.. |image69| image:: /asserts/nucleistudio/projectrun/image69.png

.. |image70| image:: /asserts/nucleistudio/projectrun/image70.png

.. |image71| image:: /asserts/nucleistudio/projectrun/image71.png

.. |image72| image:: /asserts/nucleistudio/projectrun/image72.png

.. |image73| image:: /asserts/nucleistudio/projectrun/image73.png

.. |image74| image:: /asserts/nucleistudio/projectrun/image74.png

.. |image75| image:: /asserts/nucleistudio/projectrun/image75.png

.. |image76| image:: /asserts/nucleistudio/projectrun/image76.png

.. |image77| image:: /asserts/nucleistudio/projectrun/image77.png

.. |image64| image:: /asserts/nucleistudio/projectrun/image64.png

.. |image65| image:: /asserts/nucleistudio/projectrun/image65.png

.. |image66| image:: /asserts/nucleistudio/projectrun/image66.png

.. |image67| image:: /asserts/nucleistudio/projectrun/image67.png

.. |image68| image:: /asserts/nucleistudio/projectrun/image68.png

.. |image69| image:: /asserts/nucleistudio/projectrun/image69.png

.. |image70| image:: /asserts/nucleistudio/projectrun/image70.png

.. |image71| image:: /asserts/nucleistudio/projectrun/image71.png

.. |image72| image:: /asserts/nucleistudio/projectrun/image72.png

.. |image73| image:: /asserts/nucleistudio/projectrun/image73.png

.. |image74| image:: /asserts/nucleistudio/projectrun/image74.png

.. |image75| image:: /asserts/nucleistudio/projectrun/image75.png

.. |image76| image:: /asserts/nucleistudio/projectrun/image76.png

.. |image77| image:: /asserts/nucleistudio/projectrun/image77.png

.. |image78| image:: /asserts/nucleistudio/projectrun/image78.png

.. |image79| image:: /asserts/nucleistudio/projectrun/image79.png

.. |image80| image:: /asserts/nucleistudio/projectrun/image80.png

.. |image81| image:: /asserts/nucleistudio/projectrun/image81.png

.. |image82| image:: /asserts/nucleistudio/projectrun/image82.png

.. |image83| image:: /asserts/nucleistudio/projectrun/image83.png