首先,分析下网上收集的解决方法:
1、uboot和内核的machine type 不匹配
那么uboot的machine type是多少怎么确定呢?打印出来不就知道了。所以在arch/arm/lib/bootm.c文件中添加printf函数,修改代码如下
r2 = gd->bd->bi_boot_params; printf("machid:0x%x\n",machid);kernel_entry(0, machid, r2);
machine type在u-boot的配置在board/samsung/xxx/xxx.c文件中 (xxx表示开发板名字,我的路径为board/samsung/goni/goni.c)
int board_init(void) { /* Set Initial global variables */ s5pc110_gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE; gd->bd->bi_arch_number = MACH_TYPE_GONI; gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; 这里MACH_TYPE_GONI宏是没有定义的,如果前面打印出来的machid值不是0xb2e,则在goni.c文件中添加 #define MACH_TYPE_GONI 2862
2、串口驱动没有编译入内核
执行 make menuconfig
查看 Device Drivers --->Character Devices ---> Serial drivers --->
<*> Samsung SoC serial support
[ ] Samsung SoC serial debug
[*] Support for console on Samsung SoC serial port
说明串口驱动已经开启。没问题
3、内核启动参数设置错误
呵呵 ,我的问题就是出在这里。uboot传递的内核启动参数不对,所以我干脆不用uboot传参数,在内核配置里设置启动参数
make menuconfig
Boot options ---> initrd=0x20800000,8M console=ttySAC1,115200 init=/linuxrc
将 ttySAC1改为ttySAC0, 也就是串口0做控制台。
然后 Kernel command line type选为 (X) Always use the default kernel command string。(默认为内核传参)
修改完成后串口0信息如下:
U-Boot 2012.10 (Jun 08 2015 - 21:41:00) CPU: S5PV210@1000MHz Board: x210v3 I2C: ready DRAM: 512 MiB WARNING: Caches not enabled Board PMIC init MMC: SAMSUNG SDHCI: 0 Using default environment In: serial Out: serial Err: serial Hit any key to stop autoboot: 0 ## Booting kernel from Legacy Image at 20008000 ... Image Name: Linux-3.8.3 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 1406024 Bytes = 1.3 MiB Load Address: 20008000 Entry Point: 20008040 XIP Kernel Image ... OK OK Starting kernel ... machid:0xb2e Uncompressing Linux... done, booting the kernel. Booting Linux on physical CPU 0x0 Linux version 3.8.3 (root@crazyrain) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #1 PREEMPT Mon Jun 8 21:42:51 CST 2015 CPU: ARMv7 Processor [412fc082] revision 2 (ARMv7), cr=10c53c7d CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine: GONI Ignoring tag cmdline (using the default kernel command line) Memory policy: ECC disabled, Data cache writeback CPU S5PV210/S5PC110 (id 0x43110220) S3C24XX Clocks, Copyright 2004 Simtec Electronics S5PV210: PLL settings, A=1000000000, M=667000000, E=96000000 V=54000000 S5PV210: ARMCLK=1000000000, HCLKM=200000000, HCLKD=166750000 HCLKP=133400000, PCLKM=100000000, PCLKD=83375000, PCLKP=66700000 sclk_dmc: source is sclk_a2m (0), rate is 200000000 sclk_onenand: source is hclk_dsys (1), rate is 83375000 sclk_fimc: source is ext_xtal (0), rate is 24000000 sclk_fimc: source is ext_xtal (0), rate is 24000000 sclk_fimc: source is ext_xtal (0), rate is 24000000 sclk_cam0: source is ext_xtal (0), rate is 24000000 sclk_cam1: source is ext_xtal (0), rate is 24000000 sclk_fimd: source is ext_xtal (0), rate is 24000000 sclk_mfc: source is sclk_a2m (0), rate is 200000000 sclk_g2d: source is sclk_a2m (0), rate is 200000000 sclk_g3d: source is sclk_a2m (0), rate is 200000000 sclk_csis: source is ext_xtal (0), rate is 24000000 sclk_pwi: source is ext_xtal (0), rate is 24000000 sclk_pwm: source is ext_xtal (0), rate is 24000000 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 Kernel command line: root=/dev/ram0 rw ramdisk=8192 initrd=0x20800000,8M console=ttySAC0,115200 init=/linuxrc PID hash table entries: 2048 (order: 1, 8192 bytes) Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) __ex_table already sorted, skipping sort Memory: 512MB = 512MB total Memory: 508668k/508668k available, 15620k reserved, 0K highmem Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) vmalloc : 0xa0800000 - 0xff000000 (1512 MB) lowmem : 0x80000000 - 0xa0000000 ( 512 MB) modules : 0x7f000000 - 0x80000000 ( 16 MB) .text : 0x80008000 - 0x8024f700 (2334 kB) .init : 0x80250000 - 0x8026d144 ( 117 kB) .data : 0x8026e000 - 0x80295540 ( 158 kB) .bss : 0x80295540 - 0x802c6130 ( 195 kB) SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 NR_IRQS:208 VIC @f6000000: id 0x00041192, vendor 0x41 VIC @f6010000: id 0x00041192, vendor 0x41 VIC @f6020000: id 0x00041192, vendor 0x41 VIC @f6030000: id 0x00041192, vendor 0x41 sched_clock: 32 bits at 33MHz, resolution 29ns, wraps every 128784ms Console: colour dummy device 80x30 Calibrating delay loop... 663.55 BogoMIPS (lpj=1658880) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok Setting up static identity map for 0x201bdec0 - 0x201bdf18 DMA: preallocated 256 KiB pool for atomic coherent allocations Registered chained gpio int handler for interrupt 62. Registered interrupt support for gpio group 18. S5PV210: Initializing architecture bio: create slab <bio-0> at 0 SCSI subsystem initialized Switching to clocksource s5p_clocksource_timer Trying to unpack rootfs image as initramfs... rootfs image is not initramfs (junk in compressed archive); looks like an initrd Freeing initrd memory: 8192K ROMFS MTD (C) 2007 Red Hat, Inc. io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) dma-pl330 dma-pl330.0: PERIPH_ID 0x0, PCELL_ID 0x0 ! dma-pl330: probe of dma-pl330.0 failed with error -22 dma-pl330 dma-pl330.1: PERIPH_ID 0x0, PCELL_ID 0x0 ! dma-pl330: probe of dma-pl330.1 failed with error -22 Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled s5pv210-uart.0: ttySAC0 at MMIO 0xe2900000 (irq = 74) is a S3C6400/10 console [ttySAC0] enabled s5pv210-uart.1: ttySAC1 at MMIO 0xe2900400 (irq = 75) is a S3C6400/10 s5pv210-uart.2: ttySAC2 at MMIO 0xe2900800 (irq = 76) is a S3C6400/10 s5pv210-uart.3: ttySAC3 at MMIO 0xe2900c00 (irq = 77) is a S3C6400/10 brd: module loaded loop: module loaded mousedev: PS/2 mouse device common for all mice VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2 RAMDISK: Couldn't find valid RAM disk image starting at 0. List of all partitions: No filesystem could mount root, tried: ext2 cramfs vfat msdos romfs Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) [<80014988>] (unwind_backtrace+0x0/0xfc) from [<801bab74>] (panic+0x98/0x1f0) [<801bab74>] (panic+0x98/0x1f0) from [<80250ec0>] (mount_block_root+0x2ec/0x300) [<80250ec0>] (mount_block_root+0x2ec/0x300) from [<802510c4>] (prepare_namespace+0x190/0x1cc) [<802510c4>] (prepare_namespace+0x190/0x1cc) from [<801ba548>] (kernel_init+0x8/0xe8) [<801ba548>] (kernel_init+0x8/0xe8) from [<8000ecd8>] (ret_from_fork+0x14/0x3c) 为了调试内核,接下来得做个简单的根文件系统