HOWTO: Debugging LAX on S32R45 Using S32 Debugger

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOWTO: Debugging LAX on S32R45 Using S32 Debugger

HOWTO: Debugging LAX on S32R45 Using S32 Debugger

The NXP device S32R45 has accelerators that can be programmed. The S32 Debugger included within the S32 Design Studio for S32 Platform IDE with the S32 Debug Probe provides the ability to debug these accelerators. The accelerator covered in this document: Linear Algebra Accelerator (LAX).

Section map:

Preparation

Setup the software tools
Setup the hardware

Procedure

Create A New Debug Configuration

Simulator
Physical Hardware

Start A Debug Session

Standalone
Multi-Core
Debugging LAX Once Debug Session is Started
Multi-thread LAX Debugging: IPPU & VCPU
Multi-LAX-core Debugging

 

Preparation

  1. Setup the software tools
    1. Install S32 Design Studio for S32 Platform
    2. Install the S32R4xx development package and the Radar extension package for S32R4xx. Both of these are required for the LAX accelerator.
      image.png
  2. Setup the hardware
    1. Confirm the setup of the S32R45 evaluation board.
      1. Connect the power supply cable
    2. Setup the S32 Debug Probe. Refer to the S32 Debug Probe User Manual for installation instructions.
      1. Connect the S32 Debug Probe to the evaluation board via JTAG cable.
      2. Connect the S32 Debug Probe to the host PC via USB cable OR via Ethernet cable (via LAN or directly connected and configured for static IP address) and power supply connected to USB port.
  3. Launch S32 Design Studio for S32 Platform
  4. Open existing project or create a new project and check that it successfully builds. If creating a new project, be sure the S32 Debugger is selected in the New Project Wizard.
    image.png
    image.png

 

Procedure
The procedure for starting a debug session and accessing the associated accelerator-specific registers is detailed here.
Application code executing on the LAX accelerator can be debugged using a simulation as well as on physical hardware.
Debugging using simulation occurs entirely on the PC and no physical hardware is required.

When debugging LAX on physical hardware, this is primarily conducted through one of two methods:

  1. Standalone: the LAX executable is loaded by a debugger over JTAG using a probe and only the LAX core is executed and available for debugging.
  2. Multi-core: the LAX executable is included within A53 executable, the A53 application loads the LAX executable to the LAX core and both A53 and LAX core are available for debugging. The debug connection is made to the two cores through one of two methods:
    1. Baremetal/Bareboard: the debugger connects to both the A53 and LAX cores using the probe over JTAG.
    2. Linux BSP: the debugger connects to the A53 core, which is running Linux BSP, using a remote Linux connection over Ethernet and then connects to the LAX core using the debug probe over JTAG.

Before a debug session can be started a debug configuration must exist.

Create A New Debug Configuration
If the New Project Wizard was used to create the project using the S32DS Application Project option, then there was an opportunity to select the desired debugger from within the wizard. If the desired debugger option was selected at this time, then the needed configuration already exists and will only require adjustments to the hardware connection settings (no hardware settings for LAX Simulator).
image.png
If the New Project Wizard was not used to create the project OR the currently desired debugger was not the one selected at the time of project creation, a new debug configuration must be created.

  1. With the existing project selected in Project Explorer, open the Debug Configurations Menu: Run -> Debug Configurations
    image.png
    Having the existing project selected in the Project Explorer view will make the creation of a new launch configuration easier as many settings will be imported from the selected project. To select a project, click on it so it becomes highlighted.

  2. Next, select the debugger for which the new debug configuration will be created.
    image.png

