自己配置的linux内核,移植到mini2440出错

自己配置的linux内核,移植到mini2440出错,第1张

具体方法参考移植手册,常见问题如下。

错误一:

NOW, Booting Linux......

Uncompressing Linux...................................................................................... done, booting the kernel.

停止的情况

下面的是tools/mach-types中关于体系的参数定义

s3c2440ARCH_S3C2440S3C2440 362

mini2440MACH_MINI2440MINI24401999

解决方法:linux机器码要与bootloader一致,否则出现这个错误!

2.内核的配置

1..[*] Enable loadable module support --->

[*] Module unloading

2. System Type ---->

[*] S3C2410 DMA support [*] Support ARM920T processor

S3C2440 Machines --->

[*] SMDK2440

[*] SMDK2440 with S3C2440 CPU moduleq

其他的比如2410,2443相关的全部去掉

3.Boot options --->

将 (root=/dev/hda1 ro init=/bin/bash console=ttySAC0) Default kernel command string

改成(noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 )

其中 mtdblock2 表示 MTD 分区的第二个分区存文件系统; Linuxrc 为启动的首个脚本。

4关掉nand ecc .因为bootload中已经有ecc校验算法

Device Drivers --->

<*>Memory Technology Device (MTD) support --->

[*] MTD partitioning support

<*>NAND Device Support --->

<*> NAND Flash support for S3C2410/S3C2440 SoC

[ ] S3C2410 NAND Hardware ECC // 这个要去掉

3.添加nand flash驱动(可参考arm/plat-s3c24xx/common-smdk.c)

在arm/mach-mini2440.c

错误二:

//注意结构和函数的顺序

中添加static struct mtd_partition mini2440_default_nand_part[] = {

[0] = {

.name= "supervivi",

.size= 0x00040000,//dev/mdkbloack0

.offset= 0,

},

[1] = {

.name= "param",

.offset = 0x00040000,

.size= 0x00020000,

},

[2] = {

.name= "Kernel",

.offset = 0x00560000,

.size=1024 * 1024 * 1024,

},

[3] = {

.name= "nand",

.offset= 0x00000000,

.size= 1024 * 1024 * 1024,

},

}

static struct s3c2410_nand_set mini2440_nand_sets[] = {

[0] = {

.name= "NAND",

.nr_chips= 1,

.nr_partitions= ARRAY_SIZE(mini2440_default_nand_part),

.partitions=mini2440_default_nand_part,

},

}

static struct s3c2410_platform_nand mini2440_nand_info = {

.tacls= 20,

.twrph0= 60,

.twrph1= 20,

.nr_sets= ARRAY_SIZE(mini2440_nand_sets),

.sets= mini2440_nand_sets,

.ignore_unset_ecc = 1,

}

错误三:

Unable to handle kernel NULL pointer dereference at virtual address 00000018

pgd = c0004000

[00000018] *pgd=00000000

Internal error: Oops: 5 [#1]

make zIamge下载后报错

解决办法:

static void __init mini2440_machine_init(void)

{

s3c24xx_fb_set_platdata(&mini2440_fb_info)

s3c_i2c0_set_platdata(NULL)

s3c_device_nand.dev.platform_data = &mini2440_nand_info //这个函数手册上没有,但得加

platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices))

//smdk_machine_init()

}

static struct platform_device *mini2440_devices[] __initdata = {

&s3c_device_usb,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c0,

&s3c_device_iis,

&s3c_device_nand, // 把 nand flash 设备添加到开发板的设备列表结构

}

更改drivers/mtd/nand/s3c2410.c关闭ecc校验

chip->ecc.mode= NAND_ECC_SOFT

改为:chip->ecc.mode= NAND_ECC_NONE

错误四:

arch/arm/mach-s3c2440/mach-mini2440.c:84: error: array type has incomplete element type

arch/arm/mach-s3c2440/mach-mini2440.c:85: error: array index in non-array initializer

arch/arm/mach-s3c2440/mach-mini2440.c:85: error: (near initialization for 'mini2440_nand_sets')

arch/arm/mach-s3c2440/mach-mini2440.c:86: error: field name not in record or union initializer

arch/arm/mach-s3c2440/mach-mini2440.c:86: error: (near initialization for 'mini2440_nand_sets')

arch/arm/mach-s3c2440/mach-mini2440.c:87: error: field name not in record or union initializer

在macn-mini2440中添加头文件

#include <plat/common-smdk.h>

#include <linux/mtd/mtd.h>

#include <linux/mtd/nand.h>

#include <linux/mtd/nand_ecc.h>

#include <linux/mtd/partitions.h>

#include <plat/nand.h>//这个也不能少的哦

编译后下载:

affs: dev is 32505858 name is "mtdblock2"

yaffs: passed flags ""

yaffs: Attempting MTD mount on 31.2, "mtdblock2"

yaffs: auto selecting yaffs2

yaffs_read_super: isCheckpointed 0

VFS: Mounted root (yaffs filesystem) on device 31:2.

Freeing init memory: 128K

错误五:

Kernel panic - not syncing: Attempted to kill init

解决办法: 这个时候懵了,哪里错呢~ 没办法,只能对照着友善的配置一个个大模块对着来改

当改到Kernel Features的时候错误消失了,原来需要选上

Use the ARM EABI to compile the kernel

Allow old ABI binaries to run with thie Kernel

为什么呢?~ Google了一下,原来友善的根文件系统在编译的时候也启用了EABI特性,内核和文件系统需要对上

文件系统用了EABI 内核也要用EABI 内核不用EABI 也只能读取不用EABI的文件系统

本移植主要参考友善之臂移植手册完成,做个笔记以备不时之需

Linux-2.6.32 内核LCD驱动移植

使用环境:fedora9

交叉编译工具链:arm-linux-gcc-4.4.3

内核源码来源:https://www.kernel.org/pub/linux/kernel/v2.6/

内核存放目录:/opt/mymini2440/linux-2.6.32

一、LCD背光驱动移植

在、opt/mymini2440/linux-2.6.32/drivers/video/目录下添加背光驱动程序mini2440_backlight.c,内容如下:

//以下头文件可能并不是每一个都必须的,但多余的并不会影响驱动程序的内容

#include <linux/errno.h>

#include <linux/kernel.h>

#include <linux/module.h>

#include <linux/slab.h>

#include <linux/input.h>

#include <linux/init.h>

#include <linux/serio.h>

#include <linux/delay.h>

#include <linux/clk.h>

#include <linux/miscdevice.h>

#include <linux/gpio.h>

#include <asm/io.h>

#include <asm/irq.h>

#include <asm/uaccess.h>

#include <mach/regs-clock.h>

#include <plat/regs-timer.h>

#include <mach/regs-gpio.h>

#include <linux/cdev.h>

#undef DEBUG

//#define DEBUG

#ifdef DEBUG

#define DPRINTK(x...) {printk(__FUNCTION__"(%d): ",__LINE__)printk(##x)}

#else

#define DPRINTK(x...) (void)(0)

#endif

//定义背光驱动的名称为backligh,将会出现在/dev/backlight

#define DEVICE_NAME "backlight"

//定义背光变量bl_state,以记录背光的开关状态

static unsigned int bl_state

//设置背光开关的函数,主要是翻转背光变量bl_state

static inline void set_bl(int state)

{

bl_state = !!state//翻转bl_state 变量

s3c2410_gpio_setpin(S3C2410_GPG(4), bl_state)//把结果写入背光所用的寄存器GPG4

}

//获取背光状态

static inline unsigned int get_bl(void)

{

return bl_state

}

//从应用程序读取参数,并传递到内核中

static ssize_t dev_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)

{

unsigned char ch

int ret

if (count == 0) {

return count

}

//使用copy_from_user 函数从用户层/应用层读取参数

ret = copy_from_user(&ch, buffer, sizeof ch) ? -EFAULT : 0

if (ret) {

return ret

}

ch &= 0x01//判断奇数还是偶数

set_bl(ch)//设置背光状态

return count

}

//把内核参数传递给用户层/应用层的读函数

static ssize_t dev_read(struct file *filp, char *buffer, size_t count, loff_t *ppos)

{

int ret

unsigned char str[] = {'0', '1' }

if (count == 0) {

return 0

}

//使用copy_to_user 函数把内核参数传递到用户层/应用层

ret = copy_to_user(buffer, str + get_bl(), sizeof(unsigned char) ) ? -EFAULT : 0

if (ret) {

return ret

}

return sizeof(unsigned char)

}

//设备 *** 作集

static struct file_operations dev_fops = {

owner: THIS_MODULE,

read:dev_read,

write: dev_write,

}

