[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ltib] mounting root filesystem
From: |
Stuart Hughes |
Subject: |
Re: [Ltib] mounting root filesystem |
Date: |
Thu, 18 Jan 2007 10:42:43 +0000 |
Hi Mehrdad,
I don't have anything specific for that platform, but there is a
deployment guide config/platform/mpc8349itx/deployment_instructions.txt
in CVS. I've attached an html version of this too. This has a section
near the end that gives some ideas about JFFS2.
Please beware, this is a general untested write up that I was working
on. The principles though are the same for most platforms:
WARNING WARNING WARNING: If you erase the wrong bit of Flash on your
boards, it won't boot and you'll need a BDM to recover the board.
IMHO unless you have the recovery tool and are confident about what
you're doing, I'd stick with NFS deployment.
If you google around, you'll probably find some much clearer and better
write ups that the one I have. There is more than one way to do this.
Regards, Stuart
On Thu, 2007-01-18 at 09:12 +1100, Mehrdad Salami wrote:
> Hi Everyone,
>
> I started to use ltib for freescale coldfire. I used uclinux and
> LinuxBSP before. They both generate one image.bin for the kernel plus
> filesystem. However it seems to me the ltib generate vmlinux.bin for
> kernel and another file (either jjfs2 or ramdisk) for filesystem. Is
> there any way to have one file which combines these two.
> If not is there any document to show how to use this separate files and
> link them to the vmlinux.bin
>
> At the moment I load vmlinux.bin in address 1000 and run from 2000. It
> stops when it get to mounting filesystem. I don't know how to use
> rootfs.jffs2 or rootfs.ext2.gz which is generated after compilation.
>
> I am running my own bootloader and compile ltib package to load and run
> the image by my bootloader.
>
>
> Regards,
>
>
> Mehrdad
>
>
> _______________________________________________
> LTIB home page: http://bitshrine.org
>
> Ltib mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/ltib
>
Copyright © Freescale Semiconductor, Inc. 2004-2005. All rights reserved.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the file doc/COPYING
Table of Contents
General Setup for the MPC8349mITX-gp
Getting connected
Here's the view of the back panel of the itx unit:
------------------------------------------------------
| |
|---------------------------------------- |
| -- -- | |
| |eth0 | | |
| |-----| | |
| _____ |-----| | |
| \ ser / | | | (+) | 12V DC 5A centre +
| ----- -- -- | |
------------------------------------------------------
With the board powered down:
- Connect a serial cable between the host and the target board (as
shown marked 'ser')
- Plug in a network patch cable from the itx (as shown marked eth0)
to a free position on your network hub.
- Plug in the supplied power supply and connect to the itx board
at the connect on the back at the right (marked DC 12V/5A)
- On the Linux host run minicom (or other terminal emulator
program) and configure the serial line setting to: 115200 8 N 1
with flow control off
Powering up to the boot prompt
- On the front of the itx, press (and briefly hold) the power switch
marked (on the right).
- On the terminal emulator you will see some text scroll by ending with
something like:
Data in EEPROM (addr 0x50) is valid.
In: serial
Out: serial
Err: serial
Net: Freescale TSEC0: PHY is VSC8201 (fc413)
Freescale TSEC0
Board Revision: rev 1.0
=>
Booting from Flash
The system as shipped has a copy of GNU/Linux already burned into Flash.
This consists of an area that contains the kernel and an area that
contains the root filesystem (a compressed ramdisk with u-boot header).
This can be run as a confidence check and as a basic system. This
is shown first as it's the simplest way to boot the system. To
do this, power up the itx to the u-boot prompt as described in the
section 'General setup' and then run the following command:
=> run flashramboot
Note: the system will attempt to configure its network configuration
using DHCP protocol.
Note also: any changes will made to the system will be lost
when you power down as you're running from a ramdisk image.
Other boot options (using the network)
For other boot methods you'll need to have a working network connection.
Not only that but you may also need to change some of the u-boot
configuration parameters.
Configuring the u-boot parameters
As supplied the u-boot parameters will be valid only for a particular
environment (the defaults can be found in u-boot_default_environment.txt).
In particular you'll need to check the following parameters
and change them. Here's a checklist and what I ended up
changing for my environment (you need to adjust appropriately).
Parameter | Default | My setting | Comment |
serverip | 192.168.1.54 | 192.168.0.9 | The IP address of your host |
gatewayip | 192.168.1.254 | none | I'm not using a gateway to boot |
tftp_path | 8349ITX-GP/fae | none | I put stuff directly in /tftpboot |
ipaddr | 192.168.1.200 | 192.168.0.254 | A free IP on your network |
rootpath | /opt/fae-root1 | /tmp/ltib/rootfs | Your NFS rootfs location |
So in my case here's what I did at the u-boot prompt:
=> setenv serverip 192.168.0.9
=> setenv gatewayip
=> setenv tftp_path
=> setenv ipaddr 192.168.0.254
=> setenv rootpath /tmp/ltib/rootfs
To make these permanent (in Flash) you need to use the following command:
=> saveenv
How to run Linux with the default built filesystem (tftpboot Option)
Using this method you download the kernel image and the root filesystem
image across the network and then use u-boot to load and run them.
This is useful if you build your own kernel and/or root filesystem
and want to try them out. The principal limitation of this method
is that anything you change while the system is running will be lost
(as your running a ramdisk image).
Before you attempt this, you need to make sure that you have a running
tftp server. Setting this up is before the scope of this note, but
one simple test I run is:
$ netstat -a | grep tftp
udp 0 0 *:tftp *:*
If you see the line output (udp....) then it's likely your tftp server
is available. Remember though, even if it is running you may have
other hurdles to overcome before you can download from it (e.g
iptables/firewalls).
Once you're confident your tftp server is working, to boot up use
the following commands:
On the host:
$ cp rootfs/boot/uImage rootfs.ext2.gz.uboot /tftpboot
On the target:
=> run tftpramboot
How to boot using tftp for the kernel and NFS for the root filesystem
This method is generally the most useful for developers. Using this
method and LTIB a user is able to change the configuration of their
root filesystem (add/remove packages) and immediately see the result
on your running system (e.g ./ltib -p strace).
Before booting using this method, in addition to the tftp server,
you'll also need a working NFS server. Setting up an NFS server
is also beyond the scope of this note but here is a brief guide (always
remember to make sure your iptables/firewall is not blocking things).
On your host (as root):
- Edit /etc/exports and add in the path to the root filesystem
you will be referencing (e.g. /tmp/ltib/rootfs). Here is
an example (note this entry allows any host from my network
to mount the filesystem):
/tmp/ltib/rootfs 192.168.0.0/24(rw,no_root_squash,sync)
# sh /etc/rc.d/init.d/nfs restart
# exit
$
Re-configure the network setup in your LTIB config
Unfortunately the default configuration setup in LTIB is to use
DHCP to get the network address for eth0. If you're using NFS
this won't work (you'll see an endless stream of
'RPC: sendmsg returned error 101'). This is because you mount
the filesystem with one IP address and then subsequently get DHCP
to change it. To fix this, here's what you need to do:
- run ltib and ask it to configure the system
$ ./ltib --configure
- Navigate to the network setup page:
--- Target System Configuration
Options --->
Network setup --->
[*] get network parameters using dhcp
- Unselect this option and then set the following:
[ ] get network parameters using dhcp
(192.168.0.254) IP address (NEW)
(255.255.255.0) netmask (NEW)
(192.168.0.255) broadcast address (NEW)
(192.168.0.1) gateway address (NEW)
(192.168.0.1) nameserver IP address (NEW)
- Then select exit and when prompted to save your new configuration
select 'yes'
Boot the target
Ltib will now run and build as required: When it done, do the following:
On the host:
$ cp rootfs/boot/uImage /tftpboot
On the target:
=> run tftpnfsboot
Working with the Flash
The Boot Flash Map:
The MPC8349E-mITX-GP platform contains one flash bank that may be used to boot
a kernels/filesystem. Here is the layout
From | To | Size | Use/Comment |
FE00_0000 | - | - | Start of Flash |
FE00_0000 | FE05_FFFF | 384K | U-Boot (begins at start of Flash) |
FE06_0000 | FE25_FFFF | 2M | Linux Kernel |
FE26_0000 | FE7F_FFFF | 5.625M | Root Filesystem |
FE7F_FFFF | - | - | End of Flash |
How To Flash U-Boot:
This is not recommended as it can render the system unbootable. If
this happens you'll need a JTAG device to get into the system.
How to Flash your Linux kernel and ramdisk file system
However if you'd like to have a completely self-contained system (that can
independently boot), you have the option of Flashing the kernel and
rootfilesystem into the board's Flash. Then by changing the parameters in
u-boot, you can have an stand-alone auto-booting system. Obviously the space
available for the root filesystem will limit the number of package that you
can add.
The space used with profile config/platform/mpc8349itx/defconfig-min-fs is:
(please select linux-2.6.13.4 for the kernel when prompted)
Region | Size |
Kernel | 1.5 MB |
Root filesystem | 1.9 MB |
- . Re-build your BSP using the smaller Flash preconfig:
$ ./ltib --preconfig config/platform/mpc8349itx/defconfig-min-fs
When you get the blue configuration screen, select linux-2.6.13.4 for the
kernel.
- . Copy the kernel and ramdisk images to your tftpboot server directory
(by default /tftpboot).
$ cp rootfs/boot/uImage <your tftp path>/
$ cp ltib-mpc8349itx-gp-20061024/rootfs.ext2.gz.uboot <your tftp path>/
- . The following commands are used to program the flash using u-boot on the
target. After cycling the power on your target:
# download the kernel into RAM
=> tftpboot $loadaddr $tftp_path/uImage
# erase the Flash memory that will hold this kernel image (takes a while)
=> erase $kernaddr fe7fffff
# write the kernel to the flash
=> cp.b $loadaddr $kernaddr $filesize
# verify that the kernel was programmed properly
=> cmp.b $loadaddr $kernaddr $filesize
# download the root filesystem into RAM
=> tftpboot $loadaddr $tftp_path/rootfs.ext2.gz.uboot
# write the ramdisk to the flash
=> cp.b $loadaddr $ramdiskaddr $filesize
# verify
=> cmp.b $loadaddr $ramdiskaddr $filesize
# verify that the images flashed are valid u-boot images
=> imls
Flash deployment using JFFS2 for the root file system
WARNING: beware this is untested on this platform. Make sure you
don't overwrite your Flash in the wrong area !!!!!!
If you want to boot stand-alone from Flash but want to be able to make
(persistent) updates to your root filesystem configuration, this is
the best option. Unfortunately I don't have tthe details for this
right now, but it's certainly possible. The sort of things you need to
do are:
- Enabled MTD/JFFS2 support in the kernel
- Reboot your target and load the new kernel (with tftpboot).
When booting supply a physmap for the MTD that give the right offset
for the rootfs partitions (e.g. add the following to the
bootargs: mtdparts=phys_mapped_flash:384k(uboot)ro,2M(kernel)ro,5760(jffs2)
- Once booted, sanity check your mtd partitions look right by doing:
# cat /proc/mtd
- Configure LTIB to build a JFFS2 image (Target Image Generation/Options)
- Copy the build JFFS2 into Flash on the running target (make sure it's
not too big to fit into the allocated space).
$ cp rootfs.jffs2 rootfs/tmp
- Erase the Flash root filesystem area on the target.
# flash_eraseall /dev/mtd2
- Copy the rootfs file into the Flash on the target
# flashcp /tmp/rootfs.jffs2 /dev/mtd2
- Test that the image has been properly copied to flash
# mount -t jffs2 /dev/mtdblock2 /mnt/src
# /mnt/src
# chroot /mnt/src
# exit
- Cycle power and boot the system
=> tftp $loadkernaddr uImage
=> setenv bootargs 'root=1f03 rootfstype=jffs2 mtdparts=phys_mapped_flash:384k(uboot)ro,2M(kernel)ro,5760(jffs2)'
=> bootm $loadkernaddr uImage
USB operation
How to insert and mount a USB Flash drive device
Connecting a USB key
TBD.
Converted on Thu Jan 18 10:35:17 2007