1
Introduction Bootloader is a piece of code executed after the CPU is reset and before entering the operating system. It is mainly used to complete the transition from hardware startup to operating system startup and provide a basic operating environment for the operating system, such as initializing the CPU, stack, memory system, etc. Bootloader code is related to factors such as the core structure and specific model of the CPU, and its function is similar to the BOIS program of a general PC. In addition to relying on the CPU architecture, Bootloader actually also depends on the configuration of specific embedded board-level devices. In other words, for two different embedded boards, even if they are built with the same CPU, if you want the Bootloader program running on one board to run on the other board, you usually need to modify the source program of the Bootloader. Therefore, it is impossible to have a universal Bootloader in the development of embedded systems. When developing, users need to transplant according to specific system design requirements.
From the perspective of actual development of embedded systems, the boot, configuration and even the running status of embedded operating systems are all related to Bootloader. It can be said that mastering Bootloader transplantation is an important tool for the smooth development of embedded systems. In embedded Linux systems, PPCBoot is a powerful boot-loader that supports multiple CPU architectures, but it is also relatively complex.
This article takes the MPC8250 microprocessor and embedded Linux as the background, and provides a targeted transplantation method for PPCBoot on the development board, which can be applied in the application development of embedded Linux systems based on MPC82xx series processors.
2 Introduction to PPCBoot
PPCBoot is a bootloader developed by the German DENX team for a variety of embedded CPUs. It is mainly maintained and developed by German engineer Wolfgang Denk and a group of freelance developers on the Internet. It supports multiple processor platforms such as PowerPC, ARM, MIPS, and m68K, and is easy to tailor and debug.
PPCBoot follows the GPL (General Public License) convention and is completely open source. The PPCBoot source code can be obtained from the community server of the sourceforge website. Its project homepage is http://sourceforge.net/projects/ppcboot, and it can also be downloaded from the DENX website http://www.denx.de. The version used by the author is PPCBoot-2.0.0.
The main features of PPCBoot are listed in Table 1.
3 Operation flow of PPCBoot
When MPC8250 is powered on or a reset signal is applied, the CPU determines its state by reading the value on the data bus D[0:31] or according to the internal default constant D[0:31]=0x00000000. If RSTCONF# is low when the CPU reads the bus value, the hard reset configuration word (HRCW) is read from the bus. If RSTCONF# is high, HRCW uses the internal default value. After power
-on, the startup storage controller CSO# (corresponding to the chip select signal of Flash) is valid, Flash is selected, and the CPU address line outputs the address 0x00000100 corresponding to the hardware reset interrupt vector, and starts reading the first instruction. In PPCBoot, this instruction corresponds to the _start: label in /ppcboot/cpu/mpc8260/start.S. The following describes the specific startup process.
(1) Run start.S (/ppcboot/cpu/mpc8260/start.S) and execute from the start: label. After completing the basic initialization of the CPU itself, it mainly initializes some states of the CPU internal registers, mainly setting IMMR, ICTRL, D-cache, I-cache, etc. Execute from in_flash:, set the C language working environment, and then transfer to the code bl cpu_init_f (step 2) and bl board_init_f (step 3).
(2) CPU bottom-level initialization (/ppcboot/cpu/mpc8260/epu_init.C) Jump from start.S to the function cpu_init_f (volatileimmap_t*immr) to perform CPU bottom-level initialization, mainly setting the watchdog, SIUMCR register, timebase register, PIT (periodic interrupt register), phase-locked loop, system timer, storage controller and CPM, etc. [page]
(3) The first initialization of the board (/ppcboot/lib_ppc/board.c) After completing step 2, the return address is placed in the LR register, and then jump from start.S to the function board_init_f (ulong bootflag), which implements the first initialization of the board, completes SMC initialization and some hardware tests. In particular, RAM is initialized, and memory space is allocated to save board information and prepare to redirect code in RAM. Then call the relocate_code function to move PPCBoot to RAM for execution.
(4) Move code to memory (/ppeboot/cpu/mpc8260/8tart.s)
Jump from the function board_init_f to the relocate_code() function in /ppcboot/cpu/mpc8260/start.S, then move the code to SDRAM, adjust the GOT table, do some relocation, and start running the code in RAM.
(5) The second initialization on the board (/ppcboot/lib_ppc/board.C) After the relocate_code() function, it will jump to the board_init_r() function to perform the second initialization, mainly completing the initialization of some data structures, high-end modules and system devices.
(6) Command analysis and execution (/ppcboot/commom/main.C) After initialization, PPCBoot will execute the main_loop() function loop in the function board_init_r(), that is, the monitoring program. The monitoring program of PPCBoot will complete the pre-set work according to the user's input from the console. This function is in /ppebooffeommom/main.c. In the function main_loop(), the run_command() function in /ppeboot/com-mom/main.C will be called to complete the command analysis and then execute the corresponding processing function.
4 Modification and compilation of PPCBoot source code
To port PPCBoot to a new development board, the source code of PPC-Boot should be modified according to the specific system design requirements and the system hardware configuration.
The porting mainly includes two levels of porting. The first level is the porting for the CPU. The CPU types supported by PPCBoot are in the directory /cpu, and MPC8250 corresponds to the directory /cpu/mpe8260; the second level is the porting for the specific board, which mainly modifies the code according to the developer's own specific design. In order to reduce the workload, you can select a board with hardware similar to your own development board from the demo board supported by PPC-Boot as a template. Here, the author selects the MPC8260ADS board as the reference board and directly modifies the source code files related to the board.
4.1 Development board hardware
Before modifying the PPCBoot source code, you must understand the hardware configuration of the development board and make corresponding modifications to the configuration values in the source code according to the hardware configuration. Table 2 lists the basic hardware information of the board. In addition, the peripheral device interfaces of the MPC8250 development board mainly include 10/100M adaptive network card interface, RS232 serial port, PCI interface and full-function JTAG debugging interface.
4.2 Modify PPCBoot source code
From the perspective of the minimum requirements for porting PPCBoot and the normal startup of PPCBoot, and after comparing the similarities and differences between the MPC8260ADS board and the development target board, the following files are mainly considered for modification.
(1) Modify the header file mpc8260ads.h. mpe8260ads.h is the board configuration file. It configures the board's CPU, system clock, SDRAM, Flash system and all other development board information. It is the most important file that needs to be modified.
Set the IMMR CPU register base address in this file. Note that this value must be the same as the operating system setting.
#define CFG-IMMR 0xF0000000
Set CPU clock
#define CONFIG_8260_CLKIN 33333333 /*in Hz */
Setting: Flash, SDRAM, including base address, size, offset and size of environmental parameters, and memory refresh cycle, should be set according to the specific situation of the target board; set environmental parameters for network download and startup; in addition, memory control values such as BR0, OR0, BR1, OR1, Watch.dog and some target board specific parameters should also be set according to the actual situation.
(2) When Linux starts, it needs to obtain memory base address and size, clock frequency, baud rate, IP address and other parameters from PPCBoot, so the member order of the structure bd-info defined in the ppcbooth file must be consistent with the definition of the Linux operating system to achieve correct parameter transmission.
(3) Modify mpc8260ads.c. mpe8260ads.c configures the I/O port table, initializes SDRAM, and completes the board verification work. Among them, the I/O port table configures the network port and some other general I/O ports on the board. The function initdram completes the initialization of SDRAM according to the configuration of SDRAM registers.
(4) Modify config.mk. Modify ppcboot/board/mpc826Oads/config.mk and set TEXT_BASE=0xEF000000 so that the value of TEXT_BASE is the same as the value of CFG_FLASH_BASE in the header file. This value defines the boot address.
4.3 Compile PPC-Boot
After the code modification is completed, it is necessary to recompile. The compilation of PPC-Boot requires the establishment of a PowerPC cross-compilation environment on the Linux host. It is usually complicated to establish a cross-compilation environment step by step by yourself. The easiest way is to use the cross-compilation tool compiled by others. The author uses the complete development tool set CDK provided by MontaVista. [page]
After establishing the cross-compilation tool on the RedHat Linux9.O host, modify the Makefile file in the PPCboot directory, specify the full path name of the cross compiler, and then use the following command to configure and compile:
#make MPC8260ADS_ config
#make
After the compilation is completed, 3 files are obtained:
* ppcboot: This is an ELF (Executable and Link Format) format file that can be recognized by most Debug programs.
*ppcboot.bin: This is a binary bin file, pure ppeboot binary execution code, does not contain ELF format and debugging information. This file is generally used to install and burn ppcboot to the user's development board.
*ppcboot.srec: Motorola's S-Record format. It is a file that can be downloaded to the development board through the serial port.
5. Transplant
the ppcboot.bin file compiled by PPCBoot and download it to the starting address of Flash through the JTAG interface. After powering on again, you can see the startup information of PPCBoot:
PPCBoot 2.0. O(Jul 12 2005-18:21:391
RewinTeeh: Fengjunping&&Huangjianzhong MPC8260
Reset Status: External Soft.Extemal Hard MPC8260
Clock Configuration
—Bus—to—C0re Mull 5x.VCO Div 2,60x Bus Freq 20—60, Core Freq 100-300-dtbrg 0, coreen f Oxob, busdf 5, cpmdf 1, plldf 0, pnmf 2 -
vco__out 199999998, scc_elk 49999999, brg_elk49999999
- cpu_clk 166666665, epm_clk 99999999, bus_clk33333333
CPU: MPC8260 (Rev 14, Mask unknown [immr = 0x0064, k = 0x002d]) at 166.666 MHz
Board: Motorola MPC8260ADS
I2C: ready
DRAM: 16MB
F1ash: 16 MB
***Warning—bad CRC. using default environment
In: serial
Out: serial
Err: serial
stan linux now (y/n): =>
Input help to get a list of all commands. Help command lists the functions of the command. Then test the Flash and network card. If they work properly, it means that the work of porting PPCBoot is basically completed. You can then debug the kernel and file system.
In the actual process, it may be necessary to modify it several times due to inconsideration. After the porting is successful, you can also add some other functions (such as LED driver, etc.). It is relatively easy to add functions on this basis.
6 Conclusion
Bootloader is the hub of operating system and hardware in embedded development. It provides necessary conditions and parameters for the startup of operating system kernel. In the process of porting, developers should not only master the structure and workflow of Bootloader, but also have a certain understanding of related hardware. At present, the PPCBoot ported by the author can run stably on the development board, and can load the kernel and file system through FIash and network, which lays a good foundation for subsequent development, especially the development of driver. For different CPUs and development boards, the basic methods and steps are the same. The author hopes that his experience can help relevant embedded designers.
Previous article:The pitfalls of crossing data types
Next article:Design of Bidirectional Silicon Controlled Rectifier Trigger Circuit
Recommended ReadingLatest update time:2024-11-16 21:34
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TI C2000 Basic Learning
- Interest group training topic: Use MOS tube or + op amp to realize a DC/DC closed-loop voltage regulator
- Simple square wave generator based on 51 single chip microcomputer
- MSP430fr6989 serial port DMA sending experimental routine
- [RISC-V MCU CH32V103 Review] First impression of CH32V103C8T6 chip
- 100 check items for PCB design to ensure you have no problems with your design!
- How to write the corresponding program process according to the timing diagram
- Differences and similarities between detection circuits, filter circuits, frequency selection circuits, threshold comparison circuits, and bandpass circuits
- When designing PCB, how to consider electromagnetic compatibility EMC/EMI, specifically...
- How to measure the PWM generated by msp430f149 with an oscilloscope