[原创]linux-3.9.8移植全过程
0赞linux已经发展到了3.9.8,不过仍然摆脱不了嵌入式专用操作系统的尴尬位置,虽然目前在很多领域都取得了斐然的成绩,但是远远没有达到作用的最大化,今天就这个新版本的移植过程给大家分享一下。
1、下载地址,当然是: https://www.kernel.org
二、解压源码
# tar xvf linux-3.9.8.tar.xz
三、打补丁
# xz patch-3.9.8.xz
# mv patch-3.9.8 linux-3.9.8
# cd linux-3.9.8
# patch -Np1 -i patch-3.9.8
四、选择板子,这个地方需要好好修改一下。
4.1、修改顶层目录下的Makefile
指定交叉编译工具链
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
改为:
ARCH ?= arm
CROSS_COMPILE ?= /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-
4.2、使用缺省配置
# cp arch/arm/configs/s5pc100_defconfig ./
# make s5pc100_defconfig
4.3、修改缺省配置及相应代码
4.3.1、修改arch/arm/mach-s5pc100/Kconfig
config MACH_SMDKC100
bool "SMDKC100"
select CPU_S5PC100
select S3C_DEV_FB
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_HSMMC2
select S3C_DEV_I2C1
select S3C_DEV_RTC
select S3C_DEV_WDT
select S5PC100_SETUP_FB_24BPP
select S5PC100_SETUP_I2C1
select S5PC100_SETUP_IDE
select S5PC100_SETUP_KEYPAD
select S5PC100_SETUP_SDHCI
select S5P_DEV_FIMC0
select S5P_DEV_FIMC1
select S5P_DEV_FIMC2
select SAMSUNG_DEV_ADC
select SAMSUNG_DEV_BACKLIGHT
select SAMSUNG_DEV_IDE
select SAMSUNG_DEV_KEYPAD
select SAMSUNG_DEV_PWM
select SAMSUNG_DEV_TS
help
Machine support for the Samsung SMDKC100
改为:
config MACH_SMDKC100
bool "SMDKC100"
select CPU_S5PC100
select S3C_DEV_FB
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_HSMMC2
select S3C_DEV_I2C1
select S3C_DEV_RTC
select S5PC100_SETUP_FB_24BPP
select S5PC100_SETUP_I2C1
select S5PC100_SETUP_SDHCI
select S5P_DEV_FIMC0
select S5P_DEV_FIMC1
select S5P_DEV_FIMC2
select SAMSUNG_DEV_ADC
select SAMSUNG_DEV_TS
help
Machine support for the Samsung SMDKC100
4.3.2、板文件定制
arch/arm/mach-s5pc100/mach-smdkc100.c
保留串口设备信息外,其他设备信息全部删除,设备列表中设备清空。
修改为:
...
/* Following are default values for UCON, ULCON and UFCON UART registers */
#define SMDKC100_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
S3C2410_UCON_RXILEVEL | \
S3C2410_UCON_TXIRQMODE | \
S3C2410_UCON_RXIRQMODE | \
S3C2410_UCON_RXFIFO_TOI | \
S3C2443_UCON_RXERR_IRQEN)
#define SMDKC100_ULCON_DEFAULT S3C2410_LCON_CS8
#define SMDKC100_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
S3C2440_UFCON_RXTRIG8 | \
S3C2440_UFCON_TXTRIG16)
static struct s3c2410_uartcfg smdkc100_uartcfgs[] __initdata = {
[0] = {
.hwport = 0,
.flags = 0,
.ucon = SMDKC100_UCON_DEFAULT,
.ulcon = SMDKC100_ULCON_DEFAULT,
.ufcon = SMDKC100_UFCON_DEFAULT,
},
[1] = {
.hwport = 1,
.flags = 0,
.ucon = SMDKC100_UCON_DEFAULT,
.ulcon = SMDKC100_ULCON_DEFAULT,
.ufcon = SMDKC100_UFCON_DEFAULT,
},
[2] = {
.hwport = 2,
.flags = 0,
.ucon = SMDKC100_UCON_DEFAULT,
.ulcon = SMDKC100_ULCON_DEFAULT,
.ufcon = SMDKC100_UFCON_DEFAULT,
},
[3] = {
.hwport = 3,
.flags = 0,
.ucon = SMDKC100_UCON_DEFAULT,
.ulcon = SMDKC100_ULCON_DEFAULT,
.ufcon = SMDKC100_UFCON_DEFAULT,
},
};
static struct platform_device *smdkc100_devices[] __initdata = {
};
static void __init smdkc100_map_io(void)
{
s5pc100_init_io(NULL, 0);
s3c24xx_init_clocks(12000000);
s3c24xx_init_uarts(smdkc100_uartcfgs, ARRAY_SIZE(smdkc100_uartcfgs));
}
static void __init smdkc100_machine_init(void)
{
platform_add_devices(smdkc100_devices, ARRAY_SIZE(smdkc100_devices));
}
...
4.3.3、修改arch/arm/mach-s5pc100/common.c初始化函数
void __init s5pc100_map_io(void)
{
/* initialise device information early */
s5pc100_default_sdhci0();
s5pc100_default_sdhci1();
s5pc100_default_sdhci2();
s3c_adc_setname("s3c64xx-adc");
/* the i2c devices are directly compatible with s3c2440 */
s3c_i2c0_setname("s3c2440-i2c");
s3c_i2c1_setname("s3c2440-i2c");
s3c_onenand_setname("s5pc100-onenand");
s3c_fb_setname("s5pc100-fb");
s3c_cfcon_setname("s5pc100-pata");
s3c64xx_spi_setname("s5pc100-spi");
}
改为:
void __init s5pc100_map_io(void)
{
/* initialise device information early */
//s5pc100_default_sdhci0();
//s5pc100_default_sdhci1();
//s5pc100_default_sdhci2();
//s3c_adc_setname("s3c64xx-adc");
/* the i2c devices are directly compatible with s3c2440 */
//s3c_i2c0_setname("s3c2440-i2c");
//s3c_i2c1_setname("s3c2440-i2c");
//s3c_fb_setname("s5pc100-fb");
}
4.3.4、修改时钟初始化代码
arch/arm/mach-s5pc100/clock.c
改为:
static struct clk_lookup s5pc100_clk_lookup[] = {
CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p),
CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_sclk_uart.clk),
CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &clk_hsmmc0),
CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &clk_hsmmc1),
CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.0", &clk_hsmmc2),
#if 0
CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
#endif
CLKDEV_INIT(NULL, "spi_busclk0", &clk_p),
CLKDEV_INIT("s5pc100-spi.0", "spi_busclk1", &clk_48m_spi0),
CLKDEV_INIT("s5pc100-spi.0", "spi_busclk2", &clk_sclk_spi0.clk),
CLKDEV_INIT("s5pc100-spi.1", "spi_busclk1", &clk_48m_spi1),
CLKDEV_INIT("s5pc100-spi.1", "spi_busclk2", &clk_sclk_spi1.clk),
CLKDEV_INIT("s5pc100-spi.2", "spi_busclk1", &clk_48m_spi2),
CLKDEV_INIT("s5pc100-spi.2", "spi_busclk2", &clk_sclk_spi2.clk),
CLKDEV_INIT("samsung-i2s.0", "i2s_opclk0", &clk_i2s0),
CLKDEV_INIT("samsung-i2s.1", "i2s_opclk0", &clk_i2s1),
CLKDEV_INIT("samsung-i2s.2", "i2s_opclk0", &clk_i2s2),
};
4.3.5、修改Makefile
arch/arm/mach-s5pc100/Makefile
obj-y += dev-audio.o
改为:
#obj-y += dev-audio.o
arch/arm/plat-samsung/Makefile
obj-y += devs.o
改为:
#obj-y += devs.o
五、选配内核
# make menuconfig
General setup --->
[*] System V IPC
[*] Embedded system
[*] Enable loadable module support --->
[*] Module unloading
[*] Module versioning support
[*] Source checksum for all modules
[*] Enable the block layer --->
Partition Types --->
[*] PC BIOS (MSDOS partition tables) support
Boot options --->
[*] Provide old way to pass kernel parameters
六、编译验证
# make