⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flashwriternor.c

📁 OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI的双核处理器
💻 C
📖 第 1 页 / 共 4 页
字号:
///////////////////////////////////////////////////////////////////////////////
//
// Copyright 1999, 2000, 2001, 2002, 2003, 2004 by Texas Instruments Incorporated. All rights 
// reserved.  Property of Texas Instruments Incorporated. Restricted rights to use,
// duplicate or disclose this code are granted through contract.
//
///////////////////////////////////////////////////////////////////////////////
//
// This file contains the stand-alone code for messaging through UART, USB or JTAG
// Flash.  
//
// Last Revision date:  2-2-04
// Release 1.9
//
//Headers
//
//#include "..\\include\\types.h"
#include "Flash_params.h"
//#include "..\\include\\OMAP.h"
//#include "..\\include\\protocol.h"
//#include "..\\include\\OST_Load.h"
//#include "..\\include\\OST_Load_uart1.h"

//Externally referenced functions for printing messages to host tool or through 
//CCS using JTAG
extern void user_message(char *msg);
extern void user_setprogressrange(unsigned long endofrange);
extern void user_setprogress(unsigned long progress);
extern void user_end();
extern void user_error(unsigned long error);
extern void uart1_transmit_data(byte *data, unsigned long len);
extern t_interface find_interface();
extern DWORD identify_device();

//
//Globals 
//
//Parameters downloaded in .vars section
//(this sits at fixed memory locations!)
#pragma DATA_SECTION ( image, ".image" )
ULONG image;
#pragma DATA_SECTION ( global_vars, ".vars" )
Download_Parms global_vars; 
Download_Parms *gp_vars = &global_vars;
volatile DWORD UART_BASE_ADDR;
volatile t_interface interface = UART1;
//
//Build Parameters
BOOL IsPerseus;
// NOR Flash Dependent Function Pointers
void (*User_Hard_Reset_Flash)(void);
void (*User_Soft_Reset_Flash)(unsigned long addr);
void (*User_Flash_Erase_Block)(unsigned long addr);
void (*User_Flash_Erase_All)(unsigned long addr);
void (*User_Flash_Write_Entry)(void);
int (*User_Flash_Write)(unsigned long *addr, unsigned short data);
int (*User_Flash_Optimized_Write)(unsigned long *addr, unsigned short data[], unsigned long);
void (*User_Flash_Write_Exit)(void);

void printinfo(ULONG size, ULONG srcAddr, ULONG destAddr)
{
	user_message("FlashWriter Version 1.9\n");	
	user_message("Starting Download to NOR Flash\n");	
}

