Chinaunix首页 | 论坛 | 博客
  • 博客访问: 64518
  • 博文数量: 10
  • 博客积分: 728
  • 博客等级: 下士
  • 技术积分: 235
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-13 13:17
文章存档

2012年(10)

分类: 嵌入式

2012-06-20 17:10:01

一、建立开发板相关的目录/文件

  1. $ tar -xjf u-boot-1.1.6.tar.bz2
  2. $ cd u-boot-1.1.6/board
  3. $ cp -r smdk2410 100ask24x0
  4. $ cd 100ask24x0
  5. $ mv smdk2410.c 100ask24x0.c
  6. $ cd ../../include/configs
  7. $ cp smdk2410.h 100ask24x0.h
二、修改 Makefile 文件
1.修改顶层 Makefile 文件,在其中加入下面2行:

  1. 100ask24x0_config : unconfig
  2. @$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0
2.修改 board/100ask24x0/Makefile 

  1. COBJS := 100ask24x0.o flash.o
  2. SOBJS := lowlevel_init.o
3.初次编译

  1. $ make 100ask24x0_config
  2. $ make
编译成功的话,顶层目录下面就有 u-boot.bin 等文件了。最重要的是,这说明我们的交叉编译工具链已经没有问题了。
三、增加2个新文件
1.新建文件 u-boot-1.1.6/board/100ask24x0/boot_init.c(参考u-boot-1.1.6_jz2440/board/100ask24x0/boot_init.c)
2.修改 u-boot-1.1.6/board/100ask24x0/Makefile

  1. COBJS := 100ask24x0.o flash.o
  2. 改为
  3. COBJS := 100ask24x0.o boot_init.o
3.修改 u-boot-1.1.5/board/100ask24x0/u-boot.lds

  1. cpu/arm920t/start.o(.text)
  2.  board/100ask24x0/boot_init.(.text)
  3.    *(.text)
4.新建文件 u-boot-1.1.6/cpu/arm920t/s3c24x0/nand_flash.c(参考u-boot-1.1.6_jz2440/cpu/arm920t/s3c24x0/nand_flash.c)
5.修改 u-boot-1.1.6/cpu/arm920t/s3c24x0/Makefile

  1. COBJS= i2c.o interrupts.o serial.o speed.o \
  2.  usb_ohci.o nand_flash.o
四、修改 u-boot-1-1.6/board/100ask24x0/lowlevel_init.S 文件
1.将54-58行的:

  1. #define B1_BWSCON (DW32)
  2. #define B2_BWSCON (DW16)
  3. #define B3_BWSCON (DW16 + WAIT + UBLB)
  4. #define B4_BWSCON (DW16)
  5. #define B5_BWSCON (DW16)
  6. 改为
  7. #define B1_BWSCON (DW16)
  8. #define B2_BWSCON (DW16)
  9. #define B3_BWSCON (DW16 +UBLB)
  10. #define B4_BWSCON (DW16 + WAIT + UBLB)
  11. #define B5_BWSCON (DW8)
2.将97-101行的:

  1. #define B4_Tcos0x0/* 0clk */
  2. #define B4_Tacc 0x7/* 14clk */
  3. #define B4_Tcoh 0x0/* 0clk */
  4. #define B4_Tah 0x0/* 0clk */
  5. #define B4_Tacp 0x0
  6. 改为
  7. #define B4_Tcos0x3/* 4clk */
  8. #define B4_Tacc 0x7/* 14clk */
  9. #define B4_Tcoh 0x1/* 1clk */
  10. #define B4_Tah 0x3/* 4clk */
  11. #define B4_Tacp 0x6 /* 6clk */
3.将126行的:

  1. #define REFCNT1113/* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */
  2. 改为
  3. #define REFCNT0x4f4/* period=7.8125us, HCLK=100Mhz, (2048+1-7.8125*100) */
4.将165行的:

  1. .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
  2. .word 0x32
  3. .word 0x30
  4. 改为
  5. .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
  6. .word 0xb1
  7. .word 0x30