Simulator

  1. To create the new configuration, either click on the ‘New launch configuration’ button from the toolbar at the top and to the left, or right-click on the ‘LAX Simulator’ and select ‘New Configuration’ from the menu.
    image.png
  2. Once the configuration is created it will be displayed and any errors with the configuration will be shown. If the project was selected in the Project Explorer, then the Name of the debug configuration will contain the project’s name and the Project and C/C++ Application fields will be populated as well. The C/C++ Application field will only be populated if the build output executable exists. Confirm these values are correct before moving on.
    image.png
  3. There is an error showing that the Device core ID is not specified on the Debugger tab. Switch to the Debugger tab and click on the button ‘Select device and core’.
    image.png
  4. From the Select Target Device and Core window, expand the listing until all cores are listed. Since the LAX Simulator only supports LAX cores on the S32R45, that is all which is listed. Select the desired LAX core and click OK.
    image.png
  5. Now that the device and core are selected, the only correct initialization script associated with the LAX is selected automatically.
    image.png
  6. No further changes are required. Click Apply to save the changes or if you are ready to debug with the LAX Simulator, then click Debug and the changes will be saved and the debug session will launch.

Physical Hardware

  1. To create the new configuration, either click on the ‘New launch configuration’ button from the toolbar at the top and to the left, or right-click on the ‘S32 Debugger’ and select ‘New Configuration’ from the menu.
    image.png
  2. Once the configuration is created it will be displayed and any errors with the configuration will be shown. If the project was selected in the Project Explorer, then the Name of the debug configuration will contain the project’s name and the Project and C/C++ Application fields will be populated as well. The C/C++ Application field will only be populated if the build output executable exists. Confirm these values are correct before moving on.
    image.png
  3. There is an error showing that the Device core ID is not specified on the Debugger tab. Switch to the Debugger tab and click on the button ‘Select device and core’.
    image.png
  4. From the Select Target Device and Core window, expand the listing until all cores are listed. Notice that all supported cores on the S32R45 are listed. Select the desired LAX core and click OK.
    image.png
  5. Now that the device and core are selected, a generic initialization script associated with the LAX is selected automatically, however, this may not be the correct one. If debugging Standalone, meaning only LAX core will be debugged, then the automatic selection ‘s32r45_generic_bareboard_all_cores.py’ is correct. This script will initialize all of the cores so the LAX can execute properly. If debugging Multicore, meaning both A53 and LAX will be debugged, then the A53 and LAX cores will already be initialized by the time the debugging on LAX begins. So a different script that doesn't initialize all of the cores is needed. Click ‘Browse’ and navigate to ‘{install_dir}\S32DS.3.4\S32DS\tools\S32Debugger\Debugger\scripts\s32r45’ and select the script ‘s32r45_attach.py’. The attach script will allow to start debugging on a core that is already initialized. Refer to the S32 Debugger User Guide, or the document 'README.txt' located in the same folder as these script files for details on all of the provided scripts.
    image.png
  6. Confirm the setting of the ‘Initial core’ checkbox. This box should be checked within the debug configuration that establishes the first connection to the target device via S32 Debug Probe. When this box is checked, the Debug Probe Connection interface and GDB Server settings become available. The probe connection only needs to be configured once and only one GDB Server needs to be running for each debug session. Therefore, this box should be checked for standalone debugging or for multicore debugging where A53 core is debugged via Remote Linux. If the A53 and LAX cores are debugged via the S32 Debug Probe, then this box should be checked for the A53 debug configuration and should not be checked for the LAX debug configuration.
  7. If this is a standalone debugging of only the LAX core, setup the Debug Probe Connection. Select either USB or Ethernet, depending upon your hardware setup. If USB is selected, the COM port for the S32 Debug Probe will automatically be detected (unless not connected or more than one probe is connected). If Ethernet is selected, then enter either the hostname (fsl + last 6 digits of MAC address) or IP address. It is highly recommended to press the ‘Test connection’ button to confirm the hardware connection is correctly configured. See the included ‘S32_Debug_Probe_User_Guide.pdf’ for more details on the setup of the S32 Debug Probe.
    image.png
  8. Check that the GDB Client section has the correct path to the LAX GDB executable. It should point to the variable ‘S32DS_R45_GDB_LAX_PATH’.
    image.png
  9. Startup tab check the following settings
    1. Load image is checked for standalone debugging, NOT checked for multicore debugging. Basically, if it is loaded by A53 core (contained in A53 ELF file), then it does not need to be loaded.
    2. Load symbols is checked. The only time you would not check this box is if there is no project binary containing symbols available.
    3. Set breakpoint at main and Resume are checked for standalone debugging, NOT checked for multicore debugging.
      image.png
  10. Now you are ready to start debugging. If debugging Standalone, click ‘Debug’. If debugging Multicore, switch to the A53 debug configuration (either C/C++ Remote Application or S32 Debugger) and start the A53 debug session first. Once the A53 debug session is running, advance the program counter to the line just after LAX is initialized.