static struct miscdevice misc = {

.minor = MISC_DYNAMIC_MINOR,

.name = DEVICE_NAME,

.fops = &dev_fops,

}

//设备初始化,内核启动时就有效

static int __init dev_init(void)

{

int ret

ret = misc_register(&misc)

printk (DEVICE_NAME"\tinitialized\n")

//初始化背光所用的端口GPG4 为输出

s3c2410_gpio_cfgpin(S3C2410_GPG(4), S3C2410_GPIO_OUTPUT)

//启动内核时打开背光

set_bl(1)

return ret

}

static void __exit dev_exit(void)

{

misc_deregister(&misc)

}

module_init(dev_init)//注册背光驱动模块

module_exit(dev_exit)//卸载背光驱动模块

MODULE_LICENSE("GPL")

MODULE_AUTHOR("FriendlyARM Inc.")

在/opt/mymini2440/linux-2.6.32/drivers/video/目录项的菜单文件Kconfig中添加LCD背光驱动配置菜单如下:

config FB_S3C2410_DEBUG

bool "S3C2410 lcd debug messages"

depends on FB_S3C2410

help

Turn on debugging messages. Note that you can set/unset at run time

through sysfs

config BACKLIGHT_MINI2440

tristate "Backlight support for mini2440 from FriendlyARM"

depends on MACH_MINI2440 &&FB_S3C2410

help

backlight driver for MINI2440 from FriendlyARM

config FB_SM501

tristate "Silicon Motion SM501 framebuffer support"

在/opt/mymini2440/linux-2.6.32/drivers/video/Makefile中添加背光驱动目标文件

# the test framebuffer is last

obj-$(CONFIG_FB_VIRTUAL) += vfb.o

#video output switch sysfs driver

obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o

obj-$(CONFIG_BACKLIGHT_MINI2440) += mini2440_backlight.o

配置内核:

Device Drivers --->Graphics support ---> <*>Support for frame buffer devices

---><*> Backlight support for mini2440 from FriendlyARM

背光驱动移植完毕!

二、LCD驱动移植

在内核中添加各种LCD 类型的支持(我是X35的屏,也是我只需关注的部分,不过还是都添加了,X35有红色标出)

删除mach-mini2440.c原有代码(本人115行-158行)

162

163 //LCD2VGA(分辨率为1024x768)模块的配置和参数设置

164 #elif defined(CONFIG_FB_S3C2410_VGA1024768)

165 #define LCD_WIDTH 1024

166 #define LCD_HEIGHT 768

167 #define LCD_PIXCLOCK 80000

168 #define LCD_RIGHT_MARGIN 15

169 #define LCD_LEFT_MARGIN 199

170 #define LCD_HSYNC_LEN 15

171 #define LCD_UPPER_MARGIN 1

172 #define LCD_LOWER_MARGIN 1

173 #define LCD_VSYNC_LEN 1

174 #define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_HWSWP)

175

176 #elif defined(CONFIG_FB_S3C2410_X240320)

177 #define LCD_WIDTH 240

178 #define LCD_HEIGHT 320

179 #define LCD_PIXCLOCK 170000

180 #define LCD_RIGHT_MARGIN 25

181 #define LCD_LEFT_MARGIN 0

182 #define LCD_HSYNC_LEN 4

183 #define LCD_UPPER_MARGIN 0

184 #define LCD_LOWER_MARGIN 4

185 #define LCD_VSYNC_LEN 9

186 #define LCD_CON5 (S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_INVVDEN | S3C2410_LCDCON5_INVVFRAME | S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVCLK | S3C2410_LCDCON5_HWSWP )

187 #endif

188

189 #if defined (LCD_WIDTH)

190

191 static struct s3c2410fb_display mini2440_lcd_cfg __initdata = {

192 #if !defined (LCD_CON5)

193 .lcdcon5 = S3C2410_LCDCON5_FRM565 |

194 S3C2410_LCDCON5_INVVLINE |

195 S3C2410_LCDCON5_INVVFRAME |

196 S3C2410_LCDCON5_PWREN |

197 S3C2410_LCDCON5_HWSWP,

198 #else

199 .lcdcon5 = LCD_CON5,

200 #endif

201 .type = S3C2410_LCDCON1_TFT,

202 .width = LCD_WIDTH,

203 .height = LCD_HEIGHT,

204 .pixclock = LCD_PIXCLOCK,

205 .xres = LCD_WIDTH,

206 .yres = LCD_HEIGHT,

207 .bpp= 16,

208 .left_margin= LCD_LEFT_MARGIN + 1,

209 .right_margin = LCD_RIGHT_MARGIN + 1,

210 .hsync_len = LCD_HSYNC_LEN + 1,

211 .upper_margin = LCD_UPPER_MARGIN + 1,

212 .lower_margin = LCD_LOWER_MARGIN + 1,

213 .vsync_len = LCD_VSYNC_LEN + 1,

214 }

