Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Allocating Internal Flash as Root

0 views
Skip to first unread message

to...@shatalmic.com

unread,
Jun 5, 2007, 2:40:47 PM6/5/07
to
I am sure this has been asked, but I can't for the life of me find the
answer I am after. I am creating a new platform based on the MX21 ADS
board. It comes with 64MB of flash. My device will power down
completely and so I need to set up the file and object store as well
as the registry so that it is all stored in the flash instead of RAM.

The first thing I need to do is figure out how to configure my system
in PB 5 to set aside half of the flash for a file system and then make
it the root file system. I was reading the documentation and it seemed
to indicate that what I want is the ROM only file system. I am still a
little unclear because one place indicated that and another indicated
that ROM only file system means there is no place to store stuff.

The second thing is to make sure I have the registry settings right so
that the hive based registry (which I also chose for my device) will
point to the above mentioned flash area.

I guess a third question is whether this is a good idea and better
than using the RAM based system and doing some kind of backup to flash
when the user powers down the unit.

Thanks, Tony

Paul G. Tobey [eMVP]

unread,
Jun 5, 2007, 2:57:58 PM6/5/07
to
If you have the flash area you're interested in already set up with a flash
filesystem driver so that it will mount as some folder (\flash, or
whatever), then all you have to do is change to mount that filesystem as the
root, as far as having a completely persistent filesystem. I think that you
want the ROM Filesystem for this.

I'm not familiar with backing the object store with some block device,
sorry. I didn't think that was even possible.

Hive-based registry is the best-supported way to save the registry, so just
following the help and setting up to write the hive to the flash filesystem
created above should handle that.

Paul T.

<to...@shatalmic.com> wrote in message
news:1181068847.8...@z28g2000prd.googlegroups.com...

to...@shatalmic.com

unread,
Jun 5, 2007, 3:03:24 PM6/5/07
to
Thanks for the quick reply. I think I need just a little more
clarification. The flash area that I want to use is the same flash
that I am currently putting the OS image on. How do I go about
partitioning this flash so that some is used for the OS image to boot
from and the rest is mounted using the file system driver as you
indicated? Could you point me to the instructions on setting each of
those things up as well as setting up the hive to write to that flash
area? I have been searching the help and I find all kind of articles
talking about things at a high level, but nothing giving exactly steps
or settings or where to do them.

Tony

Paul G. Tobey [eMVP]

unread,
Jun 5, 2007, 3:24:00 PM6/5/07
to
Flash is just linear, typically. It doesn't require partitioning. Are you
executing the code out of flash? If so, you *cannot* do what you're talking
about unless you have a driver for that flash which is designed to handle
the case of executing out of the flash and also using it as filesystem.
Intel Persistent Storage Manager does this. If that's what you're using,
you need to say so.

The hive won't know it's on flash. It's just on a block device somewhere.
It could be a hard disk for all the hive knows. Look at the FMD driver
information in the help. This is the first step that you have to do (write
a driver for your flash to make it look like a disk device).

Once you have a disk device that is implemented with some of your flash, you
want to mount that disk as the root. Look up Storage Device Settings or
something like that in the help to see how to change your registry to mount
the flash filesystem as the root.

Finally, you want to store the hive-based registry on this disk that you've
created, so read up on hive-based registry, make sure that your mount/flags
information for the flash filesystem is in the boot hive (special tags
placed around its entries in the registry). Set the hive settings properly
to store the hive where you want it in the filesystem.

That should be it, from a high level...

Paul T.

<to...@shatalmic.com> wrote in message
news:1181070204....@d30g2000prg.googlegroups.com...

to...@shatalmic.com

unread,
Jun 5, 2007, 3:38:46 PM6/5/07
to
I am not executing out of flash. It is a normal system that has a
couple of flash chips that the OS image is stored in.

If I write (or get from the manufacturer) a driver that makes the
flash look like a drive I assume there must be something in the
configuration of that driver that will tell it to only use the flash
starting at address x because the OS image is already in the starting
part of the flash, right?

Is there anywhere in the config that I have to specific where the OS
image will be in the flash and what its max size is or do I just make
sure the file system driver starts high enough that it won't over
write the end of the OS image?

The hive stuff I think I have a handle on, thanks.

Paul G. Tobey [eMVP]

unread,
Jun 5, 2007, 4:05:29 PM6/5/07
to
OK, so your bootloader is copying the OS image to RAM before executing it?
Just want to be sure...

