mini2440移植linux内核,移植最新内核linux-3.14.6到mini2440开发板

转载请注明出处lingdxuyan.blog.chinaunix.net

#include #include #include #include //nand flash分区表

static struct mtd_partition lingd2440_default_nand_part[] = {

[0] = {

.name= "bootloader",

.size= SZ_256K,

.offset= 0,

},

[1] = {

.name= "param",

.offset = SZ_256K,

.size= SZ_128K,

},

[2] = {

.name= "kernel",

.offset = SZ_128K * 3,

.size= SZ_1M * 5,

},

[3] = {

.name= "root",

.offset= SZ_1M * 5 + SZ_128K * 3,

.size= MTDPART_SIZ_FULL,

},

[4] = {

.name= "nand",

.offset = 0,

.size= MTDPART_SIZ_FULL,

}

};

//开发板nand flash芯片集,mini2440只有一片nand flash

static struct s3c2410_nand_set lingd2440_nand_sets[] = {

[0] = {

.name= "NAND",

.nr_chips= 1,

.nr_partitions= ARRAY_SIZE(lingd2440_default_nand_part),

.partitions= lingd2440_default_nand_part,

},

};

//开发板nand flash芯片信息

static struct s3c2410_platform_nand lingd2440_nand_info = {

.tacls= 20,

.twrph0= 60,

.twrph1= 20,

.nr_sets= ARRAY_SIZE(lingd2440_nand_sets),

.sets= lingd2440_nand_sets,

.ignore_unset_ecc = 1,

};

//将nand flash添加到平台设备中

static struct platform_device *lingd2440_devices[] __initdata = {

&s3c_device_ohci,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c0,

&s3c_device_iis,

&s3c_device_nand,//添加nand flash平台设备

};

//调用s3c_nand_set_platdata将nand flash芯片信息添加到nand flash平台设备中

static void __init lingd2440_machine_init(void)

{

s3c24xx_fb_set_platdata(&lingd2440_fb_info);

s3c_i2c0_set_platdata(NULL);

s3c_nand_set_platdata(&lingd2440_nand_info);//将nand flash芯片信息添加到nand flash平台设备中

platform_add_devices(lingd2440_devices, ARRAY_SIZE(lingd2440_devices));

//smdk_machine_init();

}

2.3 内核配置选项

ftl_cs: FTL header not found.问题解决方法:取消以下内核配置选项

lingd@ubuntu14:~/arm/linux-3.14.6$ make menuconfig

Device Drivers  --->

Memory Technology Device (MTD) support  --->

< >   FTL (Flash Translation Layer) support

< >   NFTL (NAND Flash Translation Layer) support

< >   INFTL (Inverse NAND Flash Translation Layer) support

3、添加yaffs2支持

3.1 获取yaffs源码

lingd@ubuntu14:~/arm$ git clone git://

3.2 为内核打yaffs2补丁

lingd@ubuntu14:~/arm$ cd yaffs2/

lingd@ubuntu14:~/arm/yaffs2$ ./patch-ker.sh l m /home/lingd/arm/linux-3.14.6

Updating /home/lingd/arm/linux-3.14.6/fs/Kconfig

Updating /home/lingd/arm/linux-3.14.6/fs/Makefile

3.3 内核配置选项

lingd@ubuntu14:~/arm/yaffs2$ cd ../linux-3.14.6/

lingd@ubuntu14:~/arm/linux-3.14.6$ make menuconfig

File systems  --->

[*] Miscellaneous filesystems  --->

yaffs2 file system support

-*-     512 byte / page devices

[ ]       Use older-style on-NAND data format with pageStatus byte

[ ]         Lets yaffs do its own ECC

-*-     2048 byte (or larger) / page devices

[*]       Autoselect yaffs2 format

[ ]       Disable yaffs from doing ECC on tags by default

[ ]     Force chunk erase check

[ ]     Empty lost and found on boot

[ ]     Disable yaffs2 block refreshing

[ ]     Disable yaffs2 background processing

[ ]     Disable yaffs2 bad block marking

[ ]     Enable yaffs2 xattr support

3.4 yaffs2补丁

最新yaffs2源码无法通过编译,需要修改,待续

4、移植网卡dm9000驱动

内核自带网卡dm9000驱动drivers/net/ethernet/davicom/dm9000.c。它也是一个平台设备,因此在目标平台初始化代码中,只要填写好相应的结构表即可,具体步骤如下:

lingd@ubuntu14:~/arm/linux-3.14.6$ vim arch/arm/mach-s3c24xx/mach-lingd2440.c

4.1 添加驱动所需的头文件 dm9000.h

//dm9000相关头文件

#include //内存控制器相关头文件

#include "regs-mem.h"

4.2 添加dm9000网卡物理基地址定义

//dm9000网卡物理基地址

#define MACH_LINGD2440_DM9000_BASE(S3C2410_CS4 + 0x300)

4.3 添加dm9000网卡资源定义

//dm9000网卡资源

static struct resource lingd2440_dm9000_resources[] = {

[0] = DEFINE_RES_MEM(MACH_LINGD2440_DM9000_BASE, 4),

[1] = DEFINE_RES_MEM(MACH_LINGD2440_DM9000_BASE + 4, 4),

[2] = DEFINE_RES_NAMED(IRQ_EINT7, 1, NULL, IORESOURCE_IRQ \

| IORESOURCE_IRQ_HIGHEDGE),

};

4.4 添加dm9000平台数据定义

//dm9000平台数据

static struct dm9000_plat_data lingd2440_dm9000_platdata = {

.flags= DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,

.dev_addr= { 0x88, 0x00, 0xC0, 0xA8, 0x00, 0x88 },//MAC地址

};

4.5 添加dm9000平台设备定义

//dm9000平台设备

struct platform_device lingd2440_dm9000 = {

.name= "dm9000",

.id= -1,

.num_resources= ARRAY_SIZE(lingd2440_dm9000_resources),

.resource= lingd2440_dm9000_resources,

.dev= {

.platform_data= &lingd2440_dm9000_platdata,

},

};

4.6 添加dm9000初始化函数

//dm9000初始化函数

static void lingd2440_dm9000_init(void)

{

/* bank 4 configurations */

#define S3C2410_BWSCON_DW4_8(0<<16)

#define S3C2410_BWSCON_DW4_16(1<<16)

#define S3C2410_BWSCON_DW4_32(2<<16)

#define S3C2410_BWSCON_WS4(1<<18)

writel((readl(S3C2410_BWSCON) & 0xFFF0FFFF) | S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4, S3C2410_BWSCON);

writel(0x1F7C, S3C2410_BANKCON4);

}

4.7 将dm9000平台设备添加到开发板平台设备定义中

static struct platform_device *lingd2440_devices[] __initdata = {

&s3c_device_ohci,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c0,

&s3c_device_iis,

&s3c_device_nand,//添加nand flash平台设备

&lingd2440_dm9000,//添加dm9000平台设备

};

4.8 在开发板初始化函数中,调用dm9000初始化函数lingd2440_dm9000_init

static void __init lingd2440_machine_init(void)

{

s3c24xx_fb_set_platdata(&lingd2440_fb_info);

s3c_i2c0_set_platdata(NULL);

lingd2440_dm9000_init();//初始化dm9000

s3c_nand_set_platdata(&lingd2440_nand_info);//将nand flash芯片信息添加到nand flash平台设备中

platform_add_devices(lingd2440_devices, ARRAY_SIZE(lingd2440_devices));

//smdk_machine_init();

}

4.9 添加dm9000支持

lingd@ubuntu14:~/arm/linux-3.14.6$ make menuconfig

Device Drivers  --->

[*] Network device support  --->

[*] Ethernet driver support  --->

DM9000 support

5、添加RTC支持

内核自带s3c2440 RTC驱动drivers/rtc/rtc-s3c.c。

5.1 将RTC平台设备添加到开发板平台设备定义中

lingd@ubuntu14:~/arm/linux-3.14.6$ vim arch/arm/mach-s3c24xx/mach-lingd2440.c

static struct platform_device *lingd2440_devices[] __initdata = {

&s3c_device_ohci,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c0,

&s3c_device_iis,

&s3c_device_rtc,//添加RTC平台设备

&s3c_device_nand,//添加nand flash平台设备

&lingd2440_dm9000,//添加dm9000平台设备

};

5.2 添加RTC支持

Device Drivers  --->

[*] Real Time Clock  --->

Samsung S3C series SoC RTC

5.3 测试

root@lingd2440:/# date

Sat Jan  1 00:00:10 UTC 2000

root@lingd2440:/# date -s 201406081948

Sun Jun  8 19:48:00 UTC 2014

root@lingd2440:/# date

Sun Jun  8 19:48:04 UTC 2014

root@lingd2440:/# hwclock

Sat Jan  1 00:00:32 2000  0.000000 seconds

root@lingd2440:/# hwclock -w

root@lingd2440:/# hwclock

Sun Jun  8 19:48:16 2014  0.000000 seconds

6、添加telnet支持

Device Drivers  --->

Character devices  --->

-*- Unix98 PTY support

[ ]   Support multiple instances of devpts

[*] Legacy (BSD) PTY support

(128) Maximum number of legacy PTY in use

7、内核正常启动过程

Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00500000 ... done

zImage magic = 0x016f2818

Setup linux parameters at 0x30000100

linux command line is: "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200"

MACH_TYPE = 1998

NOW, Booting Linux......

Booting Linux on physical CPU 0x0

Linux version 3.14.6 (lingd@ubuntu14) (gcc version 4.4.3 (ctng-1.6.1) ) #8 Sun Jun 8 19:44:34 CST 2014

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177

CPU: VIVT data cache, VIVT instruction cache

Machine: lingd mini2440 development board

Warning: Neither atags nor dtb found

Memory policy: Data cache writeback

CPU S3C2440A (id 0x32440001)

S3C24XX Clocks, Copyright 2004 Simtec Electronics

S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064

Kernel command line: noinitrd root=/dev/mtdblock3 rw init=/linuxrc console=ttySAC0,115200

PID hash table entries: 64 (order: -4, 256 bytes)

Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)

Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)

Memory: 10756K/16384K available (3797K kernel code, 185K rwdata, 1012K rodata, 144K init, 246K bss, 5628K reserved)

Virtual kernel memory layout:

vector  : 0xffff0000 - 0xffff1000   (   4 kB)

fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)

vmalloc : 0xc1800000 - 0xff000000   ( 984 MB)

lowmem  : 0xc0000000 - 0xc1000000   (  16 MB)

modules : 0xbf000000 - 0xc0000000   (  16 MB)

.text : 0xc0008000 - 0xc04ba840   (4811 kB)

.init : 0xc04bb000 - 0xc04df22c   ( 145 kB)

.data : 0xc04e0000 - 0xc050e4e0   ( 186 kB)

.bss : 0xc050e4e0 - 0xc054bfd0   ( 247 kB)

SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

NR_IRQS:103

S3C2440: IRQ Support

irq: clearing pending status 00000003

irq: clearing pending status 00000002

sched_clock: 16 bits at 1012kHz, resolution 987ns, wraps every 64725925ns

Console: colour dummy device 80x30

Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)

Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)

CPU: Testing write buffer coherency: ok

Setting up static identity map for 0x303a0f78 - 0x303a0fd0

NET: Registered protocol family 16

DMA: preallocated 256 KiB pool for atomic coherent allocations

cpuidle: using governor ladder

cpuidle: using governor menu

S3C2440: Initialising architecture

S3C244X: Clock Support, DVS off

bio: create slab at 0

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

s3c-i2c s3c2440-i2c.0: slave address 0x10

s3c-i2c s3c2440-i2c.0: bus frequency set to 98 KHz

s3c-i2c s3c2440-i2c.0: i2c-0: S3C I2C adapter

Advanced Linux Sound Architecture Driver Initialized.

Switched to clocksource samsung_clocksource_timer

NET: Registered protocol family 2

TCP established hash table entries: 1024 (order: 0, 4096 bytes)

TCP bind hash table entries: 1024 (order: 0, 4096 bytes)

TCP: Hash tables configured (established 1024 bind 1024)

TCP: reno registered

UDP hash table entries: 256 (order: 0, 4096 bytes)

UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)

NET: Registered protocol family 1

RPC: Registered named UNIX socket transport module.

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

futex hash table entries: 256 (order: -1, 3072 bytes)

NFS: Registering the id_resolver key type

Key type id_resolver registered

Key type id_legacy registered

jffs2: version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 21

io scheduler noop registered

io scheduler deadline registered

io scheduler cfq registered (default)

Console: switching to colour frame buffer device 60x53

s3c2410-lcd s3c2410-lcd: fb0: s3c2410fb frame buffer device

s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 74, base_baud = 0) is a S3C2440

console [ttySAC0] enabled

s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 77, base_baud = 0) is a S3C2440

s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 80, base_baud = 0) is a S3C2440

brd: module loaded

s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns

s3c24xx-nand s3c2440-nand: NAND soft ECC

nand: device found, Manufacturer ID: 0xec, Chip ID: 0xda

nand: Samsung NAND 256MiB 3,3V 8-bit

nand: 256MiB, SLC, page size: 2048, OOB size: 64

Scanning device for bad blocks

Bad eraseblock 1344 at 0x00000a800000

Bad eraseblock 1476 at 0x00000b880000

Creating 5 MTD partitions on "NAND":

0x000000000000-0x000000040000 : "bootloader"

0x000000040000-0x000000060000 : "param"

0x000000060000-0x000000560000 : "kernel"

0x000000560000-0x000010000000 : "root"

0x000000000000-0x000010000000 : "nand"

dm9000 dm9000: read wrong id 0x01010101

eth0: dm9000e at c18ca300,c18cc304 IRQ 55 MAC: 88:00:c0:a8:00:88 (platform data)

ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver

ohci-s3c2410: OHCI S3C2410 driver

s3c2410-ohci s3c2410-ohci: OHCI Host Controller

s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1

s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

mousedev: PS/2 mouse device common for all mice

s3c-rtc s3c2410-rtc: rtc disabled, re-enabling

s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0

s3c-rtc s3c2410-rtc: warning: invalid RTC value so initializing it

i2c /dev entries driver

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq disabled

sdhci: Secure Digital Host Controller Interface driver

sdhci: Copyright(c) Pierre Ossman

hidraw: raw HID events driver (C) Jiri Kosina

usbcore: registered new interface driver usbhid

usbhid: USB HID core driver

TCP: cubic registered

NET: Registered protocol family 17

Key type dns_resolver registered

s3c-rtc s3c2410-rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)

ALSA device list:

No soundcards found.

yaffs: dev is 32505859 name is "mtdblock3" rw

yaffs: passed flags ""

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

Freeing unused kernel memory: 144K (c04bb000 - c04df000)

Processing /etc/init.d/rcS

mount -a

Processing /etc/rc.local

Get hostname

Starting mdev

Starting telnetd

ifconfig eth0 192.168.1.100

dm9000 dm9000 eth0: link down

**************************************************

*                                                *

*                  lingd rootfs                  *

*                                                *

*          arm-linux-gcc version 4.4.3           *

*                                                *

*                   2014-05-11                   *

*                                                *

**************************************************

Please press Enter to activate this console.

阅读(6705) | 评论(3) | 转发(5) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Boot是一个高效的开发框架,它能够轻松地调用第三方接口。下面是使用Spring Boot调用第三方接口的步骤: 1. 导入相关依赖 在pom.xml文件中添加相关依赖,例如: ``` <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.14.6</version> </dependency> </dependencies> ``` 其中,spring-boot-starter-web是Spring Boot的web启动器,okhttp是一个HTTP客户端库,可以用来发送HTTP请求。 2. 编写调用代码 在Java代码中使用OkHttp发送HTTP请求,例如: ``` import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; // ... OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://api.example.com/user") .build(); Response response = client.newCall(request).execute(); String responseBody = response.body().string(); // 获取响应体 ``` 在这个示例中,我们使用OkHttpClient创建一个HTTP客户端,并使用Request构建器创建一个HTTP请求对象。然后,我们使用HTTP客户端发送请求,并获取响应体。在实际使用中,您需要根据具体的接口文档和业务需求来编写代码。 3. 配置接口地址和参数 在实际使用中,您需要根据具体的接口文档和业务需求来配置接口地址和参数。您可以使用properties或yaml文件配置接口地址和参数,例如: ``` api.url=https://api.example.com/user api.key=your_api_key ``` 然后,在Java代码中使用@Value注解获取配置值,例如: ``` import org.springframework.beans.factory.annotation.Value; // ... @Value("${api.url}") private String apiUrl; @Value("${api.key}") private String apiKey; // ... OkHttpClient client = new OkHttpClient(); HttpUrl.Builder urlBuilder = HttpUrl.parse(apiUrl).newBuilder(); urlBuilder.addQueryParameter("key", apiKey); String url = urlBuilder.build().toString(); Request request = new Request.Builder() .url(url) .build(); Response response = client.newCall(request).execute(); String responseBody = response.body().string(); ``` 在这个示例中,我们使用@Value注解获取配置值,并使用HttpUrl构建器构建URL,并添加查询参数。然后,我们使用HTTP客户端发送请求,并获取响应体。 4. 处理响应 在实际使用中,您需要根据具体的接口文档和业务需求来处理响应。您可以使用Jackson或Gson等JSON处理库来解析响应数据,例如: ``` import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.JsonNode; // ... ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseJson = objectMapper.readTree(responseBody); String name = responseJson.get("name").asText(); // 获取name字段的值 ``` 在这个示例中,我们使用ObjectMapper解析JSON响应体,并获取响应中的name字段的值。 以上就是使用Spring Boot调用第三方接口的步骤。为了保证代码的可靠性和可维护性,建议您在编写代码之前,先仔细阅读接口文档,并进行必要的测试和调试。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值