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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? nand.c

?? i.Mx31 bootloader(for WinCE6.0)
?? C
?? 第 1 頁 / 共 4 頁
字號:
//-----------------------------------------------------------------------------
//
//  Use of this source code is subject to the terms of the Microsoft end-user
//  license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
//  If you did not accept the terms of the EULA, you are not authorized to use
//  this source code. For a copy of the EULA, please see the LICENSE.RTF on
//  your install media.
//
//-----------------------------------------------------------------------------
//
//  Copyright (C) 2004-2007, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//-----------------------------------------------------------------------------
//
//  File:  nand.c
//
//  Contains BOOT NAND flash support functions.
//
//-----------------------------------------------------------------------------
#include "bsp.h"
#include "loader.h"
#pragma warning(push)
#pragma warning(disable: 4115)
#include <fmd.h>
#pragma warning(pop)

//-----------------------------------------------------------------------------
// External Functions


//-----------------------------------------------------------------------------
// External Variables
extern BOOL g_bNandExist;


//-----------------------------------------------------------------------------
// Defines
#define     NANDFC_BOOT_SIZE        (2*1024)


//-----------------------------------------------------------------------------
// Types


//-----------------------------------------------------------------------------
// Global Variables
BYTE sectorBuf[NANDFC_BOOT_SIZE];
static FlashInfo g_flashInfo;


//-----------------------------------------------------------------------------
// Local Variables


//-----------------------------------------------------------------------------
// Local Functions


//-----------------------------------------------------------------------------
//
//  Function:  NANDWriteXldr
//
//  This function writes to NAND flash memory the XLDR image stored 
//  in the RAM file cache area.
//
//  Parameters:
//      dwStartAddr 
//          [in] Address in flash memory where the start of the downloaded 
//          XLDR image is to be written.
//
//      dwLength 
//          [in] Length of the XLDR image, in bytes, to be written to flash
//          memory.            
//
//  Returns:
//      TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL NANDWriteXldr(DWORD dwStartAddr, DWORD dwLength)
{
    FlashInfo flashInfo;
    LPBYTE pSectorBuf, pImage;
    SectorInfo sectorInfo;
    SECTOR_ADDR sectorAddr, endSectorAddr;

    // Check for NAND device availability
    //
    if (!g_bNandExist)
    {
        EdbgOutputDebugString("WARNING: NAND device doesn't exist - unable to store image.\r\n");
        return(FALSE);
    }

    EdbgOutputDebugString("INFO: Writing XLDR image to NAND (please wait)...\r\n");

    if (!FMD_GetInfo(&flashInfo))
    {
        EdbgOutputDebugString("ERROR: Unable to get NAND flash information.\r\n");
        return(FALSE);
    }

    // XLDR is placed in block #0 of the NAND device.  

    // Block #0 is always good, so just erase it
    if (!FMD_EraseBlock(0))
    {
        EdbgOutputDebugString("ERROR: Unable to erase NAND flash block #0\r\n");
        return(FALSE);
    }

    // Get cached image location
    pImage = OEMMapMemAddr(dwStartAddr, dwStartAddr);

    // If image is larger than 4K, this must be xldr.bin produced by
    // ROMIMAGE
    if (dwLength > 0x1000)
    {
        // ROMIMAGE adds 4K page at the beginning of the image.
        // We will flash the first 2K bytes that appear after this 4K page.
        //
        pImage += 0x1000;
        dwLength -= 0x1000;
    }

    // Make sure XLDR length does not exceed size that can be supported by NANDFC (2KB)
    if (dwLength > NANDFC_BOOT_SIZE)
    {
        EdbgOutputDebugString("ERROR: XLDR exceeds 2KByte\r\n");
        return(FALSE);
    }

    // Fill unused space with 0xFF
    memset(pImage + dwLength, 0xFF, (NANDFC_BOOT_SIZE) - dwLength);

    EdbgOutputDebugString("INFO: Using XLDR image from flash cache address 0x%x, size = %d\r\n", pImage, dwLength);

    sectorInfo.dwReserved1 = 0xFFFFFFFF;
    sectorInfo.bOEMReserved = 0x00;
    sectorInfo.bBadBlock = 0xFF;    
    sectorInfo.wReserved2 = 0xFFFF;
    
    endSectorAddr = (NANDFC_BOOT_SIZE / flashInfo.wDataBytesPerSector);
    
    // Write XLDR to NAND flash
    pSectorBuf = pImage;
    for (sectorAddr = 0; sectorAddr < endSectorAddr; sectorAddr++)
    {
        if (!FMD_WriteSector(sectorAddr, pSectorBuf, &sectorInfo, 1))
        {
            EdbgOutputDebugString("ERROR: Failed to update XLDR.\r\n");
            return(FALSE);
        }

        pSectorBuf += flashInfo.wDataBytesPerSector;
    }

    // Read XLDR from NAND flash to verify contents
    pSectorBuf = pImage + NANDFC_BOOT_SIZE;
    for (sectorAddr = 0; sectorAddr < endSectorAddr; sectorAddr++)
    {
        if (!FMD_ReadSector(sectorAddr, pSectorBuf, &sectorInfo, 1))
        {
            EdbgOutputDebugString("ERROR: Failed to verify XLDR.\r\n");
            return(FALSE);
        }

        pSectorBuf += flashInfo.wDataBytesPerSector;
    }

    if (memcmp(pImage, pImage + NANDFC_BOOT_SIZE, NANDFC_BOOT_SIZE) != 0)
    {
        EdbgOutputDebugString("ERROR: Failed to verify XLDR.\r\n");
    }
    

    EdbgOutputDebugString("INFO: Update of XLDR completed successfully.\r\n");

    
    return(TRUE);

}


