Wince EBOOT 中 bootpart 疑惑

时间:2021-08-01 18:04:17
EBOOT自动启动通过调用ReadOSImageFromBootMedia会从NandFlash中加载内核运行.
在ReadOSImageFromBootMedia函数中,调用BP_OpenPartition

BOOL ReadOSImageFromBootMedia()
{
   ......
   hPart = BP_OpenPartition( NEXT_FREE_LOC,
                              USE_REMAINING_SPACE,
                              PART_BINFS,
                              TRUE,
                              PART_OPEN_EXISTING);

    if (hPart == INVALID_HANDLE_VALUE )
    {
        OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: Failed to open existing partition.\r\n")));
        return(FALSE);
    }

    //这里打印出相关的信息,奇怪的是Part_StartSector和Part_TotalSectors都为0
    PPARTENTRY pPartEntry = (PPARTENTRY)hPart;
    RETAILMSG (1, (TEXT("ReadOSImageFromBootMedia:StartSector=%X\r\n"), pPartEntry->Part_StartSector)); //输出0
    RETAILMSG (1, (TEXT("ReadOSImageFromBootMedia:TotalSector=%X\r\n"), pPartEntry->Part_TotalSectors));//输出0

    
    if ( !BP_SetDataPointer(hPart, g_pTOC->id[g_dwTocEntry].dwStoreOffset) )
    {
        OALMSG(OAL_ERROR, (TEXT("ERROR: ReadOSImageFromBootMedia: Failed to set data pointer in partition(offset=0x%x).\r\n"), g_pTOC->id[g_dwTocEntry].dwStoreOffset));
        return(FALSE);
    }
   ......
}

另外\WINCE600\public\common\oak\drivers\ethdbg\bootpart\bootpart.cpp中的所有打印信息都没有输出,难道不是这个路径下的bootpart.cpp,但通过文件查找,只找到这一处。

9 个解决方案

#1


USE_REMAINING_SPACE, 打开的是可用分区空间 返回0 没有空间可以分配

BP_OpenPartition的疑问
BP_OpenPartition

http://blog.csdn.net/feishanm/article/details/5807399

#2


不是啊,查看源代码里面,只要PART_OPEN_EXISTING,根本就没用到第一和二个参数
,而且我可以肯定有可用的,因为程序都跑起来了。
HANDLE BP_OpenPartition(DWORD dwStartSector, DWORD dwNumSectors, DWORD dwPartType, BOOL fActive, DWORD dwCreationFlags)
{
        DWORD dwPartIndex;
        BOOL fExists;

        ASSERT (g_pbMBRSector);
        
        if (!IsValidMBR()) {
            DWORD dwFlags = 0;

            if (dwCreationFlags == PART_OPEN_EXISTING) {
                RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR.  Cannot open existing partition 0x%x.\r\n"), dwPartType));
                return INVALID_HANDLE_VALUE;
            }
            
            RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR.  Formatting flash.\r\n")));
            if (g_FlashInfo.flashType == NOR) {
                dwFlags |= FORMAT_SKIP_BLOCK_CHECK;
            }
            BP_LowLevelFormat (0, g_FlashInfo.dwNumBlocks, dwFlags);
            dwPartIndex = 0;
            fExists = FALSE;
        }
        else {
            fExists = GetPartitionTableIndex(dwPartType, fActive, &dwPartIndex);        
        }

        RETAILMSG(1, (TEXT("OpenPartition: Partition Exists=0x%x for part 0x%x.\r\n"), fExists, dwPartType));
        if (fExists) {

            // Partition was found.  
            if (dwCreationFlags == PART_CREATE_NEW)
                return INVALID_HANDLE_VALUE;
            
            if (g_partStateTable[dwPartIndex].pPartEntry == NULL) {
                // Open partition.  If this is the boot section partition, then file pointer starts after MBR
                g_partStateTable[dwPartIndex].pPartEntry = (PPARTENTRY)(g_pbMBRSector + PARTTABLE_OFFSET + sizeof(PARTENTRY)*dwPartIndex);
                g_partStateTable[dwPartIndex].dwDataPointer = 0;
            }            
            return (HANDLE)&g_partStateTable[dwPartIndex];            
        }
        else {

            // If there are already 4 partitions, or creation flag specified OPEN_EXISTING, fail.
            if ((dwPartIndex == NUM_PARTS) || (dwCreationFlags == PART_OPEN_EXISTING))
                return INVALID_HANDLE_VALUE;

            // Create new partition
            return CreatePartition (dwStartSector, dwNumSectors, dwPartType, fActive, dwPartIndex);
        }

        return INVALID_HANDLE_VALUE;
        
}

#3


我在应用程序更新内核时,进行到跳转那就没有打印消息。我打出了跳转处的4字节代码与正常进时的对比较是一样的
异常下的信息:
ReadOSImageFromBootMedia:Launch[3, 0, 0, EA,]
System ready!
Preparing for download...
INFO: *** Device Name 'SMDK24400' ***
INFO: Using static IP address 2020201.
INFO: Using subnet mask 2525250.
waitforconnect
INFO: using TOC[1] dwJumpAddress: 0x8022a64c
INFO: OEMLaunch: Jumping to Physical Address 0x3022A64Ch (Virtual Address 0x8022A64Ch)...

C


正常下的信息:
.................................
ReadOSImageFromBootMedia:MBRSectorNum=5C0
ReadOSImageFromBootMedia:MBR[0..2](E9,FD,FF)
ReadOSImageFromBootMedia:MBR[446..448](3,18,1)
ReadOSImageFromBootMedia:MBR[446..448](3,18,1)
ReadOSImageFromBootMedia:MBR[450,454..461](21, 0600, C02A00)
ReadOSImageFromBootMedia:LoadAddr=80200000
ReadOSImageFromBootMedia:JumpAddress=8022A64C
ReadOSImageFromBootMedia:TtlSectors=2A94
ReadOSImageFromBootMedia:StoreOffset=0
ReadOSImageFromBootMedia:FirstHead=1
ReadOSImageFromBootMedia:FirstSector=8
ReadOSImageFromBootMedia:StartSector=0
ReadOSImageFromBootMedia:TotalSector=0
ReadOSImageFromBootMedia:Launch[3, 0, 0, EA,]
System ready!
Preparing for download...
INFO: *** Device Name 'SMDK24400' ***
INFO: Using static IP address 2020201.
INFO: Using subnet mask 2525250.
waitforconnect
INFO: using TOC[1] dwJumpAddress: 0x8022a64c
INFO: OEMLaunch: Jumping to Physical Address 0x3022A64Ch (Virtual Address 0x8022A64Ch)...

CWindows CE Kernel for ARM (Thumb Enabled) Built on Nov 24 2008 at 14:58:01
DCache: 8 sets, 64 ways, 32 line size, 16384 size
ICache: 8 sets, 64 ways, 32 line size, 16384 size
FMD: ReadID (Mfg=ec, Dev=da)
FMD_Init: finished successful
.............................

#4


该回复于2012-07-01 10:58:18被版主删除

#5


你要追究修改bootpart文件里的内容,要重新编译和sysgen整个工程才行呀。或者把这个文件移植到BSP包里也行。我就是这么干的。呵呵

#6


学习,Eboot中如何确定对空余Flash分区进行了分区?

#7


其实我最后就是在fmd.cpp重写了bootpart.cpp我要用到的部分代码,只是下载后重启系统就出现上述问题!

#8


分区也是使用这个BP_OpenPartition函数,只是在上层加文件系统的时候,怎么知道分区号的呢。

#9


public中的代码必须用sysgen编译,或者你自己去rebuild一下对应的目录。不然没有效果的。
我的eboot是直接将这个文件copy到目录里面去了。

#1


USE_REMAINING_SPACE, 打开的是可用分区空间 返回0 没有空间可以分配

BP_OpenPartition的疑问
BP_OpenPartition

http://blog.csdn.net/feishanm/article/details/5807399

#2


