Documentation:NGW/Newbie/boot from SD

From AVRFreaks Wiki

Jump to: navigation, search

[edit] Howto: Boot from SD card

After starting to play with the NGW100 you'll find quite rapidly that the internal flash is quite limited and you are running out of storage space. The instructions here tell you how to use the SD card slot as boot device to get more space.

[edit] Prerequisites

  • Valid linux OS for the the SD card

See the [Atmel Norway buildroot page] for a tarball of a pre-built OS.

See this [AVRFreaks forum thread] on how to build it yourself using the Atmel 'buildroot' utility.

  • Linux system with SD card reader

You'll need the Linux system to format the SD card with the ext2 file system and unpack the tarball to it. You will also make some minor modifications to some files before moving it to the NGW.

  • Suitable SD card.

The u-boot shipped on most Atmel boards does not support SD cards with large block sizes. This includes any SD card 2GB or greater. Also, it's highly recommended you get an SD card from a reputable manufacturer. Partly for data reliability but mainly as some of the smaller manufacturers take a 'close enough is good enough' approach to timing requirements and you may find that your cheap SD card just doesn't work, or at least doesn't work reliably. If you upgrade u-boot to at least release 1.3 (shipped with recent buildroot) then you can use 2GB and bigger SD cards.

[edit] Detailed Instructions

  • Download the tarball to your linux system
  • create a partition and filesystem on the card
  • mount the SD card somewhere 'mount /dev/sdd /tmp/SD'
  • uncompress the tarball to the card 'tar xjf <tarball> -C /tmp/SD'
  • modify /etc/fstab on the SD, the '/' fs should point to /dev/mmcblk0p1
  • umount the SD card 'umount /tmp/SD'
  • Set up the bootloader

Sample linux session to prepare the SD card:

root@altair:/work/avr32# sfdisk -l /dev/sdd

Disk /dev/sdd: 15664 cylinders, 2 heads, 32 sectors/track
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdd1          0+  15663   15664-    501232   83  Linux
/dev/sdd2          0       -       0          0    0  Empty
/dev/sdd3          0       -       0          0    0  Empty
/dev/sdd4          0       -       0          0    0  Empty
root@altair:/work/avr32# mkfs -t ext2 /dev/sdd1
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
125488 inodes, 501232 blocks
25061 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
62 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
root@altair:/work/avr32# mkdir /work/avr32/SD
mkdir: cannot create directory `/work/avr32/SD': File exists
root@altair:/work/avr32# mount /dev/sdd1 /work/avr32/SD
root@altair:/work/avr32# ls root*
rootfs.avr32_nofpu.tar.bz2
root@altair:/work/avr32# tar xjf rootfs.avr32_nofpu.tar.bz2 -C /work/avr32/SD
root@altair:/work/avr32# ls /work/avr32/SD
bin   config  etc   lib      lost+found  proc  sys  usr  www
boot  dev     home  linuxrc  media       sbin  tmp  var
root@altair:/work/avr32# vi /work/avr32/SD/etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount pt>      <type>          <options>       <dump>  <pass>
/dev/mmcblk0p1  /               ext2            defaults        0       0
root@altair:/work/avr32# umount /work/avr32/SD

Remarks:

  • Filesystem: You can use ext2 or ext3, both work. Ext2 is more appropriate on an SD card. The main advantage of ext3 is a shorter fsck after a crash, but ext3 will write a log, causing more writes to the card. Your card will wear out faster.


Settings for the bootloader:

Uboot> askenv bootcmd
Please enter 'bootcmd':mmcinit; ext2load mmc 0:1 0x10400000 /boot/uImage; bootm
Uboot> set bootargs 'console=ttyS0 root=/dev/mmcblk0p1 rootwait'
Uboot> saveenv
Uboot> boot

Explanation:

  • The bootcmd variable contains a list of the commands to run at boot (after the 1s delay)
    • mmcinit - initialize the MMC/SD card
    • extload - load the boot/uImage file from the mmc card to memory location 0x10400000. It will then be extracted to 0x10000000 before boot. Note that some older tutorials may have 0x10200000 or 0x10300000 in place of 0x10400000. With the 2 former options, there is the possibility that the kernel being extracted to address 0x10000000 will start overwriting the compressed kernel image. This is the most common cause of the board being stuck in continuous reboots. Long story short: You should always specify the load address to be 0x10400000.
    • bootm - boot from memory
  • The bootargs variable contains the parameters passed to the linux kernel at boot
    • console - where the console is
    • root - where to find the root filesystem
    • rw - mount the root filesystem read/write
    • rootwait - wait for the root device (mmc) to become ready before starting. Note that if you are running a kernel before 2.6.23 (including .atmel versions based on these kernels) you should use "rootwait=1" instead.

--Markus b 12:07, 29 January 2008 (UTC)

Personal tools