void printNORflashtype(enum NORFlashType flash_id)
{
	switch (flash_id)
	{
		case FLASH_NOT_FOUND:	
			user_message("Flash not Found or unsupported!\n");
			break;
		case FLASH_AMD_DL323_4MB_BOTTOM:  	// chip size is 4MB (AM29DL323CB:  2MBx16bit)
			user_message("Flash AMD DL323 4MB Bottom\n");
			break;
		case FLASH_FUJITSU_DL323_4MB_BOTTOM:// chip size is 4MB (MBM29DL323BD:  2MBx16bit)
			user_message("Flash Fujitsu DL323 4MB Bottom\n");
			break;		
		case FLASH_AMD_LV160_2MB_BOTTOM:
			user_message("Flash AMD LV160 2MB Bottom\n");
			break;
		case FLASH_AMD_LV256M_32MB:                   
			user_message("Flash AMD LV256M 32MB\n");        
			break; 
///ahuo add			   
		case S29NS128N:                   
			user_message("S29NS128N\n");        
			break;  
			
			
			                              			
		case FLASH_INTEL_BURST_16MB_BOTTOM:  // 4 2MB devices=8MB total
			user_message("Flash Intel Burst 8MB Bottom\n");
			break;	
		case FLASH_INTEL_STRATA_J3_4MB:  // 2 4MB devices=8MB
			user_message("Flash Intel J3 Strata 8 MB\n");
			break;
		case FLASH_INTEL_STRATA_J3_8MB:  // 2 8MB devices=16MB  			
			user_message("Flash Intel J3 Strata 16MB\n");
			break;
		case FLASH_INTEL_STRATA_J3_16MB:  // 2 16MB devices=32MB
			user_message("Flash Intel J3 Strata 32 MB\n");
			break;
		case FLASH_INTEL_STRATA_K3_16MB:  // 16MB devices=32MB
			user_message("Flash Intel K3 Strata 32 MB\n");
			break;
		case FLASH_INTEL_W18_16MB_BOTTOM: 		
			user_message("Flash Intel W18 16MB Bottom\n");
			break;
		case FLASH_INTEL_W18_16MB_TOP: 
			user_message("Flash Intel W18 16MB Top\n");
			break;		
		case FLASH_INTEL_L18_16MB_BOTTOM: 		
			user_message("Flash Intel L18 16MB Bottom\n");
			break;
		case FLASH_INTEL_L18_16MB_TOP: 
			user_message("Flash Intel L18 16MB Muxed Top\n");
			break;		
		case FLASH_INTEL_L18_32MB_BOTTOM: 		
			user_message("Flash Intel L18 32MB Bottom\n");
			break;
		case FLASH_INTEL_L18_32MB_TOP: 
			user_message("Flash Intel L18 32MB Top\n");
			break;
//modify by mjwu,2005-11-23,start
		case FLASH_INTEL_L18_8MB_TOP_MUX:
			user_message("Flash Intel L18 8MB MUXED Top\n");
			break;
		case FLASH_INTEL_L18_16MB_TOP_MUX:
			user_message("Flash Intel L18 16MB MUXED Top\n");
			break;
//modify by mjwu,2005-11-23,end
		case FLASH_INTEL_L18_32MB_TOP_MUX:
			user_message("Flash Intel L18 32MB MUXED Top\n");
			break;
		case FLASH_INTEL_K18_32MB_BOTTOM: 
			user_message("Flash Intel K18 32 MB Stacked device\n");
			break;		
		case FLASH_MICRON_16MB_TOP: 		
			user_message("Flash Micron 16MB Top\n");
			break;
		case FLASH_SAMSUNG_16MB_TOP: 		
			user_message("Flash SAMSUNG 16MB Top\n");
			break;
		case FLASH_SAMSUNG_32MB_TOP_MUX:
			user_message("Flash SAMSUNG 32MB MUXED Top\n");
			break;
		default:
			user_message("ERROR\n");
			break;
		
	    }
}

///////////////////////////////////////////////////////////////////////////////
//
// IdentifyNORFlash
//
// Description:
//   Reads the Flash Manufacturer ID and device codes to differentiate
//   the flash device for the Flash Device at address 0x0C000000.
//
// Return:
//   FLASH_NOT_FOUND
//   FLASH_UNSUPPORTED
//	 FLASH_device
//	
///////////////////////////////////////////////////////////////////////////////
enum NORFlashType IdentifyNORFlash(ULONG addr)
{
	enum NORFlashType flash_id;
	Hwd manf;
	Hwd code;
	Hwd code1;                 // First  Mult-Address Code     //   
	Hwd code2;                 // Second Mult-Address Code     //     
	volatile USHORT *fladdr = (volatile USHORT *) addr;
	
	// Initialize Function Pointers. 
	User_Flash_Erase_Block = (void (*)(ULONG))Flash_Do_Nothing;
	User_Flash_Erase_All   = (void (*)(ULONG))Flash_Do_Nothing;
	User_Flash_Write       = (int (*)(ULONG *, USHORT))Flash_Do_Nothing;        		
	User_Flash_Optimized_Write = (int (*)(ULONG *, USHORT[], ULONG))Flash_Do_Nothing;

	//  First try the AMD device
	*(fladdr + AMD_CMD0_ADDR) = AMD_ID_CMD0;
	*(fladdr + AMD_CMD1_ADDR) = AMD_ID_CMD1;
	*(fladdr + AMD_CMD2_ADDR) = AMD_ID_CMD2;

  	manf = *fladdr;	
  	