I would presume that any generic driver for the flash on your board would
work that way, yes. There's no standard requirements with respect to that
and it could be hard-coded in the source for the driver.

What you have to specify is entirely dependent on the driver. The OS could
not possibly care any less about how you've split up your linear flash (or
if there even *is* any linear flash). Obviously, you don't want to use part
of the area that contains the OS for filesystem, as that would destroy the
OS image. The driver will determine what is possible and what you have to
do to make it happen.

Paul T.

<to...@shatalmic.com> wrote in message
news:1181072326.5...@r19g2000prf.googlegroups.com...

to...@shatalmic.com

unread,
Jun 5, 2007, 4:58:06 PM6/5/07
to
Fair enough. I will see if I can take it from here. Thanks for all the
answers.

to...@shatalmic.com

unread,
Jun 6, 2007, 2:33:49 PM6/6/07
to
Ok, my dev board comes with a NAND flash sub module and I decided to
try getting it working before I get around to actually implementing
the real hardware.

I plug the board in. I then right click on the BSP component that is
for that board from my BSP maker (freescale). I found it in the
catalog under the third party / bsp / freescale mx21 / storage
drivers / ms flash / nand flash driver. I assume this is the one.

Once it was added to my BSP I got a new set of registry entries in my
reginit.ini file. They are:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\NandFlash]
"Dll"="nandfcd.dll"
"Order"=dword:0
"Prefix"="DSK"
"Profile"="FlashDisk"
"IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
"FriendlyName"="i.MX21 NAND FLASH Driver"

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk]
"Name"="i.MX21 NAND FLASH"
"Folder"="NAND Flash"
"DefaultFileSystem"="FATFS"
"AutoMount"=dword:1
; Auto part and format disk if no partitions are present.
; WARNING! This can cause long boot times when encountering a
fresh disk.
"AutoPart"=dword:1
"AutoFormat"=dword:1

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk\FATFS]
; Override common setting to enable automatic formatting of
unformatted volumes
"Flags"=dword:00000024

There are a lot of comments as well, but I cut those out for this
posting.

I then boot my device and can see in the built in devices the above
entries when I use the remote registry editor. What I don't see is a
drive called NAND Flash as the profile indicates.

I then saw in the driver's .reg file an environment parameter called
BSP_PS_NAND and decided to set that in my platform settings. Once I
did that I got these additional entries in the reginit.ini:

[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\Nandfcd]
"DriverPath"="Drivers\\BuiltIn\\NandFlash"
; LoadFlags 0x01 == load synchronously
"LoadFlags"=dword:1
"BootPhase"=dword:0
; Note: if BinFS is used together with PS, then should ensure
; this is loaded after BinFS by setting order to 1 and that
; BinFS autoload order is 0.
"Order"=dword:0

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk\FATFS]
; System registry in FATFS partition
"MountAsBootable"=dword:1
; To mount FAT partition as root
"MountAsRoot"=dword:1

I was hoping this would cause the NAND to be used as the main storage.
It doesn't. I am also not sure, but I seem to recall that devices that
actually get loaded are copied from the BuiltIt registry area to the
Active registry area. I didn't see the nand driver anywhere in the
Active section.

Any ideas what I am missing here?

Paul G. Tobey [eMVP]

unread,
Jun 6, 2007, 2:42:26 PM6/6/07
to
Turn on debug message output and see what happens during boot. This is
always the most-informative way to boot. You'll have to read the BSP
documentation, but typically stuff comes out a serial port and will show,
even in a retail build, the serious errors.

Paul T.

<to...@shatalmic.com> wrote in message
news:1181154829.3...@z28g2000prd.googlegroups.com...

to...@shatalmic.com

unread,
Jun 7, 2007, 2:00:39 PM6/7/07
to
Ok, I turned on debugging and saw that I had not included the mspart
partition manager. I added that to the platform and now it loads the
driver. Now I just need to figure out how to make it use the flash as
the root files system for everything.

to...@shatalmic.com

unread,
Jun 7, 2007, 2:33:17 PM6/7/07
to
Ok, I have the Flash loading and showing up as a drive on my system. I
have set all the registry settings that I could find in the help
documentation to tell it to mount as the root file system.

How do I tell if it is working? If I create a folder under any of the
standard places (like My Docments) the folder disappears the next time
I boot up the system. Could this be because I am loading, running and
debugging from ram instead of flashing the unit and then trying it? Is
this the right way to verify it?