不是啊,查看源代码里面,只要PART_OPEN_EXISTING,根本就没用到第一和二个参数
,而且我可以肯定有可用的,因为程序都跑起来了。
HANDLE BP_OpenPartition(DWORD dwStartSector, DWORD dwNumSectors, DWORD dwPartType, BOOL fActive, DWORD dwCreationFlags)
{
        DWORD dwPartIndex;
        BOOL fExists;

        ASSERT (g_pbMBRSector);
        
        if (!IsValidMBR()) {
            DWORD dwFlags = 0;

            if (dwCreationFlags == PART_OPEN_EXISTING) {
                RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR.  Cannot open existing partition 0x%x.\r\n"), dwPartType));
                return INVALID_HANDLE_VALUE;
            }
            
            RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR.  Formatting flash.\r\n")));
            if (g_FlashInfo.flashType == NOR) {
                dwFlags |= FORMAT_SKIP_BLOCK_CHECK;
            }
            BP_LowLevelFormat (0, g_FlashInfo.dwNumBlocks, dwFlags);
            dwPartIndex = 0;
            fExists = FALSE;
        }
        else {
            fExists = GetPartitionTableIndex(dwPartType, fActive, &dwPartIndex);        
        }

        RETAILMSG(1, (TEXT("OpenPartition: Partition Exists=0x%x for part 0x%x.\r\n"), fExists, dwPartType));
        if (fExists) {

            // Partition was found.  
            if (dwCreationFlags == PART_CREATE_NEW)
                return INVALID_HANDLE_VALUE;
            
            if (g_partStateTable[dwPartIndex].pPartEntry == NULL) {
                // Open partition.  If this is the boot section partition, then file pointer starts after MBR
                g_partStateTable[dwPartIndex].pPartEntry = (PPARTENTRY)(g_pbMBRSector + PARTTABLE_OFFSET + sizeof(PARTENTRY)*dwPartIndex);
                g_partStateTable[dwPartIndex].dwDataPointer = 0;
            }            
            return (HANDLE)&g_partStateTable[dwPartIndex];            
        }
        else {

            // If there are already 4 partitions, or creation flag specified OPEN_EXISTING, fail.
            if ((dwPartIndex == NUM_PARTS) || (dwCreationFlags == PART_OPEN_EXISTING))
                return INVALID_HANDLE_VALUE;

            // Create new partition
            return CreatePartition (dwStartSector, dwNumSectors, dwPartType, fActive, dwPartIndex);
        }

        return INVALID_HANDLE_VALUE;
        
}

#3


我在应用程序更新内核时,进行到跳转那就没有打印消息。我打出了跳转处的4字节代码与正常进时的对比较是一样的
异常下的信息:
ReadOSImageFromBootMedia:Launch[3, 0, 0, EA,]
System ready!
Preparing for download...
INFO: *** Device Name 'SMDK24400' ***
INFO: Using static IP address 2020201.
INFO: Using subnet mask 2525250.
waitforconnect
INFO: using TOC[1] dwJumpAddress: 0x8022a64c
INFO: OEMLaunch: Jumping to Physical Address 0x3022A64Ch (Virtual Address 0x8022A64Ch)...

C


正常下的信息:
.................................
ReadOSImageFromBootMedia:MBRSectorNum=5C0
ReadOSImageFromBootMedia:MBR[0..2](E9,FD,FF)
ReadOSImageFromBootMedia:MBR[446..448](3,18,1)
ReadOSImageFromBootMedia:MBR[446..448](3,18,1)
ReadOSImageFromBootMedia:MBR[450,454..461](21, 0600, C02A00)
ReadOSImageFromBootMedia:LoadAddr=80200000
ReadOSImageFromBootMedia:JumpAddress=8022A64C
ReadOSImageFromBootMedia:TtlSectors=2A94
ReadOSImageFromBootMedia:StoreOffset=0
ReadOSImageFromBootMedia:FirstHead=1
ReadOSImageFromBootMedia:FirstSector=8
ReadOSImageFromBootMedia:StartSector=0
ReadOSImageFromBootMedia:TotalSector=0
ReadOSImageFromBootMedia:Launch[3, 0, 0, EA,]
System ready!
Preparing for download...
INFO: *** Device Name 'SMDK24400' ***
INFO: Using static IP address 2020201.
INFO: Using subnet mask 2525250.
waitforconnect
INFO: using TOC[1] dwJumpAddress: 0x8022a64c
INFO: OEMLaunch: Jumping to Physical Address 0x3022A64Ch (Virtual Address 0x8022A64Ch)...

CWindows CE Kernel for ARM (Thumb Enabled) Built on Nov 24 2008 at 14:58:01
DCache: 8 sets, 64 ways, 32 line size, 16384 size
ICache: 8 sets, 64 ways, 32 line size, 16384 size
FMD: ReadID (Mfg=ec, Dev=da)
FMD_Init: finished successful
.............................

#4


该回复于2012-07-01 10:58:18被版主删除

#5


你要追究修改bootpart文件里的内容,要重新编译和sysgen整个工程才行呀。或者把这个文件移植到BSP包里也行。我就是这么干的。呵呵

#6


学习,Eboot中如何确定对空余Flash分区进行了分区?

#7


其实我最后就是在fmd.cpp重写了bootpart.cpp我要用到的部分代码,只是下载后重启系统就出现上述问题!

#8


分区也是使用这个BP_OpenPartition函数,只是在上层加文件系统的时候,怎么知道分区号的呢。

#9


public中的代码必须用sysgen编译,或者你自己去rebuild一下对应的目录。不然没有效果的。
我的eboot是直接将这个文件copy到目录里面去了。