命令使用:
烧写Uboot:protect off 1:0
erase 1:0
tftp 30008000 u-boot.bin
cp.b 30008000 0 20000
对于Uboot下一步的工作是增加一个fl命令,应该比这个erase好用些,因为erase察出要知道那几个扇区或者是那两块地址之间
烧写BMP图片:tftp 30008000 logo.bmp
cp.b 300080000 00fa0000 $filesize
setenv splashimage 00fa0000
saveenv
bmp info $splashimage
把JPG转换成BMP(在Linux下使用PBM工具):
#jpegtopnm Bergkirchen.jpg | \
> ppmquant 256 | \
> ppmtobmp -bpp 8 >Bergkirchen-8bit.bmp
jpegtopnm: WRITING PPM FILE
ppmquant: making histogram...
ppmquant: too many colors!
ppmquant: scaling colors from maxval=255 to maxval=127 to improve clustering...
ppmquant: making histogram...
ppmquant: too many colors!
ppmquant: scaling colors from maxval=127 to maxval=63 to improve clustering...
ppmquant: making histogram...
ppmquant: 9760 colors found
ppmquant: choosing 256 colors...
ppmquant: mapping image to new colors...
ppmtobmp: analyzing colors...
ppmtobmp: 231 colors found
ppmtobmp: Writing 8 bits per pixel with a color pallette
制作uImage:
./mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -n 'linux-2.4.18' -d zImage Image
-A 设置那种类型的CPU
-O 设置那种类型的OS
-T 设置映像image类型
-C 是否压缩
-a 设置装载点
-e 设置进入点(内核的入口地址,信息头的大小是0X40,在制作uImage时,加的一个头,在使用bootm时会判别这个头)
-n 设置image名称
把信息传入linux核心的TAG定义:
#define CONFIG_SETUP_MEMORY_TAGS //如果没有定义这个参数,则uboot参数必须加入men=内存大小
#define CONFIG_INITRD_TAG
#define CONFIG_CMDLINE_TAG //设置bootargs出入内核必须
#define CFG_LOAD_ADDR 0x33000000 //把0X33000000改为0X30008000
设置NFS启动:
set bootargs root=/dev/nfs nfsroot=192.168.0.5:/home/zouzheng/HHARM/rootbox rw noinitrd init=/linuxrc ip=192.168.0.240:192.168.0.5:192.168.0.5:255.255.255.0:hharm:eth0:off console=ttyS0,115200
设置RAMDISK启动:
set bootargs initrd=0x30800000,0x440000 mem=64M root=/dev/ram init=/linuxrc console=ttyS0
内核启动参数
/////////////关于根文件系统的位置:
(1)initrd=0x30800000,0x440000 root=/dev/ram init=/linuxrc (ramdisk)
(2)console=ttyS0,115200 nfsroot=10.0.0.38:/root_arm ip=10.0.0.182:10.0.0.38:10.0.0.38:255.0.0.0:arm_emb:eth0:off (网络文件系统)
(3)noinitrd root=/dev/mtdblock/3 init=/linuxrc console=ttySAC0" (在jffs2 或 cramfs)
(4)console=ttySC1,115200 root=/dev/inftla" (在DOC)
要看你到底使用的什么文件系统,及文件系统的位置
1.调试时最便捷的搭配:(内核---server/tftpboot/zImage ; 文件系统----sever/root_arm)
#define CONFIG_BOOTCOMMAND"help;help;tftp 30008000 zImage;go 30008000"
console=ttySAC0,115200 nfsroot=10.0.0.38:/root_arm ip=10.0.0.182:10.0.0.38:10.0.0.38:255.0.0.0:arm_emb:eth0:off (网络文件系统)
2.典型应用:(内核---flash ; 文件系统----flash)
#define CONFIG_BOOTCOMMAND"help ;version ; cp 01040000 30008000 100000; cp 01140000 30800000 400000; go 30008000 "
initrd=0x30800000,0x440000 root=/dev/ram init=/linuxrc
3.最终产品:(内核---flash ; 文件系统----DOC)
#define CONFIG_BOOTCOMMAND"help ;version ; cp 01040000 30008000 200000; go 30008000 "
console=ttySC0,115200 root=/dev/inftla"
Uboot编译错误记录:
1、此时会出现一个错误:cc1: error: invalid option `abi=apcs-gnu'
修改/cpu/arm920t/下的config.mk:
将 PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
改成:PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,$(call cc-option,-mabi=apcs-gnu),)
2、编译的时候出现下面的错误:
/usr/local/arm/3.4.1/bin/arm-linux-ld: ERROR:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a(_divsi3.oS) uses hardware FP, whereas u-boot uses software FP
/usr/local/arm/3.4.1/bin/arm-linux-ld: failed to merge target specific data of file /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a(_divsi3.oS)
/usr/local/arm/3.4.1/bin/arm-linux-ld: ERROR:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a(_modsi3.oS) uses hardware FP, whereas u-boot uses software FP
/usr/local/arm/3.4.1/bin/arm-linux-ld: failed to merge target specific data of file
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a(_modsi3.oS)lib_arm/libarm.a(_udivsi3.o)(.text+0x8c):/u-boot/u-boot-1.1.4/lib_arm/_udivsi3.S:67:relocation truncated to fit: R_ARM_PLT32 __div0 lib_arm/libarm.a(_umodsi3.o)(.text+0xa:/u-boot/u-boot-1.1.4/lib_arm/_umodsi3.S:79:
relocation truncated to fit: R_ARM_PLT32 __div0
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a(_divsi3.oS)(.text+0x11c):/work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/gcc/config/arm/lib1funcs.asm:735:
relocation truncated to fit: R_ARM_PLT32 __div0
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a(_modsi3.oS)(.text+0xd:/work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/gcc/config/arm/lib1funcs.asm:795:
relocation truncated to fit: R_ARM_PLT32 __div0
make: *** [u-boot] Error 1
出现上面的错误有人说这样修改:
PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8
# -msoft-float
PLATFORM_CPPFLAGS += -march=armv4
# =========================================================================
#
# Supply options according to compiler version
#
# =========================================================================
#PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,)
PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
其实这样改是没有用的,问题是3.4.1用的是hardware FP,而u-boot uses software FP,用2.95或者3.3.2版本可解决这个问题
不过用2.95版本的时候还要修改一个链接
在Uboot里找一块使用相同Flash的板子
如:使用SST160 Flash
grep –R ‘SST160A’ ./
看到一大堆的板子,我们选用名字为dave中的flash.c,拷贝这个flash.c到smdk2410目录,
cp board/dave/common/flash.c board/smdk2410/
如:使用SST39VF160 Flash的板子
grep -nir sst39vf160 u-boot
然后把使用sst39vf160的flash拷贝
如:找44B0的板子
find . -exec grep -l 44B0 {} \;
问题:如果你在uboot保存环境变量时saveenv,出现Error: end address not on sector boundary
解决办法:/include/configs/at91rm9200dk.h(smdk2410.h)中 #define CFG_ENV_ADDR (PHYS_FLASH_1+0X20000) #define CFG_ENV_SIZE 0X20000(将环境变量放到了0x10040000,大家也可以根据具体情况改变你的地址,即修改CFG_ENV_ADDR)