📄 post.c
字号:
/*H*****************************************************************************
*
* $Archive:: $
* $Revision:: $
* $Date:: $
* $Author:: $
*
* DESCRIPTION: TMS320C64xx TEB test code
*
* GLOBALS
*
* PUBLIC FUNCTIONS:
*
* PRIVATE FUNCTIONS:
*
* USAGE/LIMITATIONS:
*
* NOTES: Assumptions:
* TMS320C64x TEB
* CPLD connected to EMIF B, TBCE0
* AMD29LV400BT flash connected to EMIF B, TBCE1
* SDRAM connected to EMIF A, TACE0
*
* COMPILE SWITCHES:
* cpld.c
* - Define CPLD_SIMULATE to provide a simple sw simulation of
* the CPLD registers. Compile command line switch.
*
* amd29lv400bt.c
* - Define FLASH_DEBUG to enable debug code for flash.
* - Define SUBROUTINE_IF to enable external call to flash test.
*
*
* LED Diagnostic Codes: (0=off, 1=on)
* C L L L
* O E E E
* D D D D
* E 2 1 0
* - - - -
* 0 0 0 0 Start state
* 1 0 0 1 TEST 1: CPLD
* 2 0 1 0 TEST 2: Internal SRAM
* 3 0 1 1 TEST 3: External SDRAM
* 4 1 0 0 TEST 4: External FLASH
* 5 1 0 1 TEST 5: External Codec
* 6 1 1 0 TEST 6: UNUSED
* 7 1 1 1 TEST 7: UNUSED/AVAILABLE FOR FUTURE TEST USE
* BLINK ALL All tests completed successfully
*
*
*H***************************************************************************/
#define post_c
/*---- compilation control switches ----------------------------------------*/
/*****************************************************************************
* INCLUDE FILES
*****************************************************************************/
/*---- system and platform files -------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <c6x.h>
/*---- program files -------------------------------------------------------*/
#include "c6416teb.h"
//#include "cpld.h"
#include "flash.h"
#include "sdram.h"
#include "timer.h"
#include "emif.h"
/*****************************************************************************
* EXTERNAL REFERENCE
*****************************************************************************/
/*---- data declarations ---------------------------------------------------*/
#define LED_TEST_START 0
#define LED_CPLD 1
#define LED_IRAM 2
#define LED_SDRAM 3
#define LED_FLASH 4
#define LED_CODEC 5
#define LED_PROG_BOOT 8
#define TEST_TIMER_DELAY 300 // Delay between tests
#define BLINK_DELAY 100 // Delay between blink
#define BLINK_COUNT 3 // Blink LED N times for visual
#define AMD_29LV400_MFG_ID 0x0001 // TEB Flash used
#define AMD_29LV400_DEV_ID 0x003E
// Start out with all tests in the error state. If they pass then we will
// set the value to pass.
int PASS_CpldVersion = 0;
int PASS_Sdram = 0;
int PASS_Flash = 0;
int PASS_Iram = 0;
int PASS_Codec = 0; // Not currently tested.
int DoProgramBootFlash = 1; // Do NOT program the boot flash by default
/*---- function prototypes -------------------------------------------------*/
/*****************************************************************************
* PUBLIC DECLARATIONS
*****************************************************************************/
/*---- data declarations ---------------------------------------------------*/
/*****************************************************************************
* PRIVATE DECLARATIONS
*****************************************************************************/
/*---- context -------------------------------------------------------------*/
/*---- data declarations ---------------------------------------------------*/
/*---- function prototypes -------------------------------------------------*/
extern int SubRoutineFlashTestMain( void );
/*---- macros --------------------------------------------------------------*/
/*****************************************************************************
* PUBLIC FUNCTION DEFINITIONS
*****************************************************************************/
void EXIT_Post( void )
{}
/****************************************
void BlinkLed( int Led )
{
int i;
for( i=0; i<BLINK_COUNT; i++ )
{
CPLD_LedOff( Led );
TIMER_DelayMsec( BLINK_DELAY );
CPLD_LedOn( Led );
TIMER_DelayMsec( BLINK_DELAY );
}
}
SetLedCode ( int Led )
{
CPLD_LedOff( LED_ALL );
CPLD_LedOn( Led );
TIMER_DelayMsec( TEST_TIMER_DELAY );
}
************************************/
void ProgramBootImage( void )
{
//int i,j;
//int Led;
// Reset all the globals for sanity
PASS_CpldVersion = 0;
PASS_Sdram = 0;
PASS_Flash = 0;
PASS_Iram = 0;
PASS_Codec = 0;
DoProgramBootFlash = 1;
// Program one flash sector with the image of this program.
if( !FLASH_Erase( FLASH_BOOT_ADDRESS ))
{
FLASH_Write( (FLASH_BOOT_ADDRESS), (void*)0, 0x8000 );
}
}
/*******************************************************************************
* FUNCTION : mem_test (Taken from C6711 DSK )
*
* ARGUMENTS :
* INT pattern <-- Pattern to be written or read from the memory
* INT start_address <-- Address from which to start testing memory
* INT size_in_word <-- Number of words to test in memory
*
* DESCRIPTION :
* Write the pattern to memory beginning at the start_address through the
* number of locations specified by size_in_word. Read the same locations
* and generate an error if the value read back differs from the pattern
* written.
*
* OUTPUTS :
* INT error <-- True if value read differs from pattern written
*
*******************************************************************************/
int mem_test (int pattern, int start_address, int size_in_word )
{
int i;
int error = 0;
int *mem_ptr = (int *)start_address;
/* Write pattern to the memory */
for(i=0;i<size_in_word;i++)
{
*mem_ptr++ = pattern;
}
/* Read memory and compare contents to the pattern written */
mem_ptr = (int *)start_address;
for(i=0;i<size_in_word;i++)
{
if ( *mem_ptr++ != pattern) error++;
}
return error;
}
/*******************************************************************************
* FUNCTION : mem_test_alt (Taken from C6711 DSK )
*
* ARGUMENTS :
* INT pattern <-- Pattern to be written or read from the memory
* INT start_address <-- Address from which to start testing memory
* INT size_in_word <-- Number of words to test in memory
*
* DESCRIPTION :
* Write the pattern to odd memory locations beginning at the start_address
* through the number of locations specified by size_in_word. AND Write the
* complement of the pattern to even memory locations. Read the same locations
* and generate an error if the value read back differs from the pattern
* written.
*
* OUTPUTS :
* INT error <-- True if value read differs from pattern written
*
*******************************************************************************/
int mem_test_alt (int pattern, int start_address, int size_in_word )
{
int i;
int temp_read, temp_expected;
int error = 0;
int *mem_ptr = (int *)start_address;
/* Write pattern to the memory */
for(i=0;i<size_in_word;i++)
{
if(i%2)
*mem_ptr++ = ~pattern;
else
*mem_ptr++ = pattern;
}
/* Read memory and compare contents to the pattern written */
mem_ptr = (int *)start_address;
for(i=0;i<size_in_word;i++)
{
temp_read = *mem_ptr++;
if(i%2)
temp_expected = ~pattern;
else
temp_expected = pattern;
if ( temp_read != temp_expected ) error++;
}
return error;
}
/*F***************************************************************************
* NAME: main
*
* DESCRIPTION:
*
* NOTES:
*
*F***************************************************************************/
void main( void )
{
int i;
//int j;
//int DramErrors;
int FlashErrors;
FLASH_MFG_CODE FlashMfg;
FLASH_DTYPE Temp;
char * pWrite;
// CSL_init();
/* DSP initialization */
// IRQ_globalDisable();
// for(i=0;i<32;i++){
// IRQ_disable(i); /* Disable and clear all IRQ events */
// IRQ_clear(i); /* except reset and NMI interrupts */
// }
// EMIF_Init();
// ===================================================================
// BEGIN: INTERNAL SRAM TEST
/*****************************************************
SetLedCode ( LED_IRAM );
if( (mem_test(ALL_5,INTERNAL_MEM_START,INTERNAL_MEM_SIZE) == 0)
&& (mem_test(ALL_A,INTERNAL_MEM_START,INTERNAL_MEM_SIZE) == 0))
{
PASS_Iram = 1;
}
// END: INTERNAL SRAM TEST
// ===================================================================
// ===================================================================
// BEGIN: SDRAM TEST
DramErrors = 0;
// Make sure all 8 byte strobes are working
if( DRAM_ByteStrobes( SDRAM_TEST_ADDRESS, 0x11223344L ))
DramErrors++;
// Test for 0/1 data on bits (31 downto 0 )
if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS, 1,32 ))
DramErrors++;
if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS, 0,32 ))
DramErrors++;
// Test for 0/1 data on bits (63 downto 32 )
if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS+4, 1,32 ))
DramErrors++;
if( DRAM_SlidingData32( SDRAM_TEST_ADDRESS+4, 0,32 ))
DramErrors++;
// Test that all the address bits to the sdram are unique
if( DRAM_SlidingAddr32( SDRAM_TEST_ADDRESS , SDRAM_ADDRESS_BITS))
DramErrors++;
// Test that all bits in the SDRAM can be written to 0/1
if( (mem_test(ALL_5,SDRAM_TEST_ADDRESS,(1<<SDRAM_ADDRESS_BITS)))
|| (mem_test(ALL_A,SDRAM_TEST_ADDRESS,(1<<SDRAM_ADDRESS_BITS))))
DramErrors++;
// Bulk test of DRAM data == DRAM address. Tests that each address
// is unique.
if( DRAM_AddressAsData( SDRAM_TEST_ADDRESS, (1<<SDRAM_ADDRESS_BITS) ))
DramErrors++;
if( DramErrors == 0 )
{
PASS_Sdram = 1;
}
********************************************************/
// END: SDRAM TEST
// ===================================================================
// ===================================================================
// BEGIN: FLASH TEST
// This will test 1 block of flash up in the upper portion of the
// array. It will NOT disturb the POST sector.
FlashErrors = 0;
FlashMfg.MfgId = 0;
FlashMfg.DevId = 0;
FLASH_MfgCode( & FlashMfg );
if( ( FlashMfg.MfgId != AMD_29LV400_MFG_ID )
|| ( FlashMfg.DevId != AMD_29LV400_DEV_ID ))
FlashErrors++;
if( FlashErrors == 0 )
{
for(i = 0; i < 15; i ++)
{
if( FLASH_Erase( FLASH_TEST_ADDRESS + i * 0x10000))
FlashErrors++;
}
if( FLASH_Erase((FLASH_ADDR)0x640f0000 ))
FlashErrors++;
if( FLASH_Erase((FLASH_ADDR)0x640f8000 ))
FlashErrors++;
if( FLASH_Erase((FLASH_ADDR)0x640fa000 ))
FlashErrors++;
if( FLASH_Erase((FLASH_ADDR)0x640fc000 ))
FlashErrors++;
if( FlashErrors == 0 )
{
for( i=0; i<255; i++ )
{
Temp = (FLASH_DTYPE)i;
FLASH_Write( (FLASH_TEST_ADDRESS+i), (void*)&Temp,1);
}
for( i=0; i<255; i++ )
{
FLASH_Read( (FLASH_TEST_ADDRESS+i), (void*)&Temp, 1 );
if( Temp != ( FLASH_DTYPE)(i &0x0ff ))
FlashErrors++;
}
}
}
if( FLASH_Erase( FLASH_TEST_ADDRESS ))
FlashErrors++;
if( FlashErrors == 0 )
{
PASS_Flash = 1;
}
// END: FLASH TEST
// ===================================================================
// ===================================================================
// BEGIN: PROGRAM BOOT IMAGE
// We only program the boot image if the user has set the
// DoProgramBootFlash value to 1 from CCS.
if( DoProgramBootFlash == 1 )
{
pWrite = (char *)(0x30000);
FLASH_Write((FLASH_ADDR)(0x64000000), pWrite,0x30000);
// ProgramBootImage();
}
myBootCode();
// END : PROGRAM BOOT IMAGE
EXIT_Post();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -