https://support.bluetechnix.at/wiki/Boot_media_(SBC-i.MX51)
Boot media (SBC-i.MX51)
From BlueWiki
Contents[hide ] |
1 General idea
The SBC supports booting from multiple media. The following is just a guideline - of course you are free to take whatever path you want.
For the first setup it is useful to write the bootloader and root file system to an SD card. You can then boot from this SD card and write the data to the NAND flash. You will then usually boot from the NAND flash during your development process.
In case you need to change the bootloader you can flash a new bootloader directly from the already running bootloader. In case this goes wrong, you can simply use the SD card to boot the "old but working" bootloader from the SD card and write it back to the NAND flash again. The other modes are mainly used for production or special applications (using the Freescale ATK Tool).
2 Boot mode pins
The boot mode pins describe, from which source the i.MX will boot. You can change these by setting the DIP switches on the board accordingly.
3 Booting from SD card
Dip switch setup: 0000 1000
3.1 Setting up a bootable SD card
- Get the updater.sh script . You can get the help output of the script by executing "./updater.sh -h".
- Insert the SD card and determine the device file (using "dmesg", for example)
- Initialize the SD card
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$ sudo ./updater.sh -i -n /dev/sde
initing device (/dev/sde)... Done
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$
- Write Redboot to the SD card
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$ sudo ./updater.sh -b ../redboot/build/redboot.bin_nopadding -n /dev/sde
Writing redboot ../redboot/build/redboot.bin_nopadding to /dev/sde...
Done
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$
- Write the Linux kernel to the SD card
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$ sudo ./updater.sh -k ~/oe/btmxc/tmp/deploy/glibc/images/i.fly/rootfs/boot/zImage -n /dev/sde
Writing the kernel ~/oe/btmxc/tmp/deploy/glibc/images/i.fly/rootfs/boot/zImage to /dev/sde... Done
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$
- Create a partition on the SD card
Start fdisk and print the partition table, it should be empty
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$ sudo fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xd5ea3f05.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sde: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0xd5ea3f05
Device Boot Start End Blocks Id System
Calculate how many cylinders correspond to a size of at least 20 MiB. The new partition must start after this boundary. For me, I calculate
<math>/frac{20971520}{3872768}=5.41</math>
Hence, there must be 6 preceding cylinders. Now create the partition.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1023, default 1): 7
Last cylinder, +cylinders or +size{K,M,G} (7-1023, default 1023):
Using default value 1023
Command (m for help): p
Disk /dev/sde: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Disk identifier: 0xd5ea3f05
Device Boot Start End Blocks Id System
/dev/sde1 7 1023 3846294 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$
- Create an EXT3 file system
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$ sudo mkfs.ext3 /dev/sde1
mke2fs 1.41.4 (27-Jan-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
240480 inodes, 961573 blocks
48078 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=985661440
30 block groups
32768 blocks per group, 32768 fragments per group
8016 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$
- Mount the partition (here: /media/disk)
harald@WS-HP4600-35:~$sudo mount -t ext3 /dev/sdd1 /media/disk
- Unpack the root file system (we are using the ifly-image from OpenEmbedded here)
harald@WS-HP4600-35:~/imx/51-i.fly/sdcard_for_booting$ cd /media/disk/
harald@WS-HP4600-35:/media/disk$ sudo tar -xjf /home/harald/imx/oe/btmxc/tmp/deploy/glibc/images/i.fly/ifly-image-i.fly.tar.bz2
harald@WS-HP4600-35:/media/disk$
- Unmount the partition
harald@WS-HP4600-35:/media/disk$ umount /media/disk
- TODO: configure redboot (required?)
3.2 Redboot configuration
RedBoot> fconfig -l
Run script at boot: true
Boot script:
.. sdhc 0 0x100000 0x100000 0x200000 r
.. e -b 0x100000 -l 0x200000 -c "console=ttymxc0,115200 console=tty1 root=/dev/mmcblk0p1 rw debug noinitrd psplash=false rootdelay=1"
Boot script timeout (1000ms resolution): 1
Use BOOTP for network configuration: true
Default server IP address: 192.168.5.1
Board specifics: 0
Console baud rate: 115200
Set FEC network hardware address [MAC]: true
FEC network hardware address [MAC]: 0x00:0x01:0x02:0x03:0x04:0x28
GDB connection port: 9000
Force console for special debug messages: false
Network debug at boot time: false
3.3 Updating Redboot and Linux kernel (in Redboot)
TODO
4 Booting from NAND flash
This is the default boot mode for the SBC.
Dip switch setup: 0011 0110
4.1 Updating Redboot, Linux kernel, and file system (in Redboot)
factive nand
TODO
...
nand read -f 0x300000 -b 0x100000 -l 0x200000
"empty" partitions:
fis create -b 0x100000 -l 0x500000 -s 0x10 -f 0x300000 kernel
fis create -b 0x100000 -l 0x40000000 -s 0x10 -f 0x800000 rootfs
fis create -b 0x100000 -l 0x3e800000 -s 0x10 -f 0x40800000 userfs1
RedBoot> fis list
... Read from 0x1fe00000-0x1feff000 at 0x00100000: ..
Name FLASH addr Mem addr Length Entry point
RedBoot 0x00000000 0x00000000 0x00100000 0x00000000
FIS directory 0x00100000 0x00100000 0x000FF000 0x00000000
RedBoot config 0x001FF000 0x001FF000 0x00001000 0x00000000
kernel 0x00300000 0x00100000 0x00500000 0x00100000
rootfs 0x00800000 0x00100000 0x40000000 0x00100000
userfs1 0x40800000 0x00100000 0x3E800000 0x00100000
5 Boot from UART/USB
The i.MX51 processor can boot from UART (UART1) or USB (USB-OTG). This is also the fall-back boot mode if boot fails.
DIP switch setup: 1100 0000
Use the ATK tool from Freescale (Windows program) to communicate with the i.MX51. (TODO...)
6 Boot from NFS (Network File System)
During development, downloading the kernel image from your PC and mounting the rootfs from your PC may save you a lot of time.
The boot loader Redboot executes from SD card or from NAND flash.
6.1 NFS root file system preparation
Refer to NFS Server for a quick NFS server how-to.
We assume that the rootfs is available at /tftpboot/rootfs-ifly . Before you let your target mount this NFS share, you have to disable configuration of the eth0 network device. This will override the kernel's network setup for the device and interrupt the connection to the NFS server and hence to the root file system.
Edit /tftpboot/rootfs-ifly/etc/network/interfaces and comment each line with eth0 in it:
#auto eth0
#iface eth0 inet dhcp
6.2 Redboot configuration
RedBoot> fconfig -l
Run script at boot: true
Boot script:
.. load -r -b 0x100000 zImage
.. e -c "console=ttymxc0,115200 console=tty1 root=/dev/nfs nfsroot=192.168.5.1:/tftpboot/rootfs-ifly/,v3,tcp rw debug noinitrd psplash=false ip=dhcp"
Boot script timeout (1000ms resolution): 1
Use BOOTP for network configuration: true
Default server IP address: 192.168.5.1
Board specifics: 0
Console baud rate: 115200
Set FEC network hardware address [MAC]: true
FEC network hardware address [MAC]: 0x00:0x01:0x02:0x03:0x04:0x28
GDB connection port: 9000
Force console for special debug messages: false
Network debug at boot time: false
6.3 Linux boot
During Linux boot, you will see the following messages if the root file system mount was successful:
eth0: config: auto-negotiation on, 100FDX, 100HDX, 10FDX, 10HDX.
Sending DHCP requests .., OK
IP-Config: Got DHCP answer from 192.168.5.1, my address is 192.168.5.121
IP-Config: Complete:
device=eth0, addr=192.168.5.121, mask=255.255.255.0, gw=192.168.5.1,
host=192.168.5.121, domain=krapfi.intern, nis-domain=(none),
bootserver=192.168.5.1, rootserver=192.168.5.1, rootpath=
Looking up port of RPC 100003/3 on 192.168.5.1
Looking up port of RPC 100005/3 on 192.168.5.1
VFS: Mounted root (nfs filesystem).
https://support.bluetechnix.at/wiki/Category:I.fly