//-----------------------------------------------------------------------------
//
//  Function:  NANDWriteBoot
//
//  This function writes to NAND flash memory the Boot image stored 
//  in the RAM file cache area.
//
//  Parameters:
//      dwStartAddr 
//          [in] Address in flash memory where the start of the downloaded 
//          Boot image is to be written.
//
//      dwLength 
//          [in] Length of the Boot image, in bytes, to be written to flash
//          memory.            
//
//  Returns:
//      TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL NANDWriteBoot(DWORD dwStartAddr, DWORD dwLength)
{
    FlashInfo flashInfo;
    LPBYTE pSectorBuf, pImage;
    SectorInfo sectorInfo;
    BLOCK_ID blockID, startBlockID, endBlockID;
    SECTOR_ADDR sectorAddr, startSectorAddr, endSectorAddr;

    // Check for NAND device availability
    //
    if (!g_bNandExist)
    {
        EdbgOutputDebugString("WARNING: NAND device doesn't exist - unable to store image.\r\n");
        return(FALSE);
    }

    EdbgOutputDebugString("INFO: Writing Boot image to NAND (please wait)...\r\n");

    if (!FMD_GetInfo(&flashInfo))
    {
        EdbgOutputDebugString("ERROR: Unable to get NAND flash information.\r\n");
        return(FALSE);
    }

    // Make sure Boot length does not exceed reserved NAND size
    if (dwLength > IMAGE_BOOT_BOOTIMAGE_NAND_SIZE)
    {
        EdbgOutputDebugString("ERROR: Boot size exceeds reserved NAND region (size = 0x%x)\r\n", dwLength);
        return(FALSE);
    }

    // Calculate the physical block range for the EBOOT image
    startBlockID = IMAGE_BOOT_BOOTIMAGE_NAND_OFFSET / flashInfo.dwBytesPerBlock;
    endBlockID = startBlockID + (IMAGE_BOOT_BOOTIMAGE_NAND_SIZE / flashInfo.dwBytesPerBlock);
    
    EdbgOutputDebugString("INFO: Erasing NAND flash blocks [0x%x - 0x%x].\r\n", startBlockID, endBlockID);
    
    // Erase range of NAND blocks reserved for EBOOT
    for (blockID = startBlockID; blockID < endBlockID; blockID++)
    {
        // Skip bad blocks
        if (FMD_GetBlockStatus(blockID) == BLOCK_STATUS_BAD)
        {
            EdbgOutputDebugString("INFO: Found bad NAND flash block [0x%x].\r\n", blockID);
            continue;
        }

        // Erase the block...
        if (!FMD_EraseBlock(blockID))
        {
            EdbgOutputDebugString("ERROR: Unable to erase NAND flash block [0x%x].\r\n", blockID);
            return(FALSE);
        }
    }

    // Get cached image location
    pImage = OEMMapMemAddr(dwStartAddr, dwStartAddr);

    // Fill unused space with 0xFF
    memset(pImage + dwLength, 0xFF, (IMAGE_BOOT_BOOTIMAGE_NAND_SIZE) - dwLength);

    EdbgOutputDebugString("INFO: Programming EBOOT/SBOOT image from flash cache address 0x%x, size = %d\r\n", pImage, dwLength);

    sectorInfo.dwReserved1 = 0xFFFFFFFF;
    sectorInfo.bOEMReserved = 0x00;
    sectorInfo.bBadBlock = 0xFF;    
    sectorInfo.wReserved2 = 0xFFFF;
    
    // Write EBOOT to NAND flash
    pSectorBuf = pImage;

    for (blockID = startBlockID; blockID < endBlockID; blockID++)
    {        
        // Skip bad blocks
        if (FMD_GetBlockStatus(blockID) == BLOCK_STATUS_BAD)
        {
            EdbgOutputDebugString("INFO: Found bad NAND flash block [0x%x].\r\n", blockID);
            continue;
        }

        // Compute sector address based on current physical block
        startSectorAddr = blockID * flashInfo.wSectorsPerBlock;
        endSectorAddr = startSectorAddr + flashInfo.wSectorsPerBlock;
        
        for (sectorAddr = startSectorAddr; sectorAddr < endSectorAddr; sectorAddr++)
        {
            if (!FMD_WriteSector(sectorAddr, pSectorBuf, &sectorInfo, 1))
            {
                EdbgOutputDebugString("ERROR: Failed to update EBOOT/SBOOT.\r\n");
                return(FALSE);
            }

            pSectorBuf += flashInfo.wDataBytesPerSector;
        }
    }
    
    // Read EBOOT from NAND flash to verify contents
    pSectorBuf = pImage + IMAGE_BOOT_BOOTIMAGE_NAND_SIZE;

    for (blockID = startBlockID; blockID < endBlockID ; blockID++)
    {        
        // Skip bad blocks
        if (FMD_GetBlockStatus(blockID) == BLOCK_STATUS_BAD)
        {
            EdbgOutputDebugString("INFO: Found bad NAND flash block [0x%x].\r\n", blockID);
            continue;
        }

        // Compute sector address based on current physical block
        startSectorAddr = blockID * flashInfo.wSectorsPerBlock;
        endSectorAddr = startSectorAddr + flashInfo.wSectorsPerBlock;
        
        for (sectorAddr = startSectorAddr; sectorAddr < endSectorAddr; sectorAddr++)
        {
            if (!FMD_ReadSector(sectorAddr, pSectorBuf, &sectorInfo, 1))
            {
                EdbgOutputDebugString("ERROR: Failed to update EBOOT/SBOOT.\r\n");
                return(FALSE);
            }

            pSectorBuf += flashInfo.wDataBytesPerSector;
        }
    }

    EdbgOutputDebugString("INFO: Verifying image.\r\n");

    if (memcmp(pImage, pImage + IMAGE_BOOT_BOOTIMAGE_NAND_SIZE, IMAGE_BOOT_BOOTIMAGE_NAND_SIZE) != 0)
    {
        EdbgOutputDebugString("ERROR: Failed to verify EBOOT/SBOOT.\r\n");
    }
    

    EdbgOutputDebugString("INFO: Update of EBOOT/SBOOT completed successfully.\r\n");

    
    return(TRUE);

}

//------------------------------------------------------------------------------
//
//  Function:  NANDWriteIPL
//
//  N/A
//
//  Parameters:
//      None.
//
//  Returns:
//      TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL NANDWriteIPL(DWORD dwStartAddr, DWORD dwLength)
{
    FlashInfo flashInfo;
    LPBYTE pSectorBuf, pImage;
    SectorInfo sectorInfo;
    BLOCK_ID blockID, startBlockID, endBlockID;
    SECTOR_ADDR sectorAddr, startSectorAddr, endSectorAddr;

    // Check for NAND device availability
    //
    if (!g_bNandExist)
    {
        EdbgOutputDebugString("WARNING: NAND device doesn't exist - unable to store image.\r\n");

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩成人免费电影| 伊人性伊人情综合网| 91麻豆蜜桃一区二区三区| 日韩主播视频在线| 国产精品久久综合| 日韩欧美在线综合网| 91福利资源站| 成人黄色在线网站| 精品一区二区三区影院在线午夜| 一区二区三区中文字幕| 亚洲一二三区在线观看| 久久精品人人做| 欧美成人在线直播| 91精品国产综合久久久蜜臀粉嫩 | 国产精品青草综合久久久久99| 欧美福利一区二区| 在线中文字幕一区二区| 成人福利电影精品一区二区在线观看 | 成人做爰69片免费看网站| 91精品免费在线观看| 亚洲国产日产av| 国产精品区一区二区三区| 精品成人一区二区三区| 欧美日韩精品电影| 欧美色精品天天在线观看视频| 波多野结衣一区二区三区| 国产精品一区二区免费不卡| 日本色综合中文字幕| 视频一区二区欧美| 午夜视黄欧洲亚洲| 亚洲国产综合在线| 亚洲国产精品视频| 午夜精品久久久久久久蜜桃app| 亚洲色图第一区| 亚洲人精品午夜| 曰韩精品一区二区| 亚洲综合丝袜美腿| 亚洲成人精品影院| 亚洲成a人v欧美综合天堂| 亚洲va天堂va国产va久| 亚洲二区在线视频| 日韩国产在线一| 天天av天天翘天天综合网色鬼国产| 一区二区三区在线视频观看58| 亚洲精品自拍动漫在线| 国产无一区二区| www.亚洲国产| 久久精品久久久精品美女| 另类小说综合欧美亚洲| 韩日av一区二区| 成人一区二区在线观看| 欧美一级淫片007| 欧美一级视频精品观看| 欧美电影免费观看完整版| 久久久高清一区二区三区| 中文在线一区二区 | 亚洲欧洲日本在线| 一区二区三区四区在线免费观看| 一区二区三区高清| 午夜精品aaa| 国内外成人在线视频| 粉嫩一区二区三区在线看| 色久优优欧美色久优优| 欧美一区二区三区不卡| 久久精品亚洲乱码伦伦中文| 国产精品成人免费精品自在线观看| 亚洲免费观看高清| 日本不卡的三区四区五区| 国产成人午夜99999| 色综合激情久久| 欧美一区二区三区视频在线观看 | 午夜电影久久久| 精品一区二区三区在线播放 | 亚洲婷婷在线视频| 日韩av一级片| www.综合网.com| 91精品综合久久久久久| 亚洲国产精品精华液ab| 亚洲国产日韩在线一区模特 | aaa亚洲精品| 91精品在线麻豆| 亚洲欧洲另类国产综合| 蜜臀久久99精品久久久久宅男| 国产91丝袜在线播放0| 欧美视频中文字幕| 久久99久久精品| 91麻豆蜜桃一区二区三区| 6080yy午夜一二三区久久| 91久久精品国产91性色tv| 欧美美女喷水视频| 国产精品高潮久久久久无| 日本aⅴ免费视频一区二区三区| 国产a久久麻豆| 日韩三级免费观看| 专区另类欧美日韩| 国产一区二区三区四区五区入口| 色婷婷激情综合| 久久蜜桃一区二区| 天天射综合影视| 色综合久久综合| 中文字幕国产一区二区| 日本美女视频一区二区| 91麻豆免费观看| 欧美国产1区2区| 久久精品99国产精品日本| 91精彩视频在线观看| 国产精品你懂的| 国产伦精品一区二区三区视频青涩 | 色综合色狠狠天天综合色| 久久综合五月天婷婷伊人| 亚洲伊人色欲综合网| 99re成人在线| 欧美激情中文不卡| 国产九色精品成人porny| 日韩精品中文字幕在线不卡尤物| 亚洲午夜羞羞片| 91国产免费看| 亚洲视频免费看| 99久久婷婷国产| 国产精品视频看| 成人高清免费观看| 亚洲国产经典视频| 国产伦精品一区二区三区免费迷 | 国产精品女上位| 成人精品高清在线| 国产精品丝袜在线| 成人爽a毛片一区二区免费| 国产日韩综合av| 高清国产一区二区| 国产精品美女一区二区三区 | 国产亚洲福利社区一区| 国产真实精品久久二三区| 欧美videos中文字幕| 美日韩黄色大片| 精品国产欧美一区二区| 国产一区在线看| 久久综合久久鬼色中文字| 国产一区二区三区四区五区入口| 久久伊人中文字幕| 国产夫妻精品视频| 国产精品视频免费| 色综合天天综合| 亚洲一区二区三区四区的| 4438x成人网最大色成网站| 欧美aaa在线| 国产调教视频一区| 5858s免费视频成人| 美女免费视频一区| 精品人伦一区二区色婷婷| 国产麻豆精品视频| 亚洲天堂久久久久久久| 在线免费观看日本一区| 日精品一区二区| 久久久久久久久蜜桃| 懂色中文一区二区在线播放| 亚洲天堂福利av| 91精品国产综合久久久久| 麻豆传媒一区二区三区| 国产日产欧美一区二区三区| heyzo一本久久综合| 亚洲成av人片一区二区梦乃| 日韩视频免费观看高清完整版| 精品午夜一区二区三区在线观看| 日本一区二区三区在线观看| 91福利在线免费观看| 麻豆91精品视频| 中文乱码免费一区二区| 欧美日韩三级视频| 国产乱码字幕精品高清av| 成人欧美一区二区三区白人| 欧美日韩国产成人在线免费| 国产剧情一区二区三区| 怡红院av一区二区三区| 精品剧情v国产在线观看在线| 99久久综合色| 美女性感视频久久| 国产精品久久久久久户外露出| 欧美日本在线播放| 国产精品69久久久久水密桃| 亚洲在线中文字幕| 国产色91在线| 在线成人av影院| 成人app软件下载大全免费| 石原莉奈一区二区三区在线观看| 国产午夜精品美女毛片视频| 欧美日韩一本到| 成人激情文学综合网| 麻豆视频一区二区| 一区二区三区日韩欧美| 国产无人区一区二区三区| 欧美理论片在线| 99久久精品国产导航| 美女视频黄a大片欧美| 亚洲尤物视频在线| 欧美国产乱子伦 | 国产精品美女视频| 日韩免费在线观看| 欧美亚洲精品一区| 99精品久久99久久久久| 国产精品77777|