微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > TE2410移植linux-2.6.14及调试过程总结(1)

TE2410移植linux-2.6.14及调试过程总结(1)

时间:11-10 来源:互联网 点击:

bd_t *bd = gd-> = gd->bd;

. . .

theKernel = (void (*)(int, int, uint))ntohl(hdr->ih_ep);

. . .

/* we assume that the kernel is in place */

printf ("\nStarting kernel ...\n\n");

#ifdef CONFIG_USB_DEVICE

{

extern void udc_disconnect (void);

udc_disconnect ();

}

#endif

cleanup_before_linux ();

theKernel (0, bd->bi_arch_number, bd->bi_boot_params);

}

theKernel = (void (*)(int, int, uint))ntohl(hdr->ih_ep);

typedef struct image_header {

uint32_tih_magic;/* Image Header Magic Number*/

uint32_tih_hcrc;/* Image Header CRC Checksum*/

uint32_tih_time;/* Image Creation Timestamp*/

uint32_tih_size;/* Image Data Size*/

uint32_tih_load;/* DataLoadAddress*/

uint32_tih_ep;/* Entry Point Address*/

uint32_tih_dcrc;/* Image Data CRC Checksum*/

uint8_tih_os;/* Operating System*/

uint8_tih_arch;/* CPU architecture*/

uint8_tih_type;/* Image Type*/

uint8_tih_comp;/* Compression Type*/

uint8_tih_name[IH_NMLEN];/* Image Name*/

} image_header_t;

可以看出跳转地址是由image_header结构体的ih_ep(Entry Point Address)成员来确定的,而ih_ep是由mkimage时自己填写的,如下是我填充的mkimage参数,其中的

-e 0x30008000就是来填充ih_ep成员的.

mkimage -A arm -O Linux -T kernel -C none -a 0x30008000-e 0x30008000-n Linux-2.6.14 -d zImage uImage

显然这个值应该是0x30008040

mkimage -A arm -O Linux -T kernel -C none -a 0x30008000-e 0x30008040-n Linux-2.6.14 -d zImage uImage

修改后启动信息如下

## Booting image at 30008000 ...

Image Name:Linux-2.6.14

Created:2008-07-148:59:37 UTC

Image Type:ARM Linux Kernel Image (uncompressed)

Data Size:1028136 Bytes = 1004 kB

Load Address: 30008000

Entry Point:30008040

Verifying Checksum ... OK

XIP Kernel Image ... OK

commandline:noinitrd root=/dev/mtdblock3 init=/linuxrc console= ttySAC0,115200 mem=64M

Starting kernel ...

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

2.Starting kernel ...

Uncompressing Linux............................................................

......... done, booting the kernel.

Error: unrecognized/unsupported machine ID (r1 = 0x000000c2).

Available machine support:

ID (hex)NAME

000000c1SMDK2410

Please check your kernel config and/or bootloader.

修改linux-2.6.14\arch\arm\kernel\head.S,如下,蓝色字体为添加内容

ENTRY(stext)

msrcpsr_c, #PSR_F_BIT | PSR_I_BIT | MODE_SVC @ ensure svc mode

@ and irqs disabled

bl__lookup_processor_type@ r5=procinfo r9=cpuid

movsr10, r5@ invalid processor (r5=0)?

beq__error_p@ yes, error p

movr1, #0xc1@参考linux-2.6.14\include\asm-arm\mach-types.h

bl__lookup_machine_type@ r5=machinfo

movsr8, r5@ invalid machine (r5=0)?

beq__error_a@ yes, error a

3.Starting kernel ...

Uncompressing Linux.................................................

......... done, booting the kernel.

然后就停止了

查看commandline完全正确,从上面的打印信息可以看出,内核已经解压成功了,这样只能进入内核跟踪调试了

在内核中arch/arm/kernel/debug.S中存在一个debug函数叫做printascii,使用方法如下:

adr r0, str_p1
bl printascii
str_p1:.asciz"\nError: unrecognized/unsupported process type\n"

用printascii在arch/arm/kernel/head.S里跟踪调试,直到跳转到start_kernel都没有发现问题,查到printascii在进入start_kernel之后也可以使用,说明如下:

mmu已经开启后,系统中的物理地址都变成虚拟地址了,因此原来基于物理地址的调试方案将都会失败,但可以使用printascii继续调试,该调试功能同时支持物理地址与虚拟地址,并且提供了一个解决方案就是将printascii加入到printk的vsprintf()之里。

修改linux-2.6.14\kernel\printk.c,蓝色字体为添加内容

extern void printascii(const char*);

asmlinkage int vprintk(const char *fmt, va_list args)

{

unsigned long flags;

int printed_len;

char *p;

static char printk_buf[1024];

static int log_level_unknown = 1;

preempt_disable();

if (unlikely(oops_in_progress) && printk_cpu == smp_processor_id())

z

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top