This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Adding second NAND memory region/partion from Bootloader?

Hello,

I want to have a separate memory region in NAND to store copies of critical data using the file system.  I do not want to store the copies in the same memory region in case that the memory corruption occurs.

I am thinking about making the first partition smaller and using the rest of space for the second partition, so I changed the function BLConfigureFlashPartitions() in flash.c of SD EBOOT from

       hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)USE_REMAINING_SPACE, PART_DOS32, FALSE, PART_CREATE_NEW);

       if (hPartition == INVALID_HANDLE_VALUE)
        {
            OALLog(L"Error creating file partition 1!!\r\n");
            goto cleanUp;
        }

to

        hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)0x02800000, PART_DOS32, FALSE, PART_CREATE_NEW); // Partition #1 = 40 MB
        if (hPartition == INVALID_HANDLE_VALUE)
        {
            OALLog(L"Error creating file partition 1!!\r\n");
            goto cleanUp;
        }
          
        hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)USE_REMAINING_SPACE, PART_DOS32, FALSE, PART_CREATE_NEW);
        if (hPartition == INVALID_HANDLE_VALUE)
        {
            OALLog(L"Error creating file partition 2!!\r\n");
            goto cleanUp;
        }

The first partition is created successfully but not the second.  Can you tell me why it fails to create the second partion?  Is it possible to create a second partition in the bootloader?  Is this the right thing to do for my purpose?

I appreciate your help and guidance.

Thanks,

Luan

  • Hi,

    For the first partition, I also tried to create it as active and had the same result - the creation of the second partition fails.

    BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)0x02800000, PART_DOS32, TRUE, PART_CREATE_NEW);

    All functions in Bootpart.cpp uses RETAILMSG for debug.  When bootloader is running, these debug messages do not come out to the serial port.  How can I get them dumped out for debugging?

    Thanks,

    Luan

  • Luan,

    One option I can think of is using PART_EXTENDED instead of PART_DOS32 for one of the partitions. I can not access my board right now, could you give it a try?

    Thanks,

    Tao

  • Hi Tao,

    I try two combinations below and in both options, the second call to BP_OpenPartition() returns INVALID_HANDLE_VALUE -

    (1)   hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)0x02800000, PART_DOS32, FALSE, PART_CREATE_NEW);

            hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)USE_REMAINING_SPACE, PART_EXTENDED, FALSE, PART_CREATE_NEW);

    (2)   hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)0x02800000, PART_DOS32, TRUE, PART_CREATE_NEW);

            hPartition = BP_OpenPartition((DWORD)NEXT_FREE_LOC, (DWORD)USE_REMAINING_SPACE, PART_EXTENDED, FALSE, PART_CREATE_NEW);

     

    I do not know the reason why INVALID_HANDLE_VALUE is returned since I don't know how to dump out the debug info to serial port

    Please let me know if you have another suggestion for me to try.

    Thanks,

    Luan

  • Luan,

    The problem is the second parameter, it is "dwNumSectors", not number of bytes.

    You still need to use PART_EXTENDED for one of the partitions, since duplication is not allowed by BP_OpenPartition().


    Thanks,

    Tao

  • Hi Tao,

    Thanks for pointing out the bug.  After changing the second parameter to number of sectors instead of number of bytes, both partitions are created successfully.

    The next challenge for me is to know how to mount the second partition and be able to access it from the file system.

    Would you please show me how to modify the registry to achieve this task?

    In my custom BSP build file, I have IMGREGHIVE and IMGNAND set to 1.  I am using BSP_A8_01_01 and I do not modify "nand.reg" at all except setting "CheckForFormat" to 1 instead of 0.

    Thanks very much for your help,

    Luan

  • Luan,

    Great!

    IMGNAND flag is used to build an image to be automatically flashed in NAND. I do not think you need this flag to be enabled for what you are trying to do.

    You can also temporarily disable IMGREGHIVE  flag, it will make debug easier.

    Good Luck!

    Tao

     

  • Hi Tao,

    Woulod you please elaborate on how the NAND registry needs to be modified to get the second partition mounted as an additional folder?

    Thanks,

    Luan

  • Luan,

    If Hive Based Registry is not enabled, changes are not needed for NAND registry as long as the Filesystem Partition type is supported by OS. Please refer to "[HKEY_LOCAL_MACHINE\System\StorageManager\PartitionTable]" settings in reginit.ini. Unfortunately, PART_EXTENDED is not supported by default, so I switch it to PART_DOS32X13. After system boots up, you will see another directory "Mounted Volume2" under "My device".

    If Hive based Registry is enabled, please make sure "MountAsRoot" is set to "0". In this case, the root will be Object store. You should see two directories for both your NAND partitions("Mounted Volume" and "Mounted Volume2").

    Thanks,

    Tao

  • Hi Tao,

    I am still not able to get the folders under "My Device".  Would you please email your reginit.ini and nand.reg to LNLUAN@yahoo.com?

    Thanks,

    Luan

  • Hi Tao,

    You said that

    "I also tried to enable hive based registry from Catalog. It is just one entry in BSP that will take care of everything in release 1.2.

     There is no need to change nand.reg. MountAsRoot is already set to 0 in release 1.2."

    I am still using release 1.1.  In this version, if IMGREGHIVE=1, MountAsRoot is set to 1 in nand.reg.  I do not modify nand.reg and still have IMGREGHIVE=1, just comment out the flags below in platform batch build file

    REM if /i "%IMGREGHIVE%"=="1" set PRJ_ENABLE_FSMOUNTASROOT=1

    REM if /i "%IMGREGHIVE%"=="1" set PRJ_BOOTDEVICE_MSFLASH=1

    and everything is fine.  I now have "Mounted Volume" and "Mounted Volume2" folders.

    Thanks very much for all your help,

    Luan