ARM exception and bare-metal development

2019-12-15

Keywords: Embedded Development, exception handling, bare-metal embedded development


 

1, ARM exception

 

Abnormal events are very common in embedded development, it is also a very important event. In simple terms, it is a kind of abnormal events will interrupt normal program execution. Abnormal often called "break."

 

The error type can be divided into the following categories:

1, interrupt

IRQ / FIQ interrupts by an external hardware trigger.

2, soft interrupt

soft interrupt interrupt event called by the system, interrupt events generated by the software.

3, Reset

Reset 

4, undefined instruction

5, data anomalies

For example, data crossing the boundary.

 

Interrupt:

ARM has two levels of external interrupt: 1, FIQ; 2, IRQ.

 

But most embedded systems have more than two external interrupt sources, in order to properly respond to all external interrupt events, you need a "Interrupt Controller."

 

Embedded system interrupt architecture substantially as shown below:

When a large amount of interrupt events in a short time, CPU can not guarantee timely response to all interrupt events. To avoid the problem of lost interrupts occur, interrupt each event will make a "record", that is our common settings "interrupt flag." When the value of the CPU interrupt flag found effective, it will initiate an interrupt event. Of course, an interrupt event we generally need only deal with one, so we usually want to interrupt the corresponding interrupt flag in the handler for the cleanup operation.

 

ARM system will be a "Interrupt Vector Table" function to specifically address storage interrupt response mechanism.

 

2, bare-metal development

 

What is the bare metal development?

 

It refers to the development of bare metal plate embedded development, the direct write mode program control to develop a hardware device. No development board operating system, within the various boards around, peripheral hardware resources required by the program to use to its full operation.

 

In addition to the development of bare metal software programming capabilities, there is a very important thing is to be able to read a variety of hardware circuit and chip manual.

 

In the schematic design of embedded art, it can often be seen with certain CPU pin device is not directly connected, but through a "triode" controlled indirectly. Reason for this design is to reduce the risk of CPU when controlling a variety of peripherals burned a total current peripherals. Take control circuit for an LED lamp, a LED lamp usually supply voltage of 3.3v, and access to a resistance of 1k. Thus, LED lights when the current work on about 3.3ma. If the CPU pin directly controls the LED light off, when the board has a large number of LED light up simultaneously, the current input to the CPU adds up will be relatively large, the CPU heat will grow, the greater risk burning . Indirectly through a control transistor LED lamp, there would be the risk, the LED current when the work will not be directly applied to the CPU.

 

In the schematic design, there is a very common concept: a pull-down resistor. They refer to the corresponding component on an external circuit or a group of resistor elements. Refers to pull-resistive element is connected to the power supply, it refers to the pull-down resistance element is connected to ground.

 

ARM chips often have a lot of pins, of which there will be several groups of GPIO pins. GPIO stands for: General purpose input / output, these pins can be simply understood as the freedom to realize is dedicated to our software logic functions. In order to save hardware resources and development costs, usually the same chip pin can also have multiple functional purposes. We need to first determine a good functional use a pin in the program before going to set the value of the pin. Thus, the control pin ARM chip typically requires two operations to register:

1, function control register;

2, the register values.

In the software development process, the first register set the pin functions we use through the use of function control, ordinary GPIO mode or other functions, direction is input or output direction. And only then the corresponding level value is written to the register values.

 

After program completion, need to build generating executable files to run on ARM chips.

 

Compilation process typically use the Linux operating system to complete. Compilation also need to use special "compilation chain", that is, with the platform to run the program matches the gcc tool. PC side of the Linux system is the default gcc for x86 chip architecture, with its compiler executable program can only run on x86 architecture chips. The gcc tools and platforms to match the need to download and install on their own, or ask to ask for chip manufacturers.

 

ARM bare metal development model is also known as "cross-development environment." It refers to the development and operation of the program is done separately. We usually use the PC to write, compile the program and then compiled executable program downloaded to the development board to run. This development environment is called "cross-development environment."

 

Some developers will board at the factory preset program uboot, uboot in the mode directly by loadb command to download the program to the development board memory, and then to run our "bare metal program" go + memory address by this command. Of course, this model is not all ARM development boards are supported, whether or not depends on the specific vendors have provided this functionality.

 


 

Guess you like

Origin www.cnblogs.com/chorm590/p/12032156.html