编译 openloongson v2.0 v2.1开发板 内核源码目录下: cp arch/mips/configs/ls1c300a_openloongson_v2.0_defconfig .config make ARCH=mips CROSS_COMPILE=mipsel-linux- menuconfig 保存退出,执行编译: make ARCH=mips CROSS_COMPILE=mipsel-linux- 平台文件: arch/mips/loongson1/ls1c/ls1c300a_openloongson_v2.0_board.c 默认配置文件: arch/mips/configs/ls1c300a_openloongson_v2.0_defconfig openloongson robot开发板 内核源码目录下: cp arch/mips/configs/ls1c300a_openloongson_robot_defconfig .config make ARCH=mips CROSS_COMPILE=mipsel-linux- menuconfig 保存退出,执行编译: make ARCH=mips CROSS_COMPILE=mipsel-linux- 平台文件: arch/mips/loongson1/ls1c/ls1c300a_openloongson_robot_board.c 编译完成生成vmlinux 生成uImage 如果使用u-boot,则要生成uImage,以下是生成uImage的方法: linux内核编译完成后,查看内核的elf信息: mipsel-linux-readelf -e vmlinux 执行这个命令后会打印很多信息,找到Entry point这个字段,例如: ... Entry point address: 0x806632e0 ... 可以确认ep地址为0x806632e0,这个入口点地址在下面的制作uImage的过程中要用到。 注意:这个地址不是固定的,更改内核配置从新编译后这个地址可能就变了,所以要根据自己编译出来的内核获取实际的地址。 制作uImage: /home/loongson/1C/u-boot-2013.10/tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80200000 -e 0x806632e0 -n "Linux-3.x" -d arch/mips/boot/compressed/vmlinux.bin.z uImage 其中/home/loongson/1C/u-boot-2013.10/tools/mkimage 是编译u-boot时候生成的工具,路径根据实际情况修改,这里u-boot源码路径是/home/loongson/1C/u-boot-2013.10/ 其中-a 0x80200000 是内核在内存中的加载地址,与arch/mips/loongson/Platform文件中的 load-$(CONFIG_LS1C_MACH) += 0xffffffff80200000 地址一致,一般不用修改。 -e 0x806632e0 则是刚才使用mipsel-linux-readelf -e vmlinux查看到的入口点地址,每次编译linux内核后都查看以下这个地址,因为这个地址可能会有所变化,把新地址替换-e 0x806632e0这个地址即可。 生成的uImage就可以在u-boot命令行下使用命令烧录到nand flash中或加载到内存中运行。 nand flash分区: 分区可能与以前开发板的内核有所不同 平台文件ls1c300a_openloongson_v2.0_board.c ls1c300a_openloongson_robot_board.c中设置nand的分区 static struct mtd_partition ls1x_nand_partitions[] = { 中设置 分区为: bootloader 1MByte 保留给nand启动用 kernel 13MByte 用于烧录内核 rootfs 50MByte 用于烧录根文件系统 mini_rootfs 64MByte 注意分区大小要与pmon或u-boot中的一致 mtd0用作nand启动的bootloader,所以内核分区变为mtd1,根文件系统分区变为mtd2,注意不要搞错。 如果用spiflash启动,不用nand启动的话可以根据自己使用的情况修改分区,注意pmon或u-boot中也要修改。