五、修改 u-boot-1.1.6/board/100ask24x0/100ask24x0.c

  1. #include <common.h>
  2. #include <s3c2410.h>
  3. DECLARE_GLOBAL_DATA_PTR;
  4. /*
  5.  * Miscellaneous platform dependent initialisations
  6.  */
  7. int board_init (void)
  8. {
  9. S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
  10. S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

  11. /* set up the I/O ports */
  12. gpio->GPACON = 0x007FFFFF;
  13. gpio->GPBCON = 0x00000000;
  14. gpio->GPBUP = 0x00000000; /* 启用上拉电阻 */
  15.     //gpio->GPBDAT |= (<< 5);
  16. gpio->GPCCON = 0xAAAAAAAA;
  17. gpio->GPCUP = 0x0000FFFF;
  18. gpio->GPDCON = 0xAAAAAAAA;
  19. gpio->GPDUP = 0x0000FFFF;
  20. gpio->GPECON = 0xAAAAAAAA;
  21. gpio->GPEUP = 0x0000FFFF;
  22. gpio->GPFCON = 0x000055AA;
  23. gpio->GPFUP = 0x000000FF;
  24. gpio->GPGCON = 0xFF95FFBA;
  25. gpio->GPGUP = 0x0000FFFF;
  26. gpio->GPHCON = 0x002AFAAA;
  27. gpio->GPHUP = 0x000007FF;
  28.     /* support both of S3C2410 and S3C2440, by www.100ask.net */
  29.     if (isS3C2410)
  30.     {
  31.         /* arch number of SMDK2410-Board */
  32.         gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
  33.     }
  34.     else
  35.     {
  36.         /* arch number of SMDK2440-Board */
  37.         gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
  38.     }
  39.    /* adress of boot parameters */
  40. gd->bd->bi_boot_params = 0x30000100;
  41. #if 0
  42. icache_enable();
  43. dcache_enable();
  44. #endif
  45. return 0;
  46. }

  47. int dram_init (void)
  48. {
  49. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  50. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  51. return 0;
  52. }
六、修改 u-boot-1.1.6/cpu/arm920t/s3c24x0/interrupts.c(copy自jz2440)
七、修改 u-boot-1.1.6/cpu/arm920t/s3c24x0/speed.c(copy自jz2440)
八、修改 u-boot-1.1.6/include/cmd_confdefs.h

  1. //#define CFG_CMD_FLASH0x00000020ULL/* flinfo, erase, protect*/
  2. //#define CFG_CMD_IMLS0x0020000000000000ULL/* List all found images*/
九、修改 u-boot-1.1.6/cpu/arm920t/start.S
1.注释掉时钟频率的初始化(其初始化放在堆栈建立后的 C 代码中)

  1. #if 0
  2. /* FCLK:HCLK:PCLK = 1:2:4 */
  3. /* default FCLK is 120 MHz ! */
  4. ldr r0, =CLKDIVN
  5. mov r1, #3
  6. str r1, [r0]
  7. #endif
2.把建立堆栈代码放在重定位(relocate)代码前,以使用 C 代码来完成重定位的工作

  1. /*
  2. * we do sys-critical inits only at reboot,
  3. * not when booting from ram!
  4. */
  5. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  6. bl cpu_init_crit
  7. #endif
  8. /* Set up the stack */
  9. stack_setup:
  10. ldr r0, _TEXT_BASE/* upper 128 KiB: relocated uboot */
  11. sub r0, r0, #CFG_MALLOC_LEN/* malloc area */
  12. sub r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo */
  13. #ifdef CONFIG_USE_IRQ
  14. sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
  15. #endif
  16. sub sp, r0, #12/* leave 3 words for abort-stack */
  17. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  18. bl clock_init /* ± */
  19. #endif
  20. #ifndef CONFIG_SKIP_RELOCATE_UBOOT
  21. relocate: /* relocate U-Boot to RAM */
  22. adr r0, _start/* r0 <- current position of code */
  23. ldr r1, _TEXT_BASE/* test if we run from flash or RAM */
  24. cmp r0, r1 /* don't reloc during debug */
  25. beq clear_bss
  26. ldr r2, _armboot_start
  27. ldr r3, _bss_start
  28. sub r2, r3, r2/* r2 <- size of armboot */
  29. #if 1
  30. bl CopyCode2Ram/* r0:source, r1:dest, r2:size */
  31. #else
  32. add r2, r0, r2/* r2 <- source end address */
  33. copy_loop:
  34. ldmia r0!, {r3-r10}/* copy from source address [r0] */
  35. stmia r1!, {r3-r10}/* copy to target address [r1] */
  36. cmp r0, r2/* until source end addreee [r2] */
  37. ble copy_loop
  38. #endif
  39. #endif /* CONFIG_SKIP_RELOCATE_UBOOT */
  40. clear_bss:
  41. ldr r0, _bss_start/* find start of bss segment */
  42. ldr r1, _bss_end/* stop here */
  43. mov r2, #0x00000000/* clear */
  44. clbss_l:str r2, [r0]/* clear loop... */
  45. add r0, r0, #4
  46. cmp r0, r1
  47. ble clbss_l
  48. SetLoadFlag:
  49. /* Set a global flag, PreLoadedONRAM */
  50. adr r0, _start/* r0 <- current position of code */
  51. ldr r1, _TEXT_BASE/* test if we run from flash or RAM */
  52. cmp r0, r1 /* don't reloc during debug */
  53. ldr r2, =PreLoadedONRAM
  54. mov r3, #1
  55. streq r3, [r2]
  56. #if 0
  57. /* try doing this stuff after the relocation */
  58. ldr r0, =pWTCON
  59. mov r1, #0x0
  60. str r1, [r0]
十、修改 u-boot-1.1.6/include/configs/100ask24x0.h
1.为支持 DM9000 网卡,将

  1. #define CONFIG_DRIVER_CS89001/* we have a CS8900 on-board */
  2. #define CS8900_BASE 0x19000300
  3. #define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */
  4. 改为
  5. //#define CONFIG_DRIVER_CS89001/* we have a CS8900 on-board */
  6. //#define CS8900_BASE 0x19000300
  7. //#define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */
  8. #define CONFIG_DRIVER_DM90001
  9. #define CONFIG_DM9000_BASE 0x20000300
  10. #define DM9000_IO CONFIG_DM9000_BASE
  11. #define DM9000_DATA (CONFIG_DM9000_BASE + 4)
  12. #define CONFIG_DM9000_USE_16BIT
2.增加 NAND 命令和 ping 命令,将

  1. /*CFG_CMD_NAND|*/ \
  2. 改为
  3.             CFG_CMD_PING| \
  4. CFG_CMD_NAND | \
3.设置 IP,将

  1. /*#define CONFIG_ETHADDR08:00:3e:26:0a:5b */
  2. #define CONFIG_NETMASK 255.255.255.0
  3. #define CONFIG_IPADDR 10.0.0.110
  4. #define CONFIG_SERVERIP 10.0.0.1
  5. 改为
  6. #define CONFIG_ETHADDR08:00:3e:26:0a:5b
  7. #define CONFIG_NETMASK 255.255.255.0
  8. #define CONFIG_IPADDR 192.168.1.7
  9. #define CONFIG_SERVERIP 192.168.1.6
4.将

  1. #define CFG_FLASH_BASEPHYS_FLASH_1
  2. 改为
  3. #define CFG_FLASH_BASEPHYS_FLASH_1
  4. #define CFG_MONITOR_BASE PHYS_FLASH_1
5.NOR FLASH的设置,将

  1. #define CONFIG_AMD_LV4001/* uncomment this if you have a LV400 flash */
  2. #if 0
  3. #define CONFIG_AMD_LV800 1/* uncomment this if you have a LV800 flash */
  4. #endif
  5. 改为
  6. #define CFG_NO_FLASH1/* 我的 FL2440 没有 NOR Flash */
  7. #if 0
  8. #define CONFIG_AMD_LV400 1/* uncomment this if you have a LV400 flash */
  9. #endif
  10. //#define CONFIG_AMD_LV800 1/* uncomment this if you have a LV800 flash */
6.把最后几行

  1. /* timeout values are in ticks */
  2. #define CFG_FLASH_ERASE_TOUT (5*CFG_HZ) /* Timeout for Flash Erase */
  3. #define CFG_FLASH_WRITE_TOUT (5*CFG_HZ) /* Timeout for Flash Write */
  4. #define CFG_ENV_IS_IN_FLASH1
  5. #define CFG_ENV_SIZE 0x10000/* Total Size of Environment Sector */
  6. #endif /* __CONFIG_H */
  7. 改为
  8. /* 增加对 NOR FLASH 的支持 */
  9. /*
  10. #define CFG_FLASH_CFI 1
  11. #define CFG_FLASH_CFI_DRIVER 1
  12. #define CFG_FLASH_USE_BUFFER_WRITE 1
  13. #define CONFIG_FLASH_CFI_LEGACY 1
  14. */
  15. #ifdef CFG_FLASH_CFI_DRIVER
  16. #define CFG_MAX_FLASH_SECT 512 /* max number of sectors on one chip */
  17. #define CFG_FLASH_CFI_WIDTH 0x02 /* FLASH_CFI_16BIT */
  18. #endif
  19. /* timeout values are in ticks */
  20. #define CFG_FLASH_ERASE_TOUT (5*CFG_HZ) /* Timeout for Flash Erase */
  21. #define CFG_FLASH_WRITE_TOUT (5*CFG_HZ) /* Timeout for Flash Write */
  22. //#define CFG_ENV_IS_IN_FLASH1
  23. #define CFG_ENV_IS_IN_NAND 1
  24. #define CFG_ENV_OFFSET 0x40000
  25. #define CFG_ENV_SIZE 0x20000/* Total Size of Environment Sector */
  26. /*-----------------------------------------------------------------------
  27. * NAND flash settings
  28. */
  29. #define CFG_NAND_BASE 0
  30. #define CFG_MAX_NAND_DEVICE 1
  31. #define NAND_MAX_CHIPS 1
  32. #endif /* __CONFIG_H */
十一、修改 u-boot-1.1.6/lib_arm/board.c
1.增加头文件

  1. #include
  2. #include
2.变量声明,只是为了点灯方便

  1. void start_armboot (void)
  2. {
  3.     S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
  4. init_fnc_t **init_fnc_ptr;
3.初始化完后点灯

  1. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  2. if ((*init_fnc_ptr)() != 0) {
  3. hang ();
  4. }
  5. }
  6.     /* 点亮 LED1,LED2 */
  7.     gpio->GPBCON = 0x00001400;
  8.     
  9. //#ifndef CFG_NO_FLASH
  10. #if 0
  11. /* configure available FLASH banks */
  12. size = flash_init ();
4.初始化 NAND FLASH 后点灯

  1. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  2. puts ("NAND: ");
  3. nand_init(); /* go init the NAND */
  4. #endif

  5.     /* 点亮 LED2,LED3 */
  6.     gpio->GPBCON = 0x00011000;
5.进入 main_loop 前点灯

  1. /* 点亮 LED3,LED4 */
  2.     gpio->GPBCON = 0x00110000;

  3. /* main_loop() can return to retry autoboot, if so just run it again. */
  4. for (;;) {
  5. main_loop ();
  6. }
十二、修改 u-boot-1.1.6/include/s3c2410.h
1.在100行增加函数定义

  1. /* for s3c2440, www.100ask.net */
  2. static inline S3C2440_NAND * const S3C2440_GetBase_NAND(void)
  3. {
  4.     return (S3C2440_NAND * const)S3C2410_NAND_BASE;
  5. }
