Debugging environment
Software: RealView MDK 4.03q
Hardware: JLINK v7, TQ2440 development board
When I first started learning ARM OS-free programming, I used Tianqian's TQ2440_Test project, which is an ads1.2 project. However, I used the Windows 7 operating system. Ads1.2 is relatively old and does not work well under Windows 7. It always crashes inexplicably, which made me very depressed. So I switched to RealView MDK, but there are few tutorials about RealView MDK on the Internet (probably because not many people use it). After a week of learning, I am familiar with the environment of RealView MDK. The following is a record of my debugging process.
1. Introduction to RealView MDK
2. Introduction to Jlink
3. Create RealView MDK LED Marquee Project
4. Debug Program
1. About RealView MDK
In fact, RealView MDK is also a product of Keil. It is a new development environment for ARM developed after Keil was acquired by ARM. I personally feel that it is much better than ads1.2. RealView MDK has many outstanding features:
startup code generation wizard, automatic boot
The startup code is closely integrated with the system hardware and must be written in assembly language, which makes it difficult for many engineers to cross multiple thresholds. RealView MDK's μVision3 tool can help you automatically generate perfect startup code and provide a graphical window for you to modify easily. Whether for beginners or experienced development engineers, it can greatly save time and improve development efficiency.
Software simulator, software development process completely separated from hardware
RealView MDK's device simulator can simulate the entire target hardware, including fast instruction set simulation, external signal and I/O simulation, interrupt process simulation, all peripheral device simulation on chip, etc. Development engineers can start software development and debugging without hardware, so that software and hardware development can be carried out simultaneously, greatly shortening the development cycle. However, general ARM development tools only provide instruction set simulators and can only support ARM core simulation debugging.
Performance analyzer, see farther, see more details, see more clearly
RealView MDK's performance analyzer is like a Halley telescope, allowing you to see farther and more accurately. It helps you view code coverage, program running time, function call times and other high-end control functions, and guides you to easily optimize the code and become an embedded development expert. Usually these functions are only available with expensive Trace tools worth thousands of dollars.
Cortex-M3 support
The Cortex-M3 core supported by RealView MDK is the latest core launched by ARM for microcontroller applications. It provides industry-leading high-performance and low-cost solutions and will become a hot spot and mainstream for MCU applications in the next few years. At present, only ARM's MDK and RVDS development tools can support the application development of Cortex-M3 chips in China.
The industry's best ARM compiler - RealView compiler, with smaller code and higher performance.
Comparison between RealView MDK's RealView compiler and ADS 1.2:
Code density: 10% smaller than the code size compiled by ADS 1.2;
Code performance: 20% higher than the code performance compiled by ADS 1.2.
You can download RealView MDK from KEIL's official website . The downloaded version is a trial version with a 32K code limit. You can find a registration machine online, and it seems that the registration machine for 3.x will do.
2. About Jlink
Jlink is a JTAG emulator launched by SEGGER to support the simulation of ARM core chips. It supports the simulation of all ARM7/ARM9 core chips in conjunction with IAR EWARM, ADS, KELL, WINARM, RealView and other integrated development environments. It is seamlessly connected to various integrated development environments through the RDI interface, easy to operate, simple and easy to learn, and is the most practical development tool for learning and developing ARM. For the features of Jlink, please refer to SEGGER's official introduction. SEGGER
3. Create a marquee project.
Open Keil uVision4 and create a new project tq2440, then select the CPU type. Here we select s3c2440a used by tq2440. After confirmation, we will be prompted whether to add the startup code of s3c2440 to our project (this is a feature of RealView MDK relative to ads1.2. It will automatically generate the startup code of the corresponding CPU, and it is also very convenient to configure the startup code. I will talk about it later.) Here we choose yes. At this time, our project is built and the startup code is also available. Let's take a look at this startup code. There are quite a lot of startup codes, more than 1,000 lines. Don't be afraid. In fact, there are not many codes. You can take a closer look. More than half of them are comments, and you can configure the startup code without manually changing the code. Click the Configuration Wizard in the red part of the picture above to configure the startup code graphically. For example, if we want to configure the watchdog timer, we can select Watchdog Time. Setup, click the plus sign on its left to make detailed settings. Here we just check all the boxes to save trouble. Okay, the startup code is configured. Now let's add our LED marquee program. Create a main.c file in the project directory and add it to the project's source file. Then add the following code to the main.c file //Define the control register address of PORTB #define GPBCON (*(volatile unsigned *) 0x56000010) #define GPBDAT (*(volatile unsigned *) 0x56000014) #define GPBUP (*(volatile unsigned *) 0x56000018) void delay() { int i, j; for(i = 0; i < 10000; i ++) for(j = 0; j < 50; j ++); } int main() { GPBCON = 0x155555; //Configure all pins of protB as outputs while(1) { //Turn on the first small light GPBDAT |= 0x1E0; GPBDAT &= 0x1C0; delay(); //Light up the second small light
GPBDAT |= 0x1E0; GPBDAT &= 0x1A0; delay();
//Light up the third small light
GPBDAT |= 0x1E0; GPBDAT &= 0x160; delay();
//Light up the fourth small light
GPBDAT |= 0x1E0; GPBDAT &= 0x0E0; delay();
}
return 0;
}
Okay, the code is complete. Now let's configure the compilation and linking options. Select the project properties Then select the Target option and set it as shown below In the Output option, select Create HEX File. Don't worry about the other options. Then press F7 to try to build and check the output information. It has been successful. There is only one Warning, which can't be ignored. [page] From the above picture, we can see that the hex file has been generated, and it also tells us that our code size is 920 bytes, read-only data is 16 bytes, readable and writable data is 0, and ZI data is 1256 bytes. OK, now we will burn it into our development board. We also need to configure the burning options. We still select the project properties and then select the Utilities option. Then select J-LINK/J-Trace in the burning options, then remove the Update Target before Debugging option, and finally click Settings to add the burning algorithm. There is no algorithm for our norflash EN29LV160AB here. We only choose a similar one, such as AM29F160DBFlash, but this algorithm can only burn and not erase (if you are interested, you can write a burning algorithm yourself). Well, everything is ready except JLINK, but before burning, please make sure you have installed the JLINK driver. The JLINK driver can be downloaded from SEGGER's official Software and documentation pack V4.14b . After the driver is installed, we connect the development board, and then change the startup mode of the development board to start from norflash, then start the development board, and finally click Download. If there is no accident, you can see the LED start to flash. 4. Debug the Marquee Program It is not enough to just download it. The most important thing is to be able to debug it. Let's see how to debug the program under RealView MDK. In fact, RealView MDK is much more powerful than ads1.2. We open the project properties, first select the Debug option and then select Use J-LINK/J-Trace, then click Settings, select JTAG Speed as Auto Selection, first select Reset Strategy as Hardware, and halt with BP@0. Finally, select Run to main(), so that it will automatically stop at the entry of our main function during debugging. In addition, we do not need a debugging initialization file. This file does not need to be written. We can find it in the RealView MDK example. For example, on my machine, it is Ext_ARM.ini under D:ToolElectronicRealViewMdkARMBoardsSamsungS3C2440RTX_Blinky. We copy it to our project directory and then select it in Initialization File. Another place we need to change is the memory address of the program. When we burned just now, we used the setting of starting address 0 and size 2M, and this address 0 corresponds to the address of our norflash. Now when we debug, we directly load the code into the memory (that is, sdram). On s3c2440, its corresponding address is 0×30000000, so we have to change the starting address of ROM to 0×3000000, and the corresponding starting address of RAM to 0×30200000, and the size remains unchanged. OK, the debugging options are all set, we start debugging, if there is no accident, it will appear as shown below. We can see that its debugging environment is very friendly, very similar to vs. The left side is the value of each register, the upper right is the assembly code, and the bottom is the corresponding source code. The current pointer stops in main, we can debug step by step, and we can also set breakpoints. We can also view information such as memory, etc. If we don’t have JLINK, we can also use the simulator that comes with RealView MDK. The method is to select the Use Simulator option in the Debug option. If you get an error like *** error 65: access violation at 0×53000008 : no 'write' permission, you can try to remove the watchdog and clock settings in the startup code.
Keywords:MDK Jlink TQ2440
Reference address:RealView MDK+Jlink+TQ2440 debugging notes
Software: RealView MDK 4.03q
Hardware: JLINK v7, TQ2440 development board
When I first started learning ARM OS-free programming, I used Tianqian's TQ2440_Test project, which is an ads1.2 project. However, I used the Windows 7 operating system. Ads1.2 is relatively old and does not work well under Windows 7. It always crashes inexplicably, which made me very depressed. So I switched to RealView MDK, but there are few tutorials about RealView MDK on the Internet (probably because not many people use it). After a week of learning, I am familiar with the environment of RealView MDK. The following is a record of my debugging process.
1. Introduction to RealView MDK
2. Introduction to Jlink
3. Create RealView MDK LED Marquee Project
4. Debug Program
1. About RealView MDK
In fact, RealView MDK is also a product of Keil. It is a new development environment for ARM developed after Keil was acquired by ARM. I personally feel that it is much better than ads1.2. RealView MDK has many outstanding features:
startup code generation wizard, automatic boot
The startup code is closely integrated with the system hardware and must be written in assembly language, which makes it difficult for many engineers to cross multiple thresholds. RealView MDK's μVision3 tool can help you automatically generate perfect startup code and provide a graphical window for you to modify easily. Whether for beginners or experienced development engineers, it can greatly save time and improve development efficiency.
Software simulator, software development process completely separated from hardware
RealView MDK's device simulator can simulate the entire target hardware, including fast instruction set simulation, external signal and I/O simulation, interrupt process simulation, all peripheral device simulation on chip, etc. Development engineers can start software development and debugging without hardware, so that software and hardware development can be carried out simultaneously, greatly shortening the development cycle. However, general ARM development tools only provide instruction set simulators and can only support ARM core simulation debugging.
Performance analyzer, see farther, see more details, see more clearly
RealView MDK's performance analyzer is like a Halley telescope, allowing you to see farther and more accurately. It helps you view code coverage, program running time, function call times and other high-end control functions, and guides you to easily optimize the code and become an embedded development expert. Usually these functions are only available with expensive Trace tools worth thousands of dollars.
Cortex-M3 support
The Cortex-M3 core supported by RealView MDK is the latest core launched by ARM for microcontroller applications. It provides industry-leading high-performance and low-cost solutions and will become a hot spot and mainstream for MCU applications in the next few years. At present, only ARM's MDK and RVDS development tools can support the application development of Cortex-M3 chips in China.
The industry's best ARM compiler - RealView compiler, with smaller code and higher performance.
Comparison between RealView MDK's RealView compiler and ADS 1.2:
Code density: 10% smaller than the code size compiled by ADS 1.2;
Code performance: 20% higher than the code performance compiled by ADS 1.2.
You can download RealView MDK from KEIL's official website . The downloaded version is a trial version with a 32K code limit. You can find a registration machine online, and it seems that the registration machine for 3.x will do.
2. About Jlink
Jlink is a JTAG emulator launched by SEGGER to support the simulation of ARM core chips. It supports the simulation of all ARM7/ARM9 core chips in conjunction with IAR EWARM, ADS, KELL, WINARM, RealView and other integrated development environments. It is seamlessly connected to various integrated development environments through the RDI interface, easy to operate, simple and easy to learn, and is the most practical development tool for learning and developing ARM. For the features of Jlink, please refer to SEGGER's official introduction. SEGGER
3. Create a marquee project.
Open Keil uVision4 and create a new project tq2440, then select the CPU type. Here we select s3c2440a used by tq2440. After confirmation, we will be prompted whether to add the startup code of s3c2440 to our project (this is a feature of RealView MDK relative to ads1.2. It will automatically generate the startup code of the corresponding CPU, and it is also very convenient to configure the startup code. I will talk about it later.) Here we choose yes. At this time, our project is built and the startup code is also available. Let's take a look at this startup code. There are quite a lot of startup codes, more than 1,000 lines. Don't be afraid. In fact, there are not many codes. You can take a closer look. More than half of them are comments, and you can configure the startup code without manually changing the code. Click the Configuration Wizard in the red part of the picture above to configure the startup code graphically. For example, if we want to configure the watchdog timer, we can select Watchdog Time. Setup, click the plus sign on its left to make detailed settings. Here we just check all the boxes to save trouble. Okay, the startup code is configured. Now let's add our LED marquee program. Create a main.c file in the project directory and add it to the project's source file. Then add the following code to the main.c file //Define the control register address of PORTB #define GPBCON (*(volatile unsigned *) 0x56000010) #define GPBDAT (*(volatile unsigned *) 0x56000014) #define GPBUP (*(volatile unsigned *) 0x56000018) void delay() { int i, j; for(i = 0; i < 10000; i ++) for(j = 0; j < 50; j ++); } int main() { GPBCON = 0x155555; //Configure all pins of protB as outputs while(1) { //Turn on the first small light GPBDAT |= 0x1E0; GPBDAT &= 0x1C0; delay(); //Light up the second small light
GPBDAT |= 0x1E0; GPBDAT &= 0x1A0; delay();
//Light up the third small light
return 0;
}
Okay, the code is complete. Now let's configure the compilation and linking options. Select the project properties Then select the Target option and set it as shown below In the Output option, select Create HEX File. Don't worry about the other options. Then press F7 to try to build and check the output information. It has been successful. There is only one Warning, which can't be ignored. [page] From the above picture, we can see that the hex file has been generated, and it also tells us that our code size is 920 bytes, read-only data is 16 bytes, readable and writable data is 0, and ZI data is 1256 bytes. OK, now we will burn it into our development board. We also need to configure the burning options. We still select the project properties and then select the Utilities option. Then select J-LINK/J-Trace in the burning options, then remove the Update Target before Debugging option, and finally click Settings to add the burning algorithm. There is no algorithm for our norflash EN29LV160AB here. We only choose a similar one, such as AM29F160DBFlash, but this algorithm can only burn and not erase (if you are interested, you can write a burning algorithm yourself). Well, everything is ready except JLINK, but before burning, please make sure you have installed the JLINK driver. The JLINK driver can be downloaded from SEGGER's official Software and documentation pack V4.14b . After the driver is installed, we connect the development board, and then change the startup mode of the development board to start from norflash, then start the development board, and finally click Download. If there is no accident, you can see the LED start to flash. 4. Debug the Marquee Program It is not enough to just download it. The most important thing is to be able to debug it. Let's see how to debug the program under RealView MDK. In fact, RealView MDK is much more powerful than ads1.2. We open the project properties, first select the Debug option and then select Use J-LINK/J-Trace, then click Settings, select JTAG Speed as Auto Selection, first select Reset Strategy as Hardware, and halt with BP@0. Finally, select Run to main(), so that it will automatically stop at the entry of our main function during debugging. In addition, we do not need a debugging initialization file. This file does not need to be written. We can find it in the RealView MDK example. For example, on my machine, it is Ext_ARM.ini under D:ToolElectronicRealViewMdkARMBoardsSamsungS3C2440RTX_Blinky. We copy it to our project directory and then select it in Initialization File. Another place we need to change is the memory address of the program. When we burned just now, we used the setting of starting address 0 and size 2M, and this address 0 corresponds to the address of our norflash. Now when we debug, we directly load the code into the memory (that is, sdram). On s3c2440, its corresponding address is 0×30000000, so we have to change the starting address of ROM to 0×3000000, and the corresponding starting address of RAM to 0×30200000, and the size remains unchanged. OK, the debugging options are all set, we start debugging, if there is no accident, it will appear as shown below. We can see that its debugging environment is very friendly, very similar to vs. The left side is the value of each register, the upper right is the assembly code, and the bottom is the corresponding source code. The current pointer stops in main, we can debug step by step, and we can also set breakpoints. We can also view information such as memory, etc. If we don’t have JLINK, we can also use the simulator that comes with RealView MDK. The method is to select the Use Simulator option in the Debug option. If you get an error like *** error 65: access violation at 0×53000008 : no 'write' permission, you can try to remove the watchdog and clock settings in the startup code.
Previous article:S3C2410 SDRAM register initialization settings
Next article:Small knowledge of ARM development summary
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Guess you like
- Keys? No more! The future of car access systems is here
- SIMETRIX/SIMPLIS simulation tutorials and examples
- Development data of National Technology N32G455
- What is IoT
- [RVB2601 Creative Application Development] User Experience 09 -- YoC Event
- [Ready to use] LIS2DTW12 functional demonstration project (STM32G474)
- Code migration process of MSPBoot
- Why is there a 2 in the denominator when calculating the baud rate of the serial port communication of the 51 single-chip microcomputer? I have always wondered why it is divided by 2
- Please share the basic principles of 5G
- Why does the g2553 circuit board omit the external 32.768k crystal oscillator?