215

216 static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {

217 .displays = &mini2440_lcd_cfg,

218 .num_displays = 1,

219 .default_display = 0,

220 .gpccon = 0xaa955699,

221 .gpccon_mask= 0xffc003cc,

222 .gpcup = 0x0000ffff,

223 .gpcup_mask = 0xffffffff,

224 .gpdcon = 0xaa95aaa1,

225 .gpdcon_mask= 0xffc0fff0,

226 .gpdup = 0x0000faff,

227 .gpdup_mask = 0xffffffff,

228 .lpcsel = 0xf82,

229 }

230

231 #endif

232

然后打开drivers/video/Kconfig,在大概1935 行加入以下配置信息:

1923 config FB_S3C2410_DEBUG

1924 bool "S3C2410 lcd debug messages"

1925 depends on FB_S3C2410

1926 help

1927 Turn on debugging messages. Note that you can set/unset at run time

1928 through sysfs

1929

1930 choice

1931 prompt "LCD select"

1932 depends on FB_S3C2410

1933 help

1934 S3C24x0 LCD size select

1935

1936 config FB_S3C2410_T240320

1937 boolean "3.5 inch 240X320 Toppoly LCD"

1938 depends on FB_S3C2410

1939 help

1940 3.5 inch 240X320 Toppoly LCD

1941

1942 config FB_S3C2410_N240320

1943 boolean "3.5 inch 240X320 NEC LCD"

1944 depends on FB_S3C2410

1945 help

1946 3.5 inch 240x320 NEC LCD

1947

1948 config FB_S3C2410_TFT640480

1949 boolean "8 inch 640X480 L80 LCD"

1950 depends on FB_S3C2410

1951 help

1952 8 inch 640X480 LCD

1953

1954 config FB_S3C2410_TFT800480

1955 boolean "7 inch 800x480 TFT LCD"

1956 depends on FB_S3C2410

1957 help

1958 7 inch 800x480 TFT LCD

1959

1960 config FB_S3C2410_VGA1024768

1961 boolean "VGA 1024x768"

1962 depends on FB_S3C2410

1963 help

1964 VGA 1024x768

1965

1966 config FB_S3C2410_X240320

1967 boolean "3.5 inch 240X320 LCD(ACX502BMU)"

1968 depends on FB_S3C2410

1969 help

1970 3.5 inch 240X320 LCD(ACX502BMU)

1971

1972 endchoice

1973

1974 config BACKLIGHT_MINI2440

配置内核

Device Drivers ---> Graphics support ---> <*>Support for frame buffer devices ---> LCD select (3.5 inch 240X320 LCD(ACX502BMU)) ---> (X) 3.5 inch 240X320 LCD(ACX502BMU)

LCD驱动移植完成!!!

三、开机logo和开机信息显示

Device Drivers ---> Graphics support ---> <*>Support for frame buffer devices --->[*] Bootup logo ---> [*] Standard 16-color Linux logo (本人的24位死活不能显示,先改成16位吧)

在文件系统rootfs/etc/inittab下作如下修改(为了在LCD上显示打印信息):

1 ::sysinit:/etc/init.d/rcS

2 tty1::askfirst:-/bin/sh//添加

3 s3c2410_serial0::askfirst:-/bin/sh

4 ::ctrlaltdel:/sbin/reboot

5 ::shutdown:/bin/umount -a -r

6

四,编译测试

#make zImage

#cd arch/arm/boot/

#mkimage -n 'mini2440_linux' -A arm -O linux -T kernel -C none -a 0x31000000 -e 0x31000040 -d zImage uImage

#chmod a+x uImage

#cp uImage /tftp/boot

设置U-BOOT参数如下:


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8567435.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-18
下一篇 2023-04-18

发表评论

登录后才能评论

评论列表(0条)

保存