This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8127中SPI boot不能启动

大家好,

      我们参照了APPro DM8127的开发板设计,软件版本为DM8127_IPNC_3.80.00。我们使用S25FL256S的spi flash,通过串口启动后把u-boot的第一阶段和第二阶段下载到spi flash中,数据读写正常。验证方法为:

1,从串口把下载第一阶段到DDR中的0x81000000的位置,使用命令把第一阶段下载到spi flash中,

sf probe 0:0
sf erase 0x0 0x20000
sf write 0x81000000 0x0 0x20000

2,从串口把下载第二阶段到DDR中的0x81000000的位置,使用命令把第二阶段下载到spi flash中,

sf probe 0:0
sf erase 0x20000 0x60000
sf write 0x81000000 0x20000 0x40000

3,清除DDR,mw.b 0x81000000 0xFF 0x40000,然后读取spi flash中的数据到ddr中,

sf probe 0:0 

sf read 0x81000000 0x20000 0x40000

然后通过md查看ddr中的数据,与原始数据相同,在运行go 0x81000000,这样u-boot能在ddr中运行,证明了数据写到spi falsh中的准确性。

我的问题是:

但是设置为spi boot后,不能从spi启动。使用示波器测量到,上电时在cs上有一段被拉低,CLK上有一段时钟,MOSI上有一段数据。

我们的spi boot设置为:BTMODE[4:0]= 10110,这个模式第一启动为spi,第二为MMC(我们没有使用),第三为uart。但我断开spi时,上电进到uart模式,有“cccccccc”打印。接上spi时,串口什么都没有打印,说明已经进到了spi模式,但是为什么不能启动呢?是什么原因导致?



  • 你好,

    请问你编译第一级mini uboot的时候,是否使用的是ti8148_evm_min_spi配置?或者是否有手动在mini uboot前面加上image header信息。
    我怀疑是第一级启动代码的的image header没有烧写到spi flash上。

  • 您好,

         谢谢您的回复。我编译的第一级mini uboot的时候,使用了ti8148_evm_min_spi配置的。是不是使用了ti8148_evm_min_spi配置就不需要手动添加image header信息?如果手动添加,怎么添加image header信息呢?谢谢

  • 你好,

    是的,如果选择ti8148_evm_min_spi,编译uboot min的时候header是会自动加到uboot min的最前面。你能否读取第一级uboot min到DDR,看一下前面的header信息是否正确,如果直接跳到min uboot的开始的地方,是否能正常启动uboot min?

  • 你好,

     我编译的命令是:

    make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm distclean
    make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm ti8148_ipnc_min_spi
    make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm u-boot.ti

    这个编译出来的uboot min应该没有问题把。我把uboot mini写到spi flash后,在读取与原文件比较,数据是相同的。我把第一级的uboot min读到DDR中,内容如下:你帮我看看header信息是否正确,谢谢。

    ZTITS_IPNC#md 0x81000000
    81000000: 54fb0000 00003040 120000ea 14f09fe5
    81000010: 14f09fe5 14f09fe5 14f09fe5 14f09fe5
    81000020: 14f09fe5 14f09fe5 20017080 80017080
    81000030: e0017080 40027080 a0027080 00037080
    81000040: 60037080 78563412 00007080 00007080
    81000050: 54fb7080 64057180 00000fe1 1f00c0e3
    81000060: d30080e3 00f029e1 1c0000eb 6c004fe2
    81000070: 30101fe5 010050e1 0700000a 38201fe5
    81000080: 38301fe5 022043e0 022080e0 f807b0e8
    81000090: f807a1e8 020050e1 fbffffda 5c001fe5
    810000a0: 090b40e2 800040e2 0cd040e2 07d0cde3
    810000b0: 68001fe5 68101fe5 0020a0e3 002080e5
    810000c0: 010050e1 040080e2 fbffff1a 150f07ee
    810000d0: 9a0f07ee 950f07ee 04f01fe5 94147080
    810000e0: 0000a0e3 170f08ee 150f07ee d50f07ee
    810000f0: 9a0f07ee 950f07ee 100f11ee 020ac0e3
    ZTITS_IPNC#
    81000100: 0700c0e3 020080e3 020b80e3 010a80e3
    81000110: 100f01ee 0ec0a0e1 ab0000eb 0ce0a0e1
    81000120: 0ef0a0e1 00f020e3 e4d01fe5 09db4de2
    81000130: 88d04de2 00e08de5 00e04fe1 04e08de5
    81000140: 13d0a0e3 0df069e1 0fe0a0e1 0ef0b0e1
    81000150: 48d04de2 ff1f8de8 14211fe5 092b42e2
    81000160: 882042e2 0c0092e8 48008de2 34508de2
    81000170: 0e10a0e1 0f0085e8 0d00a0e1 a40500eb
    81000180: 00f020e3 00f020e3 04d04de2 00008de5
    81000190: 4c011fe5 090b40e2 880040e2 00e080e5
    810001a0: 00004fe1 04e080e5 00009de5 04d08de2
    810001b0: 48d04de2 ff1f8de8 74211fe5 092b42e2
    810001c0: 882042e2 0c0092e8 48008de2 34508de2
    810001d0: 0e10a0e1 0f0085e8 0d00a0e1 830500eb
    810001e0: 00f020e3 00f020e3 a4d11fe5 09db4de2
    810001f0: 88d04de2 00e08de5 00e04fe1 04e08de5
    ZTITS_IPNC#
    81000200: 13d0a0e3 0df069e1 0fe0a0e1 0ef0b0e1
    81000210: 48d04de2 ff1f8de8 d4211fe5 092b42e2
    81000220: 882042e2 0c0092e8 48008de2 34508de2
    81000230: 0e10a0e1 0f0085e8 0d00a0e1 620500eb
    81000240: 00f020e3 00f020e3 04d21fe5 09db4de2
    81000250: 88d04de2 00e08de5 00e04fe1 04e08de5
    81000260: 13d0a0e3 0df069e1 0fe0a0e1 0ef0b0e1
    81000270: 48d04de2 ff1f8de8 34221fe5 092b42e2
    81000280: 882042e2 0c0092e8 48008de2 34508de2
    81000290: 0e10a0e1 0f0085e8 0d00a0e1 410500eb
    810002a0: 00f020e3 00f020e3 64d21fe5 09db4de2
    810002b0: 88d04de2 00e08de5 00e04fe1 04e08de5
    810002c0: 13d0a0e3 0df069e1 0fe0a0e1 0ef0b0e1
    810002d0: 48d04de2 ff1f8de8 94221fe5 092b42e2
    810002e0: 882042e2 0c0092e8 48008de2 34508de2
    810002f0: 0e10a0e1 0f0085e8 0d00a0e1 200500eb

    直接运行uboo mini 不能运行,现象为:

    ZTITS_IPNC#go 0x81000000
    ## Starting application at 0x81000000 ...

  • 你好,

      是否有连上仿真器看看呢?

      1. 检查一下CONTROL_STATUS Register 的值是否正确?

      2. 查看一下ROM CODE 的Tracing Vectors看卡在哪一步了?这部分介绍在TRM手册的4.12章。

  • 你好,

    同意Louis的建议,如果有仿真器的话,可以连上看看相关信息。

    我看了一下你读取的第一级uboot的值。会不会是大小端的问题?

    下面是uboot min for nand的最开始的header信息,用工具在pc上读取的文件信息。header信息请参考DM814x TRM 4.9.1.1 Image Formats章节。 

    下面是从IPNC机器上读取的uboot min for nand的信息:

    _IPNC#nand read.i 0x81000000 0x0 0x20000

    NAND read: device 0 offset 0x0, size 0x20000
     131072 bytes read: OK

    _IPNC#md 0x81000000
    81000000: 00016594 40300000 ea000012 e59ff014    .e....0@........

    uboot里面读取的mini uboot的header的值,32-bit内的两个16-bit正好和你的是相反的。

    有一点想不明白的是,为什么第二级uboot从spi flash读到DDR上是可以运行的。下面是我这里nand的第二级boot的最开始的代码,你能和你的比较一下么?看类似么?

    _IPNC#nand read.i 0x81000000 0x20000 0x60000

    NAND read: device 0 offset 0x20000, size 0x60000
     393216 bytes read: OK
    _IPNC#md 81000000
    81000000: ea000012 e59ff014 e59ff014 e59ff014    ................
    81000010: e59ff014 e59ff014 e59ff014 e59ff014

    另,我这里也尝试直接在ddr上运行min uboot (go 0x81000008,跳过header)但也是不成功,不清楚是否因为实际应用上uboot min是在IRAM里面运行的。

  • 你好,

        做板的时候没有板jtag连接出来,所以连接不上仿真器。

  • 你好,Chris Meng

        大小端应该没什么问题,我从nand 里面读取的mini uboot,打印如下:

    ZTITS_IPNC#md 0x81000000
    81000000: 00016b68 40300000 ea000012 e59ff014   hk....0@........


    第二级我读出来ddr中,打印出来是:

    ZTITS_IPNC#md 0x81000000
    81000000: ea000012 e59ff014 e59ff014 e59ff014 ................
    81000010: e59ff014 e59ff014 e59ff014 e59ff014 ................

    和你的相同。


  • anguo wang 说:

       大小端应该没什么问题,我从nand 里面读取的mini uboot,打印如下:

    ZTITS_IPNC#md 0x81000000
    81000000: 00016b68 40300000 ea000012 e59ff014   hk....0@........


    为什么前面一个帖子是下面的输出?

    ZTITS_IPNC#md 0x81000000
    81000000: 54fb0000 00003040 120000ea 14f09fe5

  • 你好,

    我想对比的是你从SPI flash 读取uboot min/uboot到DDR的信息。

    我手上没有SPI flash的硬件,但从读取到DDR的内容上来对比,NAND和SPI flash应该是类似的。

  • 你好,

    我从SPI flash读取的第一阶段min uboot到DDR中打印出来是:

    ZTITS_IPNC#md 0x81000000
    81000000: e4f90000 00003040 120000ea 14f09fe5 ....@0..........
    81000010: 14f09fe5 14f09fe5 14f09fe5 14f09fe5 ........

    从SPI flash读取第二阶段的内容为:

    ZTITS_IPNC#md 0x81000000
    81000000: ea000012 e59ff014 e59ff014 e59ff014 ................
    81000010: e59ff014 e59ff014 e59ff014 e59ff014 ................

    你帮我看看。谢谢

  • 感觉 spi flash读取的min uboot是存在大小端的问题,但是就这几个信息,其他的感觉又是正常的,是不是编译导致呢?

    ZTITS_IPNC#md 0x81000000
    81000000: e4f90000 00003040 120000ea 14f09fe5 ....@0..........

  • 你好,

    我对比一下用spi和nand配置分别编译出来的spi的uboot min和nand的uboot min,的确两个bin文件的大小端是不一样的。我之前只在DM8148 EVM上用CCS的烧写工程烧写uboot min到spi flash上,没有使用uboot里面的命令来试过。可能CCS烧写需要的endian和uboot里面spi 驱动使用的endian正好是不一样的。

    uboot代码的u-boot\tools\tiimage.c里面有如下的代码,SPI的image是专门做了endian的转换的,和上面的uboot min对比结果是一致的。你能否修改uboot代码,把tiimage_swap32去掉,看看新编译出的spi uboot min能否正常使用?

    /* SPI image for TI81XX needs endian conversion */
    #if defined(CONFIG_TI81XX_SPI_BOOT)
    static uint32_t tiimage_swap32(uint32_t data)
    {
     uint32_t result = 0;
     result  = (data & 0xFF000000) >> 24;
     result |= (data & 0x00FF0000) >> 8;
     result |= (data & 0x0000FF00) << 8;
     result |= (data & 0x000000FF) << 24;
     return result;
    }

    static int ti81xximage_spi(void *hdr, int hdr_size,
     char *in_file, char *out_file)
    {
     FILE *in_fp = NULL;
     FILE *out_fp = NULL;
     uint32_t *rd;
     uint8_t rds[4];
     uint32_t wr = 0;
     uint32_t count;

     in_fp = fopen(in_file, "r");
     out_fp = fopen(out_file, "w");

     if(in_fp == NULL || out_fp == NULL) {
      printf("file open error \n");
      return 0;
     }
     rd = (uint32_t*)(hdr);

     while (hdr_size > 0) {
      wr = tiimage_swap32(*rd);
      fwrite(&wr, sizeof(uint32_t), 1, out_fp);
      hdr_size -= sizeof(uint32_t);
      rd++;
     }

     rd = (uint32_t*)(rds);
     while (!feof(in_fp)) {
      count = fread(rds, sizeof(uint32_t), 1, in_fp);
      if (feof(in_fp))
       break;
      wr = tiimage_swap32(*rd);
      fwrite(&wr, sizeof(uint32_t), 1, out_fp);
     }

     fclose(in_fp);
     fclose(out_fp);
     return 0;
    }
    #endif

  • 你好,

    我把tiimage_swap32去掉后,编译出来的spi uboot min还是不能正常使用。读取到ddr中打印为:

    ZTITS_IPNC#md 0x81000000
    81000000: 0000f9e4 40300000 ea000012 e59ff014 ......0@........

    这个看起来是正常了。但是还是不能spi boot启动。


  • 你好,

    请问你是如何修改代码的?是把wr = tiimage_swap32(*rd);改为wr = *rd;么?

    请问你uboot里面除了DDR相关时序部分和endian swap外,其他是否有什么修改? spi flash启动在DM8148 EVM上是可以成功的,而DM8127这部分和DM812x是类似的,所以uboot的代码应该是没有大问题的。

    另外有一点,没有JTAG接口的话,DDR SW leveling就没有办法做,这个是必须做的。你们后续的板子上至少要把JTAG的焊点留出来,至少有一块板子上要把JTAG飞线出来做DDR SW leveling。

  • 你好,

    1,我是直接修改原函数的:把

    static uint32_t tiimage_swap32(uint32_t data)
    {
    uint32_t result = 0;
    result = (data & 0xFF000000) >> 24;
    result |= (data & 0x00FF0000) >> 8;
    result |= (data & 0x0000FF00) << 8;
    result |= (data & 0x000000FF) << 24;
    return result;
    }

    修改为:

    static uint32_t tiimage_swap32(uint32_t data)
    {
    return data;
    }

    2,我就修改我我们是的SPI flash芯片的驱动,其他没有修改。

    3,目前来看,DDR是能正常运行的,不做DDR SW leveling会有影响吗?

  • 你好,

    请问你用的是SPI0么?

    如果不做DDR SW leveling,无法保证系统可以长时间稳定运行。

  • 你好,Chris Meng

         我使用的是SPI0,我这批样板调试通过后,下次打板就可以把JTAG引出来,就可以做DDR SW leveling。

    但是我现在SPI flash启动不了,查不出具体原因来。