I looked into the registry and I have the following entries actually
in the file system:

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\NandFlash]
"Dll"="nandfcd.dll"
"Order"=dword:0
"Prefix"="DSK"
"Profile"="FlashDisk"
"IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}"
"FriendlyName"="i.MX21 NAND FLASH Driver"

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk]
"Name"="i.MX21 NAND FLASH"
"Folder"="NAND Flash"
"DefaultFileSystem"="FATFS"
"AutoMount"=dword:1
; Auto part and format disk if no partitions are present.
; WARNING! This can cause long boot times when encountering a
fresh disk.
"AutoPart"=dword:1
"AutoFormat"=dword:1

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk\FATFS]
; Override common setting to enable automatic formatting of
unformatted volumes
"Flags"=dword:00000024

[HKEY_LOCAL_MACHINE\System\StorageManager\AutoLoad\Nandfcd]


"DriverPath"="Drivers\\BuiltIn\\NandFlash"
; LoadFlags 0x01 == load synchronously
"LoadFlags"=dword:1
"BootPhase"=dword:0
; Note: if BinFS is used together with PS, then should ensure
; this is loaded after BinFS by setting order to 1 and that
; BinFS autoload order is 0.
"Order"=dword:0

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\FlashDisk\FATFS]
; System registry in FATFS partition
"MountAsBootable"=dword:1
; To mount FAT partition as root
"MountAsRoot"=dword:1

Notice the MoustAsRoot setting and all.

I looked through the debug log and didn't see any errors. The only
thing I saw that stood out was:

8993 PID:bfc44ee TID:bfc44ca 0x8bfc4288: >>> Loading module
fatfsd.dll at address 0x03E40000-0x03E6B000 (RW data at
0x01FF2000-0x01FF263C)
Loaded symbols for 'C:\WINCE500\PBWORKSPACES\3PLAY\RELDIR
\MX21_ARMV4I_DEBUG\FATFSD.DLL'
9005 PID:bfc44ee TID:bfc44ca 0x8bfc4288: >>> Loading module
fatutil.dll at address 0x03E10000-0x03E27000 (RW data at
0x01FED000-0x01FEE0E8)
Loaded symbols for 'C:\WINCE500\PBWORKSPACES\3PLAY\RELDIR
\MX21_ARMV4I_DEBUG\FATUTIL.DLL'
9009 PID:bfc44ee TID:bfc44ca 0x8bfc4288: FormatDisk!FormatVolume:
New extended boot sector successfully written
9508 PID:bfc44ee TID:bfc44ca 0x8bfc4288:
FLASHDRV.DLL:L2P_GetPhysicalSectorAddr() - Secondary table doesn't
exist for logical sector 0x200!!!
10002 PID:bfc44ee TID:bfc44ca 0x8bfc4288:
FLASHDRV.DLL:L2P_GetPhysicalSectorAddr() - Secondary table doesn't
exist for logical sector 0x400!!!
10033 PID:bfc44ee TID:bfc44ca 0x8bfc4288: FormatDisk!FormatVolume:
New FAT #0 successfully written
10034 PID:bfc44ee TID:bfc44ca 0x8bfc4288: FormatDisk!FormatVolume:
New root directory successfully written
10036 PID:bfc44ee TID:bfc44ca 0x8bfc4288: FormatDisk!FormatVolume:
New BPB successfully written
10036 PID:bfc44ee TID:bfc44ca 0x8bfc4288: FormatDisk!FormatVolume
complete.
10037 PID:bfc44ee TID:bfc44ca 0x8bfc4288: <<< Unloading module
fatutil.dll at address 0x03E10000-0x03E27000 (RW data at
0x01FED000-0x01FEE0E8)
Unloaded symbols for 'C:\WINCE500\PBWORKSPACES\3PLAY\RELDIR
\MX21_ARMV4I_DEBUG\FATUTIL.DLL'

It seems to be formatting the drive when it boots. The only thing that
doesn't make sense if that is true is that if I create a folder
directly on the drive that is created (NAND Flash) it remains. So if I
create a folder on that drive it stays, but if I create a folder in
one of the standard folders they go away when I reboot.

Help?


to...@shatalmic.com

unread,
Jun 7, 2007, 2:45:17 PM6/7/07
to
My posts don't seem to be getting through. this is a test.

Bruce Eitman [eMVP]

unread,
Jun 7, 2007, 2:59:39 PM6/7/07
to
They are getting through. This is your third in about 15 minutes.

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member

<to...@shatalmic.com> wrote in message
news:1181241917.3...@a26g2000pre.googlegroups.com...

to...@shatalmic.com

