如何从0移植uboot支持exynos4412?

系统 Linux
本文主要目的是如何从0编译和移植uboot,增加串口、网络、emmc等功能,让他支持exynos4412开发板。

[[394638]]

 本文主要目的是如何从0编译和移植uboot,增加串口、网络、emmc等功能,让他支持exynos4412开发板。

一、移植步骤

1. Uboot配置

1.指定交叉编译工具链 进入uboot代码根目录

  1. $ cd  u-boot-2013.01 

修改 Makefile 在

  1. ifeq ($(HOSTARCH),$(ARCH)) 
  2.    CROSS_COMPILE ?= 
  3. endif 

 下添加

  1. ifeq   (arm,$(ARCH)) 
  2.    CROSS_COMPILE ?= arm-none-linux-gnueabi- 
  3. endif 

 

交叉编译工具

2.指定产品CPU 我们产品用的CPU是 exynos 4412;

查看u-boot源码:

  1. arch/arm/cpu/armv7/exynos/ 

可见U-boot已支持该CPU。

3.指定产品BOARD 三星公司已经为exynos 4412发布了初始化的程序:

origen

4.cpu硬件信息 对应的该CPU硬件信息头文件位于以下位置:

  1. include/configs/origen.h 

该文件定义了uboot启动必须关于exynos 4412必须的一些资源信息。

5.boards.cfg 在uboot-2013-01中,顶层目录下的boards.cfs文件中查看它支持的开发板和相应的信息,后续的编译过程需要根据配置名检索到相应的信息。文件格式如下:

和以前的老版本比,配置更加规范化了,其实这些就是相关文件分类的一个文件夹的描述。依照这个层次关系,我们可以很方便地对我们开发板进行配置。

6.编译u-boot

不同版本的uboot的配置命令可能是不同的,源码包的文件README通常会有相应的配置命令【其他版本的uboot会不一样】:

配置和编译命令如下:

  1. $ make  distclean 
  2. $ make  origen_config 

 改配置命令会生成以下文件:

  1. include/config.h 

config.h

编译:

  1. $ make all 

编译完成后生成的u-boot.bin就是可执行的镜像文件。

但是并不会生成真正适配我们板子的uboot,只是适配参考板,该文件还不能在我们板子上运行,我们需要对u-boot源代码进行相应的修改。

2. 确认第一条指令有运行到 (点灯法)

在arch/arm/cpu/armv7/start.S 134 行后添加点灯程序

  1. #if 1 
  2.   ldr r0, =0x11000c40 @GPX2_7 led2 
  3.   ldr r1, [r0] 
  4.   bic r1, r1, #0xf0000000 
  5.   orr r1, r1, #0x10000000 
  6.   str r1, [r0] 
  7.   
  8.   ldr r0, =0x11000c44 
  9.   mov r1,#0xff 
  10.   str r1, [r0] 
  11. #endif  

 因为uboot刚启动的时候,串口没有来得及初始化,我们可以通过点亮LED的方法来判断程序是否执行到此处。

代码详解参考《十、LED汇编、C语言驱动编写》

3. 添加三星加密方式

exynos 需要三星提供的初始引导加密后,我们的u-boot,才能被引导运行,这其中要用到下面的几个命令或三星提供的工具软件,这些操作的目的就是根据三星的芯片的启动要求对uboot.bin 进行一些处理,包括在特定长度的位置加上和校验信息以及插入一些文件段。

  1. $cp  sdfuse_q  u-boot-2013.01  -rf  
  2. $ chmod  777  u-boot-2013.01/sdfuse_q  -R       
  3. $cp  CodeSign4SecureBoot  u-boot-2013.01  -rf      

 注:CodeSign4SecureBoot 三星提供的安全启动方式 ,对应的程序由三星提供。sdfuse_q目录下的文件是针对三星堆uboot.bin文件格式要求进行加密编写的文件。

修改根目录Makefile,实现sdfuse_q的编译 在

  1. $(obj)u-boot.bin: $(obj)u-boot 
  2.   $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ 
  3.   $(BOARD_SIZE_CHECK)  

 下添加

  1. @#./mkuboot 
  2. @split  -b  14336  u-boot.bin  bl2 
  3. @make -C sdfuse_q/ 
  4. @#cp u-boot.bin u-boot-4212.bin 
  5. @#cp u-boot.bin u-boot-4412.bin 
  6. @#./sdfuse_q/add_sign 
  7. @./sdfuse_q/chksum 
  8. @./sdfuse_q/add_padding 
  9. @rm bl2a* 
  10. @echo 

 注意是tab键缩进的,否则makefile编译报错 注意如果执行了make distclean 需重新拷贝CodeSign4SecureBoot

为方便起见,在根目录下创建编译脚本build.sh,该脚本将自动完成添加加密方式。

  1.  1 #!/bin/sh 
  2.  2  
  3.  3 sec_path="CodeSign4SecureBoot/" 
  4.  4 CPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}'
  5.  5 ROOT_DIR=$(pwd) 
  6.  6 CUR_DIR=${ROOT_DIR##*/} 
  7.  7  
  8.  8 case "$1" in 
  9.  9     clean) 
  10. 10         echo make clean 
  11. 11         make mrproper 
  12. 12         ;; 
  13. 13     *) 
  14. 14  
  15. 15         if [ ! -d $sec_path ] 
  16. 16         then 
  17. 17             echo "**********************************************" 
  18. 18             echo "[ERR]please get the CodeSign4SecureBoot first" 
  19. 19             echo "**********************************************" 
  20. 20             return 
  21. 21         fi      
  22. 22  
  23. 23         make origen_config 
  24. 24  
  25. 25         make -j$CPU_JOB_NUM 
  26. 26  
  27. 27         if [ ! -f checksum_bl2_14k.bin ] 
  28. 28         then 
  29. 29             echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 
  30. 30             echo "There are some error(s) while building uboot, please use command make to check." 
  31. 31             echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 
  32. 32             exit 0 
  33. 33         fi 
  34. 34  
  35. 35         cp -rf checksum_bl2_14k.bin $sec_path 
  36. 36         cp -rf u-boot.bin $sec_path 
  37. 37         rm checksum_bl2_14k.bin 
  38. 38  
  39. 39         cd $sec_path 
  40. 40         cat E4412_N.bl1.SCP2G.bin bl2.bin all00_padding.bin u-boot.bin tzsw_SMDK4412_SCP_2GB.bin > u-boot-origen.bin 
  41. 41         mv u-boot-origen.bin $ROOT_DIR 
  42. 42  
  43. 43         rm checksum_bl2_14k.bin 
  44. 44         rm u-boot.bin 
  45. 45  
  46. 46         echo  
  47. 47         echo  
  48. 48         ;; 
  49. 49  
  50. 50 esac 

 编译脚本

  1. $ chmod   777  u-boot-2013.01/ build.sh 
  2. $ ./buildsh 

 注:build.sh 脚本方式完成自动添加加密方式, 编译生成所需文件u-boot_origen.bin

  1. root@ubuntu:/home/peng/uboot/u-boot-2013.01# ls 
  2. api                  config.mk  examples     Makefile  sdfuse_q         u-boot.bin 
  3. arch                 COPYING    fs           mkconfig  snapshot.commit  u-boot.map 
  4. board                CREDITS    helper.mk    nand_spl  spl              u-boot-origen.bin 
  5. boards.cfg           disk       include      net       System.map       u-boot.srec 
  6. build.sh             doc        lib          post      test 
  7. CodeSign4SecureBoot  drivers    MAINTAINERS  README    tools 
  8. common               dts        MAKEALL      rules.mk  u-boot 

 

u-boot_origen.bin

4. 实现串口输出

修改lowlevel_init.S文件

  1. $vim  board/samsung/origen/lowlevel_init.S 

a) 添加临时栈,在

  1. 41 lowlevel_init: 

后添加

  1. ldr  sp,=0x02060000 @use iRom stack in bl2 

b) 添加关闭看门狗代码: 在

  1. 67     beq wakeup_reset   

