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.

C6678 spi测试不通过



芯片为C6678,SPI NOR FLASH型号为N25Q128A11ESF40F,板子是自己设计的。目前只有I2C和GPIO测试通过了。测试SPI时候遇到很多问题,以下是SPI测试过程的一些记录。本人软件基础比较薄弱,希望大神帮忙分析下。

1.   最初启动配置为SPI启动模式,运行SPI测试例程时提示DDR3 Leveling failed,后来看了论坛说要修改DDR3的初始化参数,按照官网提供的表格修改后没有再提示Leveling failed。

2.   但是SPI测试程序跑不通。后来看SPI的测试文档说要改为no boot mode。

3.   之后将启动方式修改为no boot mode,程序编译完加载的时候提示如下:

C66xx_0: GEL Output: Setup_Memory_Map...

C66xx_0: GEL Output: Setup_Memory_Map... Done.

C66xx_0: GEL Output:

Connecting Target...

C66xx_0: GEL Output: DSP core #0

C66xx_0: GEL Output: C6678L GEL file Ver is 2.005

C66xx_0: GEL Output: Global Default Setup...

C66xx_0: GEL Output: Setup Cache...

C66xx_0: GEL Output: L1P = 32K  

C66xx_0: GEL Output: L1D = 32K  

C66xx_0: GEL Output: L2 = ALL SRAM  

C66xx_0: GEL Output: Setup Cache... Done.

C66xx_0: GEL Output: Main PLL (PLL1) Setup ...

C66xx_0: GEL Output: PLL in Bypass ...

C66xx_0: GEL Output: PLL1 Setup for DSP @ 1000.0 MHz.

C66xx_0: GEL Output:            SYSCLK2 = 333.3333 MHz, SYSCLK5 = 200.0 MHz.

C66xx_0: GEL Output:            SYSCLK8 = 15.625 MHz.

C66xx_0: GEL Output: PLL1 Setup... Done.

C66xx_0: GEL Output: Power on all PSC modules and DSP domains...

C66xx_0: GEL Output: Security Accelerator disabled!

C66xx_0: GEL Output: Power on all PSC modules and DSP domains... Done.

C66xx_0: GEL Output: PA PLL (PLL3) Setup ...

C66xx_0: GEL Output: PA PLL Setup... Done.

C66xx_0: GEL Output: DDR3 PLL (PLL2) Setup ...

C66xx_0: GEL Output: DDR3 PLL Setup... Done.

C66xx_0: GEL Output: DDR begin (1333 auto)

C66xx_0: GEL Output: XMC Setup ... Done

——————————————————————————————

C66xx_0: GEL Output:

DDR3 initialization is complete.

C66xx_0: GEL Output: DDR done

C66xx_0: GEL Output: DDR3 memory test... Started

C66xx_0: GEL Output: DDR3 memory test... Failed

C66xx_0: GEL Output: Main PLL (PLL1) Setup ...

C66xx_0: GEL Output: PLL not in Bypass, Enable BYPASS in the PLL Controller...

C66xx_0: GEL Output: PLL1 Setup for DSP @ 1000.0 MHz.

C66xx_0: GEL Output:            SYSCLK2 = 333.3333 MHz, SYSCLK5 = 200.0 MHz.

C66xx_0: GEL Output:            SYSCLK8 = 15.625 MHz.

C66xx_0: GEL Output: PLL1 Setup... Done.

C66xx_0: GEL Output: PA PLL (PLL3) Setup ...

C66xx_0: GEL Output: PA PLL Setup... Done.

C66xx_0: GEL Output: DDR3 PLL (PLL2) Setup ...

C66xx_0: GEL Output: DDR3 PLL Setup... Done.

C66xx_0: GEL Output: DDR begin (1333 auto)

C66xx_0: GEL Output: XMC Setup ... Done

—————————————————————虚线之间部分循环十次

C66xx_0: GEL Output:

SGMII SERDES has been configured.

C66xx_0: GEL Output: Enabling EDC ...

C66xx_0: GEL Output: L1P error detection logic is enabled.

C66xx_0: GEL Output: L2 error detection/correction logic is enabled.

C66xx_0: GEL Output: MSMC error detection/correction logic is enabled.

C66xx_0: GEL Output: Enabling EDC ...Done

C66xx_0: GEL Output: Configuring CPSW ...

C66xx_0: GEL Output: Configuring CPSW ...Done

C66xx_0: GEL Output: Global Default Setup... Done.

C66xx_0: GEL Output: Invalidate All Cache...

C66xx_0: GEL Output: Invalidate All Cache... Done.

C66xx_0: GEL Output: GEL Reset...

C66xx_0: GEL Output: GEL Reset... Done.

C66xx_0: GEL Output: Disable all EDMA3 interrupts and events.

4.   加载完成后运行

#define SPI_LOOPBACK_TEST               1

#define SPI_NOR_FLASH_TEST             1

#define SPI_EDMA_TEST                          1

上面这三个是最初选择的测试项,运行时提示

[C66xx_0] JTAG ID= 0x1009e02f. This is C6678/TCI6608 device, version variant = 1.

DEVSTAT= 0x00018200. big endian, No boot or EMIF16(NOR FLASH) or UART boot, PLL configuration implies the input clock for core is 50MHz.

SmartReflex VID= 50, required core voltage= 1.020V.

Die ID= 0x01013011, 0x04043ad2, 0x00000000, 0x7b160021

Device speed grade = 1000MHz.

Enable Exception handling...

Initialize DSP main clock = 156.25MHz/5x32 = 1000MHz

Initialize DDR speed = 156.25MHzx/15x128 = 1333.333MTS

ERROR: SPI format 1 speed higher than 66 MHz!

 

SPI internal loopback test at 858993MHz...

SPI loopback test passed with data pattern 0x0. Throughput= 20Mbps

SPI loopback test failed at word 0: TX 0xffff, RX 0x0

SPI loopback test failed at word 0: TX 0x5555, RX 0x0

此时发现loopback的时钟设置超过66MHz了,于是看了下在

***.dataFormat[1]= &loopbackDataFormat;

之后spiCfg.dataFormat[1]->clockSpeedKHz内并没有写入正确值(后来发现loopbackDataFormat内所有值都没正确赋给spiCfg.dataFormat[1])。这里不知道为什么。

没办法只能将SPI_Init()函数里面的三个结构体数组赋值处单独按DataFormat内容写一遍,如下:

***.dataFormat[0]= &FlashDataFormat;

***.dataFormat[0]->delayBetweenTrans_ns = 0;

***.dataFormat[0]->ShifDirection = SPI_MSB_SHIFT_FIRST;

***.dataFormat[0]->disable_CS_timing = 0;

***.dataFormat[0]->clockPolarity = SPI_CLOCK_LOW_INACTIVE;

***.dataFormat[0]->clockPhase = 1;

***.dataFormat[0]->clockSpeedKHz = 54000;

***.dataFormat[0]->wordLength = 8;

 

***.dataFormat[1]= &loopbackDataFormat;

***.dataFormat[1]->delayBetweenTrans_ns = 0;

***.dataFormat[1]->ShifDirection = SPI_MSB_SHIFT_FIRST;

***.dataFormat[1]->disable_CS_timing = 1;

***.dataFormat[1]->clockPolarity = SPI_CLOCK_LOW_INACTIVE;

***.dataFormat[1]->clockPhase = 0;

***.dataFormat[1]->clockSpeedKHz = 66000;

***.dataFormat[1]->wordLength = 16;

 

***.dataFormat[2]= &EdmaDataFormat;

***.dataFormat[2]->delayBetweenTrans_ns = 0;

***.dataFormat[2]->ShifDirection = SPI_MSB_SHIFT_FIRST;

***.dataFormat[2]->disable_CS_timing = 1;

***.dataFormat[2]->clockPolarity = SPI_CLOCK_LOW_INACTIVE;

***.dataFormat[2]->clockPhase = 0;

***.dataFormat[2]->clockSpeedKHz = 66000;

***.dataFormat[2]->wordLength = 16;

这回结构体数组内容对了,运行下:

SPI internal loopback test at 66MHz...

SPI loopback test passed with data pattern 0x0. Throughput= 20Mbps

SPI loopback test failed at word 0: TX 0xffff, RX 0x0

SPI loopback test failed at word 0: TX 0x5555, RX 0x0

SPI interrupt test: manually generate RX overrun error…

Loopback failed然后停住不动了。

5.   之后把EDMA测试去掉

#define SPI_LOOPBACK_TEST               1

#define SPI_NOR_FLASH_TEST             1

#define SPI_EDMA_TEST                          0

运行结果loopback通过了。。。什么情况

SPI internal loopback test at 66MHz...

SPI loopback test passed with data pattern 0x0. Throughput= 28Mbps

SPI loopback test passed with data pattern 0xffff. Throughput= 28Mbps

SPI loopback test passed with data pattern 0x5555. Throughput= 28Mbps

SPI interrupt test: manually generate RX overrun error...

但是中断测试那里又停住了。。。

6.   为了测试SPI Flash,把loopback测试里面的SPI_interrupt_test();屏蔽掉,再运行。

SPI internal loopback test at 66MHz...

SPI loopback test passed with data pattern 0x0. Throughput= 28Mbps

SPI loopback test passed with data pattern 0xffff. Throughput= 28Mbps

SPI loopback test passed with data pattern 0x5555. Throughput= 28Mbps

 

SPI NOR FLASH test at 30MHz...

Read SPI NOR FLASH ID = 0x48 0x17 0xa2

Save data from 0xf00000 to 0xf40000.

erase failed at 0xf00000

loopback过去了, NOR FLASH的ID读取错误,正确值应该为0x20 0xbb 0x18

降低时钟频率,再试:

SPI internal loopback test at 66MHz...

SPI loopback test passed with data pattern 0x0. Throughput= 28Mbps

SPI loopback test passed with data pattern 0xffff. Throughput= 28Mbps

SPI loopback test passed with data pattern 0x5555. Throughput= 28Mbps

 

SPI NOR FLASH test at 1MHz...

Read SPI NOR FLASH ID = 0xa1 0x11 0x9c 这里值不同了

Save data from 0xf00000 to 0xf40000.

erase failed at 0xf00000

 

有下面几个疑问:

(1)程序加载的时候提示的

C66xx_0: GEL Output: DDR3 memory test... Started

C66xx_0: GEL Output: DDR3 memory test... Failed

C66xx_0: GEL Output: PLL and DDR Initialization failed ...

是什么意思,leveling没成功?我是5片4Gbit的DDR3,是不是哪里设置不对。ECC不用的话DDR3焊5片的话会有影响吗?我的DDR3型号为MT41K256M16HA-107IT:E

(2)EDMA_TEST对loopback_TEST有影响吗,同时进行的时候LOOPBACK不成功是什么原因。

(3)***.dataFormat[0] = &FlashDataFormat;赋值不成功原因是什么?

(4)NOR FLASH的ID读取错误,找了半天不知道什么原因啊。根DDR3会有关系吗?

NOR FLASH型号与开发板不同,是N25Q128A11ESF40F,需要修改哪里吗?

C比较弱,读程序比较吃力,希望高手帮分析下。