How to debug Mbed program on GR-PEACH using Offline Development Tools

At present, not only online but offline development tools are available. The online tools are Mbed online compiler, while offline tools are known as mbed CLI. In this Notebook, the following items are described so that you can debug Mbed program on GR-PEACH using offline development tools.

Offline Development Tools - mbed CLI

mbed CLI is the command-line tool providing the following functionalities:

  • Git- and Mercurial- based version control
  • Dependency management
  • Code publishing
  • Support for remotely hosted repositories (e.g. GitHub, GitLab, mbed.org, etc.)
  • Use of ARM mbed OS build system
  • Export functions
    etc.

For details on mbed CLI, please refer to the following URL:
https://github.com/ARMmbed/mbed-cli

Installation

With respect to the installation of mbed CLI, please refer to the following video:

Here is the URL for downloading the tools to be required for installation:

C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin
C:\Program Files\Mercurial
C:\Program Files\Git
C:\Python27\Scripts

After the installation is completed, you can check if the installation of python, git and mercurial is succeeded by the following command, respectively:

$ python --version
$ git --version
$ hg --version


Then, you can install mbed-cli. One way to install it is to use pip as follows:

$ pip install mbed-cli


If the expected version is shown on the command line, you can think the installation is successfully done,

Importing programs

You can import the programs based on mbed OS 2 and mbed OS 5 using mbed CLI. Here is the way for importing mbed-os-example-blinky (https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky):

  1. Launch terminal (e.g. command prompt on windows PC)
  2. Move to the directory where you would like to import the program by cd command
  3. Invoke the following command
$ mbed import https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky

Note that import may takes time. After import is completed, mbed-os-example-blinky directory should be created, and ready to build the program.

Build programs

You can use mbed compile command to build programs.
In order to specify GR-PEACH and GCC ARM Embedded for target platform and toolchain, respectively, you should specify RZ_A1H for the option -m and GCC_ARM for the option -t described below:

$ mbed compile -m RZ_A1H -t GCC_ARM --profile debug


Here is the actual log when building "mbed-os-example-blinky":

Building project mbed-os-example-blinky (RZ_A1H, GCC_ARM)
Scan: .
Scan: FEATURE_BLE
Scan: FEATURE_COMMON_PAL
Scan: FEATURE_LWIP
Scan: FEATURE_UVISOR
Scan: FEATURE_ETHERNET_HOST
Scan: FEATURE_LOWPAN_BORDER_ROUTER
Scan: FEATURE_LOWPAN_HOST
Scan: FEATURE_LOWPAN_ROUTER
Scan: FEATURE_NANOSTACK
Scan: FEATURE_NANOSTACK_FULL
Scan: FEATURE_THREAD_BORDER_ROUTER
Scan: FEATURE_THREAD_END_DEVICE
Scan: FEATURE_THREAD_ROUTER
Scan: FEATURE_STORAGE
Scan: mbed
Scan: env
Compile [  0.4%]: cache.S
Compile [  0.8%]: AnalogIn.cpp
Compile [  1.2%]: BusIn.cpp
Compile [  1.6%]: BusInOut.cpp
Compile [  2.0%]: main.cpp

///Omission///

Compile [100.0%]: test_env.cpp
Link: mbed-os-example-blinky
Elf2Bin: mbed-os-example-blinky
+------------------------+-------+-------+-------+
| Module                 | .text | .data |  .bss |
+------------------------+-------+-------+-------+
| Fill                   |  1053 |     9 |     7 |
| Misc                   | 20204 |  2180 |   108 |
| cmsis/TOOLCHAIN_GCC    |   180 |     0 |     0 |
| drivers                |   184 |     4 |   716 |
| hal                    |   608 |     0 |     8 |
| platform               |  1890 |     4 |   269 |
| rtos                   |    56 |     4 |     4 |
| rtos/rtx               |  9737 |    21 | 21139 |
| targets/TARGET_RENESAS |  8732 |     6 |  3129 |
| Subtotals              | 42644 |  2228 | 25380 |
+------------------------+-------+-------+-------+
Allocated Heap: 524288 bytes
Allocated Stack: 82688 bytes
Total Static RAM memory (data + bss): 27608 bytes
Total RAM memory (data + bss + heap + stack): 634584 bytes
Total Flash memory (text + data + misc): 44872 bytes

Image: .\BUILD\RZ_A1H\GCC_ARM\mbed-os-example-blinky.bin

You can confirm the place of a binay file generated in the last line of build message.

Image: .\BUILD\RZ_A1H\GCC_ARM\mbed-os-example-blinky.bin


Then, you should copy the resultant binary file (.bin) to the USB drive named mbed which should be detected by connecting GR-PEACH to your PC for flashing the program.

For more detail on the usage of mbed CLI, please refer to the following video:


How to debug programs on Offline Environment (e2studio)

GR-PEACH can use Eclipse-based e2studio and OpenOCD for debugging programs offline. Here is the procedure for the debug:

  • Requisite
  • Debug Procedure
    Please launch e2studio and follow the procedure stated below:
    • Create a empty project.
    • Open Debug Configurations from the menu Run - Debug Configurations... as shown below:
      /media/uploads/HinoNaka/debug_configuration_1.png
    • Double-click GDB OpenOCD Debugging highlighted in the following figure: /media/uploads/HinoNaka/debug_configuration_2.png
    • Specify the full pathname of the elf file (.elf) generated in build process at C/C++ Application: in the area highlighted in the following figure: /media/uploads/HinoNaka/debug_configuration_3.png
    • Click the Debugger tab and apply the following configurations:
      • Write in -f board/renesas_gr-peach.cfg into Config options: of OpenOCD Setup
      • Replace the string stated in Excecutable: of GDB Client Setup with arm-none-eabi-gdb /media/uploads/HinoNaka/debug_configuration_4.png
    • Click the Startup tab and apply the following changes:
      • Uncheck Initial Reset. and Enable ARM semihosting. of Initialization Commands
      • Uncheck Load executable of Load Symbols and Executable /media/uploads/HinoNaka/debug_configuration_5.png
    • Click Apply button
    • Plug microUSB cable into GR-PEACH's connector lying opposite to RJ45 connector
    • Copy binary file (*.bin) to the USB drive named mbed:
    • Unplug USB cable from GR-PEACH, then re-plug it
    • Click Debug button

A.O.B

  • Reset GR-PEACH via e2Studio
    You can reset GR-PEACH by inputting the following command to Console: /media/uploads/HinoNaka/debug_configuration_6.png
monitor reset init
  • Way to change build options
    Build option is specified by the json file (*.json) below:
$(project)\mbed-os\tools\profiles\debug.json

Note that $(project) is the directory created when invoking mbed import command. By editing the option which is labeled with GCC_ARM, you can build programs under expected option.

Information

The file location and/or name might be changed in the later version of Mbed OS. If you won't be able to find out the above json file, please search the symbol name of option in order to identify where the file is located.

After that you need to re-invoke mbed compile command with -c option so that the binary and elf file can be updated accordingly. In this case, there is no difference in the above mentioned debug procedure.


Please log in to post comments.