后添加

  1. #if 1 /*for close watchdog */     
  2.      /* PS-Hold high */ 
  3.   ldr r0, =0x1002330c 
  4.   ldr r1, [r0] 
  5.   orr r1, r1, #0x300 
  6.   str r1, [r0]          
  7.   ldr     r0, =0x11000c08 
  8.   ldr r1, =0x0 
  9.   str r1, [r0] 
  10. /* Clear  MASK_WDT_RESET_REQUEST  */ 
  11.   ldr r0, =0x1002040c 
  12.   ldr r1, =0x00 
  13.   str r1, [r0] 
  14. #endif   

 c) 添加串口初始化代码: 在uart_asm_init: 的

  1. 351     str r1, [r0, #EXYNOS4_GPIO_A1_CON_OFFSET] 

后添加

  1. ldr r0, =0x10030000  
  2. ldr r1, =0x666666   
  3. ldr r2, =CLK_SRC_PERIL0_OFFSET 
  4. str r1, [r0, r2] 
  5. ldr r1, =0x777777  
  6. ldr r2, =CLK_DIV_PERIL0_OFFSET 
  7. str r1, [r0, r2] 

 d) 注释掉trustzone初始化 注释掉

  1. 104     bl uart_asm_init 

下的代码:

  1. #if 0 
  2.     bl tzpc_init 
  3. #endif  

 5. 网卡移植

因为各个厂家使用的网卡不尽相同,所以三星公司提供的驱动程序只预留了网卡初始化的函数入口,针对不同的板子,我们需要针对电路自己移植网卡的驱动。网卡的驱动详解,我们会在后一章节详细讲解。

1、 添加网络初始化代码

  1. $ vim   board/samsung/origen/origen.c 

  1. 31 struct exynos4_gpio_part2 *gpio2; 

后添加:

  1. #ifdef CONFIG_DRIVER_DM9000 
  2. #define EXYNOS4412_SROMC_BASE 0X12570000 
  3.  
  4. #define DM9000_Tacs     (0x1)  
  5. #define DM9000_Tcos     (0x1)  
  6. #define DM9000_Tacc     (0x5)  
  7. #define DM9000_Tcoh     (0x1)  
  8. #define DM9000_Tah      (0xC)  
  9. #define DM9000_Tacp     (0x9)    
  10. #define DM9000_PMC      (0x1)   
  11.  
  12. struct exynos_sromc { 
  13.         unsigned int bw; 
  14.         unsigned int bc[6]; 
  15. }; 
  16.  
  17. /* 
  18.  * s5p_config_sromc() - select the proper SROMC Bank and configure the 
  19.  * band width control and bank control registers 
  20.  * srom_bank    - SROM 
  21.  * srom_bw_conf  - SMC Band witdh reg configuration value 
  22.  * srom_bc_conf  - SMC Bank Control reg configuration value 
  23.  */ 
  24. void exynos_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf) 
  25.         unsigned int tmp; 
  26.         struct exynos_sromc *srom = (struct exynos_sromc *)(EXYNOS4412_SROMC_BASE); 
  27.  
  28.         /* Configure SMC_BW register to handle proper SROMC bank */ 
  29.         tmp = srom->bw; 
  30.         tmp &= ~(0xF << (srom_bank * 4)); 
  31.         tmp |= srom_bw_conf; 
  32.         srom->bw = tmp; 
  33.  
  34.         /* Configure SMC_BC register */ 
  35.         srom->bc[srom_bank] = srom_bc_conf; 
  36. static void dm9000aep_pre_init(void) 
  37.        unsigned int tmp; 
  38.        unsigned char smc_bank_num = 1; 
  39.        unsigned int     smc_bw_conf=0; 
  40.        unsigned int     smc_bc_conf=0; 
  41.         
  42.        /* gpio configuration */ 
  43.        writel(0x00220020, 0x11000000 + 0x120); 
  44.        writel(0x00002222, 0x11000000 + 0x140); 
  45.        /* 16 Bit bus width */ 
  46.        writel(0x22222222, 0x11000000 + 0x180); 
  47.        writel(0x0000FFFF, 0x11000000 + 0x188); 
  48.        writel(0x22222222, 0x11000000 + 0x1C0); 
  49.        writel(0x0000FFFF, 0x11000000 + 0x1C8); 
  50.        writel(0x22222222, 0x11000000 + 0x1E0); 
  51.        writel(0x0000FFFF, 0x11000000 + 0x1E8);               
  52.        smc_bw_conf &= ~(0xf<<4); 
  53.        smc_bw_conf |= (1<<7) | (1<<6) | (1<<5) | (1<<4); 
  54.        smc_bc_conf = ((DM9000_Tacs << 28) 
  55.                     | (DM9000_Tcos << 24) 
  56.                     | (DM9000_Tacc << 16) 
  57.                     | (DM9000_Tcoh << 12) 
  58.                     | (DM9000_Tah << 8) 
  59.                     | (DM9000_Tacp << 4) 
  60.                      | (DM9000_PMC)); 
  61.        exynos_config_sromc(smc_bank_num,smc_bw_conf,smc_bc_conf); 
  62. #endif 

 在

  1. gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);  

后添加

  1. #ifdef CONFIG_DRIVER_DM9000 
  2.  dm9000aep_pre_init(); 
  3. #endif 

 在文件末尾添加

  1. #ifdef CONFIG_CMD_NET 
  2. int board_eth_init(bd_t *bis)                                                   
  3. {       
  4.        int rc = 0; 
  5. #ifdef CONFIG_DRIVER_DM9000 
  6.        rc = dm9000_initialize(bis);                                             
  7. #endif                                                                          
  8.        return rc;                                                               
  9. }   
  10. #endif 

 2、 修改配置文件添加网络相关配置 $ vim include/configs/origen.h 修改

  1. 85 #undef CONFIG_CMD_PING 

  1. #define  CONFIG_CMD_PING 

修改

  1. 90 #undef CONFIG_CMD_NET  

  1. #define  CONFIG_CMD_NET 

在文件末尾

  1. #endif /* __CONFIG_H */    

前面添加

  1. #ifdef CONFIG_CMD_NET 
  2. #define CONFIG_NET_MULTI 
  3. #define CONFIG_DRIVER_DM9000  1 
  4. #define CONFIG_DM9000_BASE    0x05000000 //内存基地址 
  5. #define DM9000_IO         CONFIG_DM9000_BASE 
  6. #define DM9000_DATA       (CONFIG_DM9000_BASE + 4) 
  7. #define CONFIG_DM9000_USE_16BIT 
  8. #define CONFIG_DM9000_NO_SROM  1 
  9. #define CONFIG_ETHADDR   11:22:33:44:55:66 
  10. #define CONFIG_IPADDR     192.168.6.187 
  11. #define CONFIG_SERVERIP         192.168.6.186 
  12. #define CONFIG_GATEWAYIP       192.168.1.1 
  13. #define CONFIG_NETMASK   255.255.255.0 
  14. #endif 

 其中CONFIG_DM9000_BASE 地址为何是0x05000000,后续章节会详细分析。

6. FLASH移植 (EMMC)

1.移植EMMC需要添加一些源文件:

  1. cmd_mmc.c 
  2. cmd_mmc_fdisk.c 
  3. cmd_movi.c 
  4. mmc.c 
  5. mmc.h 
  6. movi.c 
  7. movi.h 
  8. s5p_mshc.c 
  9. s5p_mshc.h 

 这些文件,由三星提供。

2.添加相关驱动

  1. cp  movi.c  arch/arm/cpu/armv7/exynos/ 

修改文件arch/arm/cpu/armv7/exynos/Makefile在pinmux.o 后添加movi.o

修改板级文件 board/samsung/origen/origen.c,在

  1. #include <asm/arch/mmc.h> 

后面添加

  1. #include <asm/arch/clk.h> 
  2. #include "origen_setup.h" 

 在

  1. #ifdef CONFIG_GENERIC_MMC  