Start A Debug Session
Starting a LAX debug session are different depending upon whether Standalone or Multi-core debugging is required. The steps for each method are detailed in separate sections below.
For convenience, the example project for S32 Design Studio from the RSDK, ‘RSDK_S32DS_template’, will be used to demonstrate multi-core A53/LAX debugging. Note: Unfortunately, this example project is not setup for standalone debugging because there is no main() executing on LAX to call the LaxVectorAddGraph(). So the standalone debugging steps will be presented only to highlight the different setup required. For instructions on loading this example project to your workspace, see ‘HOWTO: Create New Project from Example RSDK_S32DS_template from Radar SDK’.

Standalone
If the standalone bareboard debugging of only LAX core was supported by the RSDK_S32DS_template example, here are the steps which would be required.

  1. Click on the LAX project so it is highlighted, then build it to ensure it builds clean and that the executable exists.
    image.png
  2. From the menu at the top, select Run -> Debug Configurations…
    image.png
  3. Select the standalone debug configuration for LAX core. In the case of the RSDK_S32DS_template example project, only the multi-core debug configuration is supported. In this case, the standalone configuration will need to be created. Right click on the multi-core configuration and select Duplicate. This will create an identical configuration.
    image.png
  4. Change the name as desired and then select the Debugger tab.
    image.png
  5. Click Browse next to Initialization script and navigate to the directory ‘{install_dir}\S32DS.3.4\S32DS\tools\S32Debugger\Debugger\scripts\s32r45’. Select the script ‘s32r45_generic_bareboard_all_cores.py’.
    image.png
  6. Adjust the Debug Probe Connection settings to match your HW setup. Use the Test connection button to confirm.
  7. Select the Startup tab. For standalone debugging the image file will not be loaded by the A53 core, so it must be loaded by the S32 Debugger. Check the boxes for Load image, Set breakpoint at: and Resume.
    image.png
  8. Click Debug to start the debug session. All of the settings made will be applied and the debug session will be launched.

