XSBase255B -- u-boot移植

本文详细介绍基于U-Boot 1.1.4版本在XSBase开发板上进行配置及移植的过程,包括编译环境搭建、板级支持包配置、内核加载方式设定等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我爱南开站 -- 同主题阅读 [讨论区: LinuxDev]
[查看全文] [回复本文] [回复作者] [作者: catchupwith ] [讨论区:LinuxDev]
发信人: catchupwith (catchupwith), 信区: LinuxDev
标  题: 基于u-boot-1.1.4的xsbase的bootloader的配置(原创?发信站: 我爱南开站 (2006年05月02日17:03:09 星期二)

最近看了看u-boot的源代码,发现u-boot虽然能够支持好些cpu和板子,但是代码不是很
方便阅读,而且编译生成的u-boot.bin文件120k左右,比较大,但是研究它对于熟悉
bootloader还是很有帮助的。下面的文章是这几天的总结,如有不足之处希望bbsers们
能够指出来,共同交流。

u-boot-1.1.4中的/cpu/pxa/config.mk在编译的时候不支持-march=armv5  -
mtune=xscale   -mabi=apcs-gnu
是交叉变异环境的版本不够新,使用arm-linux-gcc3.3.2可以解决这个问题,但是-
mabi=apcs-gnu仍然不支持,kill it!
1.cpu 中包含pxa
Config.mk的配置如下:

PLATFORM_RELFLAGS  +=   - fno - strict - aliasing   - fno - common  - ffixed - r8   - msoft -
float
   PLATFORM_CPPFLAGS 
+=   - march = armv5  - mtune = xscale
PLATFORM_CPPFLAGS 
+= $(call cc - option, - mapcs - 32 )
PLATFORM_RELFLAGS 
+= $(call cc - option, - mshort - load - bytes,$(call
cc
- option, - malignment - traps,))

  其它文件不作任何改动。
2.board中新建xsbase目录
由于xsbase板子与lubbock板相似,拷贝lubbock目录中的文件过来
  Config.mk文件:TEXT_BASE = 0xa3f80000
  Lowlevel_init.s最后加上:

   /*Loading kernel image*/
        ldr r4, 
= KERNEL_SRAM_BASE
        ldr r5, 
= KERNEL_DRAM_BASE
        ldr r6, 
= KERNEL_MAX_SIZE
        add r6, r6, r4
repeat1:
        ldmia   r4
! {r0-r3, r7-r10}
        stmia   r5
! {r0-r3, r7-r10}
        cmp             r4, r6
        blt             repeat1

表示把内核从flash拷贝入sdram中。
Makefile:
OBJS := xsbase.o flash.o
Lubbock.c改名为xsbase.c,其中/* gd->bd->bi_arch_number = MACH_TYPE_LUBBOCK;*/
        gd->bd->bi_arch_number = 200;//因为在内核文件Kernel/2.4.18-rmk7-pxa1-
XSBase255B/arch/arm/tools/mach-types中
xhyper255          ARCH_XHYPER255          XHYPER255           200
3.common/cmd_boot.c文件更改为(参照了emdoor板子的bootloader)

#include  < common.h >
#include 
< command.h >
#include 
< net.h >
void  do_go (cmd_tbl_t  * cmdtp,  int  flag,  int  argc,  char   * argv[])
{
 
ulong addr;
        
long    opt[2];
        
void (*theKernel)(int zero,int arch);
        opt[
0= 0;
 opt[
1= 200//mach-types 中对应的号码


 
if (argc < 2{
  printf (
"Usage: %s ", cmdtp->usage);
  
return 1;
 }


 addr 
= simple_strtoul(argv[1], NULL, 16);  //小写转为大写
theKernel = (void (*)(intint))addr;  //addr为内核在内存中的起始地址 go 
a0008000
 printf (
"## Starting application at 0x%08lX ... ", addr);
        theKernel(opt[
0], opt[1]);//启动内核
 
}

U_BOOT_CMD(
 go, CFG_MAXARGS, 
1 , do_go,
 
" go      - start application at address 'addr' " ,
 
" addr [arg ...]     - start application at address 'addr' "
 
"       passing 'arg' as arguments "
);

extern   int  do_reset (cmd_tbl_t  * cmdtp,  int  flag,  int  argc,  char   * argv[]);

U_BOOT_CMD(
 reset, 
1 0 , do_reset,
 
" reset   - Perform RESET of the CPU " ,
 NULL
);

4.drivers/cs8900.c更改
a.加入函数说明

void  MemSet( void   * dest,  char  c,  int  len) {
 
char *s=dest;
 
char *limit = (char *)dest+len;

 
while (s < limit) *s++ = c;
              }
  //  MemSet.

 b.只要有往寄存器CS8900_PPTR写入地址片内偏移地址,并读取寄存器
CS8900_PDATA的值时,如下

CS8900_PPTR  =  regno;
CS8900_PDATA 
=  val;

 需要在前面加上代码改为:

MemSet(( char   * ) 0x04000000 0x0 2 );   //  Test Code
CS8900_PPTR  =  regno;
CS8900_PDATA 
=  val;

   为什么?因为0x04000000只是CS8900的片选地址,要想片选有效,必须向这个地址
输入0,使片选信号cs=0,选通cs8900
    当出现cs8900 can not be found!说明cs8900的驱动有问题,本板子就是一个很好
的例子,这时需要参照自己的bootloader。
5. include/configs 目录下添加xsbase.h
板子配置文件(参照了lubbock.h),参数的具体意思可以看u-boot中的README文档

#ifndef __CONFIG_H
#define  __CONFIG_H
#define  BOARD_LATE_INIT  1

#undef  CONFIG_USE_IRQ   /* we don't need IRQ/FIQ stuff */

#define  CONFIG_PXA250           1    // cpu类型
#define  CONFIG_XSBASE           1    // 板子类型
#define  KERNEL_SRAM_BASE  0x000C0000   // lowlevel_init.s中拷贝
内核时用到
#define  KERNEL_DRAM_BASE  0xA0008000
#define  KERNEL_MAX_SIZE  0x00200000
/*
 * 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   // 支持cs8900网卡
#define  CS8900_BUS16  1
#define  CS8900_BASE  0x04000300  
#define   RTC                    1
#define   CCCR_VALUE             0x00000161

/*
 * select serial console configuration
 
*/

#define  CONFIG_FFUART        1       /* we use FFUART on LUBBOCK */

/* allow to overwrite serial and ethaddr */
#define  CONFIG_ENV_OVERWRITE

#define  CONFIG_BAUDRATE  115200

#define  CONFIG_COMMANDS  (CONFIG_CMD_DFL | CFG_CMD_JFFS2)

/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include 
< cmd_confdefs.h >

#define  CONFIG_BOOTDELAY 3
/*#define CONFIG_ETHADDR          08:00:3e:21:c7:f7*/
#define  CONFIG_ETHADDR  15:14:36:18:8A:11   // 网卡的配置
#define  CONFIG_NETMASK  255.255.255.0
#define  CONFIG_IPADDR  192.168.0.10
#define  CONFIG_SERVERIP  192.168.0.1
#define  CONFIG_BOOTCOMMAND "go 0xa0008000"  // 当bootloader处于自动模式时
默认运行的命令
                              表示从内存中a0008000的地方运行内核。
#define  CONFIG_BOOTARGS  "root=/dev/mtdblock2 
rootfstype
= jffs2 console = ttyS0, 115200 "
#define  CONFIG_CMDLINE_TAG
#define  CONFIG_TIMESTAMP
/*
 * Miscellaneous configurable options
 
*/

#define  CFG_HUSH_PARSER  1
#define  CFG_PROMPT_HUSH_PS2 "> "

#define  CFG_LONGHELP    /* undef to save memory
  
*/
#ifdef CFG_HUSH_PARSER
#define  CFG_PROMPT  "leibo$ "  /* Monitor Command 
Prompt 
*/
#else
#define  CFG_PROMPT  "=> "  /* Monitor Command 
Prompt 
*/
#endif
#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_DEVICE_NULLDEV 1

#define  CFG_MEMTEST_START  0xa0400000 /* memtest works on */
#define  CFG_MEMTEST_END  0xa0800000 /* 4 ... 8 MB in DRAM */

#undef  CFG_CLKS_IN_HZ  /* everything, incl board info, in 
Hz 
*/

#define  CFG_LOAD_ADDR (CFG_DRAM_BASE + 0x8000) /* default load address */

#define  CFG_HZ   3686400  /* 
incrementer freq: 
3.6864  MHz  */
#define  CFG_CPUSPEED  0x00000161  /* set core clock to 
400 / 200 / 100  MHz  */
// cpu的频率,内存频率的设置值

      
/* valid 
baudrates 
*/

#define  CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }

#define  CFG_MMC_BASE  0xF0000000

/*
 * 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 4    /* we have 2 banks of DRAM */
#define  PHYS_SDRAM_1  0xa0000000 /* SDRAM Bank #1 */
#define  PHYS_SDRAM_1_SIZE 0x04000000 /* 64 MB */
#define  PHYS_SDRAM_2  0xa4000000 /* SDRAM Bank #2 */
#define  PHYS_SDRAM_2_SIZE 0x00000000 /* 0 MB */
#define  PHYS_SDRAM_3  0xa8000000 /* SDRAM Bank #3 */
#define  PHYS_SDRAM_3_SIZE 0x00000000 /* 0 MB */
#define  PHYS_SDRAM_4  0xac000000 /* SDRAM Bank #4 */
#define  PHYS_SDRAM_4_SIZE 0x00000000 /* 0 MB */

#define  PHYS_FLASH_1  0x00000000 /* Flash Bank #1 */
#define  PHYS_FLASH_2  0x04000000 /* Flash Bank #2 */
#define  PHYS_FLASH_SIZE  0x02000000 /* 32 MB */
#define  PHYS_FLASH_BANK_SIZE 0x02000000 /* 32 MB Banks */
#define  PHYS_FLASH_SECT_SIZE 0x00040000 /* 256 KB sectors (x2) */

#define  CFG_DRAM_BASE  0xa0000000
#define  CFG_DRAM_SIZE  0x04000000

#define  CFG_FLASH_BASE  PHYS_FLASH_1

#define  FPGA_REGS_BASE_PHYSICAL 0x08000000

/*
 * GPIO settings  //参考emdoor板子的设置数值
 
*/

#define  CFG_GPSR0_VAL  0x00408030
#define  CFG_GPSR1_VAL  0x00BFA882
#define  CFG_GPSR2_VAL  0x0001C000
#define  CFG_GPCR0_VAL  0xC0031100
#define  CFG_GPCR1_VAL  0xFC400300
#define  CFG_GPCR2_VAL  0x00003FFF
#define  CFG_GPDR0_VAL  0xC0439330
#define  CFG_GPDR1_VAL  0xFCFFAB82
#define  CFG_GPDR2_VAL  0x0001FFFF
#define  CFG_GAFR0_L_VAL  0x80000000
#define  CFG_GAFR0_U_VAL  0xA5000010
#define  CFG_GAFR1_L_VAL  0x60008018
#define  CFG_GAFR1_U_VAL  0xAAA5AAAA
#define  CFG_GAFR2_L_VAL  0xAAA0000A
#define  CFG_GAFR2_U_VAL  0x00000002



#define  CFG_PSSR_VAL  0x00000030

/*
 * Memory settings
 
*/

#define  CFG_MSC0_VAL  0x7ff87ff0
#define  CFG_MSC1_VAL  0x12BC5554
#define  CFG_MSC2_VAL  0x7FF87FF1
#define  CFG_MDCNFG_VAL  0x00001AC9
#define  CFG_MDREFR_VAL  0x000BC018
#define  CFG_MDMRS_VAL  0x00000000

/*
 * PCMCIA and CF Interfaces
 
*/

#define  CFG_MECR_VAL  0x00000000
#define  CFG_MCMEM0_VAL  0x00010504
#define  CFG_MCMEM1_VAL  0x00010504
#define  CFG_MCATT0_VAL  0x00010504
#define  CFG_MCATT1_VAL  0x00010504
#define  CFG_MCIO0_VAL  0x00004715
#define  CFG_MCIO1_VAL  0x00004715

#define  _LED   0x08000010
#define  LED_BLANK  0x08000040

/*
 * FLASH and environment organization
 
*/

#define  CFG_MAX_FLASH_BANKS 1 /* max number of memory banks 
 
*/
// 板子上的flash只有32M所以选择1就可以了
#define  CFG_MAX_FLASH_SECT 128  /* max number of sectors on one chip    
*/

/* timeout values are in ticks */
#define  CFG_FLASH_ERASE_TOUT (25*CFG_HZ) /* Timeout for Flash Erase */
#define  CFG_FLASH_WRITE_TOUT (25*CFG_HZ) /* Timeout for Flash Write */

/* NOTE: many default partitioning schemes assume the kernel starts at the
 * second sector, not an environment.  You have been warned!
 
*/

#define  CFG_MONITOR_LEN  PHYS_FLASH_SECT_SIZE
#define  CFG_ENV_IS_IN_FLASH 1
#define  CFG_ENV_ADDR  (PHYS_FLASH_1 + PHYS_FLASH_SECT_SIZE)
#define  CFG_ENV_SECT_SIZE PHYS_FLASH_SECT_SIZE
#define  CFG_ENV_SIZE  (PHYS_FLASH_SECT_SIZE / 16)


/*
 * FPGA Offsets
 
*/

#define  WHOAMI_OFFSET  0x00
#define  HEXLED_OFFSET  0x10
#define  BLANKLED_OFFSET  0x40
#define  DISCRETELED_OFFSET 0x40
#define  CNFG_SWITCHES_OFFSET 0x50
#define  USER_SWITCHES_OFFSET 0x60
#define  MISC_WR_OFFSET  0x80
#define  MISC_RD_OFFSET  0x90
#define  INT_MASK_OFFSET  0xC0
#define  INT_CLEAR_OFFSET 0xD0
#define  GP_OFFSET  0x100

#endif  /* __CONFIG_H */

6.MAKEALL文件更改

LIST_pxa = "  
 adsvix  cerf250  cradle 
 csb226  
 innokom  lubbock  pxa255_idp wepep250 
 xaeniax  xm250  xsengine   xsbase 
 
"

7.Makefile文件更该
xsbase_config : unconfig
 @./mkconfig $(@:_config=) arm pxa xsbase
arm为cpu种类,pxa为arm中对应的目标代码,xsbase是自己的开发板对应的目录
mkconfig是一段shell程序,同时自动生成include/config.h文件,根据
include/configs/xsbase.h生成
8.最后编译,生成u-boot.bin文件的命令:
make clean
make xsbase_config
make all
9.检测网卡:
leibo$ tftp 0xa0008000 my_kernel
TFTP from server 192.168.0.1; our IP address is 192.168.0.10
Filename 'my_kernel'.
Load address: 0xa0008000
Loading: #################################################################
         #################################################################
         ###############################################################
done
Bytes transferred = 986520 (f0d98 hex)

10.最后的结果:
U-Boot 1.1.4 (May  2 2006 - 09:49:09)
                                                                            
  
U-Boot code: A3F80000 -> A3F9C884  BSS: -> A3FA0F9C
//由ld文件决定
RAM Configuration:
Bank #0: a0000000 64 MB
Bank #1: a4000000  0 kB
Bank #2: a8000000  0 kB
Bank #3: ac000000  0 kB
Flash: 32 MB
In:    serial
Out:   serial
Err:   serial

ethaddris 15  //为了调试网卡cs8900的方便,自己加上去的
ethaddris 14
ethaddris 36
ethaddris 18
ethaddris 8A
ethaddris 11
ID is:630E

cs8900 is ok!
Hit any key to stop autoboot:  0
## Starting application at 0xA0008000 ...
Uncompressing
Linux.............................................................Linux
version 2.4.18-rmk7-pxa1-xhyper255 (root@localhost) (gcc version 2.95.3
25CPU:
Intel XScale-PXA255 revision 6
Machine: HYBUS X-Hyper255
Warning: bad configuration page, trying to continue
MCS0 = 0x7ff87ff0
MCS1 = 0x5aa85aa8
MCS2 = 0x24482448
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=1f03 rw console=ttyS0,115200 init=/linuxrc
Console: colour dummy device 80x30
Calibrating delay loop... 397.31 BogoMIPS
Memory: 64MB = 64MB total
Memory: 61728KB available (2028K code, 334K data, 372K init)
Dentry-cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode-cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount-cache hash table entries: 1024 (order: 1, 8192 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Today is : 2165. 85. 85.  45:85:80
PXA USB Controller Core Initialized
get_random_bytes called before random driver initialization
USB Function Ethernet Driver Interface
Starting kswapd
JFFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communications
AB.
Console: switching to colour frame buffer device 80x30
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with no serial options enabled
ttyS00 at 0x0000 (irq = 14) is a PXA UART
ttyS01 at 0x0000 (irq = 13) is a PXA UART
ttyS02 at 0x0000 (irq = 12) is a PXA UART
ads7843 touch screen driver initialized
init FPGA Board 0 , Made by Ray.xian
init FPGA Board 1, Made by Ray.xian
init FPGA Board 2, Made by Ray.xian
init FPGA Board 3, Made by Ray.xian
init FPGA Board 4, Made by Ray.xian
init FPGA Board 5, Made by Ray.xian
block: 128 slots per queue, batch=32
Cirrus Logic CS8900A driver for Linux (V0.01)
eth0: CS8900A rev E at 0xf0000300 irq=0, no eeprom , addr: 00:12:34:56:78:9A
Linux video capture interface: v1.00
SCSI subsystem driver Revision: 1.00
request_module[scsi_hostadapter]: Root fs not mounted
request_module[scsi_hostadapter]: Root fs not mounted
ac97_codec: AC97 Audio codec, id: 0x4352:0x5914 (Cirrus Logic CS4297A rev B)
Probing X-Hyper250 Flash at physical address 0x00000000
Using buffer write method
No RedBoot partition table detected in X-Hyper255 Flash
Using static partition definition
Creating 4 MTD partitions on "X-Hyper255 Flash":
0x00000000-0x00040000 : "Bootloader"
0x00040000-0x000c0000 : "Partition Tables"
0x000c0000-0x002c0000 : "Kernel"
0x002c0000-0x02000000 : "Filesystem"
Linux Kernel Card Services 3.1.22
  options:  none
Intel PXA250/210 PCMCIA (CS release 3.1.22)
X-Hyper250 PCMCIA INIT
usb.c: *****registered new driver usbdevfs
usb.c: registered new driver usbdevfs
usb.c: *****registered new driver hub
usb.c: registered new driver hub
usb.c: *****registered new driver usb_mouse
usb.c: registered new driver usb_mouse
usbmouse.c: v1.6:USB HID Boot Protocol mouse driver
usb.c: *****registered new driver keyboard
usb.c: registered new driver keyboard
usbkbd.c: :USB HID Boot Protocol keyboard driver
usb.c: *****registered new driver quickcam
usb.c: registered new driver quickcam
usb.c: *****registered new driver ov511
usb.c: registered new driver ov511
ov511.c: v1.50 for Linux 2.4 : OV511 USB Camera Driver
usb.c: new USB bus registered, assigned bus number 1
hub.c: USB hub found
hub.c: 1 port detected
Initializing USB Mass Storage driver...
usb.c: *****registered new driver usb-storage
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
MMC subsystem, $Revision: 0.3.1.14 $
MMC block device driver, $Revision: 0.3.1.16 $
PXA250 MMC controller driver, $Revision: 0.3.1.12 $
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.95 (c) 1998-1999 Rebel.com
IrCOMM protocol (Dag Brattli)
FAT: bogus logical sector size 381
UMSDOS: msdos_read_super failed, mount aborted.
FAT: bogus logical sector size 381
FAT: bogus logical sector size 381
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 372K
Setting up RAMFS, please wait ...
done and exiting
INIT: version 2.78 booting
INIT: Entering runlevel: 3
Starting syslog Starting system logger:
                                                                             
Starting pcmcia Starting PCMCIA
Starting etwork Starting network
Starting X...
                                                                             
XSBASE login:

--
           LEIBO      HAOHUA          
            ___       ___         
          {~._.~}   {~._.~}       
           ( Y )     ( Y )        
          ()~*~()   ()~*~()       
          (_)-(_)   (_)-(_)

※ 来源:·我爱南开站 nkbbs.org ·Web[FROM: 202.113.229.144]

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值