2002-09-24 20:47:27

by Michael D. Crawford

[permalink] [raw]
Subject: Conserving memory for an embedded application

I am helping my client design an embedded hardware device that we may run Linux
on. An important concern is to minimize the amount of ROM and flash ram that
the device has, both to save manufacturing cost and to minimize power consumption.

One question I have is whether it is possible to burn an uncompressed image of
the kernel into flash, and then boot the kernel in-place, so that it is not
copied to RAM when it runs. Of course the kernel would need RAM for its data
structures and user programs, but it would seem to me I should be able to run
the kernel without making a RAM copy.

It would be OK if I had to mess with the bootloader to do this.

It would also be helpful if a filesystem image containing a user program could
be burned into flash, and then the program run directly out of flash. Some
amount of RAM would be saved if the executing code were run from the flash ROM
rather than being copied into RAM as would normally be the case when executing a
demand-paged executable.

This last is probably not as important as running the kernel out of flash as I
don't think the user program would be very large.

Also, what is the minimum amount of physical ram that you think I can get any
version of the kernel later than 2.0 or so to run in? I heard somewhere that
someone can boot an x86 system with as little as 2MB of RAM. Is that the case?

Thank you,

Mike
--
Michael D. Crawford
GoingWare Inc. - Expert Software Development and Consulting
http://www.goingware.com/
[email protected]

Tilting at Windmills for a Better Tomorrow.


2002-09-25 00:47:32

by Ralf Baechle

[permalink] [raw]
Subject: Re: Conserving memory for an embedded application

On Wed, Sep 25, 2002 at 12:53:16AM -0400, Michael D. Crawford wrote:

> on. An important concern is to minimize the amount of ROM and flash ram that
> the device has, both to save manufacturing cost and to minimize power consumption.
>
> One question I have is whether it is possible to burn an uncompressed image of
> the kernel into flash, and then boot the kernel in-place, so that it is not
> copied to RAM when it runs. Of course the kernel would need RAM for its data
> structures and user programs, but it would seem to me I should be able to run
> the kernel without making a RAM copy.

Flash is much slower than normal memory so if you want any performance
beyond the level of Eniac I suggest to copy it to RAM ...

> don't think the user program would be very large.
>
> Also, what is the minimum amount of physical ram that you think I can get any
> version of the kernel later than 2.0 or so to run in? I heard somewhere that
> someone can boot an x86 system with as little as 2MB of RAM. Is that the case?

That's rather old kernels and also heavily hacked.

Ralf

2002-09-24 22:01:14

by Brad Hards

[permalink] [raw]
Subject: Re: Conserving memory for an embedded application

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 25 Sep 2002 14:53, Michael D. Crawford wrote:
> One question I have is whether it is possible to burn an uncompressed image
> of the kernel into flash, and then boot the kernel in-place, so that it is
> not copied to RAM when it runs. Of course the kernel would need RAM for
> its data structures and user programs, but it would seem to me I should be
> able to run the kernel without making a RAM copy.
The uclinux guys have eXecute In Place - google search for uclinux and XIP
will produce a stack of hits - here's one:
http://www.snapgear.com/tb20010618.html

Brad
- --
http://conf.linux.org.au. 22-25Jan2003. Perth, Aust. Tickets booked.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9kOBRW6pHgIdAuOMRAvEKAKCdutujZNT2tBk8gxkjkVz1ColD0wCdGZr+
75U01oH+2G4UWiJSk59/CBU=
=SJGg
-----END PGP SIGNATURE-----

2002-09-25 05:13:00

by Robert Schwebel

[permalink] [raw]
Subject: Re: Conserving memory for an embedded application

On Wed, Sep 25, 2002 at 12:53:16AM -0400, Michael D. Crawford wrote:
> I am helping my client design an embedded hardware device that we may
> run Linux on. An important concern is to minimize the amount of ROM
> and flash ram that the device has, both to save manufacturing cost and
> to minimize power consumption.

IMHO this isn't worth the efford. Flash is slow and (per kbyte) more
expensive than RAM, so I would'n waste too much time on this if you
don't plan to make more than >10000 pieces of your device. If you care
for power consumption use another architecture than x86.

> It would also be helpful if a filesystem image containing a user program
> could be burned into flash, and then the program run directly out of flash.

Use jffs2 for the root file system.

> Also, what is the minimum amount of physical ram that you think I can
> get any version of the kernel later than 2.0 or so to run in? I heard
> somewhere that someone can boot an x86 system with as little as 2MB of
> RAM. Is that the case?

This depends on which drivers you need, how much stuff you need in
userspace and how memory hungry your application is. Running a 2.4
kernel with busybox/uclibc in 2 MB RAM is possible.

Robert
--
Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
Braunschweiger Str. 79, 31134 Hildesheim, Germany
Handelsregister: Amtsgericht Hildesheim, HRA 2686
Phone: +49-5121-28619-0 | Fax: +49-5121-28619-4

2002-09-25 06:20:08

by Greg Ungerer

[permalink] [raw]
Subject: Re: Conserving memory for an embedded application

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Wed, 25 Sep 2002 14:53, Michael D. Crawford wrote:
>> One question I have is whether it is possible to burn an uncompressed image
>> of the kernel into flash, and then boot the kernel in-place, so that it is
>> not copied to RAM when it runs. Of course the kernel would need RAM for
>> its data structures and user programs, but it would seem to me I should be
>> able to run the kernel without making a RAM copy.
> The uclinux guys have eXecute In Place - google search for uclinux and XIP
> will produce a stack of hits - here's one:
> http://www.snapgear.com/tb20010618.html

Yep, we have this for uClinux. Currently we are only doing
this on MMU-less processors though, I haven't heard of anyone
doing kernel (or apps) XIP from flash on VM processors.

Kernel running direct from flash is reasonably easy to do
in uClinux, and pretty much all supported architectures can do it.
(The supported archiectures includes embedded Motorola m68k
(68306, 68328, 68332, 68360), Motorola ColdFire (5206, 5206e,
5249, 5272, 5307, 5407), MMUless ARM cores (Atmel/AT91,
NetSilicon/NET+ARM, Samsung/4510, Conexant/P52, etc),
SPARC LEON, NEC v850, OPENcores OR1000, NIOS core, i960,
and in the works SH2, and MIPS 4k.

We can do apps too, although on most architecture with no
VM this requires some compiler support for PIC code (either
using a GOT or only relative addressing). Currently this
is only done for the m68k, ColdFire and ARM platforms. This
would not be a problem for VM processors.

Most uClinux platforms only have flash, so this setup is
used extensively. And most people use read-only root filesystems
on flash to make them as small as possible. Someting like
the ROMfs type or CRAMfs are good options here.

I know others have mentioned performance here. But for most
people in this space it is the unit $ that is most important.
For simple uClinux systems using a 2.0.39 kernel you can run
in 2MiB of RAM if you don't want many apps (and you have
configured your kernel appropriaetely). That would be with 1MiB
of flash for kernel and small filesystem. Although you can trade
off RAM and flash here to get your best mix. I build demo
uClinux systems for the older Motorola ColdFire eval boards that
have 1MiB of RAM. And in that I run a 2.0.39 kernel and a shell,
with about 100k left over :-) [And that is all in RAM, kernel +
filesystem + apps]

Many of the modern embedded 32bit CPU's have cache, and the slower
flash access speeds are well hidden anyway. Usually only a small
performance penalty. I have a demo board that I can configure
for either 32 or 16 bit memory, and the difference on most
benchmarks with that is about 10%.

Regards
Greg



------------------------------------------------------------------------
Greg Ungerer -- Chief Software Wizard EMAIL: [email protected]
SnapGear Pty Ltd PHONE: +61 7 3435 2888
825 Stanley St, FAX: +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia WEB: http://www.SnapGear.com

2002-10-01 22:19:51

by Pavel Machek

[permalink] [raw]
Subject: Re: Conserving memory for an embedded application

Hi!

> >> One question I have is whether it is possible to burn an uncompressed image
> >> of the kernel into flash, and then boot the kernel in-place, so that it is
> >> not copied to RAM when it runs. Of course the kernel would need RAM for
> >> its data structures and user programs, but it would seem to me I should be
> >> able to run the kernel without making a RAM copy.
> > The uclinux guys have eXecute In Place - google search for uclinux and XIP
> > will produce a stack of hits - here's one:
> > http://www.snapgear.com/tb20010618.html
>
> Yep, we have this for uClinux. Currently we are only doing
> this on MMU-less processors though, I haven't heard of anyone
> doing kernel (or apps) XIP from flash on VM processors.

I thought they were doing XIP on VTechHelio? That's MIPS39xx and has MMU.
See linux-vr project.

--
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.