Skip to contentSkip to conversation

linux kernel without file system

DISCUSSION Tomasz Chmielewski 9 participants 19 messages Jan 14, 2009 – Jan 17, 2009

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application program and removing all the file-system part of linux.

Quoted 8 lines

Is that doable ?

Is there a 'standard' way of doing that ?

The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ?

Is there a way to access devices that does not require a file-system ?

You could put everything in initramfs (and embed it in the kernel).

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#1 lore raw
Quoted 11 lines · Tomasz Chmielewski
Quoted 10 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application
program and removing all the file-system part of linux.
Is that doable ?
Is there a 'standard' way of doing that ?
The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ? Is there a way to access devices that does not require a file-system ?

Quoted 1 line

You could put everything in initramfs (and embed it in the kernel).

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

Thanks anyway

Philippe

#3 lore raw
In reply to Xavier Bestel
Quoted 16 lines · Xavier Bestel
Quoted 14 lines · Philippe De Muyter
Quoted 12 lines · Tomasz Chmielewski
Quoted 10 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application
program and removing all the file-system part of linux.
Is that doable ?
Is there a 'standard' way of doing that ?
The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ? Is there a way to access devices that does not require a file-system ?

You could put everything in initramfs (and embed it in the kernel).

Quoted 7 lines
Quoted 4 lines

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

You can still mount sysfs somewhere and access the device nodes from there.

Keeping thinking about it, I now think that my 'application program' (basically a serial-to-ethernet converter) should be a kernel thread, because of the small memory constraints.

The question is thus how to access the serial lines from a kernel thread.

Philippe

#2 lore raw
In reply to Philippe De Muyter
Quoted 12 lines · Philippe De Muyter
Quoted 11 lines · Tomasz Chmielewski
Quoted 10 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application
program and removing all the file-system part of linux.
Is that doable ?
Is there a 'standard' way of doing that ?
The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ? Is there a way to access devices that does not require a file-system ?

Quoted 6 lines
Quoted 1 line

You could put everything in initramfs (and embed it in the kernel).

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

You can still mount sysfs somewhere and access the device nodes from there.

Xav

#10 lore raw
Quoted 15 lines · Xavier Bestel
Quoted 14 lines · Philippe De Muyter
Quoted 12 lines · Tomasz Chmielewski
Quoted 10 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application
program and removing all the file-system part of linux.
Is that doable ?
Is there a 'standard' way of doing that ?
The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ? Is there a way to access devices that does not require a file-system ?

You could put everything in initramfs (and embed it in the kernel).

Quoted 7 lines
Quoted 4 lines

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

You can still mount sysfs somewhere and access the device nodes from there.

There are no device nodes in sysfs to talk to the device, only attributes, which are mostly plain small text files. For some devices there are a few writable and mappable files which can change the device's state, but that's nothing like a device node.

Kay

#13 lore raw
In reply to Philippe De Muyter
Quoted 4 lines · Philippe De Muyter

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

One thing that you can do is remove support for block devices in somewhat recent kernels, which gets you most of the way. File systems themselves are required for the majority of all system calls (anything that takes a file descriptor) and for the boot process.

	Arnd <><
#14 lore raw
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Philippe De Muyter

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

One thing that you can do is remove support for block devices in somewhat recent kernels, which gets you most of the way. File systems themselves are required for the majority of all system calls (anything that takes a file descriptor) and for the boot process.

file descriptor is actually an historical name, now too particular.

I would like to keep sockets and serial lines, for which the handle is a "file descriptor", but not use any file. So, of course I need to keep write(), read(), poll(), socket() etc, but not open(), link(), mknod() and everything that walks a directory tree.

Philippe

#11 lore raw
In reply to Kay Sievers

Oh yes sorry, I mixed that with the dev entry in sysfs, which contains the device major:minor in textual form (e.g. /sys/block/fd0/dev). Confused memory ...

Xav

Quoted 31 lines · Kay Sievers
Quoted 15 lines · Xavier Bestel
Quoted 14 lines · Philippe De Muyter
Quoted 12 lines · Tomasz Chmielewski
Quoted 10 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application
program and removing all the file-system part of linux.
Is that doable ?
Is there a 'standard' way of doing that ?
The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ? Is there a way to access devices that does not require a file-system ?

