none
s3c6410的nandflash分区问题,格式化binfs,exfat破坏了 RRS feed

  • 问题

  • 现在在ut的开发板上学习,想吧nandflash的分区方式改一下:
      256MB flash
    ------ bootloader
    ------ TOC
      ------ eboot
    ------ MBR
    ------ nk.bin, //binfs
    ------ exfat //从80M后全部是exfat

    原来有个函数是BP_LowLevelFormat,格式化从mbr后面的区域,现在分为2个函数:
    /*格式化binfs*/
    BOOL BP_LowLevelFormatBINFS(DWORD dwStartBlock, DWORD dwNumBlocks,DWORD dwFlags)
    {
      dwNumBlocks = min (dwNumBlocks, g_FlashInfo.dwNumBlocks);

      RETAILMSG(1,(TEXT("Enter LowLevelFormat [0x%x, 0x%x].\r\n"), dwStartBlock, dwStartBlock + dwNumBlocks - 1));

      // Erase all the flash blocks.
        
        
      if (IsValidMBR())
      {
      RETAILMSG (1, (TEXT("is mbr.\r\n\r\n")));
      //如有MBR的话,只格式化binfs
      if (!EraseBlocks(dwStartBlock+1, dwNumBlocks -1, dwFlags))
      return(FALSE);
      }
      else  
      {
      //不存在MBR,格式化mbr和binfs
      if (!EraseBlocks(dwStartBlock, dwNumBlocks, dwFlags))
      return(FALSE);
    // Determine first good starting block
    while (IS_BLOCK_UNUSABLE (dwStartBlock) && dwStartBlock < g_FlashInfo.dwNumBlocks) {
    dwStartBlock++;
    }

    if (dwStartBlock >= g_FlashInfo.dwNumBlocks)  
    {
    RETAILMSG(1,(TEXT("BP_LowLevelFormat: no good blocks\r\n")));   
    return FALSE;
    }
    g_dwMBRSectorNum = dwStartBlock * g_FlashInfo.wSectorsPerBlock;
    // Create an MBR.
    CreateMBR();
      }
      RETAILMSG (1, (TEXT("Done.\r\n\r\n")));
      return(TRUE);
    }

    /*格式化fat*/
    BOOL BP_LowLevelFormatFAT(DWORD dwFATStartBlock, DWORD dwFlags)
    {
    DWORD dwNumBlocks = 0;
        
      if(g_FlashInfo.dwNumBlocks < dwFATStartBlock)
      return(FALSE);

      dwNumBlocks = g_FlashInfo.dwNumBlocks - dwFATStartBlock;

      RETAILMSG(1,(TEXT("Enter FAT Format [0x%x, 0x%x].\r\n"), dwFATStartBlock,g_FlashInfo.dwNumBlocks));

      // Erase all the flash blocks.
      if (!EraseBlocks(dwFATStartBlock, dwNumBlocks, dwFlags))
      return(FALSE);

      // Determine first good starting block
      while (IS_BLOCK_UNUSABLE (dwFATStartBlock) && dwFATStartBlock < g_FlashInfo.dwNumBlocks) {
      dwFATStartBlock++;
      }

      if (dwFATStartBlock >= g_FlashInfo.dwNumBlocks)  
      {
      RETAILMSG(1,(TEXT("FAT Format: no good blocks\r\n")));   
      return FALSE;
      }
      RETAILMSG (1, (TEXT("Done.\r\n\r\n")));
      return(TRUE);
    }


    吧bootloader中的格式化改了下,
    // Images start after OEM Reserved Blocks
    #define IMAGE_START_BLOCK RESERVED_BOOT_BLOCKS
    #define IMAGE_START_SECTOR BLOCK_TO_SECTOR(IMAGE_START_BLOCK)

    //这个参数是定义预览 block 的数量,默认是NBOOT + TOC + EBOOT,屏蔽前面80M空间
    //nk.bin不要超过64Mb
    #define FAT_START_BLOCK SECTOR_TO_BLOCK(FILE_TO_SECTOR_SIZE(0x5000000))
    #define FAT_START_SECTOR BLOCK_TO_SECTOR(FAT_START_BLOCK)

     // 格式化FAT区域
      if ( !BP_LowLevelFormatFAT(FAT_START_BLOCK,FORMAT_SKIP_BLOCK_CHECK) )
      {
      OALMSG(OAL_ERROR, (TEXT("ERROR: BootMonitor: Low-level boot media format failed.\r\n")));
      continue;
      }
    //格式化Binfs区域
    if ( !BP_LowLevelFormatBINFS(IMAGE_START_BLOCK,FAT_START_BLOCK - IMAGE_START_BLOCK ,FORMAT_SKIP_BLOCK_CHECK) )
    {
      OALMSG(OAL_ERROR, (TEXT("ERROR: BootMonitor: Low-level boot media format failed.\r\n")));
      continue;
     }

    现在发现格式化binfs后,启动后
    [FMD] FMD_GetInfo() : NUMBLOCKS = 2048(0x800), SECTORSPERBLOCK = 64(0x40), BYTESPERSECTOR = 2048(0x800)  
    [FMD:ERR] FMD_OEMIoControl() : Unknown IOCTL (0x00071c24)
    MECC Uncorrectable error(0x38d)
    MECC Uncorrectable error(0x38d)


    大家看看这个是哪个地方出现问题了?为什么单单格式化binfs区域,fat怎么会被破坏了
    谢谢!
    2010年5月28日 6:45