/*移植内核Linux4.0.8*/
1.机器码匹配(linux/arch/arm/tools/mach-types)
mini2440 MACH_MINI2440 MINI2440 1999
oluan2440 MACH_OLUAN2440 OLUAN2440 1999
MACH_TYPE_xxx 与MACHINE_START中匹配
CONFIG_xxxx 与linux/arch/arm/mach-s3c2440中的Kconfig、Makefile匹配
2.修改:MACHINE_START(S3C2440, "SMDK2440")
为: MACHINE_START(OLUAN, "Hello Hulin oluan!")
3.修改晶振频率:
s3c2440_init_clocks(12000000); //友善之臂开发板晶振频率为12MHz
4.修改Makefile和Kconfig
修改Kconfig,添加
config MACH_OLUAN2440
bool "OLUAN2440 Test Hello xiaozeng"
select EEPROM_AT24 if I2C
select LEDS_CLASS
select LEDS_TRIGGERS
select LEDS_TRIGGER_BACKLIGHT
select NEW_LEDS
select S3C_DEV_NAND
select S3C_DEV_USB_HOST
select S3C_SETUP_CAMIF
help
Say Y here to select support for the MINI2440. Is a 10cm x 10cm board
available via various sources. It can come with a 3.5" or 7" touch LCD.
5.make mini2440_defconfig
6.make menuconfig
配置system type
7.make zImage
移植出错:“MACH_TYPE_OLUAN” undeclared here (not in a function)
解决: MACHINE_START(OLUAN, "Hello Hulin oluan!")写错
该写为 (OLUAN2440, "Hello Hulin oluan!")
再次make zImage
(等待较长时间...)
Kernel: arch/arm/boot/zImage is ready 大小:2.8 MB
8.将zImage烧入开发板,错误:no os found
将fs_mini一并烧入开发板,错误:串口信息停止在Load Kernel...
9.在移植内核中修改Nand Flash分区表
/*下面开始分析smdk2440_machine_init(void)*/
1.添加
2.make menuconfig
3.make zImage
编译错误:undefined reference to 'smdk_machine_init'
解决: 注释:
//smdk_machine_init()
自己添加相关函数:
s3c_nand_set_platdata(&oluan2440_nand_info);
platform_add_devices(oluan_devices, ARRAY_SIZE(oluan_devices));
编译错误:arch/arm/mach-s3c24xx/mach-oluan2440.c:214: error: array type has incomplete element type
arch/arm/mach-s3c24xx/mach-oluan2440.c:215: error: array index in non-array initializer
解决: 添加头文件:
4.Kernel: arch/arm/boot/zImage is ready 大小:2.8 MB
5.将fs_mini一并烧入开发板,错误仍然为:串口信息停止在Load Kernel...
/*换了开源的uboot
E:嵌入式Linux【申嵌培训】u-boot移植与开发班
【申嵌培训】u-boot实战移植篇srcu-boot-2010.03-embedclub-menuu-boot-2010.03
*/
1.make uImage
编译错误:"mkimage" command not found - U-Boot images will not be built
解决: mkimage
bash: mkimage: 未找到命令...
安装软件包“uboot-tools”以提供命令“mkimage”? [N/y] y
2.make uImage
Image Name: Linux-4.0.8
Created: Mon Dec 5 02:38:32 2016
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2772696 Bytes = 2707.71 kB = 2.64 MB
Load Address: 30008000
Entry Point: 30008000
Image arch/arm/boot/uImage is ready
3.把uImage(linux4.0.8)烧入开发板
[u-boot@SMDK2440A]
Image Name: Linux-4.0.8
Created: 2016-12-04 18:38:32 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2772696 Bytes = 2.6 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
Starting kernel ...
data abort
pc : [<30008008>] lr : [<33fa6cac>]
sp : 33f3d64c ip : 00000000 fp : 30008000
r10: 33fc4008 r9 : 000007cf r8 : 33f3ffe0
r7 : 33f3ffc4 r6 : 33f412ad r5 : 30000100 r4 : 00000000
r3 : 00000000 r2 : 30000100 r1 : 000007cf r0 : 00000000
Flags: nzCv IRQs off FIQs off Mode SVC_32
Resetting CPU ...
resetting ...
解决:手动法:http://blog.csdn.net/zgrjkflmkyc/article/details/8975750
自动法:http://blog.chinaunix.net/uid-28382924-id-3421282.html
4.内核正常启动信息:
Image Name: Linux kernel www.embedclub.com
Created: 2011-08-17 6:24:43 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2266616 Bytes = 2.2 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux.....................................................
.............................................. done, booting the kernel.
5.出错: Starting kernel ... 之后串口输出全是乱码
解决: 修改串口波特率
set bootargs noinitrd root=/dev/mtdblock3 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
save
出错: ftl_cs: FTL header not found的解决办法
解决: http://blog.chinaunix.net/uid-20665047-id-3451562.html
出错: 企鹅图标没有
6.
挂载root时候出错:
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 8
解决:Kernel command line: 出错
bootargs noinitrd root=/dev/mtdblock4 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
少了rootfstype
在uboot下
set bootargs noinitrd root=/dev/mtdblock3 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200;save
7. 烧写内核: nand erase 0x60000 0x500000; nand write 0x30008000 0x60000 0x500000
烧写root: nand erase 0x560000 $filesize; nand write.yaffs 0x30008000 0x560000 $filesize
出错:VFS: Cannot open root device "mtdblock3" or unknown-block(31,3): error -19
Please append a correct "root=" boot option; here are the available partitions:
解决:给内核打上yaffs2补丁
8.打yaffs2补丁
出错:In function 'yaffs_readpage_nolock': //http://www.2cto.com/kf/201608/533812.html
struct file has no member named 'f_dentry'
解决:在yaffs_vfs.c中添加:
出错:fs/yaffs2/yaffs_endian.h:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'swap_loff_t'
解决:在yaffs_endian.h中添加:
出错:conflicting types for 'nval_del'
解决:error: conflicting types for ‘nval_del’,查看nval_del几个函数,这里我看不出有什么类型冲突错误,
网上搜了下主要是第一个WARNING那里引起的.
在yaffs_nameval.h中,结构体struct yaffs_dev的定义出现在参数列表中,
而在此之前没有定义,这样会导致函数不识别这个结构体引发上面的错误,
查询了下struct yaffs_dev在”yaffs_guts.h”中被定义,
因此在yaffs_nameval.h文件中include下”yaffs_guts.h”就OK了
出错:yaffs_guts.c:line: undefined reference to function
解决:在Makefile下面添加:yaffs-y += yaffs_endian.o
9. make uImage
烧写内核: nand erase 0x60000 0x500000; nand write 0x30008000 0x60000 0x500000
烧写root: usbslave 1 0x30008000;nand erase 0x560000 $filesize; nand write.yaffs 0x30008000 0x560000 $filesize
10. 成功加载yaffs2根文件系统
Please press Enter to activate this console.
starting pid 768, tty '/dev/ttySAC0': '/bin/sh'
11. 烧写自己制作的first_fs.yaffs2后
出错:Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
解决:kernel 编译的时候,没有选中 EABI 选项
12.make menuconfig
选中EABI
make uImage
烧入开发板后,启动...
Please press Enter to activate this console
出错:编译linux4.0.8 mach-mini2440时遇到no machine record defined错误的解决方法
解决:http://blog.chinaunix.net/uid-21868349-id-1813595.html
static void __init smdk2440_machine_init(void)
{
s3c24xx_fb_set_platdata(&smdk2440_fb_info);
s3c_i2c0_set_platdata(NULL);
platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
smdk_machine_init();
}
smdk_machine_init(linux/arch/arm/mach-s3c244xx/common-smdk.c)
void __init smdk_machine_init(void)
{
/* Configure the LEDs (even if we have no LED support)*/
int ret = gpio_request_array(smdk_led_gpios,
ARRAY_SIZE(smdk_led_gpios));
if (!WARN_ON(ret < 0))
gpio_free_array(smdk_led_gpios, ARRAY_SIZE(smdk_led_gpios));
if (machine_is_smdk2443())
smdk_nand_info.twrph0 = 50;
s3c_nand_set_platdata(&smdk_nand_info);
platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
s3c_pm_init();
}
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_ohci,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
};