  	if (manf == AMD_MANF_ID)
	{
		// Check device ID
		code = *(fladdr + AMD_DEVICE_ID_OFFSET);    // device code at address 1
		switch (code)
		{
			case AMD1_DEVICE_ID:			   // More Codes need to go here
				flash_id = FLASH_AMD_DL323_4MB_BOTTOM;				
				User_Flash_Erase_Block = AMD_Flash_Erase_Block;
				User_Flash_Erase_All   = AMD_Flash_Erase_All;
				User_Flash_Write_Entry = Flash_Do_Nothing;
				User_Flash_Write   =    AMD_Flash_Write;
				User_Flash_Write_Exit = Flash_Do_Nothing;
				break;
			case AMD2_DEVICE_ID:			   // More Codes need to go here
				flash_id = FLASH_AMD_LV160_2MB_BOTTOM;
				User_Flash_Erase_Block = AMD_Flash_Erase_Block;
				User_Flash_Erase_All   = AMD_Flash_Erase_All;
				User_Flash_Write_Entry = Flash_Do_Nothing;
				User_Flash_Write   =    AMD_Flash_Write;
				User_Flash_Write_Exit = Flash_Do_Nothing;
				break;
			case AMD_DEVICE_ID_MULTI:          //For Multi-Address ID Devices 
                

				{                                                                     
					code1 = *(fladdr + AMD_DEVICE_ID_OFFSET1);                        
					code2 = *(fladdr + AMD_DEVICE_ID_OFFSET2);                                                                                                              
					//first multi-address device check                        
					if ((code1 == AMD3_DEVICE_ID1) && (code2 == AMD3_DEVICE_ID2))     
					{    user_message("Flash FLASH_AMD_LV256M_32MB!\n");                                                             
						flash_id = FLASH_AMD_LV256M_32MB;                             
						User_Hard_Reset_Flash  = Flash_Do_Nothing;                	  
						User_Soft_Reset_Flash  = AMD_Soft_Reset_Flash;                
						User_Flash_Erase_Block = AMD_Flash_Erase_Block;               
						User_Flash_Erase_All   = AMD_Flash_Erase_All;                 
						User_Flash_Write_Entry = Flash_Do_Nothing;                    
						User_Flash_Write       = AMD_Flash_Write;                     
						User_Flash_Write_Exit  = Flash_Do_Nothing;                    
						User_Flash_Optimized_Write = AMD_Flash_Optimized_Write;       
						break;                                                        
					} 
							
					                                                   
					//Add additional multi-address device checks here.           
					//NOTE: intentional drop through to "default case"  
					
				}  
				
				///ahuo add			 
			
			    case AMD4_DEVICE_ID:          //For Multi-Address ID Devices 
                

				{                                                                     
					code1 = *(fladdr + AMD_DEVICE_ID_OFFSET1);                        
					code2 = *(fladdr + AMD_DEVICE_ID_OFFSET2);                                                                                                              
					//first multi-address device check                        
				
					if ((code1 == AMD4_DEVICE_ID1) && (code2 == AMD4_DEVICE_ID2))     
					{  
					flash_id = S29NS128N;                             
						User_Hard_Reset_Flash  = Flash_Do_Nothing;                	  
						User_Soft_Reset_Flash  = AMD_Soft_Reset_Flash;                
						User_Flash_Erase_Block = AMD_Flash_Erase_Block;               
						User_Flash_Erase_All   = AMD_Flash_Erase_All;                 
						User_Flash_Write_Entry = Flash_Do_Nothing;                    
						User_Flash_Write       = AMD_Flash_Write;                     
						User_Flash_Write_Exit  = Flash_Do_Nothing;                    
						User_Flash_Optimized_Write = AMD_Flash_Optimized_Write;       
						break;                                                               
					//Add additional multi-address device checks here.           
					//NOTE: intentional drop through to "default case"  
					}
		            
				}  

 
			     		
				                
				
				                                                                
			default:

                
				flash_id = FLASH_NOT_FOUND;
		}
		// Put back into Read ArrayMode 
		AMD_Soft_Reset_Flash((ULONG) fladdr);
  	}  
  	else if (manf == FUJITSU_MANF_ID) 
  	{                                                               
		// Check device ID
		code = *(fladdr + AMD_DEVICE_ID_OFFSET);    // device code at address 1
		switch (code)
		{
	 		case FUJITSU1_DEVICE_ID:	   
				flash_id = FLASH_FUJITSU_DL323_4MB_BOTTOM;			
				User_Flash_Erase_Block = AMD_Flash_Erase_Block;
				User_Flash_Erase_All   = AMD_Flash_Erase_All;
				User_Flash_Write_Entry = Flash_Do_Nothing;
				User_Flash_Write   =    AMD_Flash_Write;
				User_Flash_Write_Exit = Flash_Do_Nothing;
				break;
			default:
				flash_id = FLASH_NOT_FOUND;
		}
		// Put back into Read ArrayMode 
		AMD_Soft_Reset_Flash((ULONG) fladdr);
	}  else if (manf == SAMSUNG_MANF_ID) 
  	{  
  		//Try SAMSUNG (which programs like an AMD device)
		// Check device ID
		code = *(fladdr + AMD_DEVICE_ID_OFFSET);    // device code at address 1
		switch (code)
		{
	 		case SAMSUNG_K8S2815E_128T:	   
				flash_id = FLASH_SAMSUNG_16MB_TOP;			
				User_Flash_Erase_Block = AMD_Flash_Erase_Block;
				User_Flash_Erase_All   = AMD_Flash_Erase_All;
				User_Flash_Write_Entry = Flash_Do_Nothing;
				User_Flash_Write   =    AMD_Flash_Write;
				User_Flash_Write_Exit = Flash_Do_Nothing;
				break;
			case SAMSUNG_K8S5615ETA_MUX:
				flash_id = FLASH_SAMSUNG_32MB_TOP_MUX;			
				User_Flash_Erase_Block = AMD_Flash_Erase_Block;
				User_Flash_Erase_All   = AMD_Flash_Erase_All;
				User_Flash_Write_Entry = Flash_Do_Nothing;
				User_Flash_Write   =    AMD_Flash_Write;
				User_Flash_Write_Exit = Flash_Do_Nothing;
				break;								
			default:
				flash_id = FLASH_NOT_FOUND;
		}
		// Put back into Read ArrayMode 
		AMD_Soft_Reset_Flash((ULONG) fladdr);  	
		
  	}  else
  	{
  		//Try INTEL
		// Okay  Now Let's Try Intel
  		INTEL_Soft_Reset_Flash((ULONG) fladdr);  		
  		*fladdr = INTEL_ID_CMD;  	// Send the Get ID command
  		manf = *fladdr;				// Check Manufacturer ID  		
   		code = *(++fladdr);   		// Check device ID    	
   		INTEL_Soft_Reset_Flash((ULONG) fladdr);
    		
  		if (manf == INTEL_MANF_ID || manf == MICRON_MANF_ID) 
		{  	
	 	 	switch (code)
    		{
	      		case INTEL_DEVICE_16B:
	        		flash_id = FLASH_INTEL_BURST_16MB_BOTTOM;
	        		break;
	      		case INTELS_J3_DEVICE_32:
	        		flash_id = FLASH_INTEL_STRATA_J3_4MB;
	        		break;
				case INTELS_J3_DEVICE_64:
			        flash_id = FLASH_INTEL_STRATA_J3_8MB;
			        break;
	      		case INTELS_J3_DEVICE_128:
	        		flash_id = FLASH_INTEL_STRATA_J3_16MB;
	        		break;
				case INTELS_K3_DEVICE_64:
	        		flash_id = FLASH_INTEL_STRATA_K3_8MB;
	        		break;
	      		case INTELS_K3_DEVICE_128:
	        		flash_id = FLASH_INTEL_STRATA_K3_16MB;
	        		break;
	      		case INTELS_K3_DEVICE_256:
	        		flash_id = FLASH_INTEL_STRATA_K3_32MB;
	        		break;
	      		case INTELS_W18_DEVICE_128B:
	        		flash_id = FLASH_INTEL_W18_16MB_BOTTOM;
	        		break;
	      		case INTELS_W18_DEVICE_128T:
	        		flash_id = FLASH_INTEL_W18_16MB_TOP;
	        		break;
	      		case INTELS_L18_DEVICE_128B:
	        		flash_id = FLASH_INTEL_L18_16MB_BOTTOM;
	        		break;
	      		case INTELS_L18_DEVICE_128T:
	        		flash_id = FLASH_INTEL_L18_16MB_TOP;
	        		break;
       			case INTELS_L18_DEVICE_256B:
                    flash_id = FLASH_INTEL_L18_32MB_BOTTOM;
                    break;
                case INTELS_L18_DEVICE_256T:
                    flash_id = FLASH_INTEL_L18_32MB_TOP;
                    break;
//modify by mjwu,2005-11-23,start
				case INTELS_L18_DEVICE_64T_MUX:
					flash_id = FLASH_INTEL_L18_8MB_TOP_MUX;//??
					break;
				case INTELS_L18_DEVICE_128T_MUX:
					flash_id = FLASH_INTEL_L18_16MB_TOP_MUX;//??
					break;
//modify by mjwu,2005-11-23,end                         	        		
				case INTELS_L18_DEVICE_256T_MUX:
					flash_id = FLASH_INTEL_L18_32MB_TOP_MUX;
					break;
	      		case INTELS_K18_DEVICE_256B:
                    flash_id = FLASH_INTEL_K18_32MB_BOTTOM;
                    break;                         	        			      		
	     		case MICRON_MT28F_DEVICE_128T:
	        		flash_id = FLASH_MICRON_16MB_TOP;
	        		break;       	
	 			default:
	        		flash_id = FLASH_NOT_FOUND;
	        		return(flash_id);	        		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -