zoukankan      html  css  js  c++  java
  • s5pv210 uboot-2012-10移植(二) 之能够启动进入控制台

       这次我们将从官网下载的最新uboot-2012-10移植到s5pv210开发板上,让其进入控制台,效果如下:


            首先,我暂时没采用内核的SPL,这个将在后面给补上,这里的BL1是我自己参考资料写的,我用的是TQ210开发板,内存1G,对于不同的开发板,需要重新配置memory和修改uboot在内存里的地址,也就是CONFIG_SYS_TEXT_BASE。我的BL1代码在这里下载

    一、添加smdkv210单板

    1.cp -a board/samsung/smdkc100 board/samsung/smdkv210

    2.cp include/configs/smdkc100.h include/configs/smdkv210.h

    3.vim boards.cfg,在270行添加

    [plain] view plaincopy
     
    1. 270 smdkv210                     arm         armv7       smdkv210            samsung        s5pc1xx  


    4.make smdkv210_config可以生成u-boot.bin了

    二、让u-boot.bin在内存里启动起来

    1.分析我的BL1代码可以得知,只拷贝了u-boot.bin,并没有清除bss,在ls arch/arm/cpu/armv7/start.S +126中添加

    [plain] view plaincopy
     
    1. reset:  
    2.     //by ZheGao clear bss  
    3.     ldr r0, =__bss_start  
    4.     ldr r1, =__bss_end__  
    5.     mov r2, #0x0  
    6. 1:  
    7.     str r2, [r0], #4  
    8.     cmp r0, r1  
    9.     bne 1b  
    10.     //end of clear bss  
    11.   
    12.     bl  save_boot_params  

    2.在BL0已经关了看门狗,在BL1里已经初始化了memory和串口,修改board/samsung/smdkv210/lowlevel_init.S +39中给屏蔽

    [cpp] view plaincopy
     
    1. .globl lowlevel_init  
    2. lowlevel_init:  
    3.     mov r9, lr  
    4. #if 0  
    5.     /* r5 has always zero */  
    6.     mov r5, #0  
    7.   
    8.     ldr r8, =S5PC100_GPIO_BASE  
    9.   
    10.     /* Disable Watchdog */  
    11.     ldr r0, =S5PC100_WATCHDOG_BASE      @0xEA200000  
    12.     orr r0, r0, #0x0  
    13.     str r5, [r0]  
    14.   
    15.     /* setting SRAM */  
    16.     ldr r0, =S5PC100_SROMC_BASE  
    17.     ldr r1, =0x9  
    18.     str r1, [r0]  
    19.   
    20.     /* S5PC100 has 3 groups of interrupt sources */  
    21.     ldr r0, =S5PC100_VIC0_BASE          @0xE4000000  
    22.     ldr r1, =S5PC100_VIC1_BASE          @0xE4000000  
    23.     ldr r2, =S5PC100_VIC2_BASE          @0xE4000000  
    24.   
    25.     /* Disable all interrupts (VIC0, VIC1 and VIC2) */  
    26.     mvn r3, #0x0  
    27.     str r3, [r0, #0x14]             @INTENCLEAR  
    28.     str r3, [r1, #0x14]             @INTENCLEAR  
    29.     str r3, [r2, #0x14]             @INTENCLEAR  
    30.   
    31.     /* Set all interrupts as IRQ */  
    32.     str r5, [r0, #0xc]              @INTSELECT  
    33.     str r5, [r1, #0xc]              @INTSELECT  
    34.     str r5, [r2, #0xc]              @INTSELECT  
    35.   
    36.     /* Pending Interrupt Clear */  
    37.     str r5, [r0, #0xf00]            @INTADDRESS  
    38.     str r5, [r1, #0xf00]            @INTADDRESS  
    39.     str r5, [r2, #0xf00]            @INTADDRESS  
    40.   
    41.     /* for UART */  
    42.     bl uart_asm_init  
    43.   
    44.     /* for TZPC */  
    45.     bl tzpc_asm_init  
    46.   
    47. 1:  
    48. #endif  
    49.     mov lr, r9  
    50.     mov pc, lr  

    3.修改第一步的sp指针,在include/configs/smdkv210.h +228修改

    [cpp] view plaincopy
     
    1. //#define CONFIG_SYS_INIT_SP_ADDR   (CONFIG_SYS_LOAD_ADDR - 0x1000000)  
    2. #define CONFIG_SYS_INIT_SP_ADDR (0x30000000)  

    4.修改board/samsung/smdkv210/smdkc100.c +80

    [cpp] view plaincopy
     
    1. int checkboard(void)  
    2. {  
    3.     printf("Board: SMDKv210 ");  
    4.     return 0;  
    5. }  

    5.修改include/configs/smdkv210.h +51

    [cpp] view plaincopy
     
    1. //#define CONFIG_SYS_SDRAM_BASE     0x30000000  
    2. #define CONFIG_SYS_SDRAM_BASE       0x20000000  

    6.修改include/configs/smdkv210.h +189

    [cpp] view plaincopy
     
    1. //#define PHYS_SDRAM_1_SIZE (128 << 20)   /* 0x8000000, 128 MB Bank #1 */  
    2. #define PHYS_SDRAM_1_SIZE   (0x40000000)    /* 0x8000000, 128 MB Bank #1 */  

    7.修改board/samsung/smdkv210/config.mk +16

    [cpp] view plaincopy
     
    1. CONFIG_SYS_TEXT_BASE = 0x5ff00000  

    8.修改 arch/arm/config.mk +88

    [cpp] view plaincopy
     
    1. #LDFLAGS_u-boot += -pie  

    9.修改include/configs/smdkv210.h +216

    [cpp] view plaincopy
     
    1. //#define CONFIG_ENV_IS_IN_ONENAND  1  
    2. #define CONFIG_ENV_IS_NOWHERE  

    10.修改arch/arm/lib/board.c +384

    [cpp] view plaincopy
     
    1. //addr -= gd->mon_len;  
    2. addr = 0x5ff00000;  


    11.因为bl1已经复制程序到指定的地址就不需要重新定位代码了,但还是需要重新设置栈,所以修改了上面的第8步,修改arch/arm/cpu/armv7/start.S +192

    [cpp] view plaincopy
     
    1. ENTRY(relocate_code)  
    2.     mov r4, r0  /* save addr_sp */  
    3.     mov r5, r1  /* save addr of gd */  
    4.     mov r6, r2  /* save addr of destination */  
    5.   
    6. #if 0  
    7.     //debug  
    8.     ldr r0, =0xE0200C00  
    9.     ldr r1, =0x1111  
    10.     str r1, [r0]  
    11.       
    12.     ldr r0, =0xE0200C04  
    13.     ldr r1, =(7)  
    14.     str r1, [r0]      
    15. #endif  
    16.   
    17.     mov sp, r4  
    18.     mov r0, r5  
    19.     mov r1, r6  
    20.   
    21.     bl board_init_r  
    22. #if 0  
    23.     /* Set up the stack                         */  
    24. stack_setup:  
    25.     mov sp, r4  
    26.   
    27.     adr r0, _start  
    28.     cmp r0, r6  
    29.     moveq   r9, #0      /* no relocation. relocation offset(r9) = 0 */  
    30.     beq clear_bss       /* skip relocation */  
    31.     mov r1, r6          /* r1 <- scratch for copy_loop */  
    32.     ldr r3, _image_copy_end_ofs  
    33.     add r2, r0, r3      /* r2 <- source end address      */  
    34.   
    35. copy_loop:  
    36.     ldmia   r0!, {r9-r10}       /* copy from source address [r0]    */  
    37.     stmia   r1!, {r9-r10}       /* copy to   target address [r1]    */  
    38.     cmp r0, r2          /* until source end address [r2]    */  
    39.     blo copy_loop  
    40.   
    41.     /* 
    42.      * fix .rel.dyn relocations 
    43.      */  
    44.     ldr r0, _TEXT_BASE      /* r0 <- Text base */  
    45.     sub r9, r6, r0      /* r9 <- relocation offset */  
    46.     ldr r10, _dynsym_start_ofs  /* r10 <- sym table ofs */  
    47.     add r10, r10, r0        /* r10 <- sym table in FLASH */  
    48.     ldr r2, _rel_dyn_start_ofs  /* r2 <- rel dyn start ofs */  
    49.     add r2, r2, r0      /* r2 <- rel dyn start in FLASH */  
    50.     ldr r3, _rel_dyn_end_ofs    /* r3 <- rel dyn end ofs */  
    51.     add r3, r3, r0      /* r3 <- rel dyn end in FLASH */  
    52. fixloop:  
    53.     ldr r0, [r2]        /* r0 <- location to fix up, IN FLASH! */  
    54.     add r0, r0, r9      /* r0 <- location to fix up in RAM */  
    55.     ldr r1, [r2, #4]  
    56.     and r7, r1, #0xff  
    57.     cmp r7, #23         /* relative fixup? */  
    58.     beq fixrel  
    59.     cmp r7, #2          /* absolute fixup? */  
    60.     beq fixabs  
    61.     /* ignore unknown type of fixup */  
    62.     b   fixnext  
    63. fixabs:  
    64.     /* absolute fix: set location to (offset) symbol value */  
    65.     mov r1, r1, LSR #4      /* r1 <- symbol index in .dynsym */  
    66.     add r1, r10, r1     /* r1 <- address of symbol in table */  
    67.     ldr r1, [r1, #4]        /* r1 <- symbol value */  
    68.     add r1, r1, r9      /* r1 <- relocated sym addr */  
    69.     b   fixnext  
    70. fixrel:  
    71.     /* relative fix: increase location by offset */  
    72.     ldr r1, [r0]  
    73.     add r1, r1, r9  
    74. fixnext:  
    75.     str r1, [r0]  
    76.     add r2, r2, #8      /* each rel.dyn entry is 8 bytes */  
    77.     cmp r2, r3  
    78.     blo fixloop  
    79.     b   clear_bss  
    80. _rel_dyn_start_ofs:  
    81.     .word __rel_dyn_start - _start  
    82. _rel_dyn_end_ofs:  
    83.     .word __rel_dyn_end - _start  
    84. _dynsym_start_ofs:  
    85.     .word __dynsym_start - _start  
    86.   
    87. clear_bss:  
    88.     ldr r0, _bss_start_ofs  
    89.     ldr r1, _bss_end_ofs  
    90.     mov r4, r6          /* reloc addr */  
    91.     add r0, r0, r4  
    92.     add r1, r1, r4  
    93.     mov r2, #0x00000000     /* clear                */  
    94.   
    95. clbss_l:cmp r0, r1          /* clear loop... */  
    96.     bhs clbss_e         /* if reached end of bss, exit */  
    97.     str r2, [r0]  
    98.     add r0, r0, #4  
    99.     b   clbss_l  
    100. clbss_e:  
    101.   
    102. /* 
    103.  * We are done. Do not return, instead branch to second part of board 
    104.  * initialization, now running from RAM. 
    105.  */  
    106. jump_2_ram:  
    107. /* 
    108.  * If I-cache is enabled invalidate it 
    109.  */  
    110. #ifndef CONFIG_SYS_ICACHE_OFF  
    111.     mcr p15, 0, r0, c7, c5, 0   @ invalidate icache  
    112.     mcr     p15, 0, r0, c7, c10, 4  @ DSB  
    113.     mcr     p15, 0, r0, c7, c5, 4   @ ISB  
    114. #endif  
    115. /* 
    116.  * Move vector table 
    117.  */  
    118. #if !defined(CONFIG_TEGRA20)  
    119.     /* Set vector address in CP15 VBAR register */  
    120.     ldr     r0, =_start  
    121.     add     r0, r0, r9  
    122.     mcr     p15, 0, r0, c12, c0, 0  @Set VBAR  
    123. #endif /* !Tegra20 */  
    124.   
    125.     ldr r0, _board_init_r_ofs  
    126.     adr r1, _start  
    127.     add lr, r0, r1  
    128.     add lr, lr, r9  
    129.     /* setup parameters for board_init_r */  
    130.     mov r0, r5      /* gd_t */  
    131.     mov r1, r6      /* dest_addr */  
    132.     /* jump to it ... */  
    133.     mov pc, lr  
    134.   
    135. _board_init_r_ofs:  
    136.     .word board_init_r - _start  
    137. #endif  
    138. ENDPROC(relocate_code)  
    139. #endif  

    重新make一下,使用下面命令烧写到sd卡里,插入开发板启动即可,看看上面的启动信息,还有很多很多地方要完善~

    [cpp] view plaincopy
     
      1. dd iflag=dsync oflag=dsync if=blSD.bin of=/dev/sdb seek=1  
      2. dd iflag=dsync oflag=dsync if=u-boot.b
  • 相关阅读:
    css 深入理解
    2018 web经典面试题
    CSS 居中布局
    HTTP首部解析
    http状态码有那些?分别代表是什么意思?
    基本HTTP协议流程是什么?
    JS-变量
    javascript基础1
    css3弹性盒模型(Flexbox)
    文字效果和颜色
  • 原文地址:https://www.cnblogs.com/cainiaoaixuexi/p/3276316.html
Copyright © 2011-2022 走看看