亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uartboot.c

?? TI DM6446 EVM 串口下載程序 使用環境:windows dos環境或者linux 使用前需安裝mono
?? C
字號:
/* --------------------------------------------------------------------------
    FILE        : uartboot.c 				                             	 	        
    PURPOSE     : UART boot and interface file
    PROJECT     : DaVinci User Boot-Loader and Flasher
    AUTHOR      : Daniel Allred
    DATE	    : Jan-22-2007  
 
    HISTORY
 	     v1.00 completion 							 						      
 	          Daniel Allred - Jan-22-2007                                              
 ----------------------------------------------------------------------------- */

#include "ubl.h"
#include "uart.h"
#include "util.h"
#include "dm644x.h"

#ifdef UBL_NOR
#include "nor.h"
#endif

#ifdef UBL_NAND
#include "nand.h"
#endif

extern Uint32 gEntryPoint;

#ifdef UBL_NAND
extern NAND_INFO gNandInfo;
#endif

#ifdef UBL_NOR
extern NOR_INFO gNorInfo;
#endif

void UART_Boot(void) {

#ifdef UBL_NAND
	NAND_BOOT          nandBoot;
#endif
#ifdef UBL_NOR
	NOR_BOOT           norBoot;
	Uint32             blkAddress, blkSize, baseAddress;
#endif	
	UART_ACK_HEADER    ackHeader;
	Uint32             dataAddr = 0,dataByteCnt=0;
	Uint32             bootCmd;

UART_tryAgain:
	// Initialize UART and TIMER
	//UARTInit();
	waitloop(100);
	UARTSendData((Uint8 *) "Starting UART Boot...\r\n", FALSE);

	// UBL Sends 'BOOTPSP/0'
	if (UARTSendData((Uint8*)"BOOTPSP", TRUE) != E_PASS)
		goto UART_tryAgain;

	// Get the BOOT command
	if(UARTGetCMD(&bootCmd) != E_PASS)
		goto UART_tryAgain;

	switch(bootCmd)
	{
		// Only used for doing simple boot of UART
		case UBL_MAGIC_SAFE:
		{
			if ( UARTSendData((Uint8*)"SENDAPP", TRUE) != E_PASS)
				goto UART_tryAgain;
			if (UARTGetHeaderAndData(&ackHeader) != E_PASS)
			{
				goto UART_tryAgain;
			}
			gEntryPoint = ackHeader.binAddr;
			break;
		}
#ifdef UBL_NOR
		// Flash the UBL to start of NOR and put header and s-record app in NOR
		case UBL_MAGIC_NOR_SREC_BURN:
		case UBL_MAGIC_NOR_BIN_BURN:
		{
			if ( UARTSendData((Uint8*)"SENDUBL", TRUE) != E_PASS)
				goto UART_tryAgain;
			// Get the UBL into binary form
			if (UARTGetHeaderAndData(&ackHeader) != E_PASS)
			{
				goto UART_tryAgain;
			}

			// Initialize the NOR Flash
			NOR_Init();

			// Erasing the Flash
			NOR_Erase(gNorInfo.flashBase, ackHeader.binByteCnt);

			// Write binary UBL to NOR flash
			NOR_WriteBytes(gNorInfo.flashBase, ackHeader.binByteCnt, ackHeader.binAddr);

			// Send SENDAPP command
			if ( UARTSendData((Uint8*)"SENDAPP", TRUE) != E_PASS)
				goto UART_tryAgain;

			// Get the application header and data
			if (UARTGetHeaderAndData(&ackHeader) != E_PASS)
			{
				goto UART_tryAgain;
			}

			// Determine whether to use binary or srec
			if (bootCmd == UBL_MAGIC_NOR_BIN_BURN) 
			{
				dataByteCnt = ackHeader.binByteCnt;
				dataAddr = ackHeader.binAddr;
			}
			else if (bootCmd == UBL_MAGIC_NOR_SREC_BURN) 
			{
				dataByteCnt = ackHeader.srecByteCnt;
				dataAddr = ackHeader.srecAddr;				
			}
	
			// Erase the NOR flash where header and data will go
			DiscoverBlockInfo( (gNorInfo.flashBase + UBL_IMAGE_SIZE), &blkSize, &blkAddress );
	        baseAddress =  (blkAddress + blkSize);
			NOR_Erase( baseAddress, (dataByteCnt + sizeof(norBoot)) );

			norBoot.magicNum = ackHeader.magicNum;			//MagicFlag for Application (binary or safe)
			norBoot.appSize = dataByteCnt;					//Bytes of application (either srec or binary)
			norBoot.entryPoint = ackHeader.appStartAddr;	//Value from ACK header
			norBoot.ldAddress = ackHeader.binAddr;			//Should be same as AppStartAddr

			// Write the NOR_BOOT header to the flash
			NOR_WriteBytes( baseAddress, sizeof(norBoot), (Uint32) &norBoot);

			// Write the application data to the flash
			NOR_WriteBytes((baseAddress + sizeof(norBoot)), dataByteCnt, dataAddr);

			// Set the entry point for code execution to the newly copied binary UBL
			gEntryPoint = gNorInfo.flashBase;
			break;
		}	
		case UBL_MAGIC_NOR_RESTORE:
		{
			// Get the APP (should be u-boot) into binary form
			if ( UARTSendData((Uint8*)"SENDAPP", TRUE) != E_PASS)
				goto UART_tryAgain;
			
			if ( UARTGetHeaderAndData(&ackHeader) != E_PASS )
				goto UART_tryAgain;

			// Initialize the NOR Flash
			if ( NOR_Init() != E_PASS )
				goto UART_tryAgain;
			
			// Erasing the Flash
			if ( NOR_Erase(gNorInfo.flashBase, ackHeader.binByteCnt) != E_PASS )
			    goto UART_tryAgain;

			// Write the actual application to the flash
			if ( NOR_WriteBytes(gNorInfo.flashBase, ackHeader.binByteCnt, ackHeader.binAddr) != E_PASS )
			    goto UART_tryAgain;

			// Set the entry point for code execution
			gEntryPoint = gNorInfo.flashBase;
			break;
		}
		case UBL_MAGIC_NOR_GLOBAL_ERASE:
		{
			// Initialize the NOR Flash
			NOR_Init();

			// Erasing the Flash
			if (NOR_GlobalErase() != E_PASS)
			{
				UARTSendData((Uint8 *)"\r\nErase failed.\r\n", FALSE);
			}
			else
			{
				UARTSendData((Uint8 *)"\r\nErase completed successfully.\r\n", FALSE);
			}

			// Set the entry point for code execution
			// Go to reset in this case since no code was downloaded
			gEntryPoint = 0x0; 

			break;
		}
#endif
#ifdef UBL_NAND
		case UBL_MAGIC_NAND_SREC_BURN:
		case UBL_MAGIC_NAND_BIN_BURN:
		{
			if ( UARTSendData((Uint8*)"SENDUBL", TRUE) != E_PASS)
				goto UART_tryAgain;

			// Get the UBL into binary form
			if (UARTGetHeaderAndData(&ackHeader) != E_PASS)
			{
				goto UART_tryAgain;
			}

			// Initialize the NAND Flash
			if (NAND_Init() != E_PASS)
			{
			    UARTSendData("NAND_Init() failed!", FALSE);
			    goto UART_tryAgain;
			}   

			// Get magicNum
			nandBoot.magicNum = ackHeader.magicNum;

			// Get entrypoint for UBL
			nandBoot.entryPoint = (Uint32) (0x0000FFFF & ackHeader.appStartAddr);

			// The UBL image is 14kBytes plus do some rounding
			nandBoot.numPage = 0;
			while ( (nandBoot.numPage * gNandInfo.bytesPerPage) < (0x3800))
			{
				nandBoot.numPage++;
			}

			// The page is always page 0 for the UBL header, so we use page 1 for data
			nandBoot.page = 1;
			// The block is always block is always 1 (to start with) for the UBL header
			nandBoot.block = START_UBL_BLOCK_NUM;
			// This field doesn't matter for the UBL header
			nandBoot.ldAddress = 0;
	
			// Write header to page 0 of block 1(or up to block 5)
			// Write the UBL to the same block, starting at page 1 (since blocks are 16k)
			UARTSendData((Uint8 *) "Writing UBL to NAND flash\r\n", FALSE);
			if (NAND_WriteHeaderAndData(&nandBoot, (Uint8 *) ackHeader.binAddr) != E_PASS)
			    goto UART_tryAgain;

			// Send SENDAPP command
			if (UARTSendData((Uint8*)"SENDAPP", TRUE) != E_PASS)
				goto UART_tryAgain;

			// Get the application header and data
			if (UARTGetHeaderAndData(&ackHeader) != E_PASS)
			{
				goto UART_tryAgain;
			}

			// Set parameters depending on whether binary or srecord
			if (bootCmd == UBL_MAGIC_NAND_SREC_BURN)
			{
				dataByteCnt = ackHeader.srecByteCnt;
				dataAddr = ackHeader.srecAddr;
			}
			else if (bootCmd == UBL_MAGIC_NAND_BIN_BURN)
			{
				dataByteCnt = ackHeader.binByteCnt;
				dataAddr = ackHeader.binAddr;
			}

			// Rely on the host applciation to send over the right magic number (safe or bin)
			nandBoot.magicNum = ackHeader.magicNum;

			// Use the entrypoint received in ACK header
			nandBoot.entryPoint = ackHeader.appStartAddr;

			// The APP s-record image is dataByteCnt bytes plus do some rounding
			nandBoot.numPage = 0;
			while ( (nandBoot.numPage * gNandInfo.bytesPerPage) < dataByteCnt )
			{
				nandBoot.numPage++;
			}

			// The page is always page 0 for the header, so we use page 1 for data
			nandBoot.page = 1;

			// The block is always 6 (to start with) for the APP header
			nandBoot.block = START_APP_BLOCK_NUM;

			// The load address is only important if this is a binary image
			nandBoot.ldAddress = ackHeader.binAddr;

			// Nand Burn of application data
			UARTSendData((Uint8 *) "Writing APP to NAND flash\r\n", FALSE);
			if (NAND_WriteHeaderAndData(&nandBoot, (Uint8 *) dataAddr) != E_PASS)
			    goto UART_tryAgain;

			// Set the entry point to nowhere, since there isn't an appropriate binary image to run */
			gEntryPoint = 0x0;
			break;
		}	/* end case UBL_MAGIC_NAND_SREC_BURN */
		case UBL_MAGIC_NAND_GLOBAL_ERASE:
		{
			// Initialize the NAND Flash
			if (NAND_Init() != E_PASS)
			{
			    UARTSendData("NAND_Init() failed!", FALSE);
			    goto UART_tryAgain;
			}

			// Unprotect the NAND Flash
			NAND_UnProtectBlocks(1,gNandInfo.numBlocks - 1);

			// Erase all the pages of the device
			if (NAND_EraseBlocks(1,(gNandInfo.numBlocks - 1)) != E_PASS)
			{
				UARTSendData((Uint8 *)"Erase failed.\r\n", FALSE);
				goto UART_tryAgain;
			}
			else
			{
				UARTSendData((Uint8 *)"Erase completed successfully.\r\n", FALSE);
			}
			            
			// Protect the device
			NAND_ProtectBlocks();

			// Set the entry point for code execution
			// Go to reset in this case since no code was downloaded 
			gEntryPoint = 0x0; 
			break;
		}
#endif
		default:
		{
			// Simple UART Boot
			if ( UARTSendData((Uint8*)"SENDAPP", TRUE) != E_PASS)
				goto UART_tryAgain;

			if (UARTGetHeaderAndData(&ackHeader) != E_PASS)
			{
				goto UART_tryAgain;
			}
			gEntryPoint = ackHeader.binAddr;
			break;
		}
	}	/* end switch statement */
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一色桃子久久精品亚洲| 欧美最猛性xxxxx直播| 一区二区三区在线视频观看58| 日韩精品在线一区二区| 欧美美女一区二区三区| 欧美日韩中文国产| 欧美无乱码久久久免费午夜一区| 99re在线精品| 欧美影片第一页| 欧美日韩一区二区三区视频| 欧美日韩一区二区在线观看| 制服丝袜亚洲播放| 欧美电影免费观看完整版| 日韩三级视频在线观看| 欧美精品一区二区精品网| 久久一二三国产| 国产精品视频九色porn| 亚洲日本在线a| 亚洲成人免费在线| 狠狠色丁香婷婷综合久久片| 国产原创一区二区三区| av激情成人网| 欧美日韩一级视频| 26uuu成人网一区二区三区| 国产女人18毛片水真多成人如厕| 国产精品美女久久久久久久久久久| 中文字幕亚洲一区二区av在线 | 91麻豆精品国产自产在线| 在线播放中文一区| 国产亚洲精品7777| 一区二区三区高清在线| 麻豆国产一区二区| a级精品国产片在线观看| 欧美日韩一区国产| 国产校园另类小说区| 一区二区高清在线| 国产精品一区二区三区四区| jizzjizzjizz欧美| 日韩一级免费观看| 亚洲同性同志一二三专区| 日韩黄色免费电影| 97精品久久久久中文字幕| 91麻豆精品国产91久久久久 | 99久久婷婷国产综合精品| 欧美性色aⅴ视频一区日韩精品| 91精品国产入口| 亚洲日本中文字幕区| 久久av资源网| 欧美疯狂做受xxxx富婆| 国产精品久久久久久久浪潮网站 | 高清国产一区二区| 69久久99精品久久久久婷婷| 国产精品视频一区二区三区不卡| 午夜精品免费在线| 色综合天天综合色综合av| 久久综合99re88久久爱| 婷婷综合另类小说色区| 91免费观看视频| 国产亲近乱来精品视频| 麻豆91精品视频| 欧美日韩视频在线一区二区| 亚洲天堂免费看| 国产91高潮流白浆在线麻豆| 精品国产一区二区三区久久影院 | 国产一区二区三区久久久| 欧美日韩国产欧美日美国产精品| 亚洲视频在线观看三级| 成人免费毛片高清视频| 国产午夜精品在线观看| 经典三级视频一区| 欧美成人免费网站| 久久国产精品区| 日韩三级视频在线看| 免费观看30秒视频久久| 日韩一二三区不卡| 日本在线不卡视频一二三区| 7777精品伊人久久久大香线蕉的| 亚洲一区视频在线观看视频| 在线免费观看视频一区| 亚洲精品免费在线观看| 91国偷自产一区二区使用方法| 亚洲视频综合在线| 日本韩国欧美一区二区三区| 亚洲精品成人天堂一二三| 在线一区二区视频| 亚洲成人资源网| 91精品黄色片免费大全| 六月丁香婷婷久久| 欧美精品一区在线观看| 国产激情一区二区三区| 综合电影一区二区三区| 欧洲精品中文字幕| 午夜av一区二区三区| 欧美tickling网站挠脚心| 国产一区二区三区av电影| 欧美国产成人在线| 色偷偷成人一区二区三区91| 国产99久久久精品| 欧美日本高清视频在线观看| 久久精品夜色噜噜亚洲aⅴ| 久久99国产乱子伦精品免费| 久久嫩草精品久久久精品一| 成+人+亚洲+综合天堂| 亚洲一区二区中文在线| 日韩欧美的一区| 国产成人精品免费网站| 亚洲黄色录像片| 日韩欧美国产综合| 99视频有精品| 蜜桃av一区二区| 欧美韩国一区二区| 91精品欧美一区二区三区综合在 | 亚洲欧美在线视频| 欧美日韩国产首页| 成人黄色小视频| 日韩高清不卡一区| 国产精品女主播在线观看| 欧美日韩不卡一区二区| 国产suv精品一区二区883| 亚洲一区二区三区自拍| 国产亚洲精品aa午夜观看| 欧美三电影在线| 成人禁用看黄a在线| 丝袜诱惑制服诱惑色一区在线观看| 久久亚洲一区二区三区明星换脸| 色综合久久久网| 国产精品一区二区果冻传媒| 亚洲成a天堂v人片| 中文字幕一区二区三区不卡| 精品久久国产老人久久综合| 在线观看视频91| 94色蜜桃网一区二区三区| 韩国av一区二区三区四区| 午夜电影久久久| 一区二区三区美女视频| 国产欧美精品一区aⅴ影院| 日韩欧美亚洲另类制服综合在线| aaa亚洲精品| 国产69精品久久久久777| 男女性色大片免费观看一区二区| 亚洲男人天堂一区| 中文字幕乱码久久午夜不卡| 精品999在线播放| 欧美福利一区二区| 欧美日韩国产高清一区二区三区| 99久久综合色| 不卡av电影在线播放| 国产美女久久久久| 国产一区二三区| 经典三级视频一区| 国产一区二区美女诱惑| 久久国产精品99久久人人澡| 免费在线看成人av| 青青草一区二区三区| 全国精品久久少妇| 免费观看在线综合| 麻豆传媒一区二区三区| 青青青爽久久午夜综合久久午夜| 午夜精品免费在线观看| 日韩av不卡一区二区| 日本不卡不码高清免费观看| 日韩电影网1区2区| 男女激情视频一区| 激情六月婷婷久久| 国产盗摄一区二区| 91一区二区在线| 欧美亚日韩国产aⅴ精品中极品| 欧美午夜一区二区三区| 欧美电影一区二区三区| 日韩视频免费观看高清完整版 | 国产午夜亚洲精品午夜鲁丝片| 国产欧美精品一区| 欧美体内she精高潮| 欧美成人a在线| 欧美疯狂做受xxxx富婆| 国产精品美女久久久久久久久久久| 成人一级片在线观看| aaa亚洲精品一二三区| 欧美午夜精品久久久久久孕妇 | 成人aa视频在线观看| 色综合久久中文字幕| 欧美高清hd18日本| 26uuu另类欧美亚洲曰本| 国产精品久久一卡二卡| 亚洲精品成人a在线观看| 日韩精品一二三| 成人综合婷婷国产精品久久| 91福利视频在线| 精品国产伦一区二区三区观看体验| 国产精品网站在线| 午夜电影网一区| 成人av小说网| 日韩欧美在线不卡| 国产精品国产三级国产aⅴ入口 | 欧美最新大片在线看| 精品国产免费人成电影在线观看四季| 中文字幕乱码日本亚洲一区二区| 亚洲超碰97人人做人人爱| 高清国产一区二区三区| 7777精品伊人久久久大香线蕉完整版 |