Forum: Mikrocontroller und Digitale Elektronik embedded linux - root filesystem mounten


von tommi (Gast)


Lesenswert?

Hallo,

ich versuche gerade auf ein custom board mit AT91rm9200, 32mb ram, 16mb 
nor flash uclinux zu portieren.
Angefangen habe ich mit der buildroot von uclibc.

U-Boot habe ich bereits erfolgreich gebaut und in den Flash gebraten. 
Einen Kernel habe ich ebenfalls gebaut und ins flash kopiert (den kann 
ich auch starten, er kommt jedoch nur bis zu der Stelle wo er merkt, 
dass er kein RootFs hat.).
Nur mit dem RootFileSystem komme ich nicht klar. Ich kann zwar alle 
möglichen FS's bauen und ins flash schreiben, nur wie werden die denn 
nun gemountet?
Ich habe jetzt schon einiges über mtd partitions gelesen, nur wie & wo 
erzeuge ich denn die einzelnen partitionen? und woher weiss der Kernel 
denn wo er das RootFs suchen muss und was für eins das ist?

Gibt es da vielleicht eine Schritt für Schritt Anleitung, die man 
befolgen kann?

Gruß & Dank Tommi

von Marius W. (mw1987)


Lesenswert?

Also ich kann persönlich nur für den AVR32 sprechen. Dort stehen die 
Flash-"Partitionen" in einer Source-Datei vom Kernel. Beim ATNGW100 zb 
heißt die Datei arch/avr32/boards/atngw100/flash.c...

Da gibts dann eine struct mtd_partition flash_parts[] drin. Dort sind 
alle Partitionen (U-Boot, Root-FS, Environment) aufgelistet.

Irgendwas sowas musst du sicherlich für dein Board auch machen.

MfG
Marius

von Ulrich P. (uprinz)


Lesenswert?

Hey Tommy,

Ich stecke noch ein paar Zeilen vorher fest, bei mir bootet der RM9200 
nämlich nicht der Kernel, den der u-boot vorher brav kopiert und 
entpackt hat. Eine eigene board.c habe ich gebaut und (hoffentlich alle) 
Konfigurationen eingebaut. Was für ein Board hast Du als Basis? 
Vielleicht können wir uns da mal zusammen tun und das ans Laufen 
bekommen. Ich habe keinen JTAG und daher z.B. beim u-boot nur eine 
Chance, daher noch 1.1.5.

Gruß, Ulrich

von C. S. (spike)


Lesenswert?

moin,

schau dir mal die datei etc/fstab an. sollte "ungefähr" so aussehen:

# device  mount point  type    options    dump  pass
/dev/mtdblock1  /    jffs2    defaults  1  1
/dev/mtdblock3  /usr    jffs2    defaults  1  1
proc    /proc    proc    defaults  0  0
sys    /sys    sysfs    defaults  0  0
dev    /dev    tmpfs    defaults  0  0
pts    /dev/pts  devpts    defaults  0  0
run    /var/run  tmpfs    defaults  0  0
log    /var/log  tmpfs    defaults  0  0
samba    /var/lib/samba  tmpfs    defaults  0  0
tmp    /tmp    tmpfs    defaults  0  0
config    /config    configfs  defaults  0  0

von Marius W. (mw1987)


Lesenswert?

Du bist gut... Die fstab liegt doch im Root-File-System. Damit der 
Kernel die Datei lesen kann muss er ja wissen, wo er das Root-FS findet.

MfG
Marius

von spike (Gast)


Lesenswert?

wieso? irgendwo muss er ja das rootfs als tarball rumliegen haben. und 
das kann man sich auf nem linux-host anschauen und ggf dateien editieren

von Nils (Gast)


Lesenswert?

Aber wenn der Kernel kein Root-FS findet, bringt die fstab auch nix. 
fstab ist ja sowieso nur Distributionsspezifisch, die wird von einem 
Script ausgewertet. Das kann man genauso auch fest ins Script einbauen 
oder automatisch machen lassen oder oder oder. Die hat mit dem Kernel 
rein GAR NICHTS am Hut.

