• 第一章之s5pv210启动顺序


    我所使用的开发板是:友善之臂smart210,cpu为s5pv210.u-boot版本是:u-boot-2012-10

    1,首先在u-boot中配置相对应的开发板的配置文件

    #make s5p_goni_config

    2,设事先编译好的交叉编译器放在Makefile中添加上去,打开Makefile

    在67行补充CROSS_COMPILE ?= arm-linux-

     3,通过s5pv210启动顺序可以看出,启动由两个过程来进行boot,分别称为BL1,BL2。

    (1)BL0:是指S5PV210的iROM中固化的启动代码
            作用:初始化系统时钟,设置看门狗,初始化堆和栈,加载BL1
     
    (2)BL1:是批在iRAM自动从外扩存储器(nand/sd/usb)中拷贝的uboot.bin二进制文件的头最大16K代码
            作用:初始化RAM,关闭Cache,设置栈,加载BL2
     
    (3)BL2:是指在代码重定向后在内存中执行的uboot的完整代码
            作用:初始化其它外设,加载OS内核
     
    (4)三者之间的关系:(Interal ROM固化代码)BL0将BL1(bootloader的前16KB--BL1)加载到iRAM;BL1然后在iRAM中运行将BL2(剩下的bootloader)加载到SDRAM;BL2加载内核,把OS在SDRAM中运行起来,最终OS是运行在SDRAM(内存)中的。
    BL1 MAX SIZE IS 16K   BL2 MAX SIZE IS 80K.
     
    4,制作u-boot.bin文件的16k的代码如下:(此文件在开发板附赠光盘的裸机代码/src/cdram中)
      1 /* 在BL0阶段,Irom内固化的代码读取nandflash或SD卡前16K的内容,
      2  * 并比对前16字节中的校验和是否正确,正确则继续,错误则停止。
      3  */
      4 #include <stdio.h>
      5 #include <string.h>
      6 #include <stdlib.h>
      7 
      8 #define BUFSIZE                 (16*1024)
      9 #define IMG_SIZE                (16*1024)
     10 #define SPL_HEADER_SIZE         16
     11 #define SPL_HEADER              "S5PC110 HEADER  "
     12 
     13 int main (int argc, char *argv[])
     14 {
     15     FILE        *fp;
     16     char        *Buf, *a;
     17     int        BufLen;
     18     int        nbytes, fileLen;
     19     unsigned int    checksum, count;
     20     int        i;
     21     
     22     // 1. 3个参数
     23     if (argc != 3)
     24     {
     25         printf("Usage: mkbl1 <source file> <destination file>
    ");
     26         return -1;
     27     }
     28 
     29     // 2. 分配16K的buffer
     30     BufLen = BUFSIZE;
     31     Buf = (char *)malloc(BufLen);
     32     if (!Buf)
     33     {
     34         printf("Alloc buffer failed!
    ");
     35         return -1;
     36     }
     37 
     38     memset(Buf, 0x00, BufLen);
     39 
     40     // 3. 读源bin到buffer
     41     // 3.1 打开源bin
     42     fp = fopen(argv[1], "rb");
     43     if( fp == NULL)
     44     {
     45         printf("source file open error
    ");
     46         free(Buf);
     47         return -1;
     48     }
     49     // 3.2 获取源bin长度
     50     fseek(fp, 0L, SEEK_END);
     51     fileLen = ftell(fp);
     52     fseek(fp, 0L, SEEK_SET);
     53     // 3.3 源bin长度不得超过16K-16byte
     54     count = (fileLen < (IMG_SIZE - SPL_HEADER_SIZE))
     55         ? fileLen : (IMG_SIZE - SPL_HEADER_SIZE);
     56     // 3.4 buffer[0~15]存放"S5PC110 HEADER  "
     57     memcpy(&Buf[0], SPL_HEADER, SPL_HEADER_SIZE);
     58     // 3.5 读源bin到buffer[16]
     59     nbytes = fread(Buf + SPL_HEADER_SIZE, 1, count, fp);
     60     if ( nbytes != count )
     61     {
     62         printf("source file read error
    ");
     63         free(Buf);
     64         fclose(fp);
     65         return -1;
     66     }
     67     fclose(fp);
     68 
     69     // 4. 计算校验和
     70      // 4.1 从第16byte开始统计buffer中共有几个1
     71     a = Buf + SPL_HEADER_SIZE;
     72     for(i = 0, checksum = 0; i < IMG_SIZE - SPL_HEADER_SIZE; i++)
     73         checksum += (0x000000FF) & *a++;
     74     // 4.2 将校验和保存在buffer[8~15]
     75     a = Buf + 8;
     76     *( (unsigned int *)a ) = checksum;
     77 
     78     // 5. 拷贝buffer中的内容到目的bin
     79     // 5.1 打开目的bin
     80     fp = fopen(argv[2], "wb");
     81     if (fp == NULL)
     82     {
     83         printf("destination file open error
    ");
     84         free(Buf);
     85         return -1;
     86     }
     87     // 5.2 将16k的buffer拷贝到目的bin中
     88     a = Buf;
     89     nbytes    = fwrite( a, 1, BufLen, fp);
     90     if ( nbytes != BufLen )
     91     {
     92         printf("destination file write error
    ");
     93         free(Buf);
     94         fclose(fp);
     95         return -1;
     96     }
     97 
     98     free(Buf);
     99     fclose(fp);
    100 
    101     return 0;
    102 }

     5,#gcc -o mkv210 mkv210_image.c生成可执行文件的


     
  • 相关阅读:
    [LeetCode]78. Remove Nth Node From end of List删除链表中倒数第N个节点
    [LeetCode]77. Reverse Linked List反转链表
    [LeetCode]76. Permutation Sequence全排列序列
    [LeetCode]75. Pow(x,n)幂运算
    粘连字符分割初探~~
    验证码识别学习~~
    用VS2010编C#程序扫盲 2
    用VS2010编C#程序扫盲
    验证码降噪方法汇总~~~~~
    新生活......
  • 原文地址:https://www.cnblogs.com/eeexu123/p/7259140.html
Copyright © 2020-2023  润新知