注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

zhouhaigang.love的博客

喜欢冬日黄昏那冻住的山

 
 
 

日志

 
 

u-boot烧写  

2011-01-13 09:44:53|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
U-BOOT针对SMDK2410的移植。

工作开始了,先把U-boot解压缩到你喜欢的地方。然后打开Source Navigator,选择New Project。在接下来的窗口中,选择一个你喜欢的Project File的名字,然后在Add Directory里选择你把U-Boot1.1.2解压缩到的那个目录。再选择OK。然后等等,U-Boot这个变态的东西有143MB大……接下来出现了一个窗口。(5-23 SNAV启动)这个窗口里列出了U-Boot所有的源代码文件。上面的Pattern是为了便于你查找某个文件输入文件名的地方。

U-Boot是一种通用的Bootloader,它支持很多种不同的板子。我用的SBC2410X(友善之臂的)就是它支持的SMDK2410开发板的一种衍生。U-BOOT同时支持自定义配置的开发板,具体的配置方法参见U-Boot目录下的Readme文件。U-Boot关于各种板子的配置文件放在/board目录下,我们的SMDK2410也在那里具体的目录是/board/smdk2410,其下有主要几个文件:flash.c——关于NORFLASH操作的函数;config.mk——指定U-BOOT代码重新加载的基址;memsetup.s——汇编语言写的内存初始化程序,在start.s中调用,以后介绍;smdk2410.c——SMDK2410目标板初始化等函数。还有一个重要的文件是在U-Boot目录/include/configs下的smdk2410.h,包含了很多对目标板设置的宏。这几个文件中的配置与移植的目标板严格对应,如果你在SMDK2410的基础上重新设计了目标板硬件,那就必须修改这些文件中的相关内容。

其实有了Source-Navigator这些文件的位置就变得无关紧要了,你只要在Pattern中输入你要查找的文件的前缀,文件就会列出在下面的列表中。你就输入smdk2410,回车,出现了2个文件:smdk2410.c和smdk2410.h,刚开始移植不需要搞太复杂的东西,只修改smdk2410.h就可以了。smdk2410.h的内容和要修改的地方(红色)如下:

/*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
* Gary Jennejohn <gj@denx.de>
* David Mueller <d.mueller@elsoft.ch>
*
* Configuation settings for the SAMSUNG SMDK2410 board.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __CONFIG_H
#define __CONFIG_H
/*
* If we are developing, we might want to start armboot from ram
* so we MUST NOT initialize critical regs like mem-timing ...
*/
#define CONFIG_INIT_CRITICAL /* undef for developing */
/*
* High Level Configuration Options
* (easy to change)
*/
#define CONFIG_ARM920T 1 /* This is an ARM920T Core */
#define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC   */
#define CONFIG_SMDK2410 1 /* on a SAMSUNG SMDK2410 Board */
/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ 12000000/* the SMDK2410 has 12MHz input clock */

#define USE_920T_MMU 1
#undef CONFIG_USE_IRQ   /* we don't need IRQ/FIQ stuff */
/*
* Size of malloc() pool
*/
#define CFG_MALLOC_LEN (CFG_ENV_SIZE + 128*1024)
#define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */
/*
* Hardware drivers
*/
#define CONFIG_DRIVER_CS8900 1 /* we have a CS8900 on-board */
#define CS8900_BASE 0x19000300
#define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */
/*
* select serial console configuration
*/
#define CONFIG_SERIAL1       1 /* we use SERIAL 1 on SMDK2410 */
/************************************************************
* RTC
************************************************************/
#define CONFIG_RTC_S3C24X0 1
/* allow to overwrite serial and ethaddr */
#define CONFIG_ENV_OVERWRITE
#define CONFIG_BAUDRATE 115200
/***********************************************************
* Command definition
***********************************************************/
#define CONFIG_COMMANDS \
  (CONFIG_CMD_DFL | \
  CFG_CMD_CACHE | \
  /*CFG_CMD_NAND |*/ \
  /*CFG_CMD_EEPROM |*/ \
  /*CFG_CMD_I2C |*/ \
  /*CFG_CMD_USB |*/ \
  CFG_CMD_REGINFO | \
  CFG_CMD_DATE | \
  CFG_CMD_ELF)
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
#define CONFIG_BOOTDELAY 3
/*#define CONFIG_BOOTARGS   "root=ramfs devfs=mount console=ttySA0,9600" */
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b
#define CONFIG_NETMASK       255.255.255.0
#define CONFIG_IPADDR 202.202.202.218
//你的开发板的IP地址
#define CONFIG_SERVERIP 202.202.202.118
//你的运行Linux的电脑的IP地址
//这些设定解决的是网络下载程序的问题
/*#define CONFIG_BOOTFILE "elinos-lart" */
/*#define CONFIG_BOOTCOMMAND "tftp; bootm" */
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CONFIG_KGDB_BAUDRATE 115200 /* speed to run kgdb serial port */
/* what's this ? it's not used anywhere */
#define CONFIG_KGDB_SER_INDEX 1 /* which serial port to use */
#endif
/*
* Miscellaneous configurable options
*/
#define CFG_LONGHELP   /* undef to save memory */
#define CFG_PROMPT "LXZROB # " /* Monitor Command Prompt */
//开发板命令提示符,你可以改成你喜欢的任何字符串
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
#define CFG_MAXARGS 16 /* max number of command args */
#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
#define CFG_MEMTEST_START 0x30000000 /* memtest works on */
#define CFG_MEMTEST_END 0x33F00000 /* 63 MB in DRAM */
#undef CFG_CLKS_IN_HZ /* everything, incl board info, in Hz */
#define CFG_LOAD_ADDR 0x33000000 /* default load address */
/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
/* it to wrap 100 times (total 1562500) to get 1 sec. */
#define CFG_HZ   1562500
/* valid baudrates */
#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
/*-----------------------------------------------------------------------
* Stack sizes
*
* The stack sizes are set up in start.S using the settings below
*/
#define CONFIG_STACKSIZE (128*1024) /* regular stack */
#ifdef CONFIG_USE_IRQ
#define CONFIG_STACKSIZE_IRQ (4*1024) /* IRQ stack */
#define CONFIG_STACKSIZE_FIQ (4*1024) /* FIQ stack */
#endif
/*-----------------------------------------------------------------------
* Physical Memory Map
*/
#define CONFIG_NR_DRAM_BANKS 1   /* we have 1 bank of DRAM */
#define PHYS_SDRAM_1 0x30000000 /* SDRAM Bank #1 */
#define PHYS_SDRAM_1_SIZE 0x04000000 /* 64 MB */
#define PHYS_FLASH_1 0x00000000 /* Flash Bank #1 */
#define CFG_FLASH_BASE PHYS_FLASH_1
/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
#define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */
#if 0
#define CONFIG_AMD_LV400 1 /* uncomment this if you have a LV400 flash */
#endif
//NORFLASH定义,使用的是1MByte的还是512kByte的
#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
#ifdef CONFIG_AMD_LV800
#define PHYS_FLASH_SIZE 0x00100000 /* 1MB */
#define CFG_MAX_FLASH_SECT (19) /* max number of sectors on one chip */
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x0F0000) /* addr of environment */
#endif
#ifdef CONFIG_AMD_LV400
#define PHYS_FLASH_SIZE 0x00080000 /* 512KB */
#define CFG_MAX_FLASH_SECT (11) /* max number of sectors on one chip */
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x070000) /* addr of environment */
#endif
/* timeout values are in ticks */
#define CFG_FLASH_ERASE_TOUT (5*CFG_HZ) /* Timeout for Flash Erase */
#define CFG_FLASH_WRITE_TOUT (5*CFG_HZ) /* Timeout for Flash Write */
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
#endif /* __CONFIG_H */


代码中红色的地方是我修改过的,可以对比原始的文件,就可以看出不同。

修改完了以后别忘了保存,然后到终端下面,输入
make distclean
……一堆E文飘过……

make smdk2410_config
Configuring for smdk2410 board...

make
……一堆E文连绵不断的飘过,你可以喝喝水,嗑瓜子……

如果没有错误的话,就会在U-Boot目录下生成U-Boot.bin文件。如果有错误,恭喜你,你的麻烦事情来了。只要你按照我这篇文章和上篇文章的步骤来做,不会有错误的。值得注意的是,必须使用U-Boot1.1.2和arm-linux交叉编译器2.95.3 ,另外看看是不是之前路径没有设置,即
export PATH=/usr/local/arm/2.95.3/bin:$PATH没有输入,呵呵,还是没有研究明白SUSE的config怎么改。

生成的U-Boot.bin烧写到开发板的NORFLASH中,移植就完成了。烧写工具的下载地址是:http://www.samsung.com/Products/Semiconductor/SemiSecure/S02/MobileSoC/ApplicationProcessor/ARM9Series/S3C2410/SECJTAGFlashSJFNANDNORFlash_v4.zip
如果不能下载,到这个页面通过注册下载:
http://www.samsung.com/Products/Semiconductor/MobileSoC/ApplicationProcessor/ARM9Series/S3C2410/S3C2410.htm
下载时选择Utility中的SEC JTAG Flash(SJF) NAND,NOR(AMD,Strata) Flash。当然,如果你买了开发板,一般就会带有这个烧写程序了,不需费心下载,这里只是告诉你最本源的出处。

推荐在Windows的虚拟DOS环境中完成烧写,命令格式sjf2410 /f:u-boot.bin。烧写速度很慢,大约需要10分钟。烧写完成后,将启动选择跳线跳到NORFlash,重启开发板,串口就有输出了。串口调试工具推荐使用Windows自带的超级终端(程序〉附件〉通讯〉超级终端),下面是U-BOOT启动的提示信息:
U-Boot 1.1.2 (May 22 2006 - 02:30:03)
U-Boot code: 33F80000 -> 33F98380 BSS: -> 33F9C47C
RAM Configuration:
Bank #0: 30000000 64 MB
Flash: 1 MB
*** Warning - bad CRC, using default environment
In:   serial
Out:   serial
Err:   serial
LXZROB #
输入help可以看到U-Boot的操作指令列表:
?     - alias for 'help'                
autoscr - run script from memory                    
base   - print or set address offset                        
bdinfo - print Board Info structure                        
boot   - boot default, i.e., run 'bootcmd'                       bootd   - boot default, i.e., run 'bootcmd'      
bootelf - Boot from an ELF image in memory
bootm   - boot application image from memory
bootp   - boot image via network using BootP/TFTP protocol
bootvx - Boot vxWorks from an ELF image
cmp   - memory compare                
coninfo - print console devices and information    
cp     - memory copy              
crc32   - checksum calculation                    
date   - get/set/reset date & time                      
dcache - enable or disable data cache                         echo   - echo args to console                    
erase   - erase FLASH memory                  
flinfo - print FLASH memory information  
go     - start application at address 'addr'    
help   - print online help                  
icache - enable or disable instruction cache
iminfo - print header information for application image
imls   - list all images found in flash
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loop   - infinite loop on address range
md     - memory display
mm     - memory modify (auto-incrementing)
mtest   - simple RAM test
mw     - memory write (fill)
nfs   - boot image via network using NFS protocol
nm     - memory modify (constant address)
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run   - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv - set environment variables
sleep   - delay execution for some time
tftpboot- boot image via network using TFTP protocol
version - print monitor version


今天发现我的交叉编译器不好使了,呵呵,用snapshot恢复。
重新解压缩交叉编译器,发现有问题,原来是KDE带的图形界面解压缩器的问题,用指令来
tar jxvf cross-2.95.3.tat.bz2 -C /usr/local/arm
这是一个。

另外,今天研究出了让路径设置永久起作用的方法,打开/etc/profile,做如下修改(本修改仅仅针对SUSE)
#
# Make path more comfortable
#

# 先找到这个注释
if test -z "$PROFILEREAD" ; then
  PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin
  if test "$HOME" != "/" ; then
for dir in $HOME/bin/$CPU $HOME/bin ; do
  test -d $dir && PATH=$dir:$PATH
done
  fi
  test "$UID" = 0 && PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
  for dir in /var/lib/dosemu \
/usr/games \
/opt/bin \
/opt/gnome/bin \
/opt/kde3/bin \
/opt/kde2/bin \
/opt/kde/bin \
/usr/openwin/bin \
/opt/cross/bin \
/usr/local/arm/2.95.3/bin

# 加上你的交叉编译器所在的路径
  do
test -d $dir && PATH=$PATH:$dir
  done
  unset dir
  export PATH
fi

u-boot烧写 - zhouhaigang.love - zhouhaigang.love的博客
李建俊 ____在郑州如有需要嵌入式linux技术支持的请和我联系,我电子信箱:lijianjun1533@163.com
  评论这张
 
阅读(106)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018