linux停在OK界面,烧写Linux Kernel uImage后,停在Uncompressing Linux... done, booting the kernel....

在串口终端打印的信息如下:

RomBOOT

AT91Bootstrap 3.6.0 (Sat Jan 30 20:44:32 CST 2016)

NAND: Done to load image

U-Boot 2014.04 (Feb 20 2016 - 12:02:56)

CPU: AT91SAM9261

Crystal frequency:   18.432 MHz

CPU clock        :  198.656 MHz

Master clock     :   99.328 MHz

DRAM:  64 MiB

WARNING: Caches not enabled

NAND:  128 MiB

*** Warning - bad CRC, using default environment

In:    serial

Out:   serial

Err:   serial

Net:   Net Initialization Skipped

No ethernet found.

Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x200000, size 0x300000

3145728 bytes read: OK

## Booting kernel from Legacy Image at 22000000 ...

Image Name:   Linux-3.4.9-AT91SAM9261

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1663528 Bytes = 1.6 MiB

Load Address: 20008000

Entry Point:  20008000

Verifying Checksum ... OK

Loading Kernel Image ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

接下来,就什么都没有了,就像没有内核一样的。。。但是内核又加载成功了一样,看了一下开发板,LED还在闪着呢,我记得Uboot烧写成功后,这个用户LED灯不闪烁。难道Linux内核已经成功运行,只是串口没有打印,看来有可能与Linux中的串口驱动有关!!!

Uboot的传递参数是正确的,其他的内核引导过正常!!

打开内核,配置一下串口的驱动,控制台的串口使用的是DEBUG串口,这里使用AT91SAM9261EK的开发板,Linux 内核为:Linux 3.4.9的内核(官方的)。

内核配置是根据默认的配置修改的,去掉一些无关项。

找到Device Driver看一下串口配置:

在shell控制台里执行:

make ARCH=arm menuconfig

(1)串口的驱动,在Device Drivers --->菜单项下:

47e88072566b548cd438b62c50e8469d.png

(2)串口设备属于:字符设备 Character devices --->

73d0654acf3e56d850fef886d3a23b0a.png

(3)找到串口驱动项:Serial drivers --->

f6c42fa43b6d25ae4217dc689ee491ec.png

(4)串口的配置正常:我这里用的是Atmel的板子。

e0bdb3b3e07a29a4e6e5dcfade2e436e.png

(5)这个DMA一定要选上,因为串口设备那里选择了串口基于DMA,否则可能串口驱动不正常,并且还不打印出错的信息,让你蒙在鼓里!!!

d6556bf02a4e16762ebe95f91d58e540.png

以上配置正确后,重新编译内核:生成uImage,使用samba烧写即可。

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage

烧写后,果然,串口终端有打印信息了,内核启动正常!!

RomBOOT

AT91Bootstrap 3.6.0 (Sat Jan 30 20:44:32 CST 2016)

NAND: Done to load image

U-Boot 2014.04 (Feb 20 2016 - 12:02:56)

CPU: AT91SAM9261

Crystal frequency:   18.432 MHz

CPU clock        :  198.656 MHz

Master clock     :   99.328 MHz

DRAM:  64 MiB

WARNING: Caches not enabled

NAND:  128 MiB

*** Warning - bad CRC, using default environment

In:    serial

Out:   serial

Err:   serial

Net:   Net Initialization Skipped

No ethernet found.

Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x200000, size 0x300000

3145728 bytes read: OK

## Booting kernel from Legacy Image at 22000000 ...

Image Name:   Linux-3.4.9-AT91SAM9261

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    1654216 Bytes = 1.6 MiB

Load Address: 20008000

Entry Point:  20008000

Verifying Checksum ... OK

Loading Kernel Image ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

Booting Linux on physical CPU 0

Linux version 3.4.9-AT91SAM9261 (root@zhangsz) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #4 Sat Feb 20 12:30:17 CST 2016

CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177

CPU: VIVT data cache, VIVT instruction cache

Machine: Atmel AT91SAM9261-EK

Memory policy: ECC disabled, Data cache writeback

AT91: Detected soc type: at91sam9261

AT91: Detected soc subtype: Unknown

AT91: sram at 0x300000 of 0x28000 mapped at 0xfef50000

Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz

gpiochip_add: registered GPIOs 0 to 31 on device: pioA

gpiochip_add: registered GPIOs 32 to 63 on device: pioB

gpiochip_add: registered GPIOs 64 to 95 on device: pioC

Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256

Kernel command line: mem=64M console=ttyS0,115200 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs) root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs

PID hash table entries: 256 (order: -2, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory: 64MB = 64MB total

Memory: 60900k/60900k available, 4636k reserved, 0K highmem

Virtual kernel memory layout:

vector  : 0xffff0000 - 0xffff1000   (   4 kB)

fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)

vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)

lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)

modules : 0xbf000000 - 0xc0000000   (  16 MB)

.text : 0xc0008000 - 0xc0395ee8   (3640 kB)

.init : 0xc0396000 - 0xc03b6000   ( 128 kB)

.data : 0xc03b6000 - 0xc03db4c0   ( 150 kB)

.bss : 0xc03db4e4 - 0xc03eef9c   (  79 kB)

NR_IRQS:16 nr_irqs:16 16

AT91: 96 gpio irqs in 3 banks

sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 4294967286ms

Console: colour dummy device 80x30

Calibrating delay loop... 98.71 BogoMIPS (lpj=493568)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

Setting up static identity map for 0x202c7130 - 0x202c7188

pinctrl core: initialized pinctrl subsystem

NET: Registered protocol family 16

AT91: Power Management

AT91: Starting after general reset

bio: create slab at 0

SCSI subsystem initialized

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

i2c-gpio i2c-gpio.0: using pins 7 (SDA) and 8 (SCL)

Switching to clocksource tcb_clksrc

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

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.

squashfs: version 4.0 (2009/01/31) Phillip Lougher

msgmni has been set to 118

io scheduler noop registered (default)

atmel_lcdfb atmel_lcdfb.0: clut resources unusable

atmel_usart.0: ttyS0 at MMIO 0xfffff200 (irq = 17) is a ATMEL_SERIAL

console [ttyS0] enabled

brd: module loaded

ssc ssc.1: Atmel SSC device at 0xc4810000 (irq 31)

atmel_nand: Use On Flash BBT

atmel_nand atmel_nand: No DMA support for NAND access.

NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-bit)

Bad block table not found for chip 0

Bad block table not found for chip 0

Scanning device for bad blocks

Bad eraseblock 446 at 0x0000037c0000

Bad eraseblock 994 at 0x000007c40000

Bad block table written to 0x000007fe0000, version 0x01

Bad block table written to 0x000007fc0000, version 0x01

2 cmdlinepart partitions found on MTD device atmel_nand

Creating 2 MTD partitions on "atmel_nand":

0x000000000000-0x000000800000 : "bootstrap/uboot/kernel"

0x000000800000-0x000008000000 : "rootfs"

UBI: attaching mtd1 to ubi0

UBI: physical eraseblock size:   131072 bytes (128 KiB)

UBI: logical eraseblock size:    129024 bytes

UBI: smallest flash I/O unit:    2048

UBI: sub-page size:              512

UBI: VID header offset:          512 (aligned 512)

UBI: data offset:                2048

UBI: empty MTD device detected

UBI: max. sequence number:       0

UBI: create volume table (copy #1)

UBI: create volume table (copy #2)

UBI: attached mtd1 to ubi0

UBI: MTD device name:            "rootfs"

UBI: MTD device size:            120 MiB

UBI: number of good PEBs:        954

UBI: number of bad PEBs:         6

UBI: number of corrupted PEBs:   0

UBI: max. allowed volumes:       128

UBI: wear-leveling threshold:    4096

UBI: number of internal volumes: 1

UBI: number of user volumes:     0

UBI: available PEBs:             941

UBI: total number of reserved PEBs: 13

UBI: number of PEBs reserved for bad PEB handling: 9

UBI: max/mean erase counter: 0/0

UBI: image sequence number:  -230112458

atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 28)

UBI: background thread "ubi_bgt0d" started, PID 810

atmel_spi atmel_spi.0: master is unqueued, this is deprecated

dm9000 Ethernet Driver, V1.31

dm9000 dm9000.0: eth%d: Invalid ethernet MAC address. Please set using ifconfig

eth0: dm9000a at c4804000,c4806044 IRQ 123 MAC: 86:74:e2:c9:41:58 (random)

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

at91_ohci at91_ohci: AT91 OHCI

at91_ohci at91_ohci: new USB bus registered, assigned bus number 1

at91_ohci at91_ohci: irq 36, io mem 0x00500000

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

Initializing USB Mass Storage driver...

usbcore: registered new interface driver usb-storage

USB Mass Storage support registered.

mousedev: PS/2 mouse device common for all mice

ads7846 spi0.2: touchscreen, irq 45

input: ADS7843 Touchscreen as /devices/platform/atmel_spi.0/spi_master/spi0/spi0.2/input/input0

rtc-at91sam9 rtc-at91sam9.0: rtc core: registered rtc-at91sam9 as rtc0

rtc-at91sam9: probe of rtc-at91sam9.0 failed with error -38

i2c /dev entries driver

at91sam9_wdt: sorry, watchdog is disabled

at91_wdt: probe of at91_wdt failed with error -5

TCP: cubic registered

NET: Registered protocol family 17

VFP support v0.3: not present

input: gpio-keys as /devices/platform/gpio-keys/input/input1

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -19

Please append a correct "root=" boot option; here are the available partitions:

1f00            8192 mtdblock0  (driver?)

1f01          122880 mtdblock1  (driver?)

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

[] (unwind_backtrace+0x0/0xf4) from [] (panic+0x74/0x1bc)

[] (panic+0x74/0x1bc) from [] (mount_block_root+0x174/0x228)

[] (mount_block_root+0x174/0x228) from [] (prepare_namespace+0x8c/0x1ac)

[] (prepare_namespace+0x8c/0x1ac) from [] (kernel_init+0x164/0x1ac)

[] (kernel_init+0x164/0x1ac) from [] (kernel_thread_exit+0x0/0x8)

总结:学习嵌入式,需要的是软件与硬件的结合,我是硬件出身,因此,出现问题,先从硬件角度去思路,也就是从硬件驱动上着手,从根本上找到为什么会这样!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux 系统中,可以通过 `zlib` 库来进行 `gzip` 压缩和解压缩操作。如果要解压 `uImage.gz` 文件,可以使用 `zlib` 库提供的函数来完成。 下面是一个使用 `zlib` 库来解压 `uImage.gz` 文件的示例代码: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zlib.h> #define CHUNK_SIZE 1024 int main(int argc, char *argv[]) { gzFile infile; char *outfile_name; FILE *outfile; char buffer[CHUNK_SIZE]; int bytes_read; int ret; if (argc < 2) { fprintf(stderr, "Usage: %s uImage.gz\n", argv[0]); return -1; } /* 打开 gzip 文件 */ infile = gzopen(argv[1], "rb"); if (!infile) { fprintf(stderr, "Error: failed to open %s\n", argv[1]); return -1; } /* 构造输出文件名 */ outfile_name = (char *)malloc(strlen(argv[1]) - 2); strncpy(outfile_name, argv[1], strlen(argv[1]) - 3); strcat(outfile_name, "\0"); /* 打开输出文件 */ outfile = fopen(outfile_name, "wb"); if (!outfile) { fprintf(stderr, "Error: failed to create %s\n", outfile_name); return -1; } /* 逐块解压并写入输出文件 */ while ((bytes_read = gzread(infile, buffer, CHUNK_SIZE)) > 0) { ret = fwrite(buffer, 1, bytes_read, outfile); if (ret < bytes_read) { fprintf(stderr, "Error: failed to write to %s\n", outfile_name); return -1; } } /* 关闭文件 */ gzclose(infile); fclose(outfile); free(outfile_name); printf("Done.\n"); return 0; } ``` 上面的代码中,我们先通过 `gzopen()` 函数打开 `uImage.gz` 文件,并指定以二进制(`"rb"`)方式打开。然后,我们通过 `malloc()` 函数动态分配内存,构造输出文件名,并打开输出文件。 接着,我们使用 `gzread()` 函数逐块从 `uImage.gz` 文件中读取数据,并通过 `fwrite()` 函数将解压后的数据写入到输出文件中。最后,我们通过 `gzclose()` 和 `fclose()` 函数关闭打开的文件,并使用 `free()` 函数释放动态分配的内存。 注意,在解压 `uImage.gz` 文件时,我们只需要解压文件头之后的数据部分,因此输出文件名中去掉了 ".gz" 后缀。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值