EC2108内核分析

来自IPTV爱好者
IPTV讨论 | 贡献2011年10月11日 (二) 13:23的版本 内核编译

跳转至: 导航搜索

概述

EC2108内核文件可从机顶盒的/dev/mtdblock1获取到,也可以在这里下载:ec2108_mtdblock1.bin。存放内核的MTD分区的大小为6MB,内核以ELF格式的vmlinux加上initrd.gz两部分构成。以7.5版的EC2108内核为例,从0x3F0D10开始为initrd.gz,分离好的initrd.gz在这里下载:ec2108_initrd.gz

内核编译

  • 解压文件:
tar xvjf stblinux-2.6.18-7.4.tar.bz2
ln -s stblinux-2.6.18 stblinux
cd stblinux
  • 内核配置:
cp arch/mips/configs/bcm97405d0-smp_initrd_defconfig .config
make menuconfig

Device Drivers - Network device support - Ethernet (10 or 100Mbit) 中取消“Use external MII interface”

[ ]     Use external MII interface
  • 修改include/asm-mips/setup.h中的COMMAND_LINE_SIZE
#define COMMAND_LINE_SIZE      256

改为:

#define COMMAND_LINE_SIZE      1024
  • 修改arch/mips/brcmstb/common/prom.c,在“#ifdef CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING”前增加一行:
#define CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING
  • 修改drivers/net/brcmint7038/bcmemac.c
unsigned char *bcmemac_get_mac_from_string(void)
{
        static unsigned char mac[0x10] = {0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F};
        extern int gNumHwAddrs;
        extern unsigned char* gHwAddrs[];
        int i; 

        if (gNumHwAddrs >= 1) {
                for (i=0; i < 6; i++)
                        mac[i] = (uint8) gHwAddrs[0][i];
        }

        return mac;
}

int bcmemac_get_connstatus(void)
{
        return bcmIsEnetUp(bcmemac_get_device());
}

EXPORT_SYMBOL(bcmemac_get_connstatus);
EXPORT_SYMBOL(bcmemac_get_mac_from_string);
  • 修改Makefile中的EXTRAVERSION,在最后增加一下内容:
EXTRAVERSION =-7.4

改为:

EXTRAVERSION =-7.5
  • 修改drivers/mtd/Makefile
obj-$(CONFIG_MTD_BLOCK_ROMBLOCK)        += romblock.o mtd_blkdevs.o

改为:

obj-$(CONFIG_MTD_BLOCK)        += romblock.o mtd_blkdevs.o
  • 修改usr/Makfile
$(obj)/initramfs_list: $(obj)/Makefile FORCE
        $(call filechk,initramfs_list)

改为:

#$(obj)/initramfs_list: $(obj)/Makefile FORCE
#       $(call filechk,initramfs_list)


  • 将文件initrd.gz解压到usr目录中:
cp initrd.gz usr/initramfs_data.cpio.gz
gunzip usr/initramfs_data.cpio.gz
cp initrd.gz usr/initramfs_data.cpio.gz

vi usr/initramfs_list

dir /dev 755 1001 1001
nod /dev/romblock7 600 0 0 b 253 7
nod /dev/romblock0 600 0 0 b 253 0
nod /dev/romblock14 600 0 0 b 253 14
nod /dev/romblock12 600 0 0 b 253 12
nod /dev/mtdblock3 600 0 0 b 31 3
nod /dev/mtdblock15 600 0 0 b 31 15
nod /dev/mtdblock1 600 0 0 b 31 1
nod /dev/romblock3 600 0 0 b 253 3
nod /dev/mtdblock10 600 0 0 b 31 10
nod /dev/mtdblock4 600 0 0 b 31 4
nod /dev/romblock4 600 0 0 b 253 4
nod /dev/mtdblock13 600 0 0 b 31 13
nod /dev/mtdblock14 600 0 0 b 31 14
nod /dev/mtdblock8 600 0 0 b 31 8
nod /dev/romblock8 600 0 0 b 253 8
nod /dev/romblock11 600 0 0 b 253 11
nod /dev/romblock13 600 0 0 b 253 13
nod /dev/romblock1 600 0 0 b 253 1
nod /dev/console 600 0 0 c 5 1
nod /dev/mtdblock11 600 0 0 b 31 11
nod /dev/romblock9 600 0 0 b 253 9
nod /dev/mtdblock9 600 0 0 b 31 9
nod /dev/mtdblock0 600 0 0 b 31 0
nod /dev/mtdblock2 600 0 0 b 31 2
nod /dev/mem 600 0 0 c 1 1
nod /dev/ttyS0 600 0 0 c 5 1
nod /dev/mtdblock12 600 0 0 b 31 12
nod /dev/romblock6 600 0 0 b 253 6
nod /dev/mtdblock6 600 0 0 b 31 6
nod /dev/romblock2 600 0 0 b 253 2
nod /dev/romblock10 600 0 0 b 253 10
nod /dev/mtdblock5 600 0 0 b 31 5
nod /dev/romblock5 600 0 0 b 253 5
nod /dev/mtdblock7 600 0 0 b 31 7
nod /dev/romblock15 600 0 0 b 253 15
nod /dev/sda1 600 0 0 b 8 1
dir /mnt 755 1001 1001
file /brcmnand-7405d0_mtdv9.ko /romfs/brcmnand-7405d0_mtdv9.ko 644 1001 1001
file /brcmnand-7405d0_mtdv5.ko /romfs/brcmnand-7405d0_mtdv5.ko 644 1001 1001
file /init /romfs/init 755 1001 1001
file /yaffs.ko /romfs/yaffs.ko 644 1001 1001
dir /proc 755 1001 1001
file /busybox /romfs/busybox 755 1001 1001
file /brcmnand-7405b0.ko /romfs/brcmnand-7405b0.ko 644 1001 1001
  • 编译内核
make
cp vmlinuz /tftpboot
  • 通过tftp方式引导新的内核
ifconfig eth0 -auto
boot -elf -addr=0x80001000 192.168.3.10:/vmlinux