Multiple fat partitions

i need to create at least 3 partitons in the 8 Mbyte serial flash of my rcm3300, the Fat Module manual suggests a solution setting specific information in the mbr_part entries for each partition I am creating and then using the function fat_FormatDevice() but if I try to use it the result is ever the error code -EPERM (partition already mounted) and no partitions is created.

The documentation in this area mentions fat_Automount or fat_Init, however, you don’t want to use fat_Automount if trying to setup multiple partitions. Use fat_Init and create your own structure variables as you will not need much, you do not have to open any files to do this. Also, it is critical that the flash is erased and has no MBR on it already. You can do this by running sflash_inspect.c and using the C (clear command) to clear the first several pages of the serial flash.

Then create your partitioning program using fat_Init as mentioned above and setup the MBR structure with the partition data you want. If you need help figuring out what this should look like, post back with the number and sizes of the partitions and I will post the proper data. In your routine, call the fat_formatDevice function and as long as the flash was empty (and you don’t call fat_Automount), you should not get the errors you’ve been running into. This is all that needs to happen in your partitioning program. You can now run fat_shell.c and it should recognize the new partition table and format the partitions for you.

Thank you very much Bill
I need to create three partition:
6 mbyte,
1 mbyte
1 mbyte

I have been meaning to write a utility program that does partitioning so I did, it is called FAT_WRITE_MBR. I have attached the program and it will allow you to specify up to all 4 partitions in the MB size you would like them made. It displays the amount of space available then allows you to set the size of partition 1. If you don’t use all the space available, it will show the remaining space and ask for the size of the next partition. All entries are in floating point and in megabytes desired. If you specify more than is available, it will give you what it can and move on. Once all the space is used, or you enter a zero size for a partition, it will ask for a confirmation to write to the flash.

This program still requires you to use sflash_inspect to clear (erase) the first page on the device, although it is a good idea to erase the first 2 or 3. If you try to run it on a flash device that has an MBR, it will error out stating the drive is not unformatted. After running the FAT_WRITE_MBR program the MBR is setup, but the partitions are not formatted yet. You can run FAT_SHELL and it will ask permission to format the first partition. It will then startup with just the A: drive mounted. You can then issue the command ‘format b’ and it will format and mount the second partition. Repeat this for partitions c and d if necessary and you will now have a fully functional multi-partition device. Let me know if you have any problems.

thank you very much Bill

I’m trying to create two FAT partitions on the built-in NAND device of a RCM3365.
With reference to the fat_write_mbr.c program I think I’ve managed to create two partitions using fat_FormatDevice but has someone please got an example or can tell me what to do next to format, enumerate e.t.c. before I can start creating files on the device?

As mentioned, after creating the MBR with multiple partitions, you run FAT_shell.c which should ask permission to format the first partition automatically. It will then show partition A as mounted and present you with a prompt. At this point, type in ‘format b’ and press enter (leave off the quotes, of course). This will format the second partition and will come back showing partition A mounted and partition B mounted. You can now work with either partition by using A: or B: to switch between partitions.

Thanks but I’m getting 'fat_AutoMount succeeded with return code -303. ’ when I run fat_shell after trying to split the 16MB NAND in half!?

I’ve got it working :slight_smile: