No such application config

今天在进行项目开发,同事启动项目就没问题。 我这里启动就有问题。No such application config! Please add <dubbo:application name="..." /> to your spring config.提示没有 dubbo 配置,但是项目文件里是由dubbo 配置的。dubbo 启动的时候没有扫描到,但是不知道为什么?

 

# DUBBO 配置
dubbo:
  check: false
  application:
    name: @project.artifactId@
    qos:
      enable: false
  scan:
    basePackages: com.redescooter.ses
  provider:
    validation: true
  #    timeout: 20000
  consumer:
    timeout: 20000
    filter: dubboContextFilter
  protocol:
    port: -1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
实验三 移植U-Boot-1.3.1 实验 【实验目的】 了解 U-Boot-1.3.1 的代码结构,掌握其移植方法。 【实验环境】 1、Ubuntu 7.0.4发行版 2、u-boot-1.3.1 3、FS2410平台 4、交叉编译器 arm-softfloat-linux-gnu-gcc-3.4.5 【实验步骤】 一、建立自己的平台类型 (1)解压文件 #tar jxvf u-boot-1.3.1.tar.bz2 (2)进入 U-Boot源码目录 #cd u-boot-1.3.1 (3)创建自己的开发板: #cd board #cp smdk2410 fs2410 –a #cd fs2410 #mv smdk2410.c fs2410.c #vi Makefile (将 smdk2410修改为 fs2410) #cd ../../include/configs #cp smdk2410.h fs2410.h 退回 U-Boot根目录:#cd ../../ (4)建立编译选项 #vi Makefile smdk2410_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0 fs2410_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t fs2410 NULL s3c24x0 arm: CPU的架构(ARCH) arm920t: CPU的类型(CPU),其对应于 cpu/arm920t子目录。 fs2410: 开发板的型号(BOARD),对应于 board/fs2410目录。 NULL: 开发者/或经销商(vender),本例为空 s3c24x0: 片上系统(SOC) (5)编译 #make fs2410_config; #make 本步骤将编译 u-boot.bin文件,但此时还无法运行在FS2410开发板上。 二、修改 cpu/arm920t/start.S文件,完成 U-Boot的重定向 (1)修改中断禁止部分 # if defined(CONFIG_S3C2410) ldr r1, =0x7ff /*根据 2410 芯片手册,INTSUBMSK 有 11位可用 */ ldr r0, =INTSUBMSK Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) str r1, [r0] # endif (2)修改时钟设置(这个文件要根据具体的平台进行修改) (3)将从Nor Flash启动改成从 NAND Flash启动 在文件中找到 195-201 代码,并在 201行后面添加如下代码: 195 copy_loop: 196 ldmia r0!, {r3-r10} /* copy from source address [r0] */ 197 stmiar1!, {r3-r10} /* copy to target address [r1] */ 198 cmp r0, r2 /* until source end addreee [r2] */ 199 ble copy_loop 200 #endif /* CONFIG_SKIP_RELOCATE_UBOOT */ 201 #endif #ifdef CONFIG_S3C2410_NAND_BOOT @ reset NAND mov r1, #NAND_CTL_BASE ldr r2, =0xf830 @ initial value str r2, [r1, #oNFCONF] ldr r2, [r1, #oNFCONF] bic r2, r2, #0x800 @ enable chip str r2, [r1, #oNFCONF] mov r2, #0xff @ RESET command strb r2, [r1, #oNFCMD] mov r3, #0 @ wait nand1: add r3, r3, #0x1 cmp r3, #0xa blt nand1 nand2: ldr r2, [r1, #oNFSTAT] @ wait ready tst r2, #0x1 beq nand2 ldr r2, [r1, #oNFCONF] orr r2, r2, #0x800 @ disable chip str r2, [r1, #oNFCONF] @ get read to call C functions (for nand_read()) ldr sp, DW_STACK_START @ setup stack pointer mov fp, #0 @ no previous frame, so fp=0 @ copy U-Boot to RAM ldr r0, =TEXT_BASE mov r1, #0x0 mov r2, #0x30000 bl nand_read_ll tst r0, #0x0 beq ok_nand_read Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)bad_nand_read: loop2: b loop2 @ infinite loop ok_nand_read: @ verify mov r0, #0 ldr r1, =TEXT_BASE mov r2, #0x400 @ 4 bytes * 1024 = 4K-bytes go_next: ldr r3, [r0], #4 ldr r4, [r1], #4 teq r3, r4 bne notmatch subs r2, r2, #4 beq stack_setup bne go_next notmatch: loop3: b loop3 @ infinite loop #endif @ CONFIG_S3C2410_NAND_BOOT (4)在 “ _start_armboot: .word start_armboot ”后加入: .align 2 DW_STACK_START: .word STACK_BASE+STACK_SIZE-4 三、创建 board/fs2410/nand_read.c 文件,加入读 NAND Flash 的操作。 #include #define __REGb(x) (*(volatile unsigned char *)(x)) #define __REGi(x) (*(volatile unsigned int *)(x)) #define NF_BASE 0x4e000000 # if defined(CONFIG_S3C2410) #define NFCONF __REGi(NF_BASE + 0x0) #define NFCMD __REGb(NF_BASE + 0x4) #define NFADDR __REGb(NF_BASE + 0x8) #define NFDATA __REGb(NF_BASE + 0xc) #define NFSTAT __REGb(NF_BASE + 0x10) #define BUSY 1 inline void wait_idle(void) { int i; while(!(NFSTAT & BUSY)) for(i=0; i<10; i++); } /* low level nand read function */ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size) { int i, j; Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) { return -1; /* invalid alignment */ } /* chip Enable */ NFCONF &= ~0x800; for(i=0; i<10; i++); for(i=start_addr; i > 9) & 0xff; NFADDR = (i >> 17) & 0xff; NFADDR = (i >> 25) & 0xff; wait_idle(); for(j=0; j NFCONF = conf; } Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)static inline void NF_Cmd(u8 cmd) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFCMD = cmd; } static inline void NF_CmdW(u8 cmd) { NF_Cmd(cmd); udelay(1); } static inline void NF_Addr(u8 addr) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); nand->NFADDR = addr; } static inline void NF_WaitRB(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); while (!(nand->NFSTAT & (1<NFDATA = data; } static inline u8 NF_Read(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); return(nand->NFDATA); } static inline u32 NF_Read_ECC(void) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); return(nand->NFECC); } static inline void NF_SetCE(NFCE_STATE s) { S3C2410_NAND * const nand = S3C2410_GetBase_NAND(); switch (s) { case NFCE_LOW: nand->NFCONF &= ~(1<NFCONF |= (1<NFCONF |= (1<<12); } extern ulong nand_probe(ulong physadr); static inline void NF_Reset(void) { int i; NF_SetCE(NFCE_LOW); NF_Cmd(0xFF); /* reset command */ for(i = 0; i < 10; i++); /* tWB = 100ns. */ NF_WaitRB(); /* wait 200~500us; */ NF_SetCE(NFCE_HIGH); } static inline void NF_Init(void) { #if 0 #define TACLS 0 #define TWRPH0 3 #define TWRPH1 0 #else #define TACLS 0 #define TWRPH0 4 #define TWRPH1 2 #endif #if defined(CONFIG_S3C2440) NF_Conf((TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4)); NF_Cont((1<<6)|(1<<4)|(1<<1)|(1<<0)); #else NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<> 20); } #endif (2)配置GPIO 和 PLL 根据开发板的硬件说明和芯片手册,修改GPIO 和 PLL的配置。 六、修改 include/configs/fs2410.h 头文件 (1)加入命令定义 /* Command line configuration. */ #include #define CONFIG_CMD_ASKENV #define CONFIG_CMD_CACHE #define CONFIG_CMD_DATE #define CONFIG_CMD_DHCP #define CONFIG_CMD_ELF #define CONFIG_CMD_PING #define CONFIG_CMD_NAND #define CONFIG_CMD_REGINFO #define CONFIG_CMD_USB #define CONFIG_CMD_FAT (2)修改命令提示符 #define CFG_PROMPT "SMDK2410 # " -> #define CFG_PROMPT "FS2410# " (3)修改默认载入地址 #define CFG_LOAD_ADDR 0x33000000 -> #define CFG_LOAD_ADDR 0x30008000 (4)加入 Flash环境信息 #define CFG_ENV_IS_IN_NAND 1 #define CFG_ENV_OFFSET 0X30000 #define CFG_NAND_LEGACY //#define CFG_ENV_IS_IN_FLASH 1 #define CFG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */ (5)加入Nand Flash设置(在文件结尾处) /* NAND flash settings */ #if defined(CONFIG_CMD_NAND) #define CFG_NAND_BASE 0x4E000000 /* NandFlash控制器在SFR区起始寄存器地址 */ #define CFG_MAX_NAND_DEVICE 1 /* 支持的最在Nand Flash数据 */ #define SECTORSIZE 512 /* 1页的大小 */ #define NAND_SECTOR_SIZE SECTORSIZE Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)#define NAND_BLOCK_MASK 511 /* 页掩码 */ #define ADDR_COLUMN 1 /* 一个字节的Column地址 */ #define ADDR_PAGE 3 /* 3字节的页块地址!!!!!*/ #define ADDR_COLUMN_PAGE 4 /* 总共4字节的页块地址!!!!! */ #define NAND_ChipID_UNKNOWN 0x00 /* 未知芯片的ID号 */ #define NAND_MAX_FLOORS 1 #define NAND_MAX_CHIPS 1 /* Nand Flash命令层底层接口函数 */ #define WRITE_NAND_ADDRESS(d, adr) {rNFADDR = d;} #define WRITE_NAND(d, adr) {rNFDATA = d;} #define READ_NAND(adr) (rNFDATA) #define NAND_WAIT_READY(nand) {while(!(rNFSTAT&(1<<0)));} #define WRITE_NAND_COMMAND(d, adr) {rNFCMD = d;} #define WRITE_NAND_COMMANDW(d, adr) NF_CmdW(d) #define NAND_DISABLE_CE(nand) {rNFCONF |= (1<<11);} #define NAND_ENABLE_CE(nand) {rNFCONF &= ~(1<<11);} /* the following functions are NOP's because S3C24X0 handles this in hardware */ #define NAND_CTL_CLRALE(nandptr) #define NAND_CTL_SETALE(nandptr) #define NAND_CTL_CLRCLE(nandptr) #define NAND_CTL_SETCLE(nandptr) /* 允许 Nand Flash写校验 */ #define CONFIG_MTD_NAND_VERIFY_WRITE 1 (6)加入Nand Flash启动支持(在文件结尾处) /* Nandflash Boot*/ #define STACK_BASE 0x33f00000 #define STACK_SIZE 0x8000 /* NAND Flash Controller */ #define NAND_CTL_BASE 0x4E000000 #define bINT_CTL(Nb) __REG(INT_CTL_BASE + (Nb)) /* Offset */ #define oNFCONF 0x00 #define CONFIG_S3C2410_NAND_BOOT 1 /* Offset */ #define oNFCONF 0x00 #define oNFCMD 0x04 #define oNFADDR 0x08 #define oNFDATA 0x0c #define oNFSTAT 0x10 #define oNFECC 0x14 #define rNFCONF (*(volatile unsigned int *)0x4e000000) #define rNFCMD (*(volatile unsigned char *)0x4e000004) Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)#define rNFADDR (*(volatile unsigned char *)0x4e000008) #define rNFDATA (*(volatile unsigned char *)0x4e00000c) #define rNFSTAT (*(volatile unsigned int *)0x4e000010) #define rNFECC (*(volatile unsigned int *)0x4e000014) #define rNFECC0 (*(volatile unsigned char *)0x4e000014) #define rNFECC1 (*(volatile unsigned char *)0x4e000015) #define rNFECC2 (*(volatile unsigned char *)0x4e000016) #endif (7)加入 jffs2的支持 /*JFFS2 Support */ #undef CONFIG_JFFS2_CMDLINE #define CONFIG_JFFS2_NAND 1 #define CONFIG_JFFS2_DEV "nand0" #define CONFIG_JFFS2_PART_SIZE 0x4c0000 #define CONFIG_JFFS2_PART_OFFSET 0x40000 /*JFFS2 Support */ (8)加入 usb的支持 /* USB Support*/ #define CONFIG_USB_OHCI #define CONFIG_USB_STORAGE #define CONFIG_USB_KEYBOARD #define CONFIG_DOS_PARTITION #define CFG_DEVICE_DEREGISTER #define CONFIG_SUPPORT_VFAT #define LITTLEENDIAN /* USB Support*/ 七、修改 include/linux/mtd/nand.h头文件 屏蔽如下定义: #if 0 /* Select the chip by setting nCE to low */ #define NAND_CTL_SETNCE 1 /* Deselect the chip by setting nCE to high */ #define NAND_CTL_CLRNCE 2 /* Select the command latch by setting CLE to high */ #define NAND_CTL_SETCLE 3 /* Deselect the command latch by setting CLE to low */ #define NAND_CTL_CLRCLE 4 /* Select the address latch by setting ALE to high */ #define NAND_CTL_SETALE 5 /* Deselect the address latch by setting ALE to low */ #define NAND_CTL_CLRALE 6 /* Set write protection by setting WP to high. Not used! */ #define NAND_CTL_SETWP 7 /* Clear write protection by setting WP to low. Not used! */ Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)#define NAND_CTL_CLRWP 8 #endif 八、修改 include/linux/mtd/nand_ids.h 头文件 在该文件中加入开发板的 NAND Flash型号 {"Samsung K9F1208U0B", NAND_MFR_SAMSUNG, 0x76, 26, 0, 4, 0x4000, 0}, 九、修改 common/env_nand.c文件 我们使用了早期的Nand读写方式,因此做出下列移植: (1) 加入函数原型定义 extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE]; extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs, size_t len, int clean); /* info for NAND chips, defined in drivers/nand/nand.c */ extern nand_info_t nand_info[CFG_MAX_NAND_DEVICE]; (2) 修改saveenv函数 注释//if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE)) 加入:if (nand_legacy_erase(nand_dev_desc + 0, CFG_ENV_OFFSET, CFG_ENV_SIZE, 0)) 注释//ret = nand_write(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); 加入:ret = nand_legacy_rw(nand_dev_desc + 0,0x00 | 0x02, CFG_ENV_OFFSET, CFG_ENV_SIZE, &total, (u_char*)env_ptr); (3) 修改env_relocate_spec函数 注释//ret = nand_read(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); 加入:ret = nand_legacy_rw(nand_dev_desc + 0, 0x01 | 0x02, CFG_ENV_OFFSET, CFG_ENV_SIZE, &total, (u_char*)env_ptr); 十、修改 common/cmd_boot.c 文件,添加内核启动参数设置 (1) 首先添加头文件#include (2) 修改do_go函数。具体修改为: int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { #if defined(CONFIG_I386) DECLARE_GLOBAL_DATA_PTR; #endif ulong addr, rc; int rcode = 0; ///////////////////////////////////////////////////////////////////////// char *commandline = getenv("bootargs"); struct param_struct *my_params=(struct param_struct *)0x30000100; memset(my_params,0,sizeof(struct param_struct)); my_params->u1.s.page_size=4096; my_params->u1.s.nr_pages=0x4000000>>12; memcpy(my_params->commandline,commandline,strlen(commandline)+1); Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)/////////////////////////////////////////////////////////////////////// if (argc usage); return 1; } addr = simple_strtoul(argv[1], NULL, 16); printf ("## Starting application at 0x%08lX ...\n", addr); /* * pass address parameter as argv[0] (aka command name), * and all remaining args */ #if defined(CONFIG_I386) /* * x86 does not use a dedicated register to pass the pointer * to the global_data */ argv[0] = (char *)gd; #endif #if !defined(CONFIG_NIOS) //////////////////////////////////////////////////////////////////// __asm__( "mov r1, #193\n" "mov ip, #0\n" "mcr p15, 0, ip, c13, c0, 0\n" /* zero PID */ "mcr p15, 0, ip, c7, c7, 0\n" /* invalidate I,D caches */ "mcr p15, 0, ip, c7, c10, 4\n" /* drain write buffer */ "mcr p15, 0, ip, c8, c7, 0\n" /* invalidate I,D TLBs */ "mrc p15, 0, ip, c1, c0, 0\n" /* get control register */ "bic ip, ip, #0x0001\n" /* disable MMU */ "mov pc, %0\n" "nop\n" : :"r"(addr) ); ////////////////////////////////////////////////////////// rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]); #else /* * Nios function pointers are address >> 1 */ rc = ((ulong (*)(int, char *[]))(addr>>1)) (--argc, &argv[1]); #endif if (rc != 0) rcode = 1; Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) printf ("## Application terminated, rc = 0x%lX\n", rc); return rcode; } 其中用//括起来的代码是要添加的代码。否则在引导LINUX 内核的时候会出现一个 Error: a 或无法传递内核启动参数的错误。其原因是平台号或启动参数没有正确传入内核。 十一、交叉编译 U-BOOT #make distclean #make fs2410_config export PATH=$PATH:/home/linux/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin: #make CROSS_COMPILE= arm-softfloat-linux-gnu- 生成的 u-boot.bin 即为我们移植后的结果。下载到开发板上运行! Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)U-Boot简介 U-Boot,全称 Universal Boot Loader,是遵循 GPL 条款的开放源码项目。从 FADSROM、 8xxROM、PPCBOOT 逐步发展演化而来。其源码目录、编译形式与 Linux 内核很相似,事 实上,不少U-Boot源码就是相应的 Linux内核源程序的简化,尤其是一些设备的驱动程序, 这从U-Boot源码的注释中能体现这一点。 但是U-Boot不仅仅支持嵌入式Linux系统的引导, 当前,它还支持 NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS嵌入式操作系统。其目 前要支持的目标操作系统是OpenBSD, NetBSD, FreeBSD,4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks, LynxOS, pSOS, QNX, RTEMS, ARTOS。这是 U-Boot中 Universal的一层含义,另外一层含义则是 U-Boot除了支持 PowerPC系列的处理器外,还能 支持 MIPS、 x86、ARM、NIOS、XScale等诸多常用系列的处理器。这两个特点正是U-Boot 项目的开发目标,即支持尽可能多的嵌入式处理器和嵌入式操作系统。就目前来看,U-Boot 对 PowerPC 系列处理器支持最为丰富,对 Linux 的支持最完善。其它系列的处理器和操作 系统基本是在2002年11 月PPCBOOT改名为U-Boot后逐步扩充的。 从PPCBOOT向U-Boot 的顺利过渡,很大程度上归功于 U-Boot 的维护人德国 DENX 软件工程中心 Wolfgang Denk[以下简称 W.D]本人精湛专业水平和持着不懈的努力。当前,U-Boot 项目正在他的领 军之下,众多有志于开放源码 BOOT LOADER移植工作的嵌入式开发人员正如火如荼地将 各个不同系列嵌入式处理器的移植工作不断展开和深入, 以支持更多的嵌入式操作系统的装 载与引导。 选择 U-Boot的理由: ① 开放源码; ② 支持多种嵌入式操作系统内核,如 Linux、NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS; ③ 支持多个处理器系列,如 PowerPC、ARM、x86、MIPS、XScale; ④ 较高的可靠性和稳定性; ④ 较高的可靠性和稳定性; ⑤ 高度灵活的功能设置,适合U-Boot调试、操作系统不同引导要求、产品发布等; ⑥ 丰富的设备驱动源码,如串口、以太网、SDRAM、FLASH、LCD、NVRAM、EEPROM、 RTC、键盘等; ⑦ 较为丰富的开发调试文档与强大的网络技术支持; U-Boot主要目录结构 - board 目标板相关文件,主要包含 SDRAM、FLASH 驱动; - common 独立于处理器体系结构的通用代码,如内存大小探测与故障检测; - cpu 与处理器相关的文件。如 mpc8xx子目录下含串口、网口、LCD 驱动及中断初始化等 文件; - driver 通用设备驱动,如 CFI FLASH 驱动(目前对INTEL FLASH 支持较好) Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)- doc U-Boot的说明文档; - examples可在 U-Boot下运行的示例程序;如 hello_world.c,timer.c; - include U-Boot头文件;尤其 configs子目录下与目标板相关的配置头文件是移植过程中经 常要修改的文件; - lib_xxx 处理器体系相关的文件,如 lib_ppc, lib_arm目录分别包含与 PowerPC、ARM体系 结构相关的文件; - net 与网络功能相关的文件目录,如 bootp,nfs,tftp; - post 上电自检文件目录。尚有待于进一步完善; - rtc RTC驱动程序; - tools 用于创建 U-Boot S-RECORD 和 BIN 镜像文件的工具; U-Boot支持的主要功能 U-Boot可支持的主要功能列表 系统引导 支持NFS挂载、RAMDISK(压缩或非压缩)形式的根文件系统 支持 NFS挂载、从 FLASH 中引导压缩或非压缩系统内核; 基本辅助功能 强大的操作系统接口功能;可灵活设置、传递多个关键参数给操作系统,适 合系统在不同开发阶段的调试要求与产品发布,尤对Linux支持最为强劲; 支持目标板环境参数多种存储方式,如 FLASH、NVRAM、EEPROM; CRC32校验,可校验 FLASH 中内核、RAMDISK 镜像文件是否完好; 设备驱动 串口、 SDRAM、 FLASH、 以太网、 LCD、 NVRAM、 EEPROM、 键盘、 USB、 PCMCIA、 PCI、RTC等驱动支持; 上电自检功能 SDRAM、FLASH 大小自动检测;SDRAM故障检测;CPU型号; 特殊功能 XIP内核引导; 移植前的准备 (1)、首先读读 uboot自带的 readme文件,了解了一个大概。 (2)、看看 common.h,这个文件定义了一些基本的东西,并包含了一些必要的头文件。再 看看 flash.h,这个文件里面定义了 flash_info_t为一个 struct。包含了 flash的一些属性定义。 并且定义了所有的 flash 的属性,其中,AMD 的有:AMD_ID_LV320B,定义为“#define AMD_ID_LV320B 0x22F922F9” 。 (3)、对于“./borad/at91rm9200dk/flash.c”的修改,有以下的方面: “void flash_identification(flash_info_t *info)”这个函数的目的是确认 flash的型号。注意的 是,这个函数里面有一些宏定义,直接读写了 flash。并获得 ID 号。 (4)、修改: ”./board/at91rm9200dk/config.mk”为 TEXT_BASE=0x21f80000 为 TEXT_BASE=0x21f00000 (当然,你应该根据自己的板子来 修改,和一级boot的定义的一致即可)。 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)(5)、再修改”./include/configs/at91rm9200dk.h”为 修改 flash和 SDRAM的大小。 (6)、另外一个要修改的文件是: ./borad/at91rm9200dk/flash.c。这个文件修改的部分比较的多。 a. 首先是OrgDef的定义,加上目前的 flash。 b. 接下来,修改”#define FLASH_BANK_SIZE 0x200000”为自己flash的 容量 c. 在修改函数 flash_identification(flash_info_t * info)里面的打印信息,这部分将在 u-boot 启动的时候显示。 d. 然后修改函数 flash_init(void)里面对一些变量的赋值。 e. 最后修改的是函数 flash_print_info(flash_info_t * info)里面实际打印的函数信息。 f. 还有一个函数需要修改,就是: “flash_erase” ,这个函数要检测先前知道的 flash类型是 否匹配,否则,直接就返回了。把这里给注释掉。 (7)、接下来看看 SDRAM的修改。 这个里面对于“SIZE”的定义都是基于字节计算的。 只要修改”./include/configs/at91rm9200dk.h”里面的 “#define PHYS_SDRAM_SIZE 0X200000”就可以了。注意,SIZE 是以字节为单位的。 (8)、还有一个地方要注意 就是按照目前的设定,一级 boot 把 u_boot 加载到了 SDRAM 的空间为:21F00000 -> 21F16B10,这恰好是 SDRAM的高端部分。另外,BSS为 21F1AE34。 (9)、编译后,可以写入 flash了。 a. 压缩这个 u-boot.bin “gzip –c u-boot.bin > u-boot.gz” 压缩后的文件大小为: 43Kbytes b. 接着把 boot.bin和 u-boot.gz 烧到 flash里面去。 Boot.bin大约 11kBytes,在 flash的 0x1000 0000 ~ 0x1000 3fff U-Boot移植过程 ① 获得发布的最新版本 U-Boot源码,与 Linux内核源码类似,也是 bzip2 的压缩格式。可 从 U-Boot的官方网站 http://sourceforge.net/projects/U-Boot上获得; ② 阅读相关文档,主要是 U-Boot 源码根目录下的 README 文档和 U-Boot 官方网站的 DULG ( The DENX U-Boot and Linux Guide ) 文档 http://www.denx.de/twiki/bin/view/DULG/Manual。尤其是DULG 文档,从如何安装建立交叉 开发环境和解决 U-Boot移植中常见问题都一一给出详尽的说明; Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) ③ 订阅 U-Boot 用户邮件列表 http://lists.sourceforge.net/lists/listinfo/u-boot-users。在移植 U-Boot 过程中遇有问题 , 在参考相关文档和搜 索 U-Boot-User 邮 件 档 案 库 http://sourceforge.net/mailarchive/forum.php?forum_id=12898 仍不能解决的情况下,第一时间 提交所遇到的这些问题,众多热心的 U-Boot开发人员会乐于迅速排查问题,而且很有可能, W.D本人会直接参与指导; ④ 在建立的开发环境下进行移植工作。绝大多数的开发环境是交叉开发环境。在这方面, DENX 和 MontaVista 均提供了完整的开发工具集; ⑤ 在目标板与开发主机间接入硬件调试器。 这是进行U-Boot移植应当具备且非常关键的调 试工具。因为在整个 U-Boot的移植工作中,尤其是初始阶段,硬件调试器是我们了解目标板 真实运行状态的唯一途径。 在这方面, W.D 本人和众多嵌入式开发人员倾向于使用 BDI2000。 一方面,其价格不如 ICE 调试器昂贵,同时其可靠性高,功能强大,完全能胜任移植和调 试 U-Boot。另外,网上也有不少关于 BDI2000调试方面的参考文档。 ⑥ 如果在参考开发板上移植 U-Boot,可能需要移除目标板上已有的 BOOT LOADER。可以 根据板上 BOOT LOADER的说明文档,先着手解决在移除当前 BOOT LOADER的情况下, 如何进行恢复。以便今后在需要场合能重新装入原先的BOOT LOADER。 U-Boot移植方法 当前,对于 U-Boot的移植方法,大致分为两种。一种是先用 BDI2000创建目标板初始运行 环境,将 U- Boot镜像文件 u-boot.bin下载到目标板 RAM中的指定位置,然后,用 BDI2000 进行跟踪调试。其好处是不用将 U-Boot 镜像文件烧写到 FLASH 中去。但弊端在于对移植 开发人员的移植调试技能要求较高,BDI2000 的配置文件较为复杂。另外一种方法是用 BDI2000先将 U-Boot 镜像文件烧写到 FLASH 中去,然后利用GDB和 BDI2000进行调试。 这种方法所用 BDI2000的配置文件较为简单,调试过程与 U-Boot移植后运行过程相吻合, 即 U-Boot先从 FLASH 中运行,再重载至 RAM中相应位置,并从那里正式投入运行。唯一 感到有些麻烦的就是需要不断烧写 FLASH。 但考虑到 FLASH 常规擦写次数基本为 10万次 左右,作为移植 U-Boot,不会占用太多的次数,应该不会为 FLASH 烧写有什么担忧。同时, W. D本人也极力推荐使用后一种方法。笔者建议,除非U-Boot移植资深人士或有强有力的 技术支持,建议采用第二种移植方法。 U-Boot移植主要修改的文件 从移植 U-Boot最小要求-U-Boot能正常启动的角度出发,主要考虑修改如下文件: ① .h头文件,如 include/configs/RPXlite.h。可以是 U-Boot源码中已有的目标板头 文件,也可以是新命名的配置头文件;大多数的寄存器参数都是在这一文件中设置完成的; ② .c文件, 如board/RPXlite/RPXlite.c。 它是SDRAM的驱动程序, 主要完成SDRAM Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)的 UPM表设置,上电初始化。 ③ FLASH的驱动程序, 如board/RPXlite/flash.c, 或common/cfi_flash.c。 可在参考已有FLASH 驱动的基础上,结合目标板 FLASH 数据手册,进行适当修改; ④ 串口驱动,如修改cpu/mpc8xx/serial.c串口收发器芯片使能部分。 U-Boot移植要点 ① BDI2000 的配置文件。如果采用第二种移植方法,即先烧入 FLASH 的方法,配置项只 需很少几个,就可以进行 U-Boot的烧写与调试了。对 PPC 8xx系列的主板,可参考DULG 文档中 TQM8xx 的配置文件进行相应的修改。下面,笔者以美国 Embedded Planet 公司的 RPXlite DW 板为例,给出在嵌入式Linux交叉开发环境下的 BDI2000参考配置文件以作参 考: ; bdiGDB configuration file for RPXlite DW or LITE_DW ; -------------------------------------------- [INIT] ; init core register WSPR 149 0x2002000F ;DER : set debug enable register ; WSPR 149 0x2006000F ;DER : enable SYSIE for BDI flash program WSPR 638 0xFA200000 ;IMMR : internal memory at 0xFA200000 WM32 0xFA200004 0xFFFFFF89 ;SYPCR [TARGET] CPUCLOCK 40000000 ;the CPU clock rate after processing the init list BDIMODE AGENT ;the BDI working mode (LOADONLY | AGENT) BREAKMODE HARD ;SOFT or HARD, HARD uses PPC hardware breakpoints [HOST] IP 173.60.120.5 FILE uImage.litedw FORMAT BIN LOAD MANUAL ;load code MANUAL or AUTO after reset DEBUGPORT 2001 START 0x0100 [FLASH] CHIPTYPE AM29BX8 ;;Flash type (AM29F | AM29BX8 | AM29BX16 | I28BX8 | I28BX16) CHIPSIZE 0x400000 ;;The size of one flash chip in bytes BUSWIDTH 32 ;The width of the flash memory bus in bits (8 | 16 | 32) WORKSPACE 0xFA202000 ; RAM buffer for fast flash programming FILE u-boot.bin ;The file to program FORMAT BIN 0x00000000 ERASE 0x00000000 BLOCK ERASE 0x00008000 BLOCK ERASE 0x00010000 BLOCK Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)ERASE 0x00018000 BLOCK [REGS] DMM1 0xFA200000 FILE reg823.def ② U-Boot 移植参考板。这是进行 U-Boot 移植首先要明确的。可以根据目标板上 CPU、 FLASH、SDRAM的情况,以尽可能相一致为原则,先找出一个与所移植目标板为同一个或 同一系列处理器的 U-Boot 支持板为移植参考板。如 RPXlite DW 板可选择 U-Boot 源码中 RPXlite 板作为 U-Boot 移植参考板。对 U-Boot 移植新手,建议依照循序渐进的原则,目标 板文件名暂时先用移植参考板的名称,在逐步熟悉 U-Boot 移植基础上,再考虑给目标板重 新命名。在实际移植过程中,可用 Linux 命令查找移植参考板的特定代码,如 grep –r RPXlite ./ 可确定出在 U-Boot中与 RPXlite板有关的代码,依此对照目标板实际进行屏蔽或 修改。同时应不局限于移植参考板中的代码,要广泛借鉴U-Boot 中已有的代码更好地实现 一些具体的功能。 ③ U-Boot烧写地址。 不同目标板, 对 U-Boot在 FLASH 中存放地址要求不尽相同。 事实上, 这是由处理器中断复位向量来决定的,与主板硬件相关,对 MPC8xx 主板来讲,就是由硬 件配置字(HRCW)决定的。也就是说,U-Boot烧写具体位置是由硬件决定的,而不是程序设 计来选择的。程序中相应 U-Boot 起始地址必须与硬件所确定的硬件复位向量相吻合;如 RPXlite DW 板的中断复位向量设置为 0x00000100。因此, U-Boot 的 BIN 镜像文件必须烧 写到 FLASH 的起始位置。 事实上, 大多数的 PPC系列的处理器中断复位向量是 0x00000100 和 0xfff00100。这也是一般所说的高位启动和低位启动的 BOOT LOADER 所在位置。可通 过修改 U-Boot 源码.h 头文件中 CFG_MONITOR_BASE 和 board//config.mk中的 TEXT_BASE 的设置来与硬件配置相对应。 ④ CPU寄存器参数设置。根据处理器系列、类型不同,寄存器名称与作用有一定差别。必 须根据目标板的实际,进行合理配置。一个较为可行和有效的方法,就是借鉴参考移植板的 配置,再根据目标板实际,进行合理修改。这是一个较费功夫和考验耐力的过程,需要仔细 对照处理器各寄存器定义、参考设置、目标板实际作出选择并不断测试。MPC8xx处理器较 为关键的寄存器设置为 SIUMCR、PLPRCR、SCCR、BRx、ORx。 ⑤ 串口调试。能从串口输出信息,即使是乱码,也可以说 U-Boot移植取得了实质性突破。 依据笔者调试经历,串口是否有输出,除了与串口驱动相关外,还与 FLASH 相关的寄存器 设置有关。因为 U-Boot 是从 FLASH 中被引导启动的,如果 FLASH 设置不正确,U-Boot 代码读取和执行就会出现一些问题。因此,还需要就FLASH 的相关寄存器设置进行一些参 数调试。同时,要注意串口收发芯片相关引脚工作波形。依据笔者调试情况,如果串口无输 出或出现乱码,一种可能就是该芯片损坏或工作不正常。 ⑥ 与启动 FLASH 相关的寄存器 BR0、OR0 的参数设置。应根据目标板 FLASH 的数据手 册与 BR0 和 OR0 的相关位含义进行合理设置。这不仅关系到 FLASH 能否正常工作,而且 与串口调试有直接的关联。 ⑦ 关于 CPLD 电路。目标板上是否有 CPLD 电路丝毫不会影响 U-Boot 的移植与嵌入式操 作系统的正常运行。事实上,CPLD 电路是一个集中将板上电路的一些逻辑关系可编程设置 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)的一种实现方法。其本身所起的作用就是实现一些目标板所需的脉冲信号和电路逻辑,其功 能完全可以用一些逻辑电路与 CPU口线来实现。 ⑧ SDRAM的驱动。串口能输出以后,U-Boot移植是否顺利基本取决于 SDRAM的驱动是 否正确。与串口调试相比,这部分工作更为核心,难度更大。 MPC8xx 目标板 SDRAM 驱 动涉及三部分。一是相关寄存器的设置;二是 UPM表;三是 SDRAM上电初始化过程。任 何一部分有问题,都会影响 U- Boot、嵌入式操作系统甚至应用程序的稳定、可靠运行。所 以说,SDRAM 的驱动不仅关系到 U-Boot 本身能否正常运行,而且还与后续部分相关,是 相当关键的部分。 ⑨ 补充功能的添加。在获得一个能工作的 U-Boot后,就可以根据目标板和实际开发需要, 添加一些其它功能支持。如以太网、LCD、NVRAM 等。与串口和 SDRAM 调试相比,在 已有基础之上,这些功能添加还是较为容易的。大多只是在参考现有源码的基础上,进行一 些修改和配置。 另外,如果在自主设计的主板上移植 U-Boot,那么除了考虑上述软件因素以外,还需要排 查目标板硬件可能存在的问题。如原理设计、PCB 布线、元件好坏。在移植过程中,敏锐 判断出故障态是硬件还是软件问题,往往是关系到项目进度甚至移植成败的关键,相应难度 会增加许多。 下面以移植 u-boot 到 44B0开发板的步骤为例,移植中上仅需要修改和硬件相关的部分。在 代码结构上: 1) 在 board 目录下创建 ev44b0ii 目录,创建 ev44b0ii.c 以及 flash.c,memsetup.S,u-boot.lds 等。不需要从零开始,可选择一个相似的目录,直接复制过来,修改文件名以及内容。我在 移植 u-boot 过程中,选择的是 ep7312 目录。由于 u-boot 已经包含基于 s3c24b0 的开发板 目录,作为参考,也可以复制相应的目录。 2) 在 cpu 目录下创建 arm7tdmi 目录,主要包含 start.S, interrupts.c 以及 cpu.c,serial.c几个文 件。同样不需要从零开始建立文件,直接从arm720t 复制,然后修改相应内容。 3) 在 include/configs 目录下添加 ev44b0ii.h,在这里放上全局的宏定义等。 4) 找到 u-boot 根目录下 Makefile 修改加入 ev44b0ii_config : unconfig @./mkconfig $(@:_config=) arm arm7tdmi ev44b0ii 5) 运行 make ev44bii_config,如果没有错误就可以开始硬件相关代码移植的工作 u-boot 的体系结构 1) 总体结构 u-boot 是一个层次式结构。从上图也可以看出,做移植工作的软件人员应当提供串口驱动 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)(UART Driver),以太网驱动(Ethernet Driver),Flash 驱动(Flash 驱动),USB 驱动(USB Driver)。目前,通过 USB 口下载程序显得不是十分必要,所以暂时没有移植 USB 驱动。 驱动层之上是 u-boot 的应用,command 通过串口提供人机界面。我们可以使用一些命令做 一些常用的工作,比如内存查看命令 md。 Kermit 应用主要用来支持使用串口通过超级终端下载应用程序。TFTP 则是通过网络方式 来下载应用程序,例如uclinux 操作系统。 2) 内存分布 在 flash rom 中内存分布图 ev44b0ii 的 flash 大小 2M(8bits),现在将 0-40000 共 256k 作为 u-boot 的存储空间。由于 u-boot 中有一些环境变量,例如 ip 地址,引导文件名等,可在命 令行通过 setenv 配置好,通过 saveenv 保存在 40000-50000(共 64k)这段空间里。如果存在 保存好的环境变量,u-boot 引导将直接使用这些环境变量。正如从代码分析中可以看到, 我们会把 flash 引导代码搬移到 DRAM 中运行。下图给出 u-boot 的代码在 DRAM 中的位 置。引导代码 u-boot 将从 0x0000 0000 处搬移到 0x0C700000 处。特别注意的由于 ev44b0ii uclinux 中断向量程序地址在 0x0c00 0000 处,所以不能将程序下载到0x0c00 0000 出,通 常下载到 0x0c08 0000 处。 2) start.S 代码结构 1) 定义入口 一个可执行的 Image 必须有一个入口点并且只能有一个唯一的全局入口,通常这个入口放 在 Rom(flash)的 0x0 地址。例如 start.S 中的 .globl _start _start: 值得注意的是你必须告诉编译器知道这个入口, 这个工作主要是修改连接器脚本文件 (lds)。 2) 设置异常向量(Exception Vector) 异常向量表,也可称为中断向量表,必须是从 0 地址开始,连续的存放。如下面的就包括 了复位(reset),未定义处理(undef),软件中断(SWI),预去指令错误(Pabort),数据错误 (Dabort), 保留,以及 IRQ,FIQ 等。注意这里的值必须与 uclinux 的 vector_base 一致。这就是说如果 uclinux 中 vector_base(include/armnommu/proc-armv/system.h) 定 义 为 0x0c00 0000, 则 HandleUndef 应该在 0x0c00 0004。 b reset //for debug ldr pc,=HandleUndef ldr pc,=HandleSWI ldr pc,=HandlePabort ldr pc,=HandleDabort b . ldr pc,=HandleIRQ ldr pc,=HandleFIQ ldr pc,=HandleEINT0 /*mGA H/W interrupt vector table*/ ldr pc,=HandleEINT1 ldr pc,=HandleEINT2 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)ldr pc,=HandleEINT3 ldr pc,=HandleEINT4567 ldr pc,=HandleTICK /*mGA*/ b . b . ldr pc,=HandleZDMA0 /*mGB*/ ldr pc,=HandleZDMA1 ldr pc,=HandleBDMA0 ldr pc,=HandleBDMA1 ldr pc,=HandleWDT ldr pc,=HandleUERR01 /*mGB*/ b . b . ldr pc,=HandleTIMER0 /*mGC*/ ldr pc,=HandleTIMER1 ldr pc,=HandleTIMER2 ldr pc,=HandleTIMER3 ldr pc,=HandleTIMER4 ldr pc,=HandleTIMER5 /*mGC*/ b . b . ldr pc,=HandleURXD0 /*mGD*/ ldr pc,=HandleURXD1 ldr pc,=HandleIIC ldr pc,=HandleSIO ldr pc,=HandleUTXD0 ldr pc,=HandleUTXD1 /*mGD*/ b . b . ldr pc,=HandleRTC /*mGKA*/ b . b . b . b . b . /*mGKA*/ b . b . ldr pc,=HandleADC /*mGKB*/ b . b . b . b . b . /*mGKB*/ b . Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)b . ldr pc,=EnterPWDN 作为对照:请看以上标记的值: .equ HandleReset, 0xc000000 .equ HandleUndef,0xc000004 .equ HandleSWI, 0xc000008 .equ HandlePabort, 0xc00000c .equ HandleDabort, 0xc000010 .equ HandleReserved, 0xc000014 .equ HandleIRQ, 0xc000018 .equ HandleFIQ, 0xc00001c /*the value is different with an address you think it may be. *IntVectorTable */ .equ HandleADC, 0xc000020 .equ HandleRTC, 0xc000024 .equ HandleUTXD1, 0xc000028 .equ HandleUTXD0, 0xc00002c .equ HandleSIO, 0xc000030 .equ HandleIIC, 0xc000034 .equ HandleURXD1, 0xc000038 .equ HandleURXD0, 0xc00003c .equ HandleTIMER5, 0xc000040 .equ HandleTIMER4, 0xc000044 .equ HandleTIMER3, 0xc000048 .equ HandleTIMER2, 0xc00004c .equ HandleTIMER1, 0xc000050 .equ HandleTIMER0, 0xc000054 .equ HandleUERR01, 0xc000058 .equ HandleWDT, 0xc00005c .equ HandleBDMA1, 0xc000060 .equ HandleBDMA0, 0xc000064 .equ HandleZDMA1, 0xc000068 .equ HandleZDMA0, 0xc00006c .equ HandleTICK, 0xc000070 .equ HandleEINT4567, 0xc000074 .equ HandleEINT3, 0xc000078 .equ HandleEINT2, 0xc00007c .equ HandleEINT1, 0xc000080 .equ HandleEINT0, 0xc000084 3) 初始化 CPU 相关的 pll,clock,中断控制寄存器 依次为关闭 watch dog timer,关闭中断,设置 LockTime,PLL(phase lock loop),以及时钟。 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)这些值(除了LOCKTIME)都可从 Samsung 44b0 的手册中查到。 ldr r0,WTCON //watch dog disable ldr r1,=0x0 str r1,[r0] ldr r0,INTMSK ldr r1,MASKALL //all interrupt disable str r1,[r0] /***************************************************** * Set clock control registers * *****************************************************/ ldr r0,LOCKTIME ldr r1,=800 // count = t_lock * Fin (t_lock=200us, Fin=4MHz) = 800 str r1,[r0] ldr r0,PLLCON /*temporary setting of PLL*/ ldr r1,PLLCON_DAT /*Fin=10MHz,Fout=40MHz or 60MHz*/ str r1,[r0] ldr r0,CLKCON ldr r1,=0x7ff8 //All unit block CLK enable str r1,[r0] 4) 初始化内存控制器 内存控制器,主要通过设置 13 个从 1c80000 开始的寄存器来设置,包括总线宽度, 8 个内存 bank,bank 大小,sclk,以及两个 bank mode。 /***************************************************** * Set memory control registers * *****************************************************/ memsetup: adr r0,SMRDATA ldmia r0,{r1-r13} ldr r0,=0x01c80000 //BWSCON Address stmia r0,{r1-r13} 5) 将 rom 中的程序复制到 RAM 中 首先利用 PC 取得 bootloader 在 flash 的起始地址,再通过标号之差计算出这个程序代 码的大小。这些标号,编译器会在连接(link)的时候生成正确的分布的值。取得正 确信息后,通过寄存器(r3 到 r10)做为复制的中间媒介,将代码复制到 RAM 中。 relocate: /* * relocate armboot to RAM */ Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)adr r0, _start /* r0 <- current position of code */ ldr r2, _armboot_start ldr r3, _armboot_end sub r2, r3, r2 /* r2 <- size of armboot */ ldr r1, _TEXT_BASE /* r1 <- destination address */ add r2, r0, r2 /* r2 baudrate) + 0.5) -1 )计算得出。这可以在手 册中查到。其他的函数包括发送,接收。这个时候没有中断,是通过循环等待来判断是否动 作完成。 例如,接收函数: while(!(rUTRSTAT0 & 0x1)); //Receive data read return RdURXH0(); 2. 时钟部分 实现了延时函数 udelay。 这里的 get_timer 由于没有使用中断,是使用全局变量来累加的。 3. flash 部分 flash 作为内存的一部分,读肯定没有问题,关键是 flash 的写部分。 Flash 的写必须先擦除,然后再写。 unsigned long flash_init (void) { int i; u16 manId,devId; //first we init it as unknown,even if you forget assign it below,it's not a problem for (i=0; i < CFG_MAX_FLASH_BANKS; ++i){ flash_info[i].flash_id = FLASH_UNKNOWN; flash_info[i].sector_count=CFG_MAX_FLASH_SECT; } /*check manId,devId*/ _RESET(); _WR(0x555,0xaa); _WR(0x2aa,0x55); _WR(0x555,0x90); manId=_RD(0x0); _WR(0x555,0xaa); _WR(0x2aa,0x55); _WR(0x555,0x90); Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)devId=_RD(0x1); _RESET(); printf("flashn"); printf("Manufacture ID=%4x(0x0004), Device ID(0x22c4)=%4xn",manId,devId); if(manId!=0x0004 && devId!=0x22c4){ printf("flash check faliluren"); return 0; }else{ for (i=0; i = CFG_FLASH_BASE //onitor protection ON by default flash_protect(FLAG_PROTECT_SET, CFG_MONITOR_BASE, CFG_MONITOR_BASE+monitor_flash_len-1, &flash_info[0]); #endif */ flash_info[0].size =PHYS_FLASH_SIZE; return (PHYS_FLASH_SIZE); } flash_init 完成初始化部分,这里的主要目的是检验flash 的型号是否正确。 int flash_erase (flash_info_t *info, int s_first, int s_last) { volatile unsigned char *addr = (volatile unsigned char *)(info->start[0]); int flag, prot, sect, l_sect; //ulong start, now, last; u32 targetAddr; u32 targetSize; /*zyy note:It is required and can't be omitted*/ rNCACHBE0=( (0x2000000>>12)<>12); //flash area(Bank0) must be non-cachable area. rSYSCFG=rSYSCFG & (~0x8); //write buffer has to be off for proper timing. if ((s_first s_last)) { if (info->flash_id == FLASH_UNKNOWN) { printf ("- missingn"); } else { printf ("- no sectors to erasen"); Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)} return 1; } if ((info->flash_id == FLASH_UNKNOWN) || (info->flash_id > FLASH_AMD_COMP)) { printf ("Can't erase unknown flash type - abortedn"); return 1; } prot = 0; for (sect=s_first; sectprotect[sect]) { prot++; } } if (prot) { printf ("- Warning: %d protected sectors will not be erased!n", prot); } else { printf ("n"); } l_sect = -1; /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts(); /* Start erase on unprotected sectors */ for (sect = s_first; sectprotect[sect] == 0) {/* not protected */ targetAddr=0x10000*sect; if(targetAddr<0x1F0000) targetSize=0x10000; else if(targetAddr<0x1F8000) targetSize=0x8000; else if(targetAddr<0x1FC000) targetSize=0x2000; else targetSize=0x4000; F29LV160_EraseSector(targetAddr); l_sect = sect; if(!BlankCheck(targetAddr, targetSize)) printf("BlankCheck Errorn"); } } /* re-enable interrupts if necessary */ if (flag) enable_interrupts(); Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)/* wait at least 80us - let's wait 1 ms */ udelay (1000); /* *We wait for the last triggered sector */ if (l_sect > 16) & 0xffff; low=swap_16(low); high=swap_16(high); tempPt=(volatile u16 *)dest; _WR(0x555,0xaa); _WR(0x2aa,0x55); _WR(0x555,0xa0); *tempPt=high; Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)_WAIT(); _WR(0x555,0xaa); _WR(0x2aa,0x55); _WR(0x555,0xa0); *(tempPt+1)=low; _WAIT(); return 0; } wirte_word 则想 flash 里面写入 unsigned long 类型的 data, 因为flash 一次只能写入16bits, 所以这里分两次写入。 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com)u-boot源码分析——启动第一阶段 分析代码当然要从上电后执行的第一条指令开始看起咯, 那第一条指令在哪呢? 还是以 smdk2410 为 例,我们看它的链接脚本: 文件 board/smsk2410/u-boot.lds: …… ENTRY(_start) //指明入口地址(见汇编指令) SECTIONS { . = 0x00000000; //入口地址为 0x00000000,硬件决定的 . = ALIGN(4); //按 4 字节对齐,即按字对齐(32 位) .text: //文本段,即代码段 { cpu/arm920t/start.o (.text) //确定启动后执行的第一个文件 *(.text) } . = ALIGN(4); .rodata : { *(.rodata) } …… } 由这个文件可知第一个执行的文件是 cpu/arm920t/start.S,那第一条指令(_start)很可能就在这个文件中 了。我们看这个文件: cpu/arm920t/start.S: .globl _start /*这 8 行为中断向量表,参考arm书籍可确定这段代码的编写方法*/ _start: b reset //复位向量,CPU上电后执行的第一条语句 ldr pc, _undefined_instruction ldr pc, _software_interrupt ldr pc, _prefetch_abort ldr pc, _data_abort ldr pc, _not_used ldr pc, _irq //中断向量 ldr pc, _fiq //快速中断向量 /*.word为伪指令,变量替换*/ _undefined_instruction: .word undefined_instruction _software_interrupt: .word software_interrupt Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) _prefetch_abort: .word prefetch_abort _data_abort: .word data_abort _not_used: .word not_used _irq: .word irq _fiq: .word fiq S3C2410的 CPU规定开机后的 PC寄存器地址为 0,即从 0 地址开始执行指令,因此我们必须把我们的 复位代码放在 0 地址处才能正常开机。 ARM核也规定启动地址处的 32个字节必须存放异常向量跳转表,里面保存有中断,异常等的处理函数 地址。当系统产生中断时,必定会跳到这里来开始处理中断。具体可参考 ARM方面的书籍。 由 u-boot.lds可知入口地址为_start, 即开机后从_start处开始执行指令。所以第一条指令就是: b reset //跳转到 reset处进行复位处理 cpu/arm920t/start.S: // CPU上电后跳转到此处,CPU进入 SVC32模式,这样可以拥有特权操作,参考 ARM书籍 /* the actual reset code */ reset: mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0xd3 msr cpsr,r0 /* turn off the watchdog */ //CPU上操作 watchdog相关的寄存器地址,可参考CPU的 datasheet,这里用到的地址都是实地址, //因为还没为 MMU等部件进行初始化,也没切换操作模式呢。 #if defined(CONFIG_S3C2400) # define pWTCON 0x15300000 # define INTMSK 0x14400008 /* Interupt-Controller base addresses */ # define CLKDIVN 0x14800014 /* clock divisor register */ #elif defined(CONFIG_S3C2410) # define pWTCON 0x53000000 # define INTMSK 0x4A000008 /* Interupt-Controller base addresses */ # define INTSUBMSK 0x4A00001C # define CLKDIVN 0x4C000014 /* clock divisor register */ #endif #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) ldr r0, =pWTCON mov r1, #0x0 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) str r1, [r0] //关闭 watchdog,具体寄存器含义可参考 CPU手册 /* * mask all IRQs by setting all bits in the INTMSK - default */ mov r1, #0xffffffff ldr r0, =INTMSK str r1, [r0] //关闭所有的中断 # if defined(CONFIG_S3C2410) ldr r1, =0x3ff ldr r0, =INTSUBMSK str r1, [r0] //关闭所有的中断 # endif /* FCLK:HCLK:PCLK = 1:2:4 */ /* default FCLK is 120 MHz ! */ //设置 HCLK 为 FCLK/2, PCLK 为 FCLK/4, FCLK 为 CPU产生 clock,HCLK 为 AHB总线上的设备产生 //clock, PCLK 为 APB总线上的设备产生 clock,具体参考 s3c2410的 datasheet ldr r0, =CLKDIVN mov r1, #3 str r1, [r0] #endif /* CONFIG_S3C2400 || CONFIG_S3C2410 */ /* * we do sys-critical inits only at reboot, * not when booting from ram! */ //做系统相关的重要初始化,这些初始化代码只在系统重起的时候执行, // CONFIG_SKIP_LOWLEVEL_INIT 可以看 README. #ifndef CONFIG_SKIP_LOWLEVEL_INIT bl cpu_init_crit //可以先看这段代码在转回来接着看后面的复位过程。 #endif //内存配置完后,可以进行重定位操作了 #ifndef CONFIG_SKIP_RELOCATE_UBOOT relocate: /* 重定位 u-boot到 RAM中*/ adr r0, _start /* r0 = flash中的代码的起始地址*/ ldr r1, _TEXT_BASE /* r1= 代码在 RAM中的起始地址 */ cmp r0, r1 /* 看是否 u-boot就在 RAM中运行*/ beq stack_setup /*如果在 RAM中则无需重定位*/ /*开始重定位,即把u-boot从 flash中搬到 RAM 中去运行*/ ldr r2, _armboot_start /*r2 = flash中代码的起始地址,看_armboot_start的定义*/ ldr r3, _bss_start /*r3 = bss段的起始地址,_bss_start可在 u-boot.lds中查看。*/ Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) sub r2, r3, r2 /* r2 = 需要重定位的字节数*/ add r2, r0, r2 /* r2 = flash中 RO,RW 内容的结束地址 */ //开始把代码从 flash中搬运到 RAM中 copy_loop: ldmia r0!, {r3-r10} /*获取从 r0开始的代码,存入 r3—r10*/ stmia r1!, {r3-r10} /*把 r3—r10 的内容存入r1 所在位置,即 RAM中*/ cmp r0, r2 /*copy所有代码 */ ble copy_loop #endif /* CONFIG_SKIP_RELOCATE_UBOOT */ /*设置栈地址*/ stack_setup: ldr r0, _TEXT_BASE /*upper 128 KiB: relocated uboot*/ sub r0, r0, #CFG_MALLOC_LEN /*malloc分配内存的区域,大小以板子的配置而定,smdk2410的在 include/configs/smdk2410.h中定义*/ sub r0, r0, #CFG_GBL_DATA_SIZE /* 存放 bdinfo的区域,定义同上*/ #ifdef CONFIG_USE_IRQ sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ) //保留中断所需的区域 #endif sub sp, r0, #12 /* 保留 12 字节给 abort-stack, 并设好堆栈*/ //bss段内容清 0 clear_bss: ldr r0, _bss_start /* find start of bss segment */ ldr r1, _bss_end /* stop here */ mov r2, #0x00000000 /* clear */ clbss_l:str r2, [r0] /* clear loop... */ add r0, r0, #4 cmp r0, r1 ble clbss_l #if 0 /* try doing this stuff after the relocation */ ldr r0, =pWTCON mov r1, #0x0 str r1, [r0] /* mask all IRQs by setting all bits in the INTMR - default*/ mov r1, #0xffffffff ldr r0, =INTMR str r1, [r0] /* FCLK:HCLK:PCLK = 1:2:4 */ /* default FCLK is 120 MHz ! */ ldr r0, =CLKDIVN mov r1, #3 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) str r1, [r0] /* END stuff after relocation */ #endif ldr pc, _start_armboot //跳转到_start_armboot处执行。 _start_armboot: .word start_armboot 总结 reset这块代码,主要完成了一下几个部分: 1. 重要部分的初始化工作,如禁止中断,关闭 watchdog,初始化 memory控制器等 2. 重定位boot loader 到 ram 3. 设置好堆栈 4. 跳转到第 2阶段执行 完成这些后,此时内存的分布情况如下: 这个图代表的是 u-boot自己在内存的情况, 和上面的图不一样, 这里的_TEXT_BASE 就是 0x33F8’ 0000 接着看 CPU_init_critical cpu/arm920t/start.S: /* ************************************************************************** * CPU_init_critical registers * 设置 cache,TLB,MMU等寄存器 * 设置内存操作的时序 * ************************************************************************* */ cpu_init_crit: /* * flush v4 I/D caches */ /*使 cache和 TLB无效,可以参考 data sheet*/ mov r0, #0 mcr p15, 0, r0, c7, c7, 0 /* 使指令 cache和数据 cache无效 */ mcr p15, 0, r0, c8, c7, 0 /* 使 TLB无效 */ /* * disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0 /*读出 c1 控制寄存器的值*/ bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM),小端对齐,关闭数据 cache,关 //闭错误检测,关闭MMU orr r0, r0, #0x00000002 @ set bit 2 (A) Align, 使能错误检测 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache, 使能指令 cache mcr p15, 0, r0, c1, c0, 0 /*设置 c1 控制寄存器*/ /*可以参考 data sheet*/ Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) /* * before relocating, we have to setup RAM timing * because memory timing is board-dependend, you will * find a lowlevel_init.S in your board directory. */ //在把 u-boot 重定位到 RAM 前,我们必须先把 RAM 的时序设置好,内存时序是依板子而定的, 所以这里的初始化应该由我们提供,一般在我们的板子所在目录下有个 lowlevel_init.S来负责这件事情。 特定板子的目录还记得吗, 呵呵回到上面在看看。 mov ip, lr bl lowlevel_init mov lr, ip mov pc, lr //类似于函数返回 cpu_init_crit主要是使能了 instruction cache,关闭了 MMU等部件,但是好像在 u-boot后面的代码里没有 看见打开 MMU 的操作,我猜测可能是留到了 OS 启动的时候再打开了吧,data cache 在第二阶段的 board_init下被使能。 接着看 lowlevel_init。以 smdk2410位例 board/smdk2410/lowlevel_init.S _TEXT_BASE: .word TEXT_BASE .globl lowlevel_init lowlevel_init: /* memory control configuration */ /* make r0 relative the current location so that it */ /* reads SMRDATA out of FLASH rather than memory ! */ // 内存控制器的配置, 配置完后就可以使用内存了 ldr r0, =SMRDATA //在下面定义 ldr r1, _TEXT_BASE sub r0, r0, r1 // ldr r1, =BWSCON /* Bus Width Status Controller */ add r2, r0, #13*4 0: ldr r3, [r0], #4 str r3, [r1], #4 //设置内存配置寄存器,可以对着datasheet来看这里的设置,包括时序位宽等 等, 使用一个循环来配置所有的寄存器 cmp r2, r0 bne 0b /* everything is fine now */ mov pc, lr .ltorg /* the literal pools origin */ //这些就是要被设置进内存配置寄存器的值, SMRDATA: Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) .word (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON< <20)+(B6_BWSCON<<24)+(B7_BWSCON<<28)) .word ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC)) .word ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC)) .word ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC)) .word ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC)) .word ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC)) .word ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC)) .word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN)) .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN)) .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT) .word 0x32 .word 0x30 .word 0x30 这部分代码主要是设置 memory的时序,位宽等参数 Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) U-BOOT源码分析及移植 本文从以下几个方面粗浅地分析 u-boot并移植到 FS2410 板上: 1、u-boot工程的总体结构 2、u-boot的流程、主要的数据结构、内存分配。 3、u-boot的重要细节,主要分析流程中各函数的功能。 4、基于 FS2410板子的u-boot移植。实现了 NOR Flash和 NAND Flash启动,网络功能。 这些认识源于自己移植 u-boot过程中查找的资料和对源码的简单阅读。下面主要以 smdk2410为分析对 象。 一、u-boot工程的总体结构: 1、源代码组织 对于 ARM而言,主要的目录如下: board 平台依赖 存放电路板相关的目录文件,每一套板子对 应一个目 录。如 smdk2410(arm920t) cpu 平台依赖 存放 CPU 相关的目录文件,每一款 CPU 对应一个目 录,例如:arm920t、 xscale、i386 等目录 lib_arm 平台依赖 存放对 ARM 体系结构通用的文件,主要用于实现 ARM平台通用的函数,如软件浮点。 common 通用 通用的多功能函数实现,如环境,命令,控制台相关的函数实 现。 include 通用 头文件和开发板配置文件,所有开发板的配置文件都在 configs目录下 lib_generic 通用 通用库函数的实现 net 通用 存放网络协议的程序 drivers 通用 通用的设备驱动程序,主要有以太网接口的驱动,nand 驱 动。 ....... 2.makefile简要分析 所有这些目录的编译连接都是由顶层目录的 makefile 来确定的。 在执行 make之前,先
1:外文原文 Struts——an open-source MVC implementation This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control change in your Web project and promote specialization. Even if you never implement a system with Struts, you may get some ideas for your future servlets and JSP page implementation. Introduction Kids in grade school put HTML pages on the Internet. However, there is a monumental difference between a grade school page and a professionally developed Web site. The page designer (or HTML developer) must understand colors, the customer, product flow, page layout, browser compatibility, image creation, JavaScript, and more. Putting a great looking site together takes a lot of work, and most Java developers are more interested in creating a great looking object interface than a user interface. JavaServer Pages (JSP) technology provides the glue between the page designer and the Java developer. If you have worked on a large-scale Web application, you understand the term change. Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data. Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifications, as part of the implementation. You may never implement a system with Struts, but looking at Struts may give you some ideas on your future Servlets and JSP implementations. Model-View-Controller (MVC) JSP tags solved only part of our problem. We still have issues with validation, flow control, and updating the state of the application. This is where MVC comes to the rescue. MVC helps resolve some of the issues with the single module approach by dividing the problem into three categories: • Model The model contains the core of the application's functionality. The model encapsulates the state of the application. Sometimes the only functionality it contains is state. It knows nothing about the view or controller. • View The view provides the presentation of the model. It is the look of the application. The view can access the model getters, but it has no knowledge of the setters. In addition, it knows nothing about the controller. The view should be notified when changes to the model occur. • Controller The controller reacts to the user input. It creates and sets the model. MVC Model 2 The Web brought some unique challenges to software developers, most notably the stateless connection between the client and the server. This stateless behavior made it difficult for the model to notify the view of changes. On the Web, the browser has to re-query the server to discover modification to the state of the application. Another noticeable change is that the view uses different technology for implementation than the model or controller. Of course, we could use Java (or PERL, C/C++ or what ever) code to generate HTML. There are several disadvantages to that approach: • Java programmers should develop services, not HTML. • Changes to layout would require changes to code. • Customers of the service should be able to create pages to meet their specific needs. • The page designer isn't able to have direct involvement in page development. • HTML embedded into code is ugly. For the Web, the classical form of MVC needed to change. Figure 4 displays the Web adaptation of MVC, also commonly known as MVC Model 2 or MVC 2. The ActionServlet class Do you remember the days of function mappings? You would map some input event to a pointer to a function. If you where slick, you would place the configuration information into a file and load the file at run time. Function pointer arrays were the good old days of structured programming in C. Life is better now that we have Java technology, XML, J2EE, and all that. The Struts Controller is a servlet that maps events (an event generally being an HTTP post) to classes. And guess what -- the Controller uses a configuration file so you don_t have to hard-code the values. Life changes, but stays the same. ActionServlet is the Command part of the MVC implementation and is the core of the Framework. ActionServlet (Command) creates and uses Action, an ActionForm, and ActionForward. As mentioned earlier, the struts-config.xml file configures the Command. During the creation of the Web project, Action and ActionForm are extended to solve the specific problem space. The file struts-config.xml instructs ActionServlet on how to use the extended classes. There are several advantages to this approach: • The entire logical flow of the application is in a hierarchical text file. This makes it easier to view and understand, especially with large applications. • The page designer does not have to wade through Java code to understand the flow of the application. • The Java developer does not need to recompile code when making flow changes. Command functionality can be added by extending ActionServlet. The ActionForm class ActionForm maintains the session state for the Web application. ActionForm is an abstract class that is sub-classed for each input form model. When I say input form model, I am saying ActionForm represents a general concept of data that is set or updated by a HTML form. For instance, you may have a UserActionForm that is set by an HTML Form. The Struts framework will: • Check to see if a UserActionForm exists; if not, it will create an instance of the class. • Struts will set the state of the UserActionForm using corresponding fields from the HttpServletRequest. No more dreadful request.getParameter() calls. For instance, the Struts framework will take fname from request stream and call UserActionForm.setFname(). • The Struts framework updates the state of the UserActionForm before passing it to the business wrapper UserAction. • Before passing it to the Action class, Struts will also conduct form state validation by calling the validation() method on UserActionForm. Note: This is not always wise to do. There might be ways of using UserActionForm in other pages or business objects, where the validation might be different. Validation of the state might be better in the UserAction class. • The UserActionForm can be maintained at a session level. Notes: • The struts-config.xml file controls which HTML form request maps to which ActionForm. • Multiple requests can be mapped UserActionForm. • UserActionForm can be mapped over multiple pages for things such as wizards. The Action class The Action class is a wrapper around the business logic. The purpose of Action class is to translate the HttpServletRequest to the business logic. To use Action, subclass and overwrite the process() method. The ActionServlet (Command) passes the parameterized classes to ActionForm using the perform() method. Again, no more dreadful request.getParameter() calls. By the time the event gets here, the input form data (or HTML form data) has already been translated out of the request stream and into an ActionForm class. Struts, an MVC 2 implementation Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. This definition implies that Struts is a framework, rather than a library, but Struts also contains an extensive tag library and utility classes that work independently of the framework. Figure 5 displays an overview of Struts. Struts overview • Client browser An HTTP request from the client browser creates an event. The Web container will respond with an HTTP response. • Controller The Controller receives the request from the browser, and makes the decision where to send the request. With Struts, the Controller is a command design pattern implemented as a servlet. The struts-config.xml file configures the Controller. • Business logic The business logic updates the state of the model and helps control the flow of the application. With Struts this is done with an Action class as a thin wrapper to the actual business logic. • Model state The model represents the state of the application. The business objects update the application state. ActionForm bean represents the Model state at a session or request level, and not at a persistent level. The JSP file reads information from the ActionForm bean using JSP tags. • View The view is simply a JSP file. There is no flow logic, no business logic, and no model information -- just tags. Tags are one of the things that make Struts unique compared to other frameworks like Velocity. Note: "Think thin" when extending the Action class. The Action class should control the flow and not the logic of the application. By placing the business logic in a separate package or EJB, we allow flexibility and reuse. Another way of thinking about Action class is as the Adapter design pattern. The purpose of the Action is to "Convert the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn_t otherwise because of incompatibility interface" (from Design Patterns - Elements of Reusable OO Software by Gof). The client in this instance is the ActionServlet that knows nothing about our specific business class interface. Therefore, Struts provides a business interface it does understand, Action. By extending the Action, we make our business interface compatible with Struts business interface. (An interesting observation is that Action is a class and not an interface. Action started as an interface and changed into a class over time. Nothing's perfect.) The Error classes The UML diagram also included ActionError and ActionErrors. ActionError encapsulates an individual error message. ActionErrors is a container of ActionError classes that the View can access using tags. ActionErrors is Struts way of keeping up with a list of errors. The ActionMapping class An incoming event is normally in the form of an HTTP request, which the servlet Container turns into an HttpServletRequest. The Controller looks at the incoming event and dispatches the request to an Action class. The struts-config.xml determines what Action class the Controller calls. The struts-config.xml configuration information is translated into a set of ActionMapping, which are put into container of ActionMappings. (If you have not noticed it, classes that end with s are containers) The ActionMapping contains the knowledge of how a specific event maps to specific Actions. The ActionServlet (Command) passes the ActionMapping to the Action class via the perform() method. This allows Action to access the information to control flow. ActionMappings ActionMappings is a collection of ActionMapping objects. Struts pros • Use of JSP tag mechanism The tag feature promotes reusable code and abstracts Java code from the JSP file. This feature allows nice integration into JSP-based development tools that allow authoring with tags. • Tag library Why re-invent the wheel, or a tag library? If you cannot find something you need in the library, contribute. In addition, Struts provides a starting point if you are learning JSP tag technology. • Open source You have all the advantages of open source, such as being able to see the code and having everyone else using the library reviewing the code. Many eyes make for great code review. • Sample MVC implementation Struts offers some insight if you want to create your own MVC implementation. • Manage the problem space Divide and conquer is a nice way of solving the problem and making the problem manageable. Of course, the sword cuts both ways. The problem is more complex and needs more management. Struts cons • Youth Struts development is still in preliminary form. They are working toward releasing a version 1.0, but as with any 1.0 version, it does not provide all the bells and whistles. • Change The framework is undergoing a rapid amount of change. A great deal of change has occurred between Struts 0.5 and 1.0. You may want to download the most current Struts nightly distributions, to avoid deprecated methods. In the last 6 months, I have seen the Struts library grow from 90K to over 270K. I had to modify my examples several times because of changes in Struts, and I am not going to guarantee my examples will work with the version of Struts you download. • Correct level of abstraction Does Struts provide the correct level of abstraction? What is the proper level of abstraction for the page designer? That is the $64K question. Should we allow a page designer access to Java code in page development? Some frameworks like Velocity say no, and provide yet another language to learn for Web development. There is some validity to limiting Java code access in UI development. Most importantly, give a page designer a little bit of Java, and he will use a lot of Java. I saw this happen all the time in Microsoft ASP development. In ASP development, you were supposed to create COM objects and then write a little ASP script to glue it all together. Instead, the ASP developers would go crazy with ASP script. I would hear "Why wait for a COM developer to create it when I can program it directly with VBScript?" Struts helps limit the amount of Java code required in a JSP file via tag libraries. One such library is the Logic Tag, which manages conditional generation of output, but this does not prevent the UI developer from going nuts with Java code. Whatever type of framework you decide to use, you should understand the environment in which you are deploying and maintaining the framework. Of course, this task is easier said than done. • Limited scope Struts is a Web-based MVC solution that is meant be implemented with HTML, JSP files, and servlets. • J2EE application support Struts requires a servlet container that supports JSP 1.1 and Servlet 2.2 specifications. This alone will not solve all your install issues, unless you are using Tomcat 3.2. I have had a great deal of problems installing the library with Netscape iPlanet 6.0, which is supposedly the first J2EE-compliant application server. I recommend visiting the Struts User Mailing List archive (see Resources) when you run into problems. • Complexity Separating the problem into parts introduces complexity. There is no question that some education will have to go on to understand Struts. With the constant changes occurring, this can be frustrating at times. Welcome to the Web. • Where is... I could point out other issues, for instance, where are the client side validations, adaptable workflow, and dynamic strategy pattern for the controller? However, at this point, it is too easy to be a critic, and some of the issues are insignificant, or are reasonable for a 1.0 release. The way the Struts team goes at it, Struts might have these features by the time you read this article, or soon after. Future of Struts Things change rapidly in this new age of software development. In less than 5 years, I have seen things go from cgi/perl, to ISAPI/NSAPI, to ASP with VB, and now Java and J2EE. Sun is working hard to adapt changes to the JSP/servlet architecture, just as they have in the past with the Java language and API. You can obtain drafts of the new JSP 1.2 and Servlet 2.3 specifications from the Sun Web site. Additionally, a standard tag library for JSP files is appearing. 2:外文资料翻译译文 Struts——MVC 的一种开放源码实现 本文介绍 Struts,它是使用 servlet 和 JavaServer Pages 技术的一种 Model-View-Controller 实现。Struts 可帮助您控制 Web 项目中的变化并提高专业化水平。尽管您可能永远不会用 Struts 实现一个系统,但您可以将其中的一些思想用于您以后的 servlet 和 JSP 网页的实现中。 简介 小学生也可以在因特网上发布 HTML 网页。但是,小学生的网页和专业开发的网站有质的区别。网页设计人员(或者 HTML 开发人员)必须理解颜色、用户、生产流程、网页布局、浏览器兼容性、图像创建和 JavaScript 等等。设计漂亮的网站需要做大量的工作,大多数 Java 开发人员更注重创建优美的对象接口,而不是用户界面。JavaServer Pages (JSP) 技术为网页设计人员和 Java 开发人员提供了一种联系钮带。 如果您开发过大型 Web 应用程序,您就理解 变化 这个词的含义。“模型-视图-控制器”(MVC) 就是用来帮助您控制变化的一种设计模式。MVC 减弱了业务逻辑接口和数据接口之间的耦合。Struts 是一种 MVC 实现,它将 Servlet 2.2 和 JSP 1.1 标记(属于 J2EE 规范)用作实现的一部分。尽管您可能永远不会用 Struts 实现一个系统,但了解一下 Struts 或许使您能将其中的一些思想用于您以后的 Servlet 的 JSP 实现中。 模型-视图-控制器 (MVC) JSP 标记只解决了部分问题。我们还得处理验证、流程控制和更新应用程序的状态等问题。这正是 MVC 发挥作用的地方。MVC 通过将问题分为三个类别来帮助解决单一模块方法所遇到的某些问题: • Model(模型) 模型包含应用程序的核心功能。模型封装了应用程序的状态。有时它包含的唯一功能就是状态。它对视图或控制器一无所知。 • View(视图) 视图提供模型的表示。它是应用程序的 外观。视图可以访问模型的读方法,但不能访问写方法。此外,它对控制器一无所知。当更改模型时,视图应得到通知。 • Controller(控制器) 控制器对用户的输入作出反应。它创建并设置模型。 MVC Model 2 Web 向软件开发人员提出了一些特有的挑战,最明显的就是客户机和服务器的无状态连接。这种无状态行为使得模型很难将更改通知视图。在 Web 上,为了发现对应用程序状态的修改,浏览器必须重新查询服务器。 另一个重大变化是实现视图所用的技术与实现模型或控制器的技术不同。当然,我们可以使用 Java(或者 PERL、C/C++ 或别的语言)代码生成 HTML。这种方法有几个缺点: • Java 程序员应该开发服务,而不是 HTML。 • 更改布局时需要更改代码。 • 服务的用户应该能够创建网页来满足它们的特定需要。 • 网页设计人员不能直接参与网页开发。 • 嵌在代码中的 HTML 很难看。 对于 Web,需要修改标准的 MVC 形式。图 4 显示了 MVC 的 Web 改写版,通常也称为 MVC Model 2 或 MVC 2。 Struts,MVC 2 的一种实现 Struts 是一组相互协作的类、servlet 和 JSP 标记,它们组成一个可重用的 MVC 2 设计。这个定义表示 Struts 是一个框架,而不是一个库,但 Struts 也包含了丰富的标记库和独立于该框架工作的实用程序类。图 5 显示了 Struts 的一个概览。 Struts 概览 • Client browser(客户浏览器) 来自客户浏览器的每个 HTTP 请求创建一个事件。Web 容器将用一个 HTTP 响应作出响应。 • Controller(控制器) 控制器接收来自浏览器的请求,并决定将这个请求发往何处。就 Struts 而言,控制器是以 servlet 实现的一个命令设计模式。 struts-config.xml 文件配置控制器。 • 业务逻辑 业务逻辑更新模型的状态,并帮助控制应用程序的流程。就 Struts 而言,这是通过作为实际业务逻辑“瘦”包装的 Action 类完成的。 • Model(模型)的状态 模型表示应用程序的状态。业务对象更新应用程序的状态。ActionForm bean 在会话级或请求级表示模型的状态,而不是在持久级。JSP 文件使用 JSP 标记读取来自 ActionForm bean 的信息。 • View(视图) 视图就是一个 JSP 文件。其中没有流程逻辑,没有业务逻辑,也没有模型信息 -- 只有标记。标记是使 Struts 有别于其他框架(如 Velocity)的因素之一。 详细分析 Struts 图 6 显示的是 org.apache.struts.action 包的一个最简 UML 图。图 6 显示了 ActionServlet (Controller)、 ActionForm (Form State) 和 Action (Model Wrapper) 之间的最简关系。 ActionServlet 类 您还记得函数映射的日子吗?在那时,您会将某些输入事件映射到一个函数指针上。如果您对此比较熟悉,您会将配置信息放入一个文件,并在运行时加载这个文件。函数指针数组曾经是用 C 语言进行结构化编程的很好方法。 现在好多了,我们有了 Java 技术、XML、J2EE,等等。Struts 的控制器是将事件(事件通常是 HTTP post)映射到类的一个 servlet。正如您所料 -- 控制器使用配置文件以使您不必对这些值进行硬编码。时代变了,但方法依旧。 ActionServlet 是该 MVC 实现的 Command 部分,它是这一框架的核心。 ActionServlet (Command) 创建并使用 Action 、 ActionForm 和 ActionForward 。如前所述, struts-config.xml 文件配置该 Command。在创建 Web 项目时,您将扩展 Action 和 ActionForm 来解决特定的问题。文件 struts-config.xml 指示 ActionServlet 如何使用这些扩展的类。这种方法有几个优点: • 应用程序的整个逻辑流程都存储在一个分层的文本文件中。这使得人们更容易查看和理解它,尤其是对于大型应用程序而言。 • 网页设计人员不必费力地阅读 Java 代码来理解应用程序的流程。 • Java 开发人员也不必在更改流程以后重新编译代码。 可以通过扩展 ActionServlet 来添加 Command 功能。 ActionForm 类 ActionForm 维护 Web 应用程序的会话状态。 ActionForm 是一个抽象类,必须为每个输入表单模型创建该类的子类。当我说 输入表单模型 时,是指 ActionForm 表示的是由 HTML 表单设置或更新的一般意义上的数据。例如,您可能有一个由 HTML 表单设置的 UserActionForm 。Struts 框架将执行以下操作: • 检查 UserActionForm 是否存在;如果不存在,它将创建该类的一个实例。 • Struts 将使用 HttpServletRequest 中相应的域设置 UserActionForm 的状态。没有太多讨厌的 request.getParameter() 调用。例如,Struts 框架将从请求流中提取 fname ,并调用 UserActionForm.setFname() 。 • Struts 框架在将 UserActionForm 传递给业务包装 UserAction 之前将更新它的状态。 • 在将它传递给 Action 类之前,Struts 还会对 UserActionForm 调用 validation() 方法进行表单状态验证。 注: 这并不总是明智之举。别的网页或业务可能使用 UserActionForm ,在这些地方,验证可能有所不同。在 UserAction 类中进行状态验证可能更好。 • 可在会话级维护 UserActionForm 。 注: • struts-config.xml 文件控制 HTML 表单请求与 ActionForm 之间的映射关系。 • 可将多个请求映射到 UserActionForm 。 • UserActionForm 可跨多页进行映射,以执行诸如向导之类的操作。 Action 类 Action 类是业务逻辑的一个包装。 Action 类的用途是将 HttpServletRequest 转换为业务逻辑。要使用 Action ,请创建它的子类并覆盖 process() 方法。 ActionServlet (Command) 使用 perform() 方法将参数化的类传递给 ActionForm 。仍然没有太多讨厌的 request.getParameter() 调用。当事件进展到这一步时,输入表单数据(或 HTML 表单数据)已被从请求流中提取出来并转移到 ActionForm 类中。 注:扩展 Action 类时请注意简洁。 Action 类应该控制应用程序的流程,而不应该控制应用程序的逻辑。通过将业务逻辑放在单独的包或 EJB 中,我们就可以提供更大的灵活性和可重用性。 考虑 Action 类的另一种方式是 Adapter 设计模式。 Action 的用途是“将类的接口转换为客户机所需的另一个接口。Adapter 使类能够协同工作,如果没有 Adapter,则这些类会因为不兼容的接口而无法协同工作。”(摘自 Gof 所著的 Design Patterns - Elements of Reusable OO Software )。本例中的客户机是 ActionServlet ,它对我们的具体业务类接口一无所知。因此,Struts 提供了它能够理解的一个业务接口,即 Action 。通过扩展 Action ,我们使得我们的业务接口与 Struts 业务接口保持兼容。(一个有趣的发现是, Action 是类而不是接口)。 Action 开始为一个接口,后来却变成了一个类。真是金无足赤。) ActionMapping 类 输入事件通常是在 HTTP 请求表单中发生的,servlet 容器将 HTTP 请求转换为 HttpServletRequest 。控制器查看输入事件并将请求分派给某个 Action 类。 struts-config.xml 确定 Controller 调用哪个 Action 类。 struts-config.xml 配置信息被转换为一组 ActionMapping ,而后者又被放入 ActionMappings 容器中。(您可能尚未注意到这一点,以 s结尾的类就是容器) ActionMapping 包含有关特定事件如何映射到特定 Action 的信息。 ActionServlet (Command) 通过 perform() 方法将 ActionMapping 传递给 Action 类。这样就使 Action 可访问用于控制流程的信息。 ActionMappings ActionMappings 是 ActionMapping 对象的一个集合。 Struts 的优点 • JSP 标记机制的使用 标记特性从 JSP 文件获得可重用代码和抽象 Java 代码。这个特性能很好地集成到基于 JSP 的开发工具中,这些工具允许用标记编写代码。 • 标记库 为什么要另发明一种轮子,或标记库呢?如果您在库中找不到您所要的标记,那就自己定义吧。此外,如果您正在学习 JSP 标记技术,则 Struts 为您提供了一个起点。 • 开放源码 您可以获得开放源码的全部优点,比如可以查看代码并让使用库的每个人检查代码。许多人都可以进行很好的代码检查。 • MVC 实现样例 如果您希望创建您自己的 MVC 实现,则 Struts 可增加您的见识。 • 管理问题空间 分治是解决问题并使问题可管理的极好方法。当然,这是一把双刃剑。问题越来越复杂,并且需要越来越多的管理。 Struts 的缺点 • 仍处于发展初期 Struts 开发仍处于初级阶段。他们正在向着发行版本 1.0 而努力,但与任何 1.0 版本一样,它不可能尽善尽美。 • 仍在变化中 这个框架仍在快速变化。Struts 1.0 与 Struts 0.5 相比变化极大。为了避免使用不赞成使用的方法,您可能隔一天就需要下载最新的 Struts。在过去的 6 个月中,我目睹 Struts 库从 90K 增大到 270K 以上。由于 Struts 中的变化,我不得不数次修改我的示例,但我不保证我的示例能与您下载的 Struts 协同工作。 • 正确的抽象级别 Struts 是否提供了正确的抽象级别?对于网页设计人员而言,什么是正确的抽象级别呢?这是一个用 $64K 的文字才能解释清楚的问题。在开发网页的过程中,我们是否应该让网页设计人员访问 Java 代码?某些框架(如 Velocity)说不应该,但它提供了另一种 Web 开发语言让我们学习。在 UI 开发中限制访问 Java 有一定的合理性。最重要的是,如果让网页设计人员使用一点 Java,他将使用大量的 Java。在 Microsoft ASP 的开发中,我总是看到这样的情况。在 ASP 开发中,您应该创建 COM 对象,然后编写少量的 ASP 脚本将这些 COM 对象联系起来。但是,ASP 开发人员会疯狂地使用 ASP 脚本。我会听到这样的话,“既然我可以用 VBScript 直接编写 COM 对象,为什么还要等 COM 开发人员来创建它呢?”通过使用标记库,Struts 有助于限制 JSP 文件中所需的 Java 代码的数量。Logic Tag 就是这样的一种库,它对有条件地生成输出进行管理,但这并不能阻止 UI 开发人员对 Java 代码的狂热。无论您决定使用哪种类型的框架,您都应该了解您要在其中部署和维护该框架的环境。当然,这项任务真是说起来容易做起来难。 • 有限的适用范围 Struts 是一种基于 Web 的 MVC 解决方案,所以必须用 HTML、JSP 文件和 servlet 来实现它。 • J2EE 应用程序支持 Struts 需要支持 JSP 1.1 和 Servlet 2.2 规范的 servlet 容器。仅凭这一点远不能解决您的全部安装问题,除非使用 Tomcat 3.2。我用 Netscape iPlanet 6.0 安装这个库时遇到一大堆问题,按理说它是第一种符合 J2EE 的应用程序服务器。我建议您在遇到问题时访问 Struts 用户邮件列表的归档资料。 • 复杂性 在将问题分为几个部分的同时也引入了复杂性。毫无疑问,要理解 Struts 必须接受一定的培训。随着变化的不断加入,这有时会令人很沮丧。欢迎访问本网站。 Struts 的前景 在这个软件开发的新时代,一切都变得很快。在不到 5 年的时间内,我已经目睹了从 cgi/perl 到 ISAPI/NSAPI、再到使用 VB 的 ASP、一直到现在的 Java 和 J2EE 的变迁。Sun 正在尽力将新的变化反映到 JSP/servlet 体系结构中,正如他们对 Java 语言和 API 所作的更改一样。您可以从 Sun 的网站获得新的 JSP 1.2 和 Servlet 2.3 规范的草案。此外,一个标准 JSP 标记库即将出现。 3:外文出处 [1]Malcolm Davis. Struts——an open-source MVC implementation [2]IBM System Journal,2006
"No such native application net.downloadhelper.coapp" 这个错误信息是指没有找到名为"net.downloadhelper.coapp"的本地应用程序。这个错误信息可能出现在某些软件或浏览器扩展中,表示该应用程序未安装或未配置正确。 要解决这个问题,可以尝试以下几个步骤: 1. 检查应用程序是否正确安装:确定您是否已正确安装了应用程序或浏览器扩展。有时,这些应用程序可能需要手动安装,您可以查看相关文档或官方网站以获取安装说明。 2. 更新应用程序:确保您使用的是最新版本的应用程序。有时,旧版本的应用程序可能不再受支持或存在一些已知的问题。可以检查官方网站或应用商店,查看是否有可用的更新版本。 3. 重新安装应用程序:如果您已经确定应用程序已经安装,并且仍然出现这个错误信息,那么尝试卸载并重新安装应用程序可能会解决问题。在重新安装之前,确保备份任何重要的数据或设置,以防数据丢失。 4. 检查其他冲突应用程序:某些应用程序可能会冲突,导致其他应用程序无法正常运行。您可以尝试关闭或卸载与该错误相关的其他应用程序,然后重新启动设备,看看问题是否得到解决。 如果尝试了上述方法仍无法解决问题,建议您联系应用程序的支持团队或寻求专业技术人员的帮助。他们可能更熟悉该应用程序,并能提供更具体的解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值