A53 / LAX Multi-Core
For multi-core debugging, the A53 core is executing an application on the Linux BSP. The EVB should be setup to boot from a flash device which has been loaded with the S32R45 Linux BSP.

  1. Before beginning the debug sessions, be sure to load the driver dependencies (oal_driver, rsdk_spt_driver, and rsdk_lax_driver) as described in the RSDK User Manual, RSDK Offline Example section ‘Running the application’.
  2. Start A53 debug. From the menu at the top, select Run -> Debug Configurations…
    image.png
  3. In the Debug Configurations menu, from the configuration list, expand the ‘C/C++ Remote Application’ group and select the ‘RSDK_S32DS_template_A53_Debug’ configuration.
    image.png
  4. On the Main tab, create a new connection for using the IP address of the EVB. The IP address could be determined either by issuing a Linux command over the serial connection, such as ‘ifconfig’, by accessing the local network connected device list, or perhaps the EVB was setup with a static IP address and it is already known.
    1. Click New… in the Connection section.
      image.png
    2. Select ‘SSH’ for connection type.
      image.png
    3. Enter the IP address in Host: field, use ‘root’ in User: field, and leave password field empty.
      image.png
  5. Click Debug to start debugging on the A53 core.
    image.png
  6. The debugger will launch and execute until the first executable line in main(). See Debugger tab in Debug Configurations menu to adjust this setting.
    image.png
  7. Now that the A53 is launched, it is necessary to execute the A53 code until just after the LAX core is initialized and buffers are allocated. Open ‘lax_processing.c’ from the ‘src’ folder in the A53 project and set a breakpoint on line 100. One way is by double-click in the space on the left side of source code editor. This is the executable line just after ‘RsdkLaxInit()’ is called.
    image.png
  8. Now press ‘Resume’ from the toolbar to advance the program counter to the breakpoint.
    image.png
  9. Wait for the breakpoint to occur.
    image.png
  10. Return to the Debug Configurations menu, select the ‘RSDK_S32DS_template_LAX_0_attach’ debug configuration and select the Debugger tab.
    image.png
  11. Adjust the Debug Probe Connection settings to match your HW setup. Use the Test connection button to confirm.
    image.png
  12. Click Debug to start the LAX debug session.
  13. Wait for the LAX debug session to launch and stop in the disassembly. Set a breakpoint in the source code. For our example, place one in ‘lax_custom_graph.c’ on line 97, where the kernel ‘ Rsdk_LA_add_VV’ is called.
    image.png
  14. Select the LAX debug thread and press Resume so it will be ready to run to the breakpoint which was just setup.
    image.png
  15. Select the A53 debug thread and press Resume to allow execution to resume and then wait for the breakpoint to be reached in the LAX code.
    image.png
  16. The breakpoint in the LAX code has been reached. Now it is possible to perform some debugging activities on the LAX core.
    image.png

Debugging LAX Once Debug Session is Started

  1. Once the LAX debug session is started, it will be stopped and only disassembly can be viewed. Select the LAX debug thread to see.
    image.png
  2. Open the C code source file and set a breakpoint within the kernel of interest.
    image.png
  3. Press Resume on the LAX debug thread.
  4. Now switch back to the A53 debug thread and press Resume.
  5. The breakpoint you set in LAX will be reached and you can now start stepping through and looking at registers, etc.
    image.pngimage.pngimage.png


Multi-thread LAX Debugging: IPPU & VCPU
Load a project which uses both IPPU and VCPU and start the debug session on LAX using one of the methods provided.

  1. Once the debug session is started on LAX, set a breakpoint on the line containing RSDK function ‘Rsdk_AU_sync_i()’
    image.png
  2. Press Resume to advance the program counter to the breakpoint. When the breakpoint is reached, the second thread appears. The first thread contains the VCPU and the second thread contains the IPPU.
    image.png
  3. Select the second thread to see the IPPU disassembly. Now instruction stepping can be performed on the IPPU. Registers can be viewed as well.
    image.pngimage.pngimage.png
  4. To see the opcodes, do not use the codes shown in the disassembly view. The disassembly view does not handle cases where many opcodes are packed into a single address. Instead, use the Memory Spaces view.
    image.png
    If the memory spaces view is not already present, then add it from the menu Window -> Show View -> Memory Spaces.
    To add a memory space, right click in the panel on the left or click on the + button at the upper right.

Multi-LAX-core Debugging
The S32R45 device contains 2 LAX cores: LAX_0 and LAX_1. To debug the additional LAX core, simply add a new debug configuration and setup for LAX_1.

  1. Create a new debug configuration for LAX_1 by first duplicating the existing debug configuration for LAX_0.
    image.png
  2. Rename the configuration to reference LAX_1, but the project name and application file (ELD) will remain the same.
    image.png
  3. On the Debugger tab, use ‘Select device and core’ button to change the core to LAX_1, change the initialization script to ‘<device>_attach.py’, and uncheck the box next to Initial core.
    image.png
  4. Depending on how you started the debug session for LAX_0, you may need to adjust the Startup tab. The settings on Startup tab should be set to match the LAX_0 debug configuration.
  5. Start the LAX_0 debug session first, then the LAX_1 debug session. Stepping within each can be conducted independently.
No ratings
Version history
Last update:
‎03-11-2022 01:44 PM
Updated by: