Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction Purpose Objectives Content Learning Time

Similar presentations


Presentation on theme: "Introduction Purpose Objectives Content Learning Time"— Presentation transcript:

1 Introduction Purpose Objectives Content Learning Time
• This training course covers debugging an application on an SH target in the Renesas HEW (High-performance Embedded Workshop) development environment using the KPIT GNU toolchain and the Renesas E10A-USB emulator. Objectives • Learn how to create a new project and make linker settings. • Understand how to configure the debug platform and connect to the target system. • Learn the process of debugging a typical application with the E10A-USB emulator. Content • 38 pages • 3 questions Learning Time • 50 minutes Welcome to the “Debugging with E10A-USB Emulator” course — one of a series of courses covering the GNU toolchain from KPIT Cummins Infosystems and microcontroller (MCU) support products from Renesas Technology. These development tools speed up the debugging of software for embedded systems. To get the most out of this material, you should be familiar with the development of embedded control systems. This course describes the process of debugging an application on an SH target — a SuperH™ MCU — in HEW using the KPIT GNU toolchain and the Renesas E10A-USB emulator. The course explains how to create a new project, make linker settings, configure the debug platform, and connect to the target system. Then it steps through the process of debugging a typical application with this setup. Other courses in this series cover additional aspects of embedded system development and explain the use of different debugging tools.

2 Prerequisites for Debugging
Renesas HEW 4 IDE is installed KPIT GNU toolchain for SH target (integrated with HEW 4) is installed Renesas E10A-USB emulator software is installed* Click each oval for more information . Before you can begin the debugging process, you must install HEW, the KPIT GNU toolchain, and the E10A-USB emulator software on the host PC. To see summary information about each of these system development aids, just click on the ovals. You can download a free evaluation version of the HEW 4 IDE with project manager, compiler interface, editor, and debugger from the KPIT Cummins website at kpitgnutools.com. You can also download and install the KPIT GNU toolchain. The software for the E10A-USB is included in the CD that comes with the emulator and target board. The HEW software should be installed on the host PC before either the emulator or toolchain software. Installing a KPIT GNU toolchain for a particular MCU adds device support for that chip to the HEW environment, thus allowing you to select it when creating a new project in HEW. You will be able to generate either sample code specifically for that device, or an empty project with the correct start-up and supporting files already added. When you install the E10A-USB software, be certain that HEW is closed and the target is disconnected from the host PC. For more information about HEW, the KPIT GNU toolchain, and the E10A-USB emulator, click on the ovals. Click on the forward arrow when you are finished. *HEW must be closed and the target disconnected from the host when the emulator software is installed.

3 About the HEW IDE HEW • A powerful, yet easy-to-use software development solution that shortens system development time - Offers a familiar Graphical User Interface (GUI) that simplifies operations - Eliminates the need to switch environments between coding and debugging operations, or between target devices - Allows users to select right tool for each process and fully exploit the tool’s capabilities - Provides many essential functions, including: Project manager Setup “Wizard” Compiler interface Configurable build engine Editor Debugger and more KPIT GNU toolchain E10A-USB Emulator Click each oval for more information The HEW IDE, a fourth-generation support tool developed by Renesas Technology, is a powerful, yet easy-to-use software development solution that shortens system development time by offering a familiar Graphical User Interface (GUI). This GUI simplifies operations and eliminates the need to switch environments between coding and debugging operations or between target devices. Importantly, it lets users select the right tool for each process — such as the KPIT GNU toolchain — and fully exploit the tool’s capabilities. As an IDE, HEW provides many essential functions, including project manager, project “Wizard,” compiler interface, configurable build engine, editor, debugger, and more. Detailed information about HEW is contained in another series of courses at this Renesas Interactive website. For more information about the KPIT GNU toolchain and the E10A-USB emulator, click on the ovals. Click on the forward arrow when you are finished. Free HEW courses are available at Renesas Interactive

4 About the GNU Toolchain
HEW Proven, pre-built, binary tools that allow more time for application development - Compiler source code, Binutils, Newlib, and a GDB source-level debugger that shows what is happening inside program as it executes Tested and optimized for Renesas targets Free and easy to use Available for Windows and Linux platforms Easy download and installation Integrated with Renesas’ proprietary tools Free technical support at dedicated web portal - GDB stubs, monitor programs, tutorials, documentation, FAQs, and discussion forum KPIT GNU toolchain E10A-USB Emulator Click each oval for more information The pre-built binary GNU toolchain offered by KPIT Cummins Microsystems Limited is thoroughly developed and proven. Thus, time can be spent on application development instead of tool-building. The toolchain includes Compiler source code, Binutils, Newlib, and a GDB source-level debugger that shows what is happening inside a program as it executes. The tools are tested and optimized for Renesas targets. They are described in more detail in the “Intro to GNU Tools” course. The tools are available at no charge and are easy to use. They run on Windows and Linux platforms and can be downloaded and installed easily. (A CD subscription is also offered.) The KPIT GNU tools have been integrated with Renesas’ proprietary tools for convenient, efficient system development. For example, Windows users can use GNU toolchain with the HEW integrated development environment and with other Renesas tools. Users of KPIT GNU tools can obtain free technical support via a dedicated web portal. It provides GDB stubs, various monitor programs for Renesas targets, and sample tutorials, as well as extensive documentation and FAQs. The portal also contains a discussion forum. For more information about HEW and the E10A-USB emulator, click on the ovals. Click on the forward arrow when you are finished.

5 About the E10A-USB Emulator
HEW • Low-cost system develop- ment tool that connects to host PC via a USB port, and to SuperH device in target system via an on-chip JTAG interface - Controlled from PC using HEW GUI - Provides real-time debugging using dedicated circuitry in target microcontroller - Offers debugging capabilities such as real-time trace, hardware breakpoints on data and address, PC breakpoints, and saved record of last four branches Connects to PC’s USB port Emulator Software is included on CD Target board with target MCU KPIT GNU toolchain E10A-USB Emulator Click each oval for more information The Renesas E10A-USB emulator is a low-cost system development tool that connects to a host PC via a USB port and connects to the SuperH microcontroller in a target system via the device's on-chip JTAG interface. The emulator is controlled from the PC using the HEW GUI and provides real-time debugging using dedicated circuitry built into the target microcontroller. The debugging capabilities of the E10A-USB include real-time trace, hardware breakpoints on data and address, 255 PC breakpoints, and a saved record of the last four branches. For more information about HEW and the KPIT GNU toolchain, click on the ovals. Click on the forward arrow when you are finished.

6 Getting Started 4 2 3 1 5 Click to launch HEW HEW Features:
• Configurable build engine - Set up compiler, assembler and linker options • Integrated text editor - Customize syntax coloring for improved legibility • Build capabilities - Run tools directly within environment • Integrated debugger - Build and debug in same application • Version control To launch HEW: • Click on HEW icon on desktop • Navigate from Start menu Click to launch HEW 1 3 4 5 2 After the installations have been completed, you can begin debugging with the KPIT GNU toolchain and the SH simulator within the HEW environment using a familiar GUI. The first step is to launch HEW, which has many useful features. It has a configurable build engine so you can set up the compiler, assembler, and linker options according to your specific needs. HEW’s integrated text editor lets you customize syntax coloring for improved code readability. HEW’s build capabilities allow you to run the tools you prefer — such as the KPIT GNU toolchain — directly within its environment. Also, the integrated debugger lets you build and debug in the same application. Version-control support is another important HEW feature. The HEW launch process is straightforward. If you have a HEW icon on your desktop, just click on that. Alternatively, navigate the following menu choices in sequence: Windows® Start menu, Programs, Renesas folder, High-performance Embedded Workshop folder, and, finally, the High-performance Embedded Workshop application.

7 Creating a Workspace Create a new project workspace Click OK
This “Welcome!” box appears when you launch HEW. It gives you the option to create a new project workspace or open an existing project. “Create a new project workspace” is checked by default. If you want to open a recently created workspace instead, click on “Open a recent project workspace” and select it from a list of recent workspaces. To open a particular “.hws” workspace file, check the third option to “Browse to another project workspace.” After you have made your selection, click “OK” to continue.

8 Creating a New Project (1/13)
Select application type 2 Enter Workspace name Enter Project name For this course, the default option to create a new project workspace has been selected, which opens the “New Project Workspace” window. The data you enter in this window initiates the creation process. First, select “C Application” as the application type. Next, name the workspace “SH_7780,” which creates a project in the directory “C:\WorkSpace\SH_7780.” It is possible to create multiple projects in a single workspace such as this. For this project, we entered “SH_7780” as the project name, then selected “SuperH RISC engine” as the CPU family and “KPIT GNUSH (ELF)” as the toolchain. Be aware that once you have selected this toolchain option, you cannot change it in this workspace. After you finish, click OK to continue. 3 Select CPU family 4 Select KPIT GNUSH(ELF) toolchain 5 Click OK

9 Creating a New Project (2/13)
Next, because you chose “KPIT GNUSH (ELF)” as the toolchain, you will see this screen. It explains how the KPIT tools are supported in HEW. You may visit the KPIT Cummins website at for free technical support. Please take a minute to read the notice before clicking “Next.” Click Next

10 Creating a New Project (3/13)
Select CPU type Now you must choose a CPU for your project. For this demonstration, “SH4a” is the appropriate CPU type because the project will be debugged on an SH7780 target, which is part of the SH4a series. Also, because the default files for the SH7780 are not yet integrated with the new workspace you have created, the target is not listed in the “CPU” section. Therefore, you must select “Other SH4a Device.” After making this selection, click “Next” to see additional CPU options. Select CPU Click Next

11 Creating a New Project (4/13)
Select Endian type Select options Here are some additional CPU options. If applicable, you can choose an “Endian type” — either “Little endian” or “Big endian” — for the CPU. Note, though, that MCUs in the SH1 and SH2A series do not support Endian selection. If you select the next option, “Shorten address refs at link time,” the compiler tries to shorten the address references for specific instructions. This is equivalent to selecting the “-relax” option and results in code-size optimization. If you select “Use Renesas calling convention rather than that for gcc,” the GNU SH toolchain generates the code in accordance with the Renesas ABI specification. The files thus generated can be linked directly to object files created with the Renesas compiler. After selecting the options appropriate for your project, click “Next.” Click Next

12 Question Is the following statement true or false? Make your selection and then click Done. “Files generated by the KPIT GNUSH toolchain must be modified before they can be linked to object files created with the Renesas compiler.” True False Here’s a question for you. Correct. An option for the GNUSH toolchain generates code in accordance with the Renesas ABI specification, so that the resulting files can be linked directly to object files created with the Renesas compiler. Click the forward arrow to continue on to the next page.] Done

13 Creating a New Project (5/13)
Project Generator adds these files to your project At this point in the process of creating a new project you are in the HEW Project Generator, which shows a list of files that will be added to the new project. main.c contains the generated application’s main function. start.asm contains the start-up code. hwinit.c contains the hardware initialization code. vects.c contains the interrupt vector table for a sample SH2 device. inthandler.h contains the declarations of the interrupt routines. inthandler.c contains the definitions of the interrupt routines. Exp_handler.s contains exception handling routines. iodefine.h contains definitions of the I/O registers. To generate the project, click “Finish” at the bottom of the screen. Click Finish to complete workspace creation

14 Creating a New Project (6/13)
The “Project generator information” window opens, summarizing the various options selected and listing the files generated by the HEW compiler. You can see CPU information, Vector information and a list of additional files. Your project will be created with the specifications shown in this window. Next, click “OK” to view the generated workspace. Click OK

15 Creating a New Project (7/13)
Workspace window Editor window The HEW GUI for the generated workspace has Workspace, Editor, and Output windows, among others. The list of project files appears in the Workspace window. Double-click on any of the project files to view its contents in the Editor window. For example, if you double-click on the file “main.c,” HEW opens it in Editor window, as shown here. Remember that “main.c” is the project file whose role is to contain the generated application’s main function. Here, it is empty, so you can add your application code to this function. Output window Enter application code here

16 Creating a New Project (8/13)
“main.c” file Contains application program (Code that controls eight LEDs on SH7780 target) For this example, the files “main.c,” “start.asm,” “iodefine.h,” “hwinit.c,” “inthandler.h,” and “inthandler.c” have been copied from the SH7780 sample programs into the new project. By double clicking on the “main.c” file in the Workspace window, you can see in the Editor window that it now contains a sample application program that controls eight LEDs mounted on on the SH7780 target system board. (Of course, in a real-world situation, the application code that is going to run on the SH target would be used instead.)

17 Creating a New Project (9/13)
“start.asm” file Startup code for project Startup program in “start.asm”. . . • Initializes the stack pointer • Initializes the microprocessor • Puts the data section into RAM at the VMA • Sets uninitialized global variables to zero • Initializes global constructors (if it is CPP) • Calls main function Let’s look more closely at those SH7780 sample files that have been copied. First, double-click in “start.asm” in the Workspace window to open it in the Editor window. This file contains the startup code for your project. Be aware that the same “start.asm” file is used in both Release Mode and Debug Mode. However, different macros are defined to execute different sets of code, depending on the mode in use. For example, the macro “#if DEBUG “is used when the GNU compiler is in Debug Mode, whereas the macros “#if RELEASE” and “#if ROMSTART” are used when it is in Release Mode. The startup program in “start.asm” performs several functions. It initializes the stack pointer and initializes the microprocessor. It puts the data section into RAM at the Virtual Memory Address (VMA), too. This is done because the variable values may change at run time, which wouldn’t be possible if they were in ROM. The start up program also zeroes-out the “block started by” symbol (BSS) section. That is, it sets the uninitialized global variables to zero. If the startup program is C++ (CPP), it initializes global constructors. The final step in “start.asm” calls the main function.

18 Creating a New Project (10/13)
“iodefine.h” file Definitions of I/O registers Let’s move on to another sample file. When you double-click on “iodefine.h” in the Workspace window, you see the contents of this file. The Editor window shows that “iodefine.h” contains definitions of the I/O registers.

19 Creating a New Project (11/13)
“hwinit.c” file Hardware initialization code By double-clicking on “hwinit.c” in the Workspace window, you can view the contents of this file. As the Editor window shows, “hwinit.c” contains hardware initialization code.

20 Creating a New Project (12/13)
“inthandler.h” file Declarations of interrupt routines When you open “inthandler.h,” the Editor window shows that this file contains declarations of interrupt routines.

21 Creating a New Project (13/13)
“inthandler.c” file Definitions of interrupt routines The last of the SH7780 sample files that have been copied is “inthandler.c.” When you double-clicking on it you can see that it contains definitions of interrupt routines. At this point, all the steps for creating a new project have been completed. Next we’ll look at how to make the appropriate linker settings.

22 Question Which of these statements correctly describe aspects of creating a new project in HEW using the KPIT GNU toolchain? Select all that apply and then click Done. Because HEW is a configurable environment, you can select a GNU toolchain during new project creation and change your selection later in the project. The Editor window lets you view code from project files listed in the Workspace Window. A generated application’s main function resides in the “main.c” project file. KPIT Cummins provides free technical support for HEW for KPIT GNU tools. Here’s another question for you. Correct. Once you have selected the KPIT GNUSH toolchain as the toolchain for a new project, your selection cannot be changed. The Editor window lets you view code from the project files listed in the Workspace Window of the generated workspace. A generated application’s main function resides in the “main.c” project file. KPIT Cummins provides free technical support for HEW for KPIT GNU tools. Done

23 Making Linker Settings
Click Build Click Linker to change the linker settings Click Sections SH7780 Hardware Manual 0x INTHandler 0xA RSTHandler 0xA text 0xA808FF00 .data 0xA vects 0xE5011FE0 .stack .init .fini .got .rodata eh_frame_hdr The linker settings applicable to the SH7780 target are detailed in the document “SH7780-hardware manual.pdf,” which can be downloaded from the Renesas website via the button on the screen. To change the linker settings in your project, click on “Build” and then “Linker.” This will cause the “Linker Options” window to open. Next, click on the “Sections” tab. From here you can change the addresses of text and data sections to match the target memory map. The sections and corresponding addresses for the SH7780 target are as follows: .text has the address 0xA It is the standard text section for program code. The user program resides in this section. .data has the address 0xA808FF00. It is the standard data section used for initialized global and static variables. .vects has the address 0xA This is the specific section used to represent the vector table. .stack has the address 0xE5011FE0. It denotes the starting address of the stack. Click OK when you have finished changing the addresses. Modify addresses to match target memory map Click OK