You could put everything in initramfs (and embed it in the kernel).

Quoted 7 lines
Quoted 4 lines

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

You can still mount sysfs somewhere and access the device nodes from there.

There are no device nodes in sysfs to talk to the device, only attributes, which are mostly plain small text files. For some devices there are a few writable and mappable files which can change the device's state, but that's nothing like a device node.

Kay

#15 lore raw
In reply to Philippe De Muyter
Quoted 4 lines · Philippe De Muyter

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

That's fighting the UNIX design, in "which everything is a file." You can remove all of the disk-based filesystems, but if you try to remove open, close, read or write there'll be almost nothing that you can usefully do.

#4 lore raw
In reply to Philippe De Muyter
Quoted 7 lines · Philippe De Muyter

Keeping thinking about it, I now think that my 'application program' (basically a serial-to-ethernet converter) should be a kernel thread, because of the small memory constraints.

The question is thus how to access the serial lines from a kernel thread.

Philippe

If your constraints are that severe, perhaps you should be investigating other solutions. e.g. eCos?

Linux doesn't ALWAYS have to be the answer :-)

Rogan

#16 lore raw
In reply to David Newall
Quoted 10 lines · David Newall
Quoted 4 lines · Philippe De Muyter

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

That's fighting the UNIX design, in "which everything is a file." You can remove all of the disk-based filesystems, but if you try to remove open, close, read or write there'll be almost nothing that you can usefully do.

Of course, I need read, write and ioctl and socket and friends but I do not need open, creat, link, rename etc.

Philippe

#5 lore raw
In reply to Rogan Dawes
Quoted 6 lines · Rogan Dawes
Quoted 4 lines · Philippe De Muyter

Keeping thinking about it, I now think that my 'application program' (basically a serial-to-ethernet converter) should be a kernel thread, because of the small memory constraints.

Quoted 6 lines
Quoted 3 lines

The question is thus how to access the serial lines from a kernel thread.

Philippe

If your constraints are that severe, perhaps you should be investigating other solutions. e.g. eCos?

I like to reuse (and contribute to) the linux drivers and kernel.

Quoted 1 line

Linux doesn't ALWAYS have to be the answer :-)

No ? :)

Philippe

#6 lore raw
Quoted 13 lines · Philippe De Muyter
Quoted 11 lines · Rogan Dawes
Quoted 7 lines · Philippe De Muyter

Keeping thinking about it, I now think that my 'application program' (basically a serial-to-ethernet converter) should be a kernel thread, because of the small memory constraints.

The question is thus how to access the serial lines from a kernel thread.

Philippe

If your constraints are that severe, perhaps you should be investigating other solutions. e.g. eCos?

Quoted 8 lines

I like to reuse (and contribute to) the linux drivers and kernel.

Quoted 1 line

Linux doesn't ALWAYS have to be the answer :-)

No ? :)

Philippe

Ok, in that case, perhaps you should explain exactly what your constraints are (target board, max memory/flash, etc), and maybe folks will be able to provide more sensible answers.

Good luck!

Rogan

#17 lore raw
In reply to Philippe De Muyter
Quoted 9 lines · Philippe De Muyter
Quoted 7 lines · David Newall
Quoted 5 lines · Philippe De Muyter

Actually, I was thinking about reducing the footprint of my kernel by removing all the fs-related system calls, so the problem is not where the file-system is, but how to access (serial) devices without giving their "/dev/..." name.

Quoted 8 lines
Quoted 5 lines

That's fighting the UNIX design, in "which everything is a file." You can remove all of the disk-based filesystems, but if you try to remove open, close, read or write there'll be almost nothing that you can usefully do.

Of course, I need read, write and ioctl and socket and friends but I do not need open, creat, link, rename etc.

I think you do need open; how else will you open the serial port?

The best advice I can offer is: Don't think about kernel threads, user-space is where you should be; and don't think about removing system calls. If your application truly is so tight, linux might not be the right tool for you.

Maybe the embedded linux list might be more in tune with what you're thinking.