2.在151行增加

  1. /* add by thisway.diy */
  2. #define _ISR_STARTADDRESS ((unsigned)isr_handle_array)

  3. #define ISR_EINT0_OFT 0
  4. #define ISR_EINT1_OFT 1
  5. #define ISR_EINT2_OFT 2
  6. #define ISR_EINT3_OFT 3
  7. #define ISR_EINT4_7_OFT 4
  8. #define ISR_EINT8_23_OFT 5
  9. #define ISR_NOTUSED6_OFT 6
  10. #define ISR_BAT_FLT_OFT 7
  11. #define ISR_TICK_OFT 8
  12. #define ISR_WDT_OFT 9
  13. #define ISR_TIMER0_OFT 10
  14. #define ISR_TIMER1_OFT 11
  15. #define ISR_TIMER2_OFT 12
  16. #define ISR_TIMER3_OFT 13
  17. #define ISR_TIMER4_OFT 14
  18. #define ISR_UART2_OFT 15
  19. #define ISR_LCD_OFT 16
  20. #define ISR_DMA0_OFT 17
  21. #define ISR_DMA1_OFT 18
  22. #define ISR_DMA2_OFT 19
  23. #define ISR_DMA3_OFT 20
  24. #define ISR_SDI_OFT 21
  25. #define ISR_SPI0_OFT 22
  26. #define ISR_UART1_OFT 23
  27. #define ISR_NOTUSED24_OFT 24
  28. #define ISR_USBD_OFT 25
  29. #define ISR_USBH_OFT 26
  30. #define ISR_IIC_OFT 27
  31. #define ISR_UART0_OFT 28
  32. #define ISR_SPI1_OFT 29
  33. #define ISR_RTC_OFT 30
  34. #define ISR_ADC_OFT 31
  35. 3.将197行的
  36. #define BIT_WDT(0x1<<9)
  37. 改为
  38. #define BIT_WDT_AC97(0x1<<9)
  39. 4.删除221行的宏定义
  40. #define ClearPending(bit) {\
  41. rSRCPND = bit;\
  42. rINTPND = bit;\
  43. rINTPND;\
  44. }
十三、修改 u-boot-1.1.6/include/s3c24x0.h
1.在128行后且在结构体 S3C24X0_CLOCK_POWER 以内增加

  1. S3C24X0_REG32 CAMDIVN; /* for s3c2440, by www.100ask.net */
2.在167行增加

  1. /* NAND FLASH (see S3C2440 manual chapter 6, www.100ask.net) */
  2. typedef struct {
  3.     S3C24X0_REG32 NFCONF;
  4.     S3C24X0_REG32 NFCONT;
  5.     S3C24X0_REG32 NFCMD;
  6.     S3C24X0_REG32 NFADDR;
  7.     S3C24X0_REG32 NFDATA;
  8.     S3C24X0_REG32 NFMECCD0;
  9.     S3C24X0_REG32 NFMECCD1;
  10.     S3C24X0_REG32 NFSECCD;
  11.     S3C24X0_REG32 NFSTAT;
  12.     S3C24X0_REG32 NFESTAT0;
  13.     S3C24X0_REG32 NFESTAT1;
  14.     S3C24X0_REG32 NFMECC0;
  15.     S3C24X0_REG32 NFMECC1;
  16.     S3C24X0_REG32 NFSECC;
  17.     S3C24X0_REG32 NFSBLK;
  18.     S3C24X0_REG32 NFEBLK;
  19. } /*__attribute__((__packed__))*/ S3C2440_NAND;
3.在474行后,S3C24X0_GPIO 结构体内增加

  1. /* s3c2440 */
  2.     S3C24X0_REG32 res9[4];
  3.     S3C24X0_REG32 GPJCON;
  4.     S3C24X0_REG32 GPJDAT;
  5.     S3C24X0_REG32 GPJUP;
4.在结尾处增加两行

  1. #endif

  2. #define rGSTATUS1 (*(volatile unsigned *)0x560000B0)
  3. #define isS3C2410 ((rGSTATUS1 & 0xffff0000) == 0x32410000)

  4. #endif /*__S3C24X0_H__*/

阅读(2498) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~