后面添加

  1. u32 sclk_mmc4;  /*clock source for emmc controller*/ 
  2. #define __REGMY(x) (*((volatile u32 *)(x))) 
  3. #define CLK_SRC_FSYS  __REGMY(EXYNOS4_CLOCK_BASE + CLK_SRC_FSYS_OFFSET) 
  4. #define CLK_DIV_FSYS3 __REGMY(EXYNOS4_CLOCK_BASE + CLK_DIV_FSYS3_OFFSET) 
  5.  
  6. int emmc_init() 
  7.  u32 tmp; 
  8.  u32 clock; 
  9.  u32 i; 
  10.  /* setup_hsmmc_clock */ 
  11.  /* MMC4 clock src = SCLKMPLL */ 
  12.  tmp = CLK_SRC_FSYS & ~(0x000f0000); 
  13.  CLK_SRC_FSYS = tmp | 0x00060000; 
  14.  /* MMC4 clock div */ 
  15.  tmp = CLK_DIV_FSYS3 & ~(0x0000ff0f); 
  16.  clock = get_pll_clk(MPLL)/1000000; 
  17.  
  18.    for(i=0 ; i<=0xf; i++)  { 
  19.       sclk_mmc4=(clock/(i+1)); 
  20.  
  21.   if(sclk_mmc4 <= 160) //200 
  22.          { 
  23.    CLK_DIV_FSYS3 = tmp | (i<<0); 
  24.    break; 
  25.   } 
  26.  } 
  27.    emmcdbg("[mjdbg] sclk_mmc4:%d MHZ; mmc_ratio: %d\n",sclk_mmc4,i); 
  28.    sclk_mmc4 *= 1000000; 
  29.  
  30.    /* 
  31.     * MMC4 EMMC GPIO CONFIG 
  32.     * 
  33.     * GPK0[0] SD_4_CLK 
  34.     * GPK0[1] SD_4_CMD 
  35.     * GPK0[2] SD_4_CDn 
  36.     * GPK0[3:6] SD_4_DATA[0:3] 
  37.     */ 
  38.     writel(readl(0x11000048)&~(0xf),0x11000048); //SD_4_CLK/SD_4_CMD pull-down enable 
  39.     writel(readl(0x11000040)&~(0xff),0x11000040);//cdn set to be output 
  40.  
  41.     writel(readl(0x11000048)&~(3<<4),0x11000048); //cdn pull-down disable 
  42.     writel(readl(0x11000044)&~(1<<2),0x11000044); //cdn output 0 to shutdown the emmc power 
  43.     writel(readl(0x11000040)&~(0xf<<8)|(1<<8),0x11000040);//cdn set to be output 
  44.     udelay(100*1000); 
  45.     writel(readl(0x11000044)|(1<<2),0x11000044); //cdn output 1 
  46.  
  47.  
  48.     writel(0x03333133, 0x11000040); 
  49.  
  50.     writel(0x00003FF0, 0x11000048); 
  51.     writel(0x00002AAA, 0x1100004C); 
  52.  
  53. #ifdef CONFIG_EMMC_8Bit 
  54.     writel(0x04444000, 0x11000060); 
  55.     writel(0x00003FC0, 0x11000068); 
  56.     writel(0x00002AAA, 0x1100006C); 
  57. #endif 
  58.  
  59. #ifdef USE_MMC4 
  60.     smdk_s5p_mshc_init(); 
  61. #endif  

 将 int board_mmc_init(bd_t *bis)函数内容改写为

  1. int board_mmc_init(bd_t *bis) 
  2.   int i, err; 
  3. #ifdef CONFIG_EMMC 
  4.   err = emmc_init(); 
  5. #endif 
  6.   return err; 

 在末尾添加

  1. #ifdef CONFIG_BOARD_LATE_INIT 
  2. #include <movi.h> 
  3. int  chk_bootdev(void)//mj for boot device check 
  4.   char run_cmd[100]; 
  5.   struct mmc *mmc; 
  6.   int boot_dev = 0; 
  7.   int cmp_off = 0x10; 
  8.   ulong  start_blk, blkcnt; 
  9.  
  10.   mmc = find_mmc_device(0); 
  11.  
  12.   if (mmc == NULL
  13.   { 
  14.    printf("There is no eMMC card, Booting device is SD card\n"); 
  15.    boot_dev = 1; 
  16.    return boot_dev; 
  17.   } 
  18.   start_blk = (24*1024/MOVI_BLKSIZE); 
  19.   blkcnt = 0x10; 
  20.  
  21.   sprintf(run_cmd,"emmc open 0"); 
  22.   run_command(run_cmd, 0); 
  23.  
  24.   sprintf(run_cmd,"mmc read 0 %lx %lx %lx",CFG_PHY_KERNEL_BASE,start_blk,blkcnt); 
  25.   run_command(run_cmd, 0); 
  26.  
  27.   /* switch mmc to normal paritition */ 
  28.   sprintf(run_cmd,"emmc close 0"); 
  29.   run_command(run_cmd, 0); 
  30.  
  31.   return 0; 
  32.  
  33. int board_late_init (void) 
  34.      int boot_dev =0 ; 
  35.      char boot_cmd[100]; 
  36.      boot_dev = chk_bootdev(); 
  37.      if(!boot_dev) 
  38.      { 
  39.            printf("\n\nChecking Boot Mode ... EMMC4.41\n"); 
  40.      } 
  41.      return 0; 
  42. #endif 

 3.添加相关命令

  1. $ cp    cmd_movi.c  common/ 
  2. $ cp    cmd_mmc.c  common/ 
  3. $ cp cmd_mmc_fdisk.c  common/ 

 修改common/Makefile 在

  1. COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o 

后添加

  1. COBJS-$(CONFIG_CMD_MMC) += cmd_mmc_fdisk.o 
  2. COBJS-$(CONFIG_CMD_MOVINAND) += cmd_movi.o 

 添加驱动

  1. $ cp   mmc.c  drivers/mmc/ 
  2. $ cp   s5p_mshc.c  drivers/mmc/ 
  3. $ cp   mmc.h  include/ 
  4. $ cp   movi.h  include/ 
  5. $ cp   s5p_mshc.h  include/ 

 修改Makefile

  1. $vim  drivers/mmc/Makefile 

添加

  1. COBJS-$(CONFIG_S5P_MSHC) += s5p_mshc.o    

4.添加EMMC相关配置

  1. $vim    include/configs/origen.h 

添加

  1. #define CONFIG_EVT1     1       /* EVT1 */ 
  2. #ifdef CONFIG_EVT1 
  3. #define CONFIG_EMMC44_CH4 //eMMC44_CH4 (OMPIN[5:1] = 4) 
  4.  
  5. #ifdef CONFIG_SDMMC_CH2 
  6. #define CONFIG_S3C_HSMMC 
  7. #undef DEBUG_S3C_HSMMC 
  8. #define USE_MMC2   
  9. #endif 
  10.  
  11. #ifdef CONFIG_EMMC44_CH4 
  12. #define CONFIG_S5P_MSHC 
  13. #define CONFIG_EMMC             1                
  14. #define USE_MMC4   
  15. /* #define CONFIG_EMMC_8Bit */ 
  16. #define CONFIG_EMMC_EMERGENCY 
  17. /*#define emmcdbg(fmt,args...) printf(fmt ,##args) *///for emmc debug  
  18. #define emmcdbg(fmt,args...) 
  19. #endif 
  20.  
  21. #endif /*end CONFIG_EVT1*/ 
  22. #define CONFIG_CMD_MOVINAND 
  23. #define CONFIG_CLK_1000_400_200 
  24. #define CFG_PHY_UBOOT_BASE      CONFIG_SYS_SDRAM_BASE + 0x3e00000 
  25. #define CFG_PHY_KERNEL_BASE     CONFIG_SYS_SDRAM_BASE + 0x8000 
  26.  
  27. #define BOOT_MMCSD      0x3 
  28. #define BOOT_EMMC43     0x6 
  29. #define BOOT_EMMC441    0x7 
  30. #define CONFIG_BOARD_LATE_INIT 

 7. 重新编译u-boot

修改顶层Makefile,注释掉spl的编译:

  1. 623 #$(obj)spl/u-boot-spl.bin:  $(SUBDIR_TOOLS) depend 
  2. 624 #       $(MAKE) -C spl all 

 重新编译uboot:

  1. $ ./build.sh  

在根目录下会生成bin文件u-boot-origen.bin。

二、SD卡制作

1. 烧写脚本

三星公司已经给我们提供了制作SD卡启动的烧写的脚本:mkuboot.sh

  1. #!/bin/bash 
  2.  
  3. # This script will create a u-boot binary for movinand/mmc boot 
  4.  
  5. echo "Fuse FS4412 trustzone uboot file into SD card" 
  6.  
  7. if [ -z $1 ] #判断参数1的字符串是否为空,如果为空,则打印出帮助信息 
  8. then 
  9.  ./sd_fusing_exynos4x12.sh /dev/sdb u-boot-origen.bin 
  10. else 
  11.  ./sd_fusing_exynos4x12.sh $1 u-boot-origen.bin 
  12. fi 

 sd_fusing_exynos4x12.sh

  1.  1 #!/bin/sh    
  2.  2 # 
  3.  3 # Copyright (C) 2010 Samsung Electronics Co., Ltd. 
  4.  4 #              http://www.samsung.com/ 
  5.  5 # 
  6.  6 # This program is free software; you can redistribute it and/or modify 
  7.  7 # it under the terms of the GNU General Public License version 2 as 
  8.  8 # published by the Free Software Foundation. 
  9.  9 # 
  10. 10 #################################### 
  11. 11 reader_type1="/dev/sd" 
  12. 12 reader_type2="/dev/mmcblk0" 
  13. 13  
  14. 14 if [ -z $2 ]  #判断参数2的字符串是否为空,如果为空,则打印出帮助信息 
  15. 15 then 
  16. 16     echo "usage: ./sd_fusing.sh <SD Reader's device file> <filename>" 
  17. 17     exit 0 
  18. 18 fi 
  19. 19  
  20. 20 param1=`echo "$1" | awk '{print substr($1,1,7)}'
  21. 21  
  22. 22 if [ "$param1" = "$reader_type1" ] 
  23. 23 then 
  24. 24     partition1=$1"1" 
  25. 25     partition2=$1"2" 
  26. 26     partition3=$1"3" 
  27. 27     partition4=$1"4" 
  28. 28  
  29. 29 elif [ "$1" = "$reader_type2" ] 
  30. 30 then 
  31. 31     partition1=$1"p1" 
  32. 32     partition2=$1"p2" 
  33. 33     partition3=$1"p3" 
  34. 34     partition4=$1"p4" 
  35. 35  
  36. 36 else 
  37. 37     echo "Unsupported SD reader" 
  38. 38     exit 0 
  39. 39 fi 
  40. 40  
  41. 41 if [ -b $1 ] #判断参数1所指向的设备节点是否存在 
  42. 42 then 
  43. 43     echo "$1 reader is identified." 
  44. 44 else 
  45. 45     echo "$1 is NOT identified." 
  46. 46     exit 0 
  47. 47 fi 
  48. 48  
  49. 49 #################################### 
  50. 50 # format 
  51. 51 umount $partition1 2> /dev/null 
  52. 52 umount $partition2 2> /dev/null 
  53. 53 umount $partition3 2> /dev/null 
  54. 54 umount $partition4 2> /dev/null 
  55. 55  
  56. 56 echo "$2 fusing..." 
  57.  # 烧写u-boot-origen.bin到SD卡(512+8K)字节处, 512+8K=17x512,即第17个block 
  58. 57 dd iflag=dsync oflag=dsync if=$2 of=$1 seek=1 && \ 
  59. 58     echo "$2 image has been fused successfully." 
  60. 59  
  61. 60 #echo "zImage fusing..." 
  62. 61 #dd iflag=dsync oflag=dsync if=../../TC4_Kernel_3.0/arch/arm/boot/zImage of=$1 seek=1024 && \ 
  63. 62 #   echo "zImage has been fused successfully." 
  64. 63  
  65. 64 #echo "ramdisk-uboot.img fusing..." 
  66. 65 #dd iflag=dsync oflag=dsync if=../../TC4_GB_2.3.4/out/target/product/smdk4212/ramdisk-uboot.img of=$1 seek=9216 && \ 
  67. 66 #   echo "ramdisk-uboot.img has been fused successfully." 
  68. 67  
  69. 68 #################################### 
  70. 69 #<Message Display> 
  71. 70 echo "Eject SD card" 
  72. 71  

 2. 制作步骤

a) 创建文件mkuboot.sh、sd_fusing_exynos4x12.sh b) 将SD卡插入电脑并被ubuntu识别 c) 拷贝编译好u-boot-origen.bin拷贝到当前目录下

  1. root@ubuntu:/home/peng/uboot/sdfuse_q# ls 
  2. mkuboot.sh  sd_fusing_exynos4x12.sh  u-boot-origen.bin 

 d) 进入sdfuse_q执行如下操作

  1. root@ubuntu:/home/peng/uboot/sdfuse_q#./mkuboot.sh  /dev/sdb 

 

d) 在SD卡中创建目录sdupdate,并把编译好的uboot镜像文件u-boot-origen.bin拷贝到这个目录。

3. 通过sd卡启动烧写uboot

a) 连接串口和板子,运行串口通信程序putty

选择右上角的”Serial”,然后点击左下角的”Serial”

按照自己的主机的情况选择COM口其他必须一直,然后点击open打开串口

b) 关闭开发板电源,将拨码开关SW1调至(1000)(SD启动模式)后打开电源 c) 将刚才做好的SD启动盘插入SD卡插槽 d) 重新打开开发板能够看到如下界面

在这里插入图片描述

在读秒倒计时时按任意键。由上图所示,已经支持EMMC和dm9000网卡。

e) 烧写 在终端上执行

  1. sdfuse  flashall 

注意:上面的命令把SD卡 sdupdate目录下的u-boot-origen.bin烧写到emmc起始位置 等待终端无输出是表示烧写结束

f) 关闭开发板电源,将拨码开关SW1调至0110(EMMC启动模式)后打开电源即可以从emmc启动

4. 网络烧写uboot

如果板子已经可以启动uboot,我们也可以通过网络烧写uboot。

步骤如下:

把编译好的u-boot-origen.bin拷贝到/tftpboot下

启动开发板,在u-boot下先下载u-boot-origen.bin到41000000;再运行

  1. movi  write  u-boot  41000000 

若编译后的u-boot-origen.bin 无法运行,可参考上一节,重新从SD卡引导烧写。

 

责任编辑:姜华 来源: 今日头条
相关推荐

2020-12-30 15:17:25

Cortex-A9UARTprintf函数

2021-12-29 16:11:11

鸿蒙HarmonyOS应用

2012-04-29 15:59:28

2021-05-25 11:50:32

ARMuboot网络协议栈

2021-01-19 19:32:01

Cortex-A9 R嵌入式系统i2c 外设

2012-06-20 11:17:02

MemSQL

2021-03-16 21:39:47

区块链DEMOGo

2023-03-29 08:52:58

视觉Vue组件库

2021-03-12 19:17:38

区块链GoPython

2021-03-17 20:29:36

区块链DEMOPython

2021-01-08 12:06:59

WDT定时装置

2023-02-06 16:21:48

2022-08-31 14:24:03

数字化转型小程序平台

2015-05-05 13:57:12

AndroidWindows

2019-01-29 14:29:03

微服务路由

2013-09-02 15:49:38

DirectX 9Windows

2011-09-05 09:28:58

MySQLMongoDB

2023-04-10 07:40:50

BI 体系数据中台

2022-06-07 15:09:21

实践研发IDE

2022-12-23 08:03:45

西瓜业务SEO前端
点赞
收藏

51CTO技术栈公众号