/*****************************************************************
***原文来自:
***http://blog.chinaunix.net/uid-23373524-id-2426918.html
*****************************************************************/
下面开始正式进入烧写程序部分,先看看x-loader-1.4.1
第一件事当然是读下README了,
***原文来自:
***http://blog.chinaunix.net/uid-23373524-id-2426918.html
*****************************************************************/
下面开始正式进入烧写程序部分,先看看x-loader-1.4.1
第一件事当然是读下README了,
Directory Hierarchy: // 下面的目录
====================
- board Board dependent files
- cpu CPU specific files
- drivers Commonly used device drivers
- lib Libraries
- cpu/arm926ejs Files specific to ARM 926 CPUs
- cpu/arm1136 Files specific to ARM 1136 CPUs
- cpu/omap3 Files specific to ARM CortexA8 CPU
- board/omap1710h3
Files specific to OMAP 1710 H3 boards
- board/omap2420h4
Files specific to OMAP 2420 H4 boards
- board/omap2430sdp
Files specific to OMAP 2430 2430sdp boards
- board/omap3430sdp
Files specific to OMAP 3420sdp boards
====================
- board Board dependent files
- cpu CPU specific files
- drivers Commonly used device drivers
- lib Libraries
- cpu/arm926ejs Files specific to ARM 926 CPUs
- cpu/arm1136 Files specific to ARM 1136 CPUs
- cpu/omap3 Files specific to ARM CortexA8 CPU
- board/omap1710h3
Files specific to OMAP 1710 H3 boards
- board/omap2420h4
Files specific to OMAP 2420 H4 boards
- board/omap2430sdp
Files specific to OMAP 2430 2430sdp boards
- board/omap3430sdp
Files specific to OMAP 3420sdp boards
Software Configuration:
=======================
Configuration is usually done using C preprocessor defines. Configuration
depends on the combination of board and CPU type; all such information is
kept in a configuration file "include/configs/<board_name>.h".
Example: For a H3 module, all configuration settings are in
"include/configs/omap1710h3.h".
For all supported boards there are ready-to-use default
configurations available; just type "make <board_name>_config".
Example: For a H3 module type:
cd x-load
make omap1710h3_config
After a board has been configured, type "make" to build it supposing the
needed cross tools are in your path.
=======================
Configuration is usually done using C preprocessor defines. Configuration
depends on the combination of board and CPU type; all such information is
kept in a configuration file "include/configs/<board_name>.h".
Example: For a H3 module, all configuration settings are in
"include/configs/omap1710h3.h".
For all supported boards there are ready-to-use default
configurations available; just type "make <board_name>_config".
Example: For a H3 module type:
cd x-load
make omap1710h3_config
After a board has been configured, type "make" to build it supposing the
needed cross tools are in your path.
Image Format:
=============
X-Loader expects OS boot loader (e.g. U-Boot) in Nand flash using
JFFS2 style ECC.
Prepare Booting Nand Flash:
===========================
After you have built x-load.bin for your board, you need to do the
followings to get it into Nand flash:
1. Use Texas Instruments IFT to sign x-load.bin. This results in a
signed image called x-load.bin.ift.
2. Use Texas Instruments FlashPrep to generate a .out file using
FlashWriterNand and specifying 0 as nand target address.
3. Use Texas instrumnets Code Composer Studio to run the .out file
which flashes x-load.bin.ift to Nand flash.
Next you need to get your OS boot loader to Nand at the address your
X-Loader expects. For the H3 example, you can use U-Boot to flash U-Boot.
You can't use FlashWriterNand because it uses ROM code ECC style.
=============
X-Loader expects OS boot loader (e.g. U-Boot) in Nand flash using
JFFS2 style ECC.
Prepare Booting Nand Flash:
===========================
After you have built x-load.bin for your board, you need to do the
followings to get it into Nand flash:
1. Use Texas Instruments IFT to sign x-load.bin. This results in a
signed image called x-load.bin.ift.
2. Use Texas Instruments FlashPrep to generate a .out file using
FlashWriterNand and specifying 0 as nand target address.
3. Use Texas instrumnets Code Composer Studio to run the .out file
which flashes x-load.bin.ift to Nand flash.
Next you need to get your OS boot loader to Nand at the address your
X-Loader expects. For the H3 example, you can use U-Boot to flash U-Boot.
You can't use FlashWriterNand because it uses ROM code ECC style.
从上面可以得知:
(1)我们第一步需要配置板子的参数,板子的参数放在include/configs/<board_name>.h,
#ls ./include/configs/
omap1510.h omap2430sdp.h omap3devkit8000.h
omap1710h3.h omap3430sdp.h omap3devkit9000.h
omap2420h4.h omap3530beagle.h sbc8100.h
很显然我使用板子是omap3devkit8000.h,
继续看看,挺长的就不贴出来了,我的目的是跑beagle的资源,不妨看下二者在x-loader的配置
(1)我们第一步需要配置板子的参数,板子的参数放在include/configs/<board_name>.h,
#ls ./include/configs/
omap1510.h omap2430sdp.h omap3devkit8000.h
omap1710h3.h omap3430sdp.h omap3devkit9000.h
omap2420h4.h omap3530beagle.h sbc8100.h
很显然我使用板子是omap3devkit8000.h,
继续看看,挺长的就不贴出来了,我的目的是跑beagle的资源,不妨看下二者在x-loader的配置
区别,
#diff ./omap3530beagle.h ./omap3devkit8000.h
41c41
< #define CONFIG_OMAP3_BEAGLE 1 /* working with BEAGLE */
---
> #define CONFIG_OMAP3_DevKit8000 1 /* working with DevKit8000 */
46,51d45
< /* Uncomment this for Rev 1 boards*/
< //#define CONFIG_BEAGLE_REV1 1
<
< /* Uncomment this for Rev 2 boards */
< #define CONFIG_BEAGLE_REV2 1
<
66d59
< #ifdef CONFIG_OMAP3_BEAGLE
68,70d60
< #else
< #define V_OSCK 19200000 /* Clock output from T2 */
< #endif
92,94d81
< #ifdef CONFIG_BEAGLE_REV1
< #define CFG_ONENAND 1
< #else
96d82
< #endif
117,119d102
< #ifdef CONFIG_BEAGLE_REV1
< #define CFG_NS16550_COM1 OMAP34XX_UART1
< #else
121d103
< #endif
127,131d108
< #ifdef CONFIG_BEAGLE_REV1
< #define CONFIG_SERIAL1 1 /* UART1 on BEAGLE */
< #define CONFIG_CONS_INDEX 1
< #else
< #define CONFIG_SERIAL1 3 /* UART3 on BEAGLE */
133d109
< #endif
162c138
< //#define NAND_16BIT
---
> #define NAND_16BIT
172c148
< #define NAND_UBOOT_END 0x0160000 /* Giving a space of 2 blocks = 256KB */
---
> #define NAND_UBOOT_END 0x01E0000 /* Giving a space of 2 blocks = 256KB */
#diff ./omap3530beagle.h ./omap3devkit8000.h
41c41
< #define CONFIG_OMAP3_BEAGLE 1 /* working with BEAGLE */
---
> #define CONFIG_OMAP3_DevKit8000 1 /* working with DevKit8000 */
46,51d45
< /* Uncomment this for Rev 1 boards*/
< //#define CONFIG_BEAGLE_REV1 1
<
< /* Uncomment this for Rev 2 boards */
< #define CONFIG_BEAGLE_REV2 1
<
66d59
< #ifdef CONFIG_OMAP3_BEAGLE
68,70d60
< #else
< #define V_OSCK 19200000 /* Clock output from T2 */
< #endif
92,94d81
< #ifdef CONFIG_BEAGLE_REV1
< #define CFG_ONENAND 1
< #else
96d82
< #endif
117,119d102
< #ifdef CONFIG_BEAGLE_REV1
< #define CFG_NS16550_COM1 OMAP34XX_UART1
< #else
121d103
< #endif
127,131d108
< #ifdef CONFIG_BEAGLE_REV1
< #define CONFIG_SERIAL1 1 /* UART1 on BEAGLE */
< #define CONFIG_CONS_INDEX 1
< #else
< #define CONFIG_SERIAL1 3 /* UART3 on BEAGLE */
133d109
< #endif
162c138
< //#define NAND_16BIT
---
> #define NAND_16BIT
172c148
< #define NAND_UBOOT_END 0x0160000 /* Giving a space of 2 blocks = 256KB */
---
> #define NAND_UBOOT_END 0x01E0000 /* Giving a space of 2 blocks = 256KB */
从中可以看出基本没有差别,就是改了下板子的名字而已。
接下来按照devkit8000步骤:
#make distclean
find . -type f \
\( -name 'core' -o -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.a' \) -print \
| xargs rm -f
find . -type f \
\( -name .depend -o -name '*.srec' -o -name '*.bin' \) \
-print \
| xargs rm -f
rm -f *.bak tags TAGS
rm -fr *.*~
rm -f x-load x-load.map
rm -f include/asm/proc include/asm/arch
rm -f x-load.bin.ift
rm -f include/config.h include/config.mk
#sudo make omap3devkit8000_config
rm -f include/config.h include/config.mk
Configuring for omap3devkit8000 board...
接下来按照devkit8000步骤:
#make distclean
find . -type f \
\( -name 'core' -o -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.a' \) -print \
| xargs rm -f
find . -type f \
\( -name .depend -o -name '*.srec' -o -name '*.bin' \) \
-print \
| xargs rm -f
rm -f *.bak tags TAGS
rm -fr *.*~
rm -f x-load x-load.map
rm -f include/asm/proc include/asm/arch
rm -f x-load.bin.ift
rm -f include/config.h include/config.mk
#sudo make omap3devkit8000_config
rm -f include/config.h include/config.mk
Configuring for omap3devkit8000 board...
然后make生成x-load.bin
然后再依据下列步骤:
1. Use Texas Instruments IFT to sign x-load.bin. This results in a
signed image called x-load.bin.ift.
2. Use Texas Instruments FlashPrep to generate a .out file using
FlashWriterNand and specifying 0 as nand target address.
3. Use Texas instrumnets Code Composer Studio to run the .out file
which flashes x-load.bin.ift to Nand flash.
第一个步骤可使用signGP,signGP.c如下:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <malloc.h>
main(int argc, char *argv[])
{
int i;
char ifname[FILENAME_MAX], ofname[FILENAME_MAX], ch;
FILE *ifile, *ofile;
unsigned long loadaddr, len;
struct stat sinfo;
// Default to x-load.bin and 0x40200800.
strcpy(ifname, "x-load.bin");
loadaddr = 0x40200800;
if ((argc == 2) || (argc == 3))
strcpy(ifname, argv[1]);
if (argc == 3)
loadaddr = strtol(argv[2], NULL, 16);
// Form the output file name.
strcpy(ofname, ifname);
strcat(ofname, ".ift");
// Open the input file.
ifile = fopen(ifname, "rb");
if (ifile == NULL) {
printf("Cannot open %s\n", ifname);
exit(0);
}
// Get file length.
stat(ifname, &sinfo);
len = sinfo.st_size;
// Open the output file and write it.
ofile = fopen(ofname, "wb");
if (ofile == NULL) {
printf("Cannot open %s\n", ofname);
fclose(ifile);
exit(0);
}
// Pad 1 sector of zeroes.
//ch = 0x00;
//for (i=0; i<0x200; i++)
// fwrite(&ch, 1, 1, ofile);
fwrite(&len, 1, 4, ofile);
fwrite(&loadaddr, 1, 4, ofile);
for (i=0; i<len; i++) {
fread(&ch, 1, 1, ifile);
fwrite(&ch, 1, 1, ofile);
}
fclose(ifile);
fclose(ofile);
}
把这个文件编译下,生成signGP
gcc -o ./signGP ./signGP.c
然后
./signGP ./x-load.bin
就会由x-load.bin转化生成x-load.bin.ift,
由于我打算用MMC卡试验,所以该需要重新命名x-load.bin.ift
mv ./x-load.bin.ift ./MLO
然后把MLO拷贝到MMC卡,
启动时按住用户键,如下:
Texas Instruments X-Loader 1.41
Starting on with MMC
Reading boot sector
然后再依据下列步骤:
1. Use Texas Instruments IFT to sign x-load.bin. This results in a
signed image called x-load.bin.ift.
2. Use Texas Instruments FlashPrep to generate a .out file using
FlashWriterNand and specifying 0 as nand target address.
3. Use Texas instrumnets Code Composer Studio to run the .out file
which flashes x-load.bin.ift to Nand flash.
第一个步骤可使用signGP,signGP.c如下:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <malloc.h>
main(int argc, char *argv[])
{
int i;
char ifname[FILENAME_MAX], ofname[FILENAME_MAX], ch;
FILE *ifile, *ofile;
unsigned long loadaddr, len;
struct stat sinfo;
// Default to x-load.bin and 0x40200800.
strcpy(ifname, "x-load.bin");
loadaddr = 0x40200800;
if ((argc == 2) || (argc == 3))
strcpy(ifname, argv[1]);
if (argc == 3)
loadaddr = strtol(argv[2], NULL, 16);
// Form the output file name.
strcpy(ofname, ifname);
strcat(ofname, ".ift");
// Open the input file.
ifile = fopen(ifname, "rb");
if (ifile == NULL) {
printf("Cannot open %s\n", ifname);
exit(0);
}
// Get file length.
stat(ifname, &sinfo);
len = sinfo.st_size;
// Open the output file and write it.
ofile = fopen(ofname, "wb");
if (ofile == NULL) {
printf("Cannot open %s\n", ofname);
fclose(ifile);
exit(0);
}
// Pad 1 sector of zeroes.
//ch = 0x00;
//for (i=0; i<0x200; i++)
// fwrite(&ch, 1, 1, ofile);
fwrite(&len, 1, 4, ofile);
fwrite(&loadaddr, 1, 4, ofile);
for (i=0; i<len; i++) {
fread(&ch, 1, 1, ifile);
fwrite(&ch, 1, 1, ofile);
}
fclose(ifile);
fclose(ofile);
}
把这个文件编译下,生成signGP
gcc -o ./signGP ./signGP.c
然后
./signGP ./x-load.bin
就会由x-load.bin转化生成x-load.bin.ift,
由于我打算用MMC卡试验,所以该需要重新命名x-load.bin.ift
mv ./x-load.bin.ift ./MLO
然后把MLO拷贝到MMC卡,
启动时按住用户键,如下:
Texas Instruments X-Loader 1.41
Starting on with MMC
Reading boot sector
1086232 Bytes Read from MMC
Starting OS Bootloader from MMC...
Starting OS Bootloader from MMC...
U-Boot 1.3.3-svn333 (Sep 10 2009 - 16:47:29)
----
证明这个MLO是没问题的。