TQ2440之移植linux 内核

这篇博客详细记录了在Ubuntu 18.04环境下,针对Linux内核4.9.84的配置过程,包括修改时钟频率、配置机械码、设置网卡参数以及编译YAFFS2文件系统。博主还遇到了在不同GCC版本下编译根文件系统导致的问题,并成功解决了。此外,还涉及到了UBOOT和Kernel的调试技巧,以及I2C设备和蜂鸣器的添加。
摘要由CSDN通过智能技术生成

ubuntu: 18.04

busybox: busybox-1.20.2.tar

修改时钟

linux-4.9.84\arch\arm\mach-s3c24xx\mach-smdk2440.c

// s3c2440_init_clocks(16934400);
s3c2440_init_clocks(12000000);

 拷贝配置

linux-4.9.84$ cp arch/arm/configs/s3c2410_defconfig ./
linux-4.9.84$ cp s3c2410_defconfig .config

修改机械码

linux-4.9.84\arch\arm\tools\mach-types

smdk2410		ARCH_SMDK2410		SMDK2410		193
smdk2440		ARCH_SMDK2440		SMDK2440		168

设置网卡参数,

linux-4.9.84\arch\arm\mach-s3c24xx\mach-smdk2440.c

#include <linux/dm9000.h>

#if 1
// new add
static struct resource s3c_dm9k_resource[] = {
    [0] = {
        .start = S3C2410_CS4,

        .end = S3C2410_CS4 + 3,

        .flags = IORESOURCE_MEM,

    },

    [1] = {
        .start = S3C2410_CS4 + 4,

        .end = S3C2410_CS4 + 4 + 3,

        .flags = IORESOURCE_MEM,

    },

    [2] = {
        .start = IRQ_EINT7,

        .end = IRQ_EINT7,

        .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,

    }

};

static struct dm9000_plat_data s3c_dm9k_platdata = {
    .flags = DM9000_PLATF_16BITONLY,

};

struct platform_device s3c_device_dm9000 = {
    .name = "dm9000",

    .id = 0,

    .num_resources = ARRAY_SIZE(s3c_dm9k_resource),

    .resource = s3c_dm9k_resource,

    .dev = {
        .platform_data = &s3c_dm9k_platdata,

    }

};
#endif

static struct platform_device *smdk2440_devices[] __initdata = {
	&s3c_device_ohci,
	&s3c_device_lcd,
	&s3c_device_wdt,
	&s3c_device_i2c0,
	&s3c_device_iis,
	&s3c_device_dm9000,
};

 下载 yaffs2

ym@ym:~/work/tq2440/lesson02$ git clone git://www.aleph1.co.uk/yaffs2
ym@ym:~/work/tq2440/lesson02$ cd yaffs2/
ym@ym:~/work/tq2440/lesson02/yaffs2$ ./patch-ker.sh c m ../linux-4.9.84
Updating ../linux-4.9.84/fs/Kconfig
Updating ../linux-4.9.84/fs/Makefile

make menuconfig

 Device Drivers  --->
 	Input device support  --->
 		[*]   Touchscreens  --->
 			<*>   Samsung S3C2410/generic touchscreen input driver  # 开启触摸屏支持
 	[*] Watchdog Timer Support  --->
 		< >   S3C2410 Watchdog  # 关闭看门狗,要不然系统会一直重启
 	 Graphics support  --->
 	 	[*] Bootup logo  --->
 	 		 [*]   Standard 16-color Linux logo  # 选中该项,取消其他项
 	<*> Memory Technology Device (MTD) support  --->
 		 < >   FTL (Flash Translation Layer) support  # 取消选中,要不然会出现警告:ftl_cs: FTL header not found
 		 < >   NFTL (NAND Flash Translation Layer) support # 取消选中,要不然会出现警告:ftl_cs: 
 		 < >   INFTL (Inverse NAND Flash Translation Layer) support # 取消选中,要不然会出现警告:ftl_cs: 
 		 <*>   NAND Device Support  --->
 		 	<*>   NAND Flash support for Samsung S3C SoCs
 		 		[*]     Samsung S3C NAND Hardware ECC  # 开启NAND的硬件ECC校验
 File systems  ---> 
 	[*] Miscellaneous filesystems  --->
 		<*>   yaffs2 file system support  # 开启yaffs2文件系统支持

 make uImage

 安装 sudo apt-get install u-boot-tools

使用gcc4.3.3 和 busybox1.6编译出来的根文件系统可以在ubuntu 上nfs挂载,但是在window 挂载无法工作。

使用gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf 和 busybox1.33.1编译出来的根文件系统无法工作

 定位uboot 和kernel debug  问题

打开在内核中配置CONFIG_DEBUG_USER=y,并在uboot 启动参数bootargs 中添加 user_debug=31,打开全部调试信息,例如 setenv bootargs console=ttySAC0,115200 user_debug=31   saveenv

错误是未定义指令

linux-4.9.84\arch\arm\kernel\traps.c

#ifdef CONFIG_DEBUG_USER
	if (user_debug & UDBG_UNDEFINED) {
		pr_info("%s (%d): undefined instruction: pc=%p\n",
			current->comm, task_pid_nr(current), pc);
		__show_regs(regs);
		dump_instr(KERN_INFO, regs);
	}
#endif

 使用反汇编工具将rootfs下可执行文件linuxc 进行反汇编

ym@ym:~/work/tq2440/lesson02/rootfs$ arm-linux-gnueabihf-objdump -D -S linuxrc > tes

找到错误指令 000f30a4

f30a4:	e300c000 	movw	ip, #0

看不出指令有什么问题。。

更换arm gcc为 4.3.3版本,重新制作根文件系统,可用。

arm-gcc 必须定制化,自己制作 4.9.1

修改IIC 

arch\arm\mach-s3c24xx\mach-mini2440.c

/*
 * I2C devices
 */
static struct at24_platform_data at24c02 = {
	.byte_len	= SZ_2K / 8,   /* 2Kbits / 8 = 256bytes */
	.page_size	= 8,           /* at24c02 page size = 8 */
	.flags = 0,
};

static struct i2c_board_info mini2440_i2c_devs[] __initdata = {
	{
		I2C_BOARD_INFO("24c02", 0x50),
		.platform_data = &at24c02,
	},
};

添加蜂鸣器

/* BEEP */

static struct s3c24xx_led_platdata mini2440_beep_pdata = {
	.name		= "beep",
	.gpio		= S3C2410_GPB(0),
	.flags		= S3C24XX_LEDF_TRISTATE,
};

static struct platform_device mini2440_beep = {
	.name		= "s3c24xx_led",
	.id		= 5,
	.dev		= {
		.platform_data	= &mini2440_beep_pdata,
	},
};

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值