📄 combineiplspl.c
字号:
/*************************************************************************Title: Filename: $Header:$Hardware: MX21Summay:Author: Company: Freescale Suzhou Design Center====================Change Log========================$Log:$********************************************************************************////@ingroup NAND_BOOTLOADER///@file combineIplSpl.c///@brief Combine ipl and spl to be one bootloader image.//////@remarks ipl occupies the front 1.5k of the first 2k size from 0x0 to 0x800./// spl occupies the following 14k size from 0x800 to 0x4000./// As They can be put in the first block of the NAND flash, we combinethem together for easy programming.//////@author ///@version $Version$///@section history History/// 24-Jun-04 New/////<<<<<Include#include <stdio.h>//>>>>>Include//<<<<<< Private Structure//>>>>>> Private Structure//<<<<<< Global VariableFILE *iplFile, *splFile, *outfile;//>>>>>> Global Variable//<<<<<Private Function Declearation//>>>>>Private Function Declearation//<<<<<Body///The main functionint main (int argc, char *argv[]){ int i,num=0; unsigned char bData = 0; if (!(iplFile = fopen("ipl.bin","rb"))) { printf("ipl.bin open error !\n"); return 0; } if (!(splFile = fopen("spl.bin","rb"))) { printf("spl.bin open error !\n"); fclose(iplFile); return 0; } if (!(outfile = fopen("bootloader.bin","wb"))) { printf("Output file open error !\n"); fclose(iplFile); fclose(splFile); return 0; } // write ipl.bin from 0x0 while( fread(&bData,sizeof(char),1,iplFile) > 0) { fwrite(&bData,sizeof(char),1, outfile); num++; } printf("read %x chars from ipl.bin\n",num); // fill the following space in the first 2k with 0x0 bData = 0; for(i=num; i<0x800; i++) fwrite(&bData, sizeof(char), 1, outfile); // write spl.bin from 0x800 while( fread(&bData,sizeof(char),1,splFile) > 0) fwrite(&bData,sizeof(char),1, outfile); fclose(outfile); fclose(iplFile); fclose(splFile); printf("\nCombination done.\n"); return 0;}//>>>>>Body
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -