Abstract: After Bootloader is on the system the electricity or the replacement, first moves section of codes, are the tended operation system and hardware’s bridge, is responsible for the initialization hardware and the pilot operation system and so on. At present had general Bootloader, but how to act according to the specific embedded platform, transplants own vectoring procedure is key and the difficulty. The article explained in detail must complete the primary mission from the Nandflash pilot operation system and realize the method, and gave has realized the test result which on S3C2410 Nandflash started.
Key word: Bootloader; Transplant; Nandflash; S3C2410
0 introductions
Bootloader usually is called system’s guidance loading sequence, the first section of code which after is the system adds electricity or replacement, carries out [1]. Generally it only when system initiation moves the very short time, but regarding the embedded system, this is a very important system composition part. Through this section of scripts, may initialize the hardware equipment, the establishment memory space mapping chart, thus system’s software and hardware environment belt to an appropriate condition, in order to approves for the transfer operating system to arrange the correct environment, simultaneously and provides the basic input, the output system monitoring function and the program debugging function.
Bootloader is relies on seriously in the hardware realizes. Each kind of different architecture’s processor has different Bootloader. Besides relies on processor’s architecture, Bootloader in fact also relies on the concrete embedded board level equipment’s disposition, i.e., speaking of two different embedded boards, even if they are construct based on the identical kind of processor, if wants to enable the movement also to move on together the board Bootloader procedure on addition together the board, usually also needs to revise and the goal hardware related code. Therefore has the necessity to analyze Bootloader, and understands and discovers principle and the rule, its specific embedded system, the transplant or the development belong to own Bootloader.
1 system hardware platform synopsis
What this system uses is SamSung Corporation’s S3C2410 processor [2], it is specially the high performance-to-price ratio which and the high performance embedded microprocessor solution provides for the motion hand-hold equipment. Its essence is ARM920T, most high energy work in 202.8MHz, to reduce the system total cost and reduce the periphery component, it integrated the following part: Respectively is the 16KB instruction and data Cahce, 1 LCD controller, the SDRAM controller, the NANDFLASH controller, 3 channel UART, 4 channel DMA, 4 has the PWM function timer and 1 internal clock, 8 channel 10 ADC, the touchscreen connections, I ² S bus interface, 2 USB host interface, 1 USB equipment interface, 2 SPI connections, SD and MMC card connection, watch-dog timer, 117 general IO mouths, 24 exterior interrupt source, 8 channel 10 AD controller and so on. This article involves S3C2410 development board’s hardware architecture as shown in Figure 1, this article main elaboration the primary mission which must complete from the Nandflash pilot operation system and realizes the method, as for from the Norflash pilot operation system, did not plan that realizes specifically.
Figure 1 S3C2410 hardware structure drawing
2 storage space distribution and mapping chart
Hardware platform’s Nandflash (the model is: K9F1208U0M [3]) the space is 64MB, SDRAM (the model is: HY57V561620 [4], 32Mx2) the space is 64M (0×30000000-0×33ffffff), uses storage space distribution map which as shown in Figure 2, because of Nandflash can only the stored routine, be unable the operating procedure. For can start from Nandflash, when on electricity replacement, S3C2410 duplicates before the hardware logic the Nandflash 4KB content in internal SRAM, but internal SRAM is mapped address 0×0, like this may take the effective instruction from address 0×0 place, starts to carry out bootloader, completes the essence code duplicates Nandflash in the sdram medium work.
Figure 2 Guidance code and operating system essence in Nandflash and in storage space distributed situation
3 Bootloader design cycles
After the Bootloader vectoring procedure is on the hardware the electricity replacement, first moves the code, loads the embedded operating system by it. Then by the operating system control overall system, carries on work and so on process management, memory management, floppy disk management and each peripheral device management. Before BootLoader is an operating system essence movement section from lifts the procedure, uses for the initialization hardware equipment, the change processor movement pattern and the reorganization interrupt vector, establishes the memory space the mapping chart, system’s software and hardware environment belt to one specific condition which has custom-made by the user, then load operating system essence. Looking from operating system’s angle, the Bootloader general objective is transfers the essence to carry out correctly. Bootloader divides into stage1 and stage2 generally two major part [5], regarding relies on the CPU architecture code, for instance the equipment initialization code and so on, usually places in stage1, moreover usually uses the assembly language to realize, serves the terse and forceful purpose, is also the start code which front said. But stage2 usually realizes with the C language, like this may realize the complex function, moreover the code will have a better readability and the probability.
3.1 Bootloader stage1
This part of codes must first complete some basic hardware initialization. Prepares some basic hardware environment for the stage2 execution as well as afterward essence’s execution. Bootloader stage1 in common currency the content includes:
(1) establishes the interrupt and the exception vector; (2) forbids the watch-dog; (3) shield all interrupts, in Boot Loader carries out in the entire process to be possible not to need to respond any interrupt, the interrupt mask may through write CPU the interrupt mask register or the condition register CPSR register completes; (4) establishes CPU the speed and the clock rate; (5) pair of RAM carries on the initialization, including correct establishment system’s memory controller’s function register and so on; (6) initialization LED or UART, are actuate LED through GPIO, may also print Bootloader through initialization UART to the serial port the debugging information to indicate that system’s condition is OK or ERROR, so that tracking system operational aspect; (7) closes CPU built-in command/data high speed buffer (cache); (8) to load Bootloader stage2 to prepare the RAM space; (9) establishes the good storehouse; (10) skips to the stage2 C entrypoint; Its flow chart as shown in Figure 3.
Figure 3 Bootloader stage1 realization
3.2 Bootloader stage2
In order to let the procedure plunge into the C language “main” the function, we use skip “main” directly the function method, realizes the code to be as follows:
b Main
After entering the main function, namely may start this stage stage2 initialization duty, this includes:
(1) if in stage1 initialization UART, at this time at least an initialization serial port, in order to carry on with the terminal user alternately, certainly may also continue to lighten or to extinguish LED to assess the program execution situation;
(2) revision clock rate;
(3) enables instruction Cache;
(5) prints some essential mutual informations from the serial port, the understanding system mode;
(6) initialization interrupt, including the shield interrupt, eliminates the interrupt to be hanging the symbol, the initialization interrupt approaches the meter, the interrupt processing function which the registration needs and so on;
(8) information and so on printing edition, time, and from Nandflash duplication essence to SDRAM in;
(9) revises the indicator, jumps directly to the essence in the SDRAM first address place, hence, has completed the Bootloader complete movement load work;
Below is main () the function and from the Nandflash duplication essence to SDRAM ReadImageFromNandflash () function concrete realization, but has abbreviated some nuts and bolts, including from serial port printing start, alternately, debugging information and some concrete function realization. Some concrete functions realize may refer to Tristar to appraise the version source code.
void Main(void)
{
JumpAddr=0×30200000; // copy essence to sdram in start address, is also the address which the essence starts to carry out
ChangeClockDivider(1,1); //1: 2:4
ChangeMPllValue(0×5c,0×1,0×1); // FCLK=202.8MHz
MMU_EnableICache(); // enables instruction Cache
Uart_Init(); // initialization serial port
Port_Init(); // initialization I/O mouth
NF_Init(); // initialization Nandflash controller
NF_ReadID(); // reads Nandflash the memory ID number
ReadImageFromNandflash(); // memory in Nandflash essence copy to SDRAM in
rINTMSK=BIT_ALLMSK; // shields all interrupts
Launch(JumpAddr); // skips to sdram in the essence starts place, and moves the essence
}
(Flash is K9F1208U0M) realizes as follows specifically from Nandflash the copy essence to the SDRAM function:
void ReadImageFromNandflash(void)
{
U8 Image_Buf[512];
U32 Sram_Space=0;
U32 j, k, numberblock;
static U32 i, SECTOR_SIZE=512;
static U8 isbad;
volatile U32 IMAGE_BASE=0×30200000; // essence the start address which moves in sdram
rINTMSK = BIT_ALLMSK; // shields all interrupts
i=2; // starts the copy essence from 2nd block, 0th uses in saving this article bootloader, 1st is useless
numberblock=2047; // copy how many block to sdram, regards the essence size to establish this value
while(1)
{
nextblock:
isbad=0;
isbad=NF_IsBadBlock(i); // judges copy block whether is bad block
if the (isbad) // is bad block, carries on corresponding processing; Otherwise neglects here, carries on the following copy
{
i=i 1; // adjusts, directional next block
isbad=0;
if (i>= numberblock) // judges whether the copy has needed block
{
Launch(JumpAddr); // copy has needed block, jumps to sdram in the essence starts place
}
goto nextblock;
}
for (k=0; k<32; k ) //1 block=32 pages
{// FMD_ReadSector () the function realizes from the Nandflash memory reads the data to the data buffer in
FMD_ReadSector (i, (U8 *) &Image_Buf, k);
for (j=0; j<SECTOR_SIZE; j ) //1 page=512 bytes
{// from data buffer copy to sdram in
* ((U8 *) (IMAGE_BASE Sram_Space j)) =Image_Buf[j];
}
Sram_Space=Sram_Space SECTOR_SIZE; // adjusts in sdram the offset address
}
i=i 1; // adjusts, directional next block
if (i>= numberblock) // judges whether the copy has needed block
{
Launch(JumpAddr); // copy has needed block, jumps to sdram in the essence starts place
}
}
}
4 test results
Because Tristar Corporation’s S3C2410 integrated the Nandflash controller, it before the hardware logic the Nandflash 4KB content, namely duplicates Bootloader in internal sram, and is mapped address 0×0 place. Through jumps the line establishment default to start from nandflash, that on after system each time electricity or replacement, first starts to move is Bootloader. Uses the ADS1.2 integrated development environment to establish the Bootloader application project, increases the essential document and establishes the good translation environment, like the Bootloader RO_Base establishment is the 0×0, RW_Base establishment is 0×33ff0000 and so on, the debugging and produces finally may carry out the binary file, writes about through the JTAG connection the Bootloader fever Nandflash the 0th block address to start place, writes about through the usb downloading tool the operating system fever the 2nd block address to start place, after replacement initialize the system movement’s result as shown in Figure 4, this procedure uses in based on the uCOS operating system’s image gathering system’s guidance. Writes the different operating system essence application procedure with the similar method fever, test result each time indicated: Bootloader moves good, the start load essence is quick, and simple, is practical, is reliable.
Figure 4 Bootloader guidance movement system
5 conclusions
The Bootloader design with realizes is a very complex process, must therefore act according to the concrete hardware and the software demand analysis carries on the transplant or the design. This article designs Bootloader completes the major function includes: The experimental board hardware’s initialization, the serial port initialization, the clock rate revision as well as from the Nandflash duplication operating system to SDRAM in the movement and so on, and have demonstrated the correct start movement information through the PC machine on super terminal, and may carry out the code only then about 3K. Therefore, this article detailed description’s Bootloader start movement’s entire process, to understood that designs and transplants Bootloader to have certain reference significance.
Reference:
[1] Xu Yuqing, yellow Yan equality. S3C44B0X Bootloader technical analysis [J]. Shanghai University of Science and Technology journal, 2005,27 (4): 369-372.
[2]SAMSUNG Corporation. Samsung s3c2410a User Manual v1.0.pdf.
[3]SAMSUNG Corporation. K9F1208U0M-YCB0.pdf.
[4] http://www.icpdf.com/pdf/HY57V561620.htm. HY57V561620(L)T.pdf.
[5] opens yu writes .32 embedded system hardware design and the debugging. Beijing: Mechanical industry publishing house, 2005,7.
[author synopsis]
Hao Weidong (1964-), male, the Han Nationality, the Hebei Ding County person, Guilin University of Electronic Science and Technology of China senior engineer, graduate student teacher, is mainly engaged in the robot technology and the medical electron aspect research.
Liu Suqi (1977-), male, the Han Nationality, the Guangxi Guilin person, the Guangxi Guilin University of Electronic Science and Technology of China robot center graduate student, is mainly engaged in the robot technology, the embedded system application aspect research.