1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Advanced Debugging on the RX600_LabProcedure (1)

25 200 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 1 of 25 ID 3L05I: Advanced Debugging with RX600 RX600 Series Description: The purpose of this lab is to get the user accustomed to using some of the advanced debugging features available on RX600 Series devices. The features covered are the expression view, complex breakpoints, and branch trace. 1 Demo Application Overview 2 Lab Sections 2 Viewing Preprocessed Files 3 3 Using the Expressions View 8 4 Complex Eventpoints 13 5 Branch Trace 19 6 Using Multiple Eventpoints Together 22 Lab Objectives 1. Learn to generate and view preprocessed source files. 2. Understand and use complex breakpoints. 3. Demonstrate trace functionality. 4. Setup and use multiple eventpoints. Skill Level: 1. Programming in C 2. Basic operations in e2Studio. 3. Basic debugging techniques. Time to Complete Lab 90 Minutes Lab Materials Please verify you have the following materials at your lab station. • RDKRX63N • USB debugger cable • e2Studio Version 1.1.0.25 • RX Toolchain Version 1.02.00 • RX_Advanced_Debug lab workspace LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 2 of 25 1 Demo Application Overview Before getting into the lab we will cover what the demo is actually doing. The code is executing a state machine to handle a very simple communications protocol. The MCU is acting as a receiver with a host sending it a series of data blocks. An outline of how the protocol works is below. Some more information in regards to the protocol: • The Device is in a waiting state when not receiving data from the Host. • All data transmitted are unsigned integers. • The ‘# of Data Blocks’ field tells the Device how many data blocks to expect and is 1 Byte • The Sequence ID (1 Byte) of a block identifies the block. The first block with have a Sequence ID of 0, the 2 nd block will have a Sequence ID of 1, and so on. • The ‘# of Bytes of Data’ (1 Byte) tells the Device how many bytes to expect in this block, not including the CRC. • The CRC is a CRC-16 CCITT with an initial seed of 0x1D0F. The Host in this lab is simulated by the Demo_Communications.c source file. It feeds data to the receive buffer of the state machine so that it can process it. The actual data is stored in the file ComData.h. Since we are simulating the actual communications, we can assume that any problems in the code are NOT due to transmission errors. LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 3 of 25 2 Viewing Preprocessed Files Overview: This section will cover generating and viewing preprocessed C source files. Being able to view the preprocessed source files can help solve some troubleshooting issues when the error message from the compiler does not seem to make sense. Step 2.1 Run e2Studio. There should be a shortcut on the Desktop. If not, go to All Programs>>Renesas Electronics e2Studio>>Renesas e2Studio. Step 2.2 Click on Browse and go to C:\Workspace\RX_Advanced_Debug. Click OK to open the workspace. Step 2.3 Go to Project>>Build All. During the build you will see an error in the file Demo_StateMachine.c. The error that is thrown will look similar to: \src\Demo_StateMachine.c(169) : C6578 (E) Case label value has already appeared in this switch at line 103 make: *** [src/Demo_StateMachine.obj] Error 1 Step 2.4 Verify that there is not another case block with the same name SM_ERROR. You can also look in the header file Demo_StateMachine.h to see the SM_States enumerator declaration for the available state machine states. Step 2.5 To help troubleshoot this issue we are now going to look at the preprocessed source files. Go to Project >> Properties. In the window that pops up expand C/C++ Build and select Settings. Tool Settings tab should be displayed. To quickly locate an error you can go to Problems view and expand the Errors. Then double click on the error to find the location in source code. This is shown in below. Also, the file with an error will be marked with a red box in Project Explorer view (far left). LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 4 of 25 Step 2.6 On Tool Settings tab, choose Object under Compiler and change the Output file type to Preprocessed source file (*.p/*.pp). Your window should look like below. . Step 2.7 Click OK to go back to the e2Studio project. Step 2.8 Go to Project>>Build All. Step 2.9 To view the preprocessed output go to File >> Open File. Navigate to the HardwareDebug\src folder and open the file Demo_StateMachine.p. This file should be in the following folder. C:\WorkSpace\RX_Advanced_Debug\RX_Advanced_Debug\HardwareDebug\src Step 2.10 Scroll down in the file until you find the location where the error occurred. Notice that while the other cases still show their enumerator names, the case that was throwing the error SM_ERROR now shows up as case (1). This means that somewhere in the code there is a #define that is substituting (1) for SM_ERROR. Step 2.11 To find this #define we will use the Search feature in e2Studio. Go to Search>>Search. A search window shows up. When outputting preprocessed source files the project build stops at the linker stage. The reason for this is that the object files are not generated and therefore the linker cannot run. You will likely get an error in the Console view. For example the RX toolchain generates the following error: ** L3300 (F) Cannot open file. LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 5 of 25 Step 2.12 Make your Search window match the window below and click Search Step 2.13 The search results will show up in the Search view. Look in the results for an occurrence where SM_ERROR was used with a #define. LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 6 of 25 Step 2.14 Double click on the occurrence of SM_ERROR with #define to be taken to the line of code in the source file. For an improved source code search options, you can use C/C++ Search tab. For example, you can select Macro from the Search For boxes to fine tune your search. The results will show only where SM_ERROR is used with a #define . This is shown below. LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 7 of 25 Step 2.15 Since this #define is not being used in the project it can be safely commented out. Comment out this line of code. //#define SM_ERROR (1) Step 2.16 Go back to Project >> Properties as was done in Step 2.5 and reset the Output file type to Machine code (*.obj). Click OK. Step 2.17 Go to Project>>Build All. The project should build with no errors. This example is designed to demonstrate where a coder accidently named a state machine state and an error flag with the same thing. Other similar types of hard-to-see errors can occur when you don’t keep track of #define statements between files. One easy way to prevent these types of problems is to follow a set of rules. Rules like “all #define names will be in all capitals” and “all states will have STATE_ at the beginning of the name” are examples that are easy to follow and will prevent most types of these problems. Question 1. Why does the linker give an error while building the project when the compiler is configured to output preprocessed source files (*.p files)? LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 8 of 25 3 Using the Expressions View Overview: This section will explain how to watch variables using the Expressions window in e2Studio. We will connect to the hardware and run the debugger. Step 3.1 Connect the RDKRX63N to the laptop using the supplied USB cable. Make sure to use the USB port labeled J-Link. Step 3.2 On the Project Explorer view (far left), right click on the RX_Advanced_Debug project and select Debug As>>Renesas GDB Hardware Launch. Step 3.3 If you see Renesas Hardware Debugging window, you need to setup the debug settings. Select Segger JLink from the list as shown below. Click OK. LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 9 of 25 Step 3.4 Now select R5F563NB from the MCU list as shown below. Click OK. Step 3.5 If you see Confirm Perspective Switch window, click in Remember my decision box first and then click Yes as shown below. LAB PROCEDURE ID 3L05I: Advanced Debugging with RX600 Page 10 of 25 Step 3.6 Click pull down arrow next to Debug icon to run debug configurations as shown below. Step 3.7 In Debug Configurations window, go to Startup tab and uncheck the Set breakpoint at box as shown below. Click Apply and Debug. Step 3.8 At this point, you should be connected to the debugger. Step 3.9 Click Restart icon to run the code. [...]... should see that the yellow warning sign next to the event disappear The value of 3 is chosen for the Compare field because that is the number the SM_States enumerator will assign to SM_ERROR On the RX toolchain the first enumerator option will get the value 0, the second option 1, th and so on Since the SM_ERROR option is the 4 in the list, it will get the value of 3 ID 3L05I: Advanced Debugging with... 3L05I: Advanced Debugging with RX600 Page 14 of 25 LAB PROCEDURE Notice that the Trigger is set to OR This means that any condition in the Event Break will stop the code From the pull down, you can select AND or SEQUENCE AND requires all condition to be satisfied before stopping the code SEQUENCE is used with events that occur one after the other Step 4.9 Click Add button Add Eventpoint window shows up The. .. powerful debugging tool By using the Mask Value field on the Data Access Settings tab, you can set a trigger to occur on a range of values For instance, if you wanted to trigger on a value between 0x0010 and 0x001F then you would set the Compare field to 0x0010, the Mask Value field to 0xFFF0, and set the Comparison drop down to Equals The zeros in mask are don’t cares The ones in mask require the result... executed before the event was encountered Notice that since this is a branch trace (not a full trace) it only captures the branch and the destination Let the computer fill in the instructions and source code in between the branches by clicking the Disassemble Mode icon The window should look similar to below Step 5.9 icon and the Source Mode Now that we have a list of instructions executed before the eventpoint... communications, we can assume there are no transmission errors This means that there is something wrong with the CRC code itself The CRC routine was provided by the manufacturer and has been verified One possible issue would be the endian of the transmitted CRC but since the first 5 blocks worked with no incident, this is very unlikely to be the problem With these points taken into consideration we can... should see the following items 1 2 3 4 Trace Start – these are the conditions to start a trace Trace Stop – these are the conditions to stop a trace Trace Record – these specify which event to filter and record Event Break – these are your complex breakpoints You can do address break, data break, and use them together 5 Before PC – this is the same as hardware breakpoints Step 4.8 Double click on Event... matches to the compare value Therefore Mask Value of 0xFFF0 will create a trigger setting of 0x001X where X can be any value Step 4.14 Click Restart icon to run the code and wait for the eventpoint to trigger Step 4.15 Verify that the code stops but the current instruction shown is not one that writes the variable CurrentState The reason for this is that the eventpoint will trigger only after the write... Observe that the LCD display on RDKRX63N It should show a Renesas logo and display RX Advanced Debug Lab Step 3.11 Click Suspend icon to stop the code Step 3.12 Go to Expression view This is shown below You can add variables to the Expressions view in a variety of ways 1 You can click on the Add new expression and type in the name of the variable 2 You can right click on Add new expressions and select... up/down arrows to move the eventpoints to change the order of events Step 6.6 Click OK to close the Edit Event Break window Click on Apply to Target icon to send the eventpoint settings to the debugger You should see that the yellow warning signs next to the events disappear Step 6.7 Click Restart Step 6.8 The MCU should stop on the ValidateData() function The block that causes the error is now next... Step Into icon or press F5 to enter the ValidateData() function Continue to step through the code until you hit the following line of code: icon to run the code and wait for the eventpoint to trigger /* Perform CRC */ for(index = 0; index < dataBytes ; index++) ID 3L05I: Advanced Debugging with RX600 Page 22 of 25 LAB PROCEDURE As mentioned at the beginning of the lab, since we are simulating the physical . is the number the SM_States enumerator will assign to SM_ERROR. On the RX toolchain the first enumerator option will get the value 0, the second option 1, and so on. Since the SM_ERROR option. 3L05I: Advanced Debugging with RX600 Page 1 of 25 ID 3L05I: Advanced Debugging with RX600 RX600 Series Description: The purpose of this lab is to get the user accustomed to using some of the advanced. click on the Add new expression and type in the name of the variable. 2. You can right click on Add new expressions and select Add Watch Expression. In the window opens up you can type the name

Ngày đăng: 22/06/2015, 14:04

TỪ KHÓA LIÊN QUAN