You are on page 1of 9

Formatting the SD card via fdisk "Expert mode"

First, lets clear the partition table:

======================================================================
==========
$ sudo fdisk /dev/sdb

Command (m for help): o


Building a new DOS disklabel. 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)
======================================================================
==========

Print card info:

======================================================================
==========
Command (m for help): p

Disk /dev/sdb: 128 MB, 128450560 bytes


....
======================================================================
==========

Note card size in bytes. Needed later below.

Then go into "Expert mode":

======================================================================
==========
Command (m for help): x
======================================================================
==========

Now we want to set the geometry to 255 heads, 63 sectors and calculate the number of
cylinders required for the particular SD/MMC card:

======================================================================
==========
Expert command (m for help): h
Number of heads (1-256, default 4): 255

Expert command (m for help): s


Number of sectors (1-63, default 62): 63
Warning: setting sector offset for DOS compatiblity
======================================================================
==========

NOTE: Be especially careful in the next step. First calculate the number of cylinders as follows:

 B = Card size in bytes (you got it before, in the second step when you printed the info out)
 C = Number of cylinders

C=B/255/63/512

When you get the number, you round it DOWN. Thus, if you got 108.8 you'll be using 108
cylinders.

======================================================================
==========
Expert command (m for help): c
Number of cylinders (1-1048576, default 1011): 15
======================================================================
==========

In this case 128MB card is used (reported as 128450560 bytes by fdisk above), thus
128450560 / 255 / 63 / 512 = 15.6 rounded down to 15 cylinders. Numbers there are 255 heads,
63 sectors, 512 bytes per sector.

So far so good, now we wanna create two partitions. One for the boot image, one for our distro.
Let's check what another wiki page has to say about it:

Linux boot disk format

Create the FAT32 partition for booting and transferring files from Windows. Mark it as bootable.

======================================================================
==========
Expert command (m for help): r
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-245, default 1): (press Enter)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): +50

Command (m for help): t


Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): a


Partition number (1-4): 1
======================================================================
==========

Create the Linux partition for the root file system.

======================================================================
==========
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (52-245, default 52): (press Enter)
Using default value 52
Last cylinder or +size or +sizeM or +sizeK (52-245, default
245):(press Enter)
Using default value 245
======================================================================
==========

Print and save the new partition records.

======================================================================
==========
Command (m for help): p

Disk /dev/sdc: 2021 MB, 2021654528 bytes


255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdc1 * 1 51 409626 c W95 FAT32
(LBA)
/dev/sdc2 52 245 1558305 83 Linux

Command (m for help): w


The partition table has been altered!

Calling ioctl() to re-read partition table.


WARNING: Re-reading the partition table failed with error 16: Device
or resource busy. The kernel still uses the old table. The new table
will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x partitions,


please see the fdisk manual page for additional information.
Syncing disks.
======================================================================
==========

Now we got both partitions, next step is formatting them.

NOTE: If the partitions (/dev/sdc1 and /dev/sdc2) does not exist, you should unplug the card
and plug it back in. Linux will now be able to detect the new partitions.

======================================================================
==========
$ sudo mkfs.msdos -F 32 /dev/sdc1 -n LABEL
mkfs.msdos 2.11 (12 Mar 2005)

$ sudo mkfs.ext3 /dev/sdc2


mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
195072 inodes, 389576 blocks
19478 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done


Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:
======================================================================
==========

All done!

NOTE: For convenience, you can add the -L option to the mkfs.ext3 command to assign a
volume label to the new ext3 filesystem. If you do that, the new (automatic) mount point
under /media when you insert that SD card into some Linux hosts will be based on that label. If
there's no label, the new mount point will most likely be a long hex string, so assigning a label
makes manual mounting on the host more convenient.

NOTE: XorA created a script to automate SD card formatting

Writing the Ångström image into the SDcard and


finally booting GNU/Linux
Now we have these two partitions. In the first one we're going to write the Linux boot image and
other stuff, while in the other one we're going to write our Ångström root filesystem.

First of all, let's download the files we're going to need from:

Ångström demo images

Get the latest Ångström demo image (Angstrom-Beagleboard-demo-image......), MLO, u-


boot.bin and uImage. Additionally, download the modules (modules-2.6.X-rX-beagleboard.tgz)
file that correspond with the kernel version you download. Without these module files some
peripherals, such as webcams, will not function.

For certain images (such as the images generated by the Narcissus build system), no separate
uImage exists. You can find the uImage in the /boot directory of the root filesystem. Just copy
the uImage-x.xx... to the vfat partition and rename it.

Now you must copy MLO, u-boot.bin and uImage into the first partition (the FAT32 one) of your
SD card. Do it in this strict order, since MLO must be in the first sectors of the card.

Mount both partitions somewhere -- I'll assume they're mounted in /mnt/sda1 and /mnt/sda2,
respectively.

$ cp MLO /mnt/sda1
$ cp u-boot.bin /mnt/sda1
$ cp uImage /mnt/sda1

Now let's copy the root filesystem into the other partition (the ext3 one):

$ sudo cp Angstrom-Beagleboard-demo-image..... /mnt/sda2

and untar it. (IMPORTANT: You must untar directly onto the SD card. Do not untar somewhere
else and then copy to the SD):

$ cd /mnt/sda2
$ sudo tar -jxvf Angstrom-Beagleboard-demo-image....
(If you get "permission denied" errors while copying or untarring it to the SD Card then issue
that command using 'sudo' e.g "sudo cp Angstrom-Beagleboard-demo-image..... /mnt/sda2")

Once that's done, delete the tarball:

$ sudo rm Angstrom-Beagleboard-demo-image....

If you downloaded the modules-2.6.X-rX-beagleboard.tgz modules file you'll need to copy and
untar it:

$ sudo cp modules-2.6.X-rX-beagleboard.tgz /mnt/sda2


$ sudo tar -xvf modules-2.6.X-rX-beagleboard.tgz

Again delete the module tarball:

$ sudo rm modules-2.6.X-rX-beagleboard.tgz

and unmount both partitions.

$ sudo umount /mnt/sda1


$ sudo umount /mnt/sda2

Setting up the boot args


If you are running a Beagle xM you can skip this section

If you are running a current version of U-boot you can skip to the next section. The newer
versions have bootargs and bootcmd set to the correct values. Note the newest version
requires kernel parameters to be passed to the g_ether module:

# setenv bootargs 'console=ttyO2,115200n8 root=/dev/mmcblk0p2 rw


rootwait g_ether.host_addr=16:0F:15:5A:E1:21
g_ether.dev_addr=16:0F:15:5A:E1:20'

Ok, we're almost done. Now we need to tell our BeagleBoard that we want it to boot from the
SD card. Let's go back to our almost-forgotten minicom shell:

OMAP3 beagleboard.org #

The commands to set it up for booting from SD are:

# setenv bootargs 'console=ttyO2,115200n8 root=/dev/mmcblk0p2 rw


rootwait'
# setenv bootcmd 'mmc init;fatload mmc 0 80300000 uImage;bootm
80300000'

You might also want to configure your screen resolution at this time.

Now we want to save these variables into the NAND Flash so we don't have to type them in
every time we reboot:

# saveenv

And, YES, we're done.

Wire up your Beagle and power it up


Connect the BeagleBoard to a screen using a DVI cable and press the RESET button while
holding down the USER button. Now you've got to be PATIENT, first boot takes a looooong
time.

gcohler has also provided a write-up on getting Angstrom running.

Connect with your beagleboard using VNC and


ethernet over USB
The Angstrom demo image for the beagleboard comes with USB networking support. The only
thing you have to do is to enable it by issuing the following commands on your beagleboard via
the terminal. Note: you can use your own MAC and IP addresses, but maintain consistency.

Optional if g_ether module not compiled into older kernels :

#cd /lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget
#modprobe g_ether host_addr=16:0F:15:5A:E1:21
dev_addr=16:0F:15:5A:E1:20

Configure networking

#ifconfig usb0 192.168.0.202 netmask 255.255.255.0


#route add default gw 192.168.0.200
#cat >> /etc/resolv.conf
nameserver 192.168.1.1
Ctrl + D
#

The beagleboard will now show up as Auto usb0 on Ubuntu. You can add it automatically by
making some udev rules.

As a precaution, first enable packet forwarding in your computer:


# sudo vi /etc/sysctl.conf
Uncomment the line net.ipv4.ip_forward=1 , to enable forwarding of
packets.
# sudo sysctl -p
# sudo cat /proc/sys/net/ipv4/ip_forward
To check that the change has been made and routing is enabled

Now create /etc/udev/ruled.d/80-beagleboard.rules

# This file causes programs to be run on device insertion.


# See udev(7) for syntax.
# http://www.reactivated.net/writing_udev_rules.html#example-netif
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add",
RUN+="/usr/local/sbin/beagleboard-usb-add.sh %k"
# For newer kernels, e.g. in Ubuntu 11.04, use DRIVERS=="cdc_eem"
instead of DRIVERS=="cdc_ether"

Next create /usr/local/sbin/beagleboard-usb-add.sh

#!/bin/sh
(
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )
ip link set "$1" address 16:0F:15:5A:E1:21:$busNum &> /dev/null
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -P FORWARD ACCEPT
) &
exit 0

Finally run "chmod +x /usr/local/sbin/beagleboard-usb-add.sh" to make it executable and now


you can use network-manager with mac specific settings to automatically connect to the
beagleboard.

 Plug your beagle into your computer's usb port.


 Note the mac address from "ifconfig usb0"
 Right-click the network manager icon in the panel.
 Click "Edit Connections..."
 Delete the "Auto usb0" entry.
 Add a new connection named 'beagleboard'
 Enter the mac address from above.
 Click the "IPv4 Settings" tab.
 Change "Method" to "Manual"
 Add an address of 192.168.0.200, 255.255.255.0 (address and netmask respectively).
 Click "Ok"
 Enter your system password (if prompted) to allow changing of this system setting.

You can now connect to your beagleboard using any VNC viewer and you should be able to
access the internet from your beagleboard.

Note: if your beagleboard can't resolve external URLs (#ping elinux.org) you might need to
replace the resolv.conf settings with those from your host. From Ubuntu:

# scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf


root@192.168.0.202's password: [ENTER]

Note: if you fail to ping host or beagle and is on revision C4 you might want to try adding
'g_ether.use_eem=0' as a boot argument
(See BeagleBoardBeginners#Setting_up_the_boot_args)

You might also like