unread,
Jun 7, 2007, 3:55:32 PM6/7/07
to
I actually sent those an hour ago. It used to only take a few seconds
to show up. I guess I am just impatient. Sorry.

Paul G. Tobey [eMVP]

unread,
Jun 7, 2007, 7:34:43 PM6/7/07
to
If mounting as the root was working, you would not have a separate other
folder representing the flash. Something is wrong with your settings that
is causing the flash to be mounted, not as the root, by like a storage card.
Nothing just leaps out at me, but you might verify whether you're running
the ROM Only or ROM & RAM filesystem, etc.

Paul T.

<to...@shatalmic.com> wrote in message
news:1181241197....@x35g2000prf.googlegroups.com...

Milind

unread,
Jun 7, 2007, 8:23:33 PM6/7/07
to

Hi there,

We are also facing very similar problem that you have. our WinCE 5.0
device is having 256MB flash memory. and our run time image is taking
18MB of that. Our bootloader is loading the NK from Flash to RAM and
executing in RAM. But we are not able to store the user data on the
flash (in short we are not able to make use of available
flash(256-18).
Whether we have to mount the remaining flash as separate drive? If so
how to do that?

thanks
Milind

Milind

unread,
Jun 8, 2007, 12:13:08 AM6/8/07
to
On Jun 7, 4:34 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT no
instrument no spam DOT com> wrote:
> Ifmountingas the root was working, you would not have a separate other
> folder representing theflash. Something is wrong with your settings that
> is causing theflashto be mounted, not as the root, by like a storage card.

> Nothing just leaps out at me, but you might verify whether you're running
> the ROM Only or ROM & RAM filesystem, etc.
>
> Paul T.
>
> <t...@shatalmic.com> wrote in message
>
> news:1181241197....@x35g2000prf.googlegroups.com...
>
>
>
> > Ok, I have theFlashloading and showing up as adriveon my system. I
> > It seems to be formatting thedrivewhen it boots. The only thing that

> > doesn't make sense if that is true is that if I create a folder
> > directly on thedrivethat is created (NANDFlash) it remains. So if I
> > create a folder on thatdriveit stays, but if I create a folder in

> > one of the standard folders they go away when I reboot.
>
> > Help?- Hide quoted text -
>
> - Show quoted text -

Hi there,

Thanks for the quick reply. But my question is how should I confirm
that my root is mounted to flash? Becasue we are loosing data after
rebooting the device. Can I have list of catalog items that you have
added apart from those are added in Mobile handheld profile? Also you
have mentioned in the mailing thread that you added '
"MSPART.dll" explicitely.
Also I observed that when OS boots I get to see debug messages from
"FMD_Read" function and never get any calls to FMD_Write. What does
this mean? Are we missing any thing?


Thanks
Milind

Paul G. Tobey [eMVP]

unread,
Jun 8, 2007, 11:16:34 AM6/8/07
to
a. You'll see in the debug messages that the filesystem is being mounted.

b. You'll see by looking in Windows CE Explorer that there's no separate
folder for the filesystem.

c. You'll write a file or a folder to some location that would normally be
in the RAM filesystem, but it will reappear after cycling the power to the
device.

The original poster said that he had to add MSPART explicitly. Maybe you
don't have the right debug zone set to get messages from the Write function
or maybe you aren't doing any writes.

Paul T.

"Milind" <mili...@gmail.com> wrote in message
news:1181275988....@i38g2000prf.googlegroups.com...

to...@shatalmic.com

unread,
Jun 8, 2007, 3:18:04 PM6/8/07
to
Well, I am stumped now then. I have followed all documentation that I
can find to make my flash drive the root and it is still showing up as
a separate folder. The debug messages don't give any indication of
why. Paul, thanks for all the help...anything further to finally solve
this would be appreciated.

Paul G. Tobey [eMVP]

unread,
Jun 11, 2007, 2:15:46 PM6/11/07
to
Tony,

Sorry. I don't have any other ideas, besides checking the registry
settings. I don't suppose that you have a persistent registry and, rather
than using the new settings that you've made in platform.reg or project.reg,
it's really using some old settings from some previous build (where the
separate folder mount was the way it was configured)? I'm sure that someone
with a lot of experience with mounting things as the root could take a look
at your registry and spot the problem, but I don't think I'm qualified (I've
done it, but I don't do it in production on our devices).

Paul T.

<to...@shatalmic.com> wrote in message
news:1181330284.6...@i13g2000prf.googlegroups.com...

0 new messages