龙芯俱乐部开源技术社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 3536|回复: 1

编译和烧写内核

[复制链接]

52

主题

125

帖子

4661

积分

论坛元老

Rank: 8Rank: 8

积分
4661
发表于 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

52

主题

125

帖子

4661

积分

论坛元老

Rank: 8Rank: 8

积分
4661
 楼主| 发表于 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
  SYSMAP  System.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#
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|龙芯俱乐部开源技术社区

GMT+8, 2024-5-2 20:21 , Processed in 0.123969 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表