CubieBoard中文论坛

 找回密码
 立即注册
搜索
热搜: unable
查看: 11330|回复: 5

大家一起玩U-boot DIY

[复制链接]
发表于 2013-6-22 10:38:16 | 显示全部楼层 |阅读模式
本帖最后由 tll 于 2013-8-5 20:10 编辑

本帖子欢迎大家来回复提供更多diy教程,提供教程有分哦
先上我的DIY作品(想试的看教程3):
  1. U-Boot 2013.07-rc1 (Jun 21 2013 - 20:44:00) TonyLianLong Software(亮点1)
  2. QQ:1040424979(亮点2)

  3. CPU:   TLL A10 CPU(亮点3)
  4. Board: TLL board(亮点4)
  5. I2C:   ready
  6. DRAM:  1 GiB
  7. MMC:   SUNXI SD/MMC: 0
  8. In:    serial
  9. Out:   serial
  10. Err:   serial
  11. Net:   emac
  12. Hit any key to stop autoboot:  0
  13. sun4i#version

  14. U-Boot 2013.07-rc1 (Jun 21 2013 - 20:44:00) TonyLianLong Software
  15. QQ:1040424979(这也是)
  16. arm-linux-gnueabi-gcc (Ubuntu/Linaro 4.7.1-5ubuntu1~ppa1) 4.7.1
  17. GNU ld (GNU Binutils for Ubuntu) 2.22.52.20120713
复制代码
教程0,下载uboot源码:
这里从http://www.tonylianlong.com下载,TLL提供技术和空间支持
  1. wget http://www.tonylianlong.com/file/2013-6-21/u-boot-sunxi.zip
  2. unzip u-boot-sunxi
  3. cd u-boot-sunxi
复制代码
教程1,添加驱动(以NAND为例):
A 一个一个添加:
  1. nano include/config_cmd_default.h
复制代码
然后在里面(#endif前)添加:
  1. #define CONFIG_CMD_NAND
复制代码
即可
提供驱动表,按照上面的方式,只不过是要把CONFIG_CMD_NAND替换成你要的:
  1. The default command configuration includes all commands
  2.                 except those marked below with a "*".

  3. 不带*的是必须的

  4.                 CONFIG_CMD_ASKENV        * ask for env variable
  5.                 CONFIG_CMD_BDI                  bdinfo
  6.                 CONFIG_CMD_BEDBUG        * Include BedBug Debugger
  7.                 CONFIG_CMD_BMP                * BMP support
  8.                 CONFIG_CMD_BSP                * Board specific commands
  9.                 CONFIG_CMD_BOOTD          bootd
  10.                 CONFIG_CMD_CACHE        * icache, dcache
  11.                 CONFIG_CMD_CONSOLE          coninfo
  12.                 CONFIG_CMD_CRC32        * crc32
  13.                 CONFIG_CMD_DATE                * support for RTC, date/time...
  14.                 CONFIG_CMD_DHCP                * DHCP support
  15.                 CONFIG_CMD_DIAG                * Diagnostics
  16.                 CONFIG_CMD_DS4510        * ds4510 I2C gpio commands
  17.                 CONFIG_CMD_DS4510_INFO        * ds4510 I2C info command
  18.                 CONFIG_CMD_DS4510_MEM        * ds4510 I2C eeprom/sram commansd
  19.                 CONFIG_CMD_DS4510_RST        * ds4510 I2C rst command
  20.                 CONFIG_CMD_DTT                * Digital Therm and Thermostat
  21.                 CONFIG_CMD_ECHO                  echo arguments
  22.                 CONFIG_CMD_EDITENV          edit env variable
  23.                 CONFIG_CMD_EEPROM        * EEPROM read/write support
  24.                 CONFIG_CMD_ELF                * bootelf, bootvx
  25.                 CONFIG_CMD_ENV_CALLBACK        * display details about env callbacks
  26.                 CONFIG_CMD_ENV_FLAGS        * display details about env flags
  27.                 CONFIG_CMD_EXPORTENV        * export the environment
  28.                 CONFIG_CMD_EXT2                * ext2 command support
  29.                 CONFIG_CMD_EXT4                * ext4 command support
  30.                 CONFIG_CMD_SAVEENV          saveenv
  31.                 CONFIG_CMD_FDC                * Floppy Disk Support
  32.                 CONFIG_CMD_FAT                * FAT command support
  33.                 CONFIG_CMD_FDOS                * Dos diskette Support
  34.                 CONFIG_CMD_FLASH          flinfo, erase, protect
  35.                 CONFIG_CMD_FPGA                  FPGA device initialization support
  36.                 CONFIG_CMD_FUSE                  Device fuse support
  37.                 CONFIG_CMD_GETTIME        * Get time since boot
  38.                 CONFIG_CMD_GO                * the 'go' command (exec code)
  39.                 CONFIG_CMD_GREPENV        * search environment
  40.                 CONFIG_CMD_HASH                * calculate hash / digest
  41.                 CONFIG_CMD_HWFLOW        * RTS/CTS hw flow control
  42.                 CONFIG_CMD_I2C                * I2C serial bus support
  43.                 CONFIG_CMD_IDE                * IDE harddisk support
  44.                 CONFIG_CMD_IMI                  iminfo
  45.                 CONFIG_CMD_IMLS                  List all images found in NOR flash
  46.                 CONFIG_CMD_IMLS_NAND          List all images found in NAND flash
  47.                 CONFIG_CMD_IMMAP        * IMMR dump support
  48.                 CONFIG_CMD_IMPORTENV        * import an environment
  49.                 CONFIG_CMD_INI                * import data from an ini file into the env
  50.                 CONFIG_CMD_IRQ                * irqinfo
  51.                 CONFIG_CMD_ITEST          Integer/string test of 2 values
  52.                 CONFIG_CMD_JFFS2        * JFFS2 Support
  53.                 CONFIG_CMD_KGDB                * kgdb
  54.                 CONFIG_CMD_LDRINFO          ldrinfo (display Blackfin loader)
  55.                 CONFIG_CMD_LINK_LOCAL        * link-local IP address auto-configuration
  56.                                           (169.254.*.*)
  57.                 CONFIG_CMD_LOADB          loadb
  58.                 CONFIG_CMD_LOADS          loads
  59.                 CONFIG_CMD_MD5SUM          print md5 message digest
  60.                                           (requires CONFIG_CMD_MEMORY and CONFIG_MD5)
  61.                 CONFIG_CMD_MEMINFO        * Display detailed memory information
  62.                 CONFIG_CMD_MEMORY          md, mm, nm, mw, cp, cmp, crc, base,
  63.                                           loop, loopw
  64.                 CONFIG_CMD_MEMTEST          mtest
  65.                 CONFIG_CMD_MISC                  Misc functions like sleep etc
  66.                 CONFIG_CMD_MMC                * MMC memory mapped support
  67.                 CONFIG_CMD_MII                * MII utility commands
  68.                 CONFIG_CMD_MTDPARTS        * MTD partition support
  69.                 CONFIG_CMD_NAND                * NAND support
  70.                 CONFIG_CMD_NET                  bootp, tftpboot, rarpboot
  71.                 CONFIG_CMD_PCA953X        * PCA953x I2C gpio commands
  72.                 CONFIG_CMD_PCA953X_INFO * PCA953x I2C gpio info command
  73.                 CONFIG_CMD_PCI                * pciinfo
  74.                 CONFIG_CMD_PCMCIA                * PCMCIA support
  75.                 CONFIG_CMD_PING                * send ICMP ECHO_REQUEST to network
  76.                                           host
  77.                 CONFIG_CMD_PORTIO        * Port I/O
  78.                 CONFIG_CMD_READ                * Read raw data from partition
  79.                 CONFIG_CMD_REGINFO        * Register dump
  80.                 CONFIG_CMD_RUN                  run command in env variable
  81.                 CONFIG_CMD_SANDBOX        * sb command to access sandbox features
  82.                 CONFIG_CMD_SAVES        * save S record dump
  83.                 CONFIG_CMD_SCSI                * SCSI Support
  84.                 CONFIG_CMD_SDRAM        * print SDRAM configuration information
  85.                                           (requires CONFIG_CMD_I2C)
  86.                 CONFIG_CMD_SETGETDCR          Support for DCR Register access
  87.                                           (4xx only)
  88.                 CONFIG_CMD_SF                * Read/write/erase SPI NOR flash
  89.                 CONFIG_CMD_SHA1SUM          print sha1 memory digest
  90.                                           (requires CONFIG_CMD_MEMORY)
  91.                 CONFIG_CMD_SOFTSWITCH        * Soft switch setting command for BF60x
  92.                 CONFIG_CMD_SOURCE          "source" command Support
  93.                 CONFIG_CMD_SPI                * SPI serial bus support
  94.                 CONFIG_CMD_TFTPSRV        * TFTP transfer in server mode
  95.                 CONFIG_CMD_TFTPPUT        * TFTP put command (upload)
  96.                 CONFIG_CMD_TIME                * run command and report execution time (ARM specific)
  97.                 CONFIG_CMD_TIMER        * access to the system tick timer
  98.                 CONFIG_CMD_USB                * USB support
  99.                 CONFIG_CMD_CDP                * Cisco Discover Protocol support
  100.                 CONFIG_CMD_MFSL                * Microblaze FSL support
复制代码
提示:适合cb的网络驱动官方没有,我看见论坛里好像有个教程帖子可以弄

B 直接把所有驱动和命令都弄上:
在源码包里:
  1. cd include
  2. cp config_cmd_all.h config_cmd_default.h
  3. cp config_cmd_all.h config_cmd_defaults.h
  4. cd ..
复制代码
然后编译试试~
提示:如果不想要全部驱动,可以编辑 include/config_cmd_default.h


教程2 编译:
  1. make cubieboard CROSS_COMPILE=arm-linux-gnueabi-
  2. dd if=spl/sunxi-spl.bin of=/dev/sdb bs=1024 seek=8
  3. dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32
复制代码
/dev/sdb是你的卡的号

教程3 DIY:
亮点1和2:
修改 include/configs/sunxi-common.h文件里面的
  1. #define CONFIG_IDENT_STRING                " Allwinner Technology"
复制代码
我改成
  1. #define CONFIG_IDENT_STRING " TonyLianLong Software\nQQ:1040424979"
复制代码
可以用搜索功能,nano里的CTRL+W
提示\n是换行
亮点3,4:
修改board/sunxi/board.c
  1. int checkboard(void)
  2. {
  3. printf("Board: %s\n", CONFIG_SYS_BOARD_NAME);
  4.         return 0;
  5. }
复制代码
  1. int checkboard(void)
  2. {
  3.         //printf("Board: %s\n", CONFIG_SYS_BOARD_NAME);
  4.         printf("Board: TLL board\n"); //改你要的
  5.         return 0;
  6. }
复制代码
修改
  1. void spl_display_print(void)
  2. {
  3. printf("Board: %s\n", CONFIG_SYS_BOARD_NAME);
  4. }
复制代码
  1. void spl_display_print(void)
  2. {
  3.         //printf("Board: %s\n", CONFIG_SYS_BOARD_NAME);
  4.         printf("Board: TLL board\n");
  5. }
复制代码
把要删掉的东西打上注释是个好习惯

然后改arch/arm/cpu/armv7/sunxi/cpu_info.c
把print_cpuinfo函数改成这样:
  1. int print_cpuinfo(void)
  2. {
  3. #ifdef CONFIG_SUN4I
  4.         puts("CPU:   TLL A10 CPU\n"); //改这有用,如果用cubieboard的配置编译
  5. #elif defined CONFIG_SUN5I
  6.         /* TODO: Distinguish A13/A10s */
  7.         puts("CPU:   Allwinner A13/A10s (SUN5I)\n"); //改这是A13和A10S的
  8. #else
  9. #warning Please update cpu_info.c with correct CPU information
  10.         puts("CPU:   TLL other SUNXI CPU\n"); //改这是其他sunxi处理器显示的
  11. #endif
  12.         return 0;
  13. }
复制代码
【第二弹】
修改common/main.c
  1. #ifdef CONFIG_MENUPROMPT
  2.         printf(CONFIG_MENUPROMPT);
  3. #else
  4.         if (bootdelay >= 0)
  5.                 printf("Hit any key to stop autoboot: %2d ", bootdelay);
  6. #endif
复制代码
到:
  1. #ifdef CONFIG_MENUPROMPT
  2.         printf(CONFIG_MENUPROMPT);
  3. #else
  4.         if (bootdelay > 0){
  5.                 printf("Hit any key to enter command: %2d ", bootdelay);
  6.         }else{
  7.                 printf("No boot delay,start booting");
  8.         }
  9. #endif
复制代码
修改common/cmd_bootmenu.c把里面的这个if改成这样:
  1.         if (menu->delay > 0) {
  2.                 printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
  3.                 printf("  Hit any key to enter command: %2d ", menu->delay);
  4.         }else{
  5.                 printf("  No boot delay,start booting");
  6.         }
复制代码
修改include/configs/sun4i.h:
  1. #define CONFIG_SYS_PROMPT               "sun4i#"
复制代码
到:
  1. #define CONFIG_SYS_PROMPT               "cubie-u-boot#"
复制代码
修改common/console.c:
  1.   puts("Print-In:    ");
  2.         if (stdio_devices[stdin] == NULL) {
  3.                 puts("No input devices available!\n");
  4.         } else {
  5.                 printf ("%s\n", stdio_devices[stdin]->name);
  6.         }

  7.         puts("Print-Out:   ");
  8.         if (stdio_devices[stdout] == NULL) {
  9.                 puts("No output devices available!\n");
  10. } else {
  11.                 printf ("%s\n", stdio_devices[stdout]->name);
  12.         }

  13.         puts("Print-Err:   ");
  14.         if (stdio_devices[stderr] == NULL) {
  15.                 puts("No error devices available!\n");
  16.         } else {
  17.                 printf ("%s\n", stdio_devices[stderr]->name);
  18.         }

复制代码
保存编译~(教程2)好了,就如本文开头(第二弹还更精彩)
回复

使用道具 举报

发表于 2013-6-22 11:05:23 | 显示全部楼层
有没有U-boot的NAND驱动????求一个
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-22 11:33:28 | 显示全部楼层
andy 发表于 2013-6-22 11:05
有没有U-boot的NAND驱动????求一个

早就有了,下次给教程
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-22 11:58:08 | 显示全部楼层
andy 发表于 2013-6-22 11:05
有没有U-boot的NAND驱动????求一个

教程来了
回复 支持 反对

使用道具 举报

发表于 2013-7-15 17:22:56 | 显示全部楼层
我手上的u-boot移植了网络驱动,我测试了tftp功能
把你这个nand加进去,就达到我使用的要求了
回复 支持 反对

使用道具 举报

发表于 2013-7-15 18:15:53 | 显示全部楼层
我在你给的网址下的u-boot不对呀,实测nand不能用,你移植成功了吗?
分享一下呗
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|粤ICP备13051116号|cubie.cc---深刻的嵌入式技术讨论社区

GMT+8, 2024-4-25 13:33 , Processed in 0.027632 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2012 Comsenz Inc. | Style by Coxxs

返回顶部