flyorange 发表于 2017-8-3 16:50:01

编译和烧写内核

本帖最后由 flyorange 于 2017-8-3 17:07 编辑

安装图形化配置工具 Ncurses。
apt-get install libncurses5-dev
------
拷 备 内 核 源 码 包 linux-3.0.82-openloongson.tar.gz , 并 解 压 到 内 核 源 码 包 根 目 录
/Workstation/Loongson_1C/BSP/Linux_Kernel 下。
tar zxvf linux-3.0.82-openloongson.tar.gz
cd linux-3.0.82-openloongson
cp arch/mips/configs/ls1c300a_openloongson_v2.0_defconfig .config
运行图形化配置命令:
make ARCH=mips CROSS_COMPILE=mipsel-linux- menuconfig
执行后进入内核配置主菜单界面,由于源码中已经全部配置好,这里不需要进行任何改
动,直接保存退出。
-----
查看平台文件 arch/mips/loongson/ls1x/ls1c/ls1c300a_openloongson_v2.0_platform.c
------
static struct mtd_partition ls1x_nand_partitions[] = {
      {
                .name      = "bootloader",
                .offset      = MTDPART_OFS_APPEND,
                .size      = 1024*1024,
      },{
                .name      = "kernel",
                .offset      = MTDPART_OFS_APPEND,
                .size      = 13*1024*1024,
      },{
                .name      = "rootfs",
                .offset      = MTDPART_OFS_APPEND,
                .size      = 50*1024*1024,
      },{
                .name      = "data",
                .offset      = MTDPART_OFS_APPEND,
                .size      = MTDPART_SIZ_FULL,
      },
};
-------
由于在 PMON 的启动中创建的三个 MTD 如下:
Creat MTD partitions on "ls1x-nand": name="kernel" size=14680064Byte
Creat MTD partitions on "ls1x-nand": name="os" size=104857600Byte
Creat MTD partitions on "ls1x-nand": name="data" size=14680064Byte
-----
所以要将平台文件的 ls1x_nand_partitions 改成原来的,否则内核不能启动:
static struct mtd_partition ls1x_nand_partitions[] = {
{
.name = "kernel",
.offset = MTDPART_OFS_APPEND,
.size = 14*1024*1024,
}, {
.name = "rootfs",
.offset = MTDPART_OFS_APPEND,
.size = 100*1024*1024,
}, {
.name = "data",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
},
};
配置完内核后,执行编译命令
make ARCH=mips CROSS_COMPILE=mipsel-linux-
-----
编译完成后,在当前目录下生成内核镜像文件 vmlinux(未压缩), vmlinuz(压缩后),
-----
将单板机进入 pmon(在终端按住空格键,开机),先擦除数据,再烧写其中一个均可。
mtd_erase /dev/mtd0
devcp tftp://193.169.2.215/vmlinuz3.0.82 /dev/mtd0

flyorange 发表于 2017-8-7 11:02:41

本帖最后由 flyorange 于 2017-8-7 11:12 编辑

root@debian:/home/orange/linux-3.0.82-openloongson#
root@debian:/home/orange/linux-3.0.82-openloongson# make ls1c300a_openloongson_v2.0_defconfig
#
# configuration written to .config
#
root@debian:/home/orange/linux-3.0.82-openloongson#
root@debian:/home/orange/linux-3.0.82-openloongson# make ARCH=mips CROSS_COMPILE=mipsel-linux-
scripts/kconfig/conf --silentoldconfig Kconfig
CHK   include/linux/version.h
CHK   include/generated/utsrelease.h
CALL    scripts/checksyscalls.sh
<stdin>:1554:2: warning: #warning syscall sendmmsg not implemented
CHK   include/generated/compile.h
LD      vmlinux
SYSMAPSystem.map
SYSMAP.tmp_System.map
CC      arch/mips/boot/compressed/dummy.o
OBJCOPY arch/mips/boot/compressed/vmlinux.bin
GZIP    arch/mips/boot/compressed/vmlinux.bin.z
OBJCOPY arch/mips/boot/compressed/piggy.o
LD      vmlinuz
STRIP   vmlinuz
Building modules, stage 2.
MODPOST 2 modules
root@debian:/home/orange/linux-3.0.82-openloongson#
页: [1]
查看完整版本: 编译和烧写内核