疯雨-版权所有,转载请注明【http://blog.csdn.net/u010346967】
uboot启动内核要注意两点:
第一,修改自启动命令。我的这个uboot版本是配置 CONFIG_BOOTCOMMAND (在配置文件配置 x210v3.h)
第二,修改启动参数(如果内核配置为uboot传递启动参数的话)。这个uboot版本是配置CONFIG_BOOTARGS。我不用uboot传参,就不改了。
关于内核的制作,我也有相应的文章,可以去看看。
下面修改启动命令:
128 //#define CONFIG_BOOTCOMMAND "run ubifsboot"
129 #define CONFIG_BOOTCOMMAND "bootm 0x20008000"
好既然是从0x20008000启动那么就要把内核代码copy到0x20008000这个内存地址吧。
去copy_to_mem里面添加拷贝函数,思路是这样的先把编译好的内核代码烧写到sd卡,然后在copy_to_mem里面添加复制代码,复制内核到内存地址0x20008000.
修改copy_to_mem,这里就不解释了 ,你应该自己能写出来,代码如下:
/**重新编译,烧写uboot。
* * This Function copy MMC(MoviNAND/iNand) Card Data to memory.
* * Always use EPLL source clock.
* * This function works at 20Mhz.
* * @param u32 DMA channel number: this is channel 2. Depend on your board.
* * @param u32 StartBlkAddress : Source card(MoviNAND/iNand MMC)) Address.(It must block address.)
* * @param u16 blockSize : Number of blocks to copy.
* * @param u32* memoryPtr : Buffer to copy from.
* * @param bool with_init : determined card initialization.
* * @return bool(u8) - Success or failure.
* */
#define CopySDMMCtoMem(z,a,b,c,e) (((int(*)(int, unsigned int, unsigned short, unsigned int*, int))(*((unsigned int *)0xD0037F98)))(z,a,b,c,e))
#define MMC_CHANNEL 2
#define BL2_START_SECTOR 49
#define KERNEL_START_SECTOR 1000
#define BL2_SECTOR_NUM 480
#define KERNEL_SECTOR_NUM (512*4*8)
#define BL2_MEM_START_ADDR 0x24800000
#define KERNEL_MEM_START_ADDR 0x20008000
#define KERNEL_SIZE 0x800000
void copy_to_mem(void)
{
/*
//print channel value to ensure which channel used
__asm__(
"ldr r0,=0xD0037488\n"
"bl display_mem\n"
:
:
:"memory");
*/
int i;
CopySDMMCtoMem(MMC_CHANNEL, BL2_START_SECTOR, BL2_SECTOR_NUM, (unsigned int *)BL2_MEM_START_ADDR, 0);
for(i=0;i < (KERNEL_SIZE>>9)/KERNEL_SECTOR_NUM; i++)
{
CopySDMMCtoMem(MMC_CHANNEL, KERNEL_START_SECTOR+i*KERNEL_SECTOR_NUM, KERNEL_SECTOR_NUM, (unsigned int *)(KERNEL_MEM_START_ADDR +i*(KERNEL_SECTOR_NUM<<9)), 0);
}
__asm__(
"ldr r0,=0x20008000\n"
"bl display_mem\n"
:
:
:"memory");
}
然后是烧写内核,下面是我编写的烧写内核的脚本,burnKernel.sh
内容如下:
dd iflag=sync oflag=sync if=uImage of=/dev/sdb seek=1000
复制uImage到与burnKernel.sh同一个目录下就可以输入./burnKernel.sh命令烧写内核了。(记得要有可执行权限哦)
root@xjg:/home/uboot/u-boot-2012.10# ls
api CREDITS lib net tools
arch disk MAINTAINERS post u-boot
board doc MAKEALL README u-boot_16k.bin
boards.cfg drivers Makefile rules.mk u-boot.bin
burnBootloader.sh dts mkconfig snapshot.commit u-boot.dis
common examples mkv210 spl u-boot.lds
config.mk fs mkv210_image.c System.map u-boot.map
COPYING include nand_spl test u-boot.srec
root@xjg:/home/uboot/u-boot-2012.10# vim burnKernel.sh
root@xjg:/home/uboot/u-boot-2012.10# chmod a+x burnKernel.sh
root@xjg:/home/uboot/u-boot-2012.10# ./burnBootloader.sh
记录了32+0 的读入
记录了32+0 的写出
16384字节(16 kB)已复制,0.904818 秒,18.1 kB/秒
记录了354+1 的读入
记录了354+1 的写出
181336字节(181 kB)已复制,8.42798 秒,21.5 kB/秒
root@xjg:/home/uboot/u-boot-2012.10# ./burnKernel.sh
记录了2831+1 的读入
记录了2831+1 的写出
1449848字节(1.4 MB)已复制,71.0321 秒,20.4 kB/秒
OK,你应该可以看到以下启动信息:
U-Boot 2012.10 (Jun 17 2015 - 12:56:28)
CPU: S5PC110@1000MHz
Board: Goni
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
Net: dm9000
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 ...
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 20095
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 consolc
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_namespac)
[<802510c4>] (prepare_namespace+0x190/0x1cc) from [<801ba548>] (kernel_init+0x8)
[<801ba548>] (kernel_init+0x8/0xe8) from [<8000ecd8>] (ret_from_fork+0x14/0x3c)
��
uboot的任务就算完成了。。。。当然这仅仅是完成了内核启动(开发板的名字什么的自己改改吧,不难),如果是做产品可不能这样就完了,一般还要提供友好的产品升级命令。我们学习的话这样就够了。。接下来就是挂载根文件系统,死磕内核了。。。。
此uboot系列文章就此结束。。。