#7 lore raw
In reply to Rogan Dawes
Quoted 18 lines · Rogan Dawes
Quoted 17 lines · Philippe De Muyter
Quoted 11 lines · Rogan Dawes
Quoted 7 lines · Philippe De Muyter

Keeping thinking about it, I now think that my 'application program' (basically a serial-to-ethernet converter) should be a kernel thread, because of the small memory constraints.

The question is thus how to access the serial lines from a kernel thread.

Philippe

If your constraints are that severe, perhaps you should be investigating other solutions. e.g. eCos?

I like to reuse (and contribute to) the linux drivers and kernel.

Quoted 1 line

Linux doesn't ALWAYS have to be the answer :-)

Quoted 8 lines
Quoted 4 lines

No ? :)

Philippe

Ok, in that case, perhaps you should explain exactly what your constraints are (target board, max memory/flash, etc), and maybe folks will be able to provide more sensible answers.

if possible, mcf52236 (256k flash 32k sram in chip) :)

kernel+uapplication XIP in flash

they seems to push something called utasker

Philippe

#8 lore raw
Quoted 6 lines · Philippe De Muyter
Quoted 3 lines · Rogan Dawes

Ok, in that case, perhaps you should explain exactly what your constraints are (target board, max memory/flash, etc), and maybe folks will be able to provide more sensible answers.

if possible, mcf52236 (256k flash 32k sram in chip) :)

256kB flash? Good luck with that!

Quoted 3 lines

kernel+uapplication XIP in flash

they seems to push something called utasker

Maybe it is the best solution . . .

Rogan

#18 lore raw
In reply to Philippe De Muyter
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Philippe" == Philippe De Muyter <[email protected]> writes:

Quoted 11 lines · Tomasz Chmielewski
Quoted 11 lines
Quoted 10 lines

I need to design a very small embedded system that must only control one ethernet port and two serial lines and must fit in a very small flash memory. So I thought about replacing the call to /etc/init by my application
program and removing all the file-system part of linux.
Is that doable ?
Is there a 'standard' way of doing that ?
The first problem I see is accessing my serial lines. How could I do that without using open("/dev/ttySx"), which requires a file system ? Is there a way to access devices that does not require a file-system ?

Quoted 1 line
Quoted 1 line

You could put everything in initramfs (and embed it in the kernel).

Philippe> Actually, I was thinking about reducing the footprint of my Philippe> kernel by removing all the fs-related system calls, so the Philippe> problem is not where the file-system is, but how to access Philippe> (serial) devices without giving their "/dev/..." name.

Does it have to be linux? I've been playing with Arduino boards
(http://www.adafruit.com) lately and they have ethernet modules, serial libraries, etc. All on a small small chip. Well, the ethernet is a daughter board, but they're still pretty small.

Depends on how general purpose you need to make this device and what you're trying to accomplish. Maybe you need to give people a better idea of what you're trying to do, instead of assuming you need Linux and trying to shoe-horn it into a really tiny space.

Cheers,
John

#9 lore raw
In reply to Philippe De Muyter
Quoted 5 lines · Philippe De Muyter

if possible, mcf52236 (256k flash 32k sram in chip) :)

kernel+uapplication XIP in flash

they seems to push something called utasker

In 256kb it will be hard to even support simple user space. One solution might be to just use linux as a library and implement your application code in the kernel, inside of the . That lets you throw out all system calls and some of the init code of the kernel (don't call rest_init).

At that stage, you have lost most of the advantages of using Linux over some other kernel.

	Arnd <><
#12 lore raw
In reply to Kay Sievers
Quoted 2 lines · Kay Sievers

There are no device nodes in sysfs to talk to the device, only attributes, which are mostly plain small text files.

Actually, it would be really cool if all serial port operations could be done via sysfs, so we don't need the device node (including all its ioctl()) at all.

BTW: did I already mention that I don't like ioctl() ?

cu

Signature · 8 lines
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux IT service - http://www.metux.de/
---------------------------------------------------------------------
 Please visit the OpenSource QM Taskforce:
 	http://wiki.metux.de/public/OpenSource_QM_Taskforce
 Patches / Fixes for a lot dozens of packages in dozens of versions:
	http://patches.metux.de/
---------------------------------------------------------------------