von Der Seppel (Gast)


Lesenswert?

Schau mal ins Makefile unter:

arch/xxxx/boot/Makefile

xxxx sollte für Deine Architektur stehen.

Darin wird ROOT_DEV definiert. Pass das mal an.

von tommi (Gast)


Lesenswert?

So, sorry, dass ich so lange gebraucht habe...
Momentan sieht es folgendermaßen aus:

- U-boot läuft...
- Kernel (2.6.28) mit jffs2 support gebaut - läuft (bis er das rootfs 
mounten will...)
- Rootfs als jffs gebaut (mit Hilfe der buildroot von www.uclibc.org) 
und an mtdblock2 geflasht

meine bootargs sehen folgendermaßen aus:

bootargs=console=ttyS0,115200 init=/linuxrc mem=32M rootfstype=jffs2 
root=/dev/mtdblock2 rw 
mtdparts=physmap-flash.0:1M(Boot),2M(Kernel),8M(root),5M(Data)

wenn ich jetzt meinen Kernel starte passiert folgendes:

U-Boot> bootm 10100000
## Booting kernel from Legacy Image at 10100000 ...
   Image Name:
   Image Type:   ARM Linux Kernel Image (gzip compressed)
   Data Size:    1135300 Bytes =  1.1 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

Uncompressing 
Linux................................................................... 
.......  done, booting the kernel.
Linux version 2.6.28 (tommi@nc10) (gcc version 4.1.2) #2 Wed Jan 21 
11:11:08 CET 2009
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: Atmel AT91RM9200-DK
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 179 MHz, master 59 MHz, main 18.432 MHz
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 
8128
Kernel command line: console=ttyS0,115200 init=/linuxrc mem=32M 
rootfstype=jffs2 root=/dev/mtdblock2 rw 
mtdparts=physmap-flash.0:1M(Boot),2M(Kernel),8M(root),5M(Data)
AT91: 128 gpio irqs in 4 banks
PID hash table entries: 128 (order: 7, 512 bytes)
Console: colour dummy device 80x30
console [ttyS0] enabled
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 32MB = 32MB total
Memory: 30088KB available (2068K code, 179K data, 108K init)
Calibrating delay loop... 89.79 BogoMIPS (lpj=350208)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 288 bytes
NET: Registered protocol family 16
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (double precision)
msgmni has been set to 58
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xfffc4000 (irq = 7) is a ATMEL_SERIAL
brd: module loaded
at91_ether: probe of at91_ether failed with error -1
physmap platform flash device: 01000000 at 10000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
 Amd/Fujitsu Extended Query Table at 0x0040
physmap-flash.0: CFI does not contain boot bank location. Assuming top.
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
4 cmdlinepart partitions found on MTD device physmap-flash.0
Creating 4 MTD partitions on "physmap-flash.0":
0x00000000-0x00100000 : "Boot"
0x00100000-0x00300000 : "Kernel"
0x00300000-0x00b00000 : "root"
0x00b00000-0x01000000 : "Data"
at91_cf: irqs det #64, io #0
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 23, io mem 0x00300000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: AT91 OHCI
usb usb1: Manufacturer: Linux 2.6.28 ohci_hcd
usb usb1: SerialNumber: at91
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
at91_rtc at91_rtc: rtc core: registered at91_rtc as rtc0
AT91 Real Time Clock driver.
i2c /dev entries driver
AT91 Watchdog Timer enabled (5 seconds, nowayout)
TCP cubic registered
NET: Registered protocol family 17
at91_rtc at91_rtc: setting system clock to 1998-01-01 00:00:28 UTC 
(883612828)
VFS: Cannot open root device "mtdblock2" or unknown-block(31,2)
Please append a correct "root=" boot option; here are the available 
partitions:
1f00            1024 mtdblock0 (driver?)
1f01            2048 mtdblock1 (driver?)
1f02            8192 mtdblock2 (driver?)
1f03            5120 mtdblock3 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on 
unknown-block(31,2


Ich sehe nicht, was ich da falsch mache. Kann mir da vielleicht jemand 
weiterhelfen?

Gr. Tommi

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.