24 Configuring Debug Platform (1/3)
Click Build All Select Debug mode Select Debug session Now let’s look at how to configure the debug platform. When a program is debugged, it first needs to be compiled and linked in Debug Mode. When you select the Debug Mode option, the compiler puts all the information necessary for debugging your C/C++ code into debug object files. When the code is built, information about the process is displayed in the “Build” tab of the output window. Be sure to look for errors or warnings in the Output window. If any are reported, eliminate them by correcting the code before proceeding. In this demonstration everything is all right because no errors were detected and no warnings were posted. Ensure that there are no errors, no warnings

25 Configuring Debug Platform (2/3)
Click Debug Click Debug Settings Select Target as “SH-4A E10 USB SYSTEM (CPU SH-4A)” Click OK Click Add The first step of configuring the debug platform is to click “Debug” and then click “Debug Settings.” You choose the target and debug format by clicking on the “Target” tab. For this example, “SH-4A E10 USB SYSTEM (CPU SH-4A)” is selected as the target because we are using a variant of the SH-4A CPU and “Elf/Dwarf2_KPIT” as the default debug format. The next step is to add your Elf/Dwarf2 (“.x”) file as a download module. This is the relocated executable file containing the code and debug data for your application. Click the “Add” button to open the Download Module window, from which you make the following settings. First, choose the “Elf/Dwarf2_KPIT” format from the pull-down menu. Then click “Browse,” to open the “Open” dialog. There you to can scroll through the windows to find the filename of your “.x” file, which is usually found in the configuration folder under your project folder. When you find the file, highlight it and then click “Open.” Then, click OK in the Download Module dialog box. Select Default Debug Format as “Elf/Dwarf2_KPIT” Select Format as ”Elf/Dwarf2_KPIT” Click Browse Select file and Click Open

26 Configuring Debug Platform (3/3)
Click Options Click OK Now let’s return again to the “Debug Settings” menu and click on the “Options” tab to bring up this dialog. From here you can add your file for “command line batch processing” and you can set the conditions for its load timing. You might do this to initialize various settings in your target before downloading your debug module, such as bus access settings for external RAM. To do so, click on the Add button. That will bring up the Command Line File dialog. Click the “Browse” button to select the .hdc file. Next you will see the “Open” dialog. After browsing through the windows to find the “.hdc” command-line file, select it and click the “Open” button. The file you have selected will now appear in the Command Line File dialog. Click “OK.” In the Debug settings dialog, the command line file you have selected now appears in the window. Notice that this dialog contains several check boxes. The first is the option, “Do not perform automatic target connection,” which some targets do not support. If this option is supported, however, and you enable it, the target will not be connected until you also select “Debug” and then “Connect.” If you check the option “Download modules after build,” your program will be downloaded automatically after the build process has been completed. Checking “Reset CPU after download module” automatically resets the debugger target after your program is downloaded. If you check the “Remove breakpoints on download” option, the breakpoints will be automatically removed after the program is downloaded. With your selected command line file in the window and after checking the options you want to use, click “OK.” Changing a target always prompts a debugger warning message. Click “Yes” to continue. Select it and click Open Click Yes Click Add Browse to select the .hdc file Click OK

27 Connecting to the Target (1/2)
Click Debug Click Connect Now the target is connected to the host. After ensuring that the target is connected properly and powered, click on “Debug” and “Connect.” Next, “SH7780” is selected as the CPU type and then “OK” is clicked. You also press the Reset button on the target board, and then click “OK.” Click OK Select CPU Press the Reset button on the hardware and click OK

28 Connecting to the Target (2/2)
As you can see here, the Output window displays “connected.” This confirms that a connection to the target has been established.

29 Downloading Module Right-click on the .x file Click Download Module
To download your program onto the target, right click on the “.x” file (SH7780.x) in the Workspace window. Then click on “Download module” to start the downloading process.

30 Debugging the Application (1/10)
When the download is complete, the Editor window will display the line numbers, source address column, and software breakpoint area. As you debug your program, you can stop its execution at any point by setting a breakpoint. Simply double-click at the desired location in the software breakpoint area. Double-click to insert breakpoint

31 Debugging the Application (2/10)
Click View Select CPU Select desired option Should your application require monitoring of various parameters, you can click on “View” and then the desired menu. The choices are CPU, Symbol, Graphic, Performance, and Code. Each of those categories offers more choices. When the “CPU” menu is selected, for example, you can select and view the Register, Memory, I/O, Status, Simulated I/O, and Trigger windows.

32 Debugging the Application (3/10)
Register window The Register window under “CPU” displays the modified values of the CPU registers after an instruction has been executed. The Memory window displays the current value of the memory, from which you can modify the memory address and data fields. Memory window

33 Debugging the Application (4/10)
Click View Click Symbol Select desired option To monitor selections under the Symbol menu, click on “View” and then “Symbol.” Select the window you wish to view—Labels, Watch, or Locals.

34 Debugging the Application (5/10)
Here is the Watch window, which shows the status of variables during the execution of the application. To view the status of a variable, simply drag it into the Watch window. Watch window

35 Debugging the Application (6/10)
Click Debug Click Run Click Go Now you select “Reset Go” from the Debug menu to start executing the program from the entry point at system startup, or “Go” to continue program execution from the current position. Alternatively, as shown here, you can start executing the program from a specific program address with the “Run…” option. This lets you select a symbol or enter an address to load into the Program Counter before running. To do so, click on “Debug” and then “Run.” Then select “_start” from the Run Program dialog and click “Go.” However, when doing this, be careful to ensure that the runtime environment is initialized. Also, be aware of stack frame status. • Ensure that the runtime environment is initialized • Be aware of stack-frame status Enter “_start”

36 Debugging the Application (7/10)
The program executes until it reaches the breakpoint that you set earlier. At that point, execution stops so that you can step through the code to find and correct any problems with the execution. Program halts at Breakpoint

37 Debugging the Application (8/10)
To step over a function, press F10. In this way you can continue stepping through your program and debugging it. Note that using step-over steps through the entire application at a higher level. (Actually it will run at full speed through the sub-functions.) By contrast, if step-in were used, the compiler would step every single line in the application, which would be an extremely tedious process. Press F10 to step through your program

38 Debugging the Application (9/10)
Click Stop If you are in “Run Mode” and want to stop the debugging process, click on the “Stop” icon in the toolbar to halt program execution. Note that this step is required before the debugger can be disconnected. You must halt program execution before the debugger can be disconnected.

39 Debugging the Application (10/10)
Click Disconnect After you have completed the debugging of your program and halted program execution, click on “Disconnect” to end the process.

40 Question Match each debug feature to the most appropriate explanation by dragging the letters on the left to the correct locations on the right. Click Done when you are finished. Include options for changing the addresses of text and data sections applicable to the target. A Debug object files B Displays the modified values of the CPU registers after an instruction has been executed. B Linker settings C Contain all the information needed by the GNU compiler for debugging your C/C++ code. C Register window A Allows you to step over a function when you are stepping through and debugging a program. Here’s a final question for you. Correct. Debug object files contain all the information needed by the compiler for debugging your C/C++ code. Linker settings include options for changing the addresses of text and data sections applicable to the target. The Register window Displays the modified values of the CPU registers after an instruction has been executed. The F10 key command allows you to step over a function when you are stepping through and debugging a program. D F10 key command D Done Reset Show Solution

41 For more information, please visit our Web site:
Course Summary • Creating a new project • Making linker settings • Configuring the debug platform • Connecting to the SH target system • Debugging an application using HEW, the KPIT GNU toolchain, and the E10A-USB emulator This concludes the “Debugging with E10A-USB Emulator” course. You learned how to create a new project, make linker settings, configure the debug platform, and connect to the target system. Then you saw, step-by-step, the process of debugging a typical application using HEW, the KPIT GNU toolchain, and the E10A-USB emulator. We now invite you to take the other courses in this series, which cover additional aspects of embedded system development and how to use different debugging tools, as well as courses on architectures, devices, peripheral functions and more. We also encourage you to use the free VirtuaLab setups at this website to gain some hands-on experience with popular MCUs and tools without having to buy products and wait for delivery. Thank you for your interest in Renesas microcontrollers and for taking advantage of the resources of the Renesas Interactive website. Please visit us often. Further, we urge you to bookmark the main Renesas website so you can obtain the latest product, application and support information whenever you need it. For more information, please visit our Web site:


Download ppt "Introduction Purpose Objectives Content Learning Time"

Similar presentations


Ads by Google