Documentation:AVR32 Linux Development/Programming an SD card with the AVR32 Linux file system
From AVRFreaks Wiki
A prebuilt AVR32 Linux image for the STK1000 can be found in the BSP CD at /BSP-CD/builds/stk1000/avr32-linux-image.img.gz. Building the AVR32 Linux file system for the STK1000 describes how to build your own file system image.
[edit] Linux users
- Insert an SD card into an SD card reader, and use
dfto see how it is mounted
# df
Filesystem 1k-blocks ... Mounted on /dev/hda1 ... ... ... ... ... ... ... /dev/sda1 ... ... /media/usbdisk-1
In this this example we will assume that /dev/sda1 is mounted on /media/usbdisk-1.
- Format the SD card and create an ext2 file system (note, the ext2 code in u-boot currently doesn't support 256 byte inodes created by newer versions of mkfs.ext2, so we must specify 128 byte inodes with the -I option).
# sudo umount /media/usbdisk-1 # sudo /sbin/e2fsck /dev/sda1 # sudo /sbin/mkfs.ext2 -I 128 /dev/sda1 # sudo mount /dev/sda1 /media/usbdisk-1
- Unpack the AVR32 Linux file system included on the BSP CD
# mkdir /tmp/avr32_image_source # cd /tmp/avr32_image_source # cp /bsp-cd/builds/avr32-linux-image.img.gz . # gunzip avr32-linux-image.img.gz
- Mount the AVR32 Linux file system image
# mkdir /tmp/avr32_image # sudo mount -o loop /tmp/avr32_image_source/avr32-linux-image.img /tmp/avr32_image
- Copy file system content to SD card
# sudo cp -a /tmp/avr32_image/* /media/usbdisk-1
- Change /etc/fstab on the SD card so it doesn't mount /usr from flash:
# sudo vi /media/usbdisk-1/etc/fstab
# /etc/fstab: static file system information. # # <file system> <mount pt> <type> <options> <dump> <pass> #mtd1 / jffs2 defaults 0 0 #mtd3 /usr jffs2 defaults 0 0
- Sync and unmount SD card to ensure that the SD-card write procedure is completed
# sudo sync; umount /dev/sda1
- (optional) unmount the temporary avr32 source folder
# sudo umount /tmp/avr32-image
[edit] Troubleshooting
PROBLEM: Does the console show u-boot messages, but no longer shows the Linux output?
Answer: The name for the serial port has changed between BSP1.0 and BSP2.0. In your u-boot environment variables, change "ttyUS0" to "ttyS0", leaving the rest of the line unchanged. This should show you the output in Linux now!
PROBLEM: Did you receive the following error message after following the above procedure - "Unsupported Architecture 0x11"?
... ## Booting image at 90400000 ... Image Name: Linux-2.6.18-at1 Image Type: Unknown Architecture Linux Kernel Image (gzip compressed) Data Size: 879298 Bytes = 858.7 kB Load Address: 10000000 Entry Point: 90000000 Verifying Checksum ... OK Unsupported Architecture 0x11
Answer: The version of u-boot is outdated. Use the u-boot.bin file found on the BSP-CD/builds/stk1000/ and follow this guide to upgrade your u-boot. Information gathered from the following AVR32 Linux Forum thread.
PROBLEM: Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
... VFS: Cannot open root device "mmcblk0p1" or unknown-block(2,0) Please append a correct "root=" boot option; here are the available partitions: 1f00 128 mtdblock0 (driver?) 1f01 8000 mtdblock1 (driver?) 1f02 64 mtdblock2 (driver?) Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
Answer: The bootargs need to be updated with the 'rootwait' option. See AVR32 Linux Patches. Get to the 'Uboot' prompt by hitting the space key on the serial console immediately after reset. Use the 'printenv', 'askenv', and 'saveenv' commands to check, update, and save the bootargs. Kernel version Linux-2.6.23 booted fine with these bootargs:
bootargs=console=ttyS0 root=/dev/mmcblk0p1 fbmem=600k rootwait
PROBLEM: ** Unable to read "/boot/uImage" from mmc 0:1 ** with SD card created with Ubuntu 8.10 or later
U-Boot> askenv bootcmd Please enter 'bootcmd':mmcinit; ext2load mmc 0:1 0x10400000 /boot/uImage; bootm U-Boot> askenv bootargs Please enter 'bootargs':console=ttyS0 root=/dev/mmcblk0p1 fbmem=600k rootwait U-Boot> boot Manufacturer ID: 27 OEM/Application ID: 5048 Product name: SD01G Product Revision: 2.0 Product Serial Number: XXXXXXXXXX Manufacturing Date: 07/01 SD Card detected (RCA 4660) CSD data: 00ffeeqq ffee33qq ffddffqq 444433qq CSD structure version: 1.0 MMC System Spec version: 0 Card command classes: 5f5 Read block length: 512 Supports partial reads Write block length: 512 Does not support partial writes Supports group WP: 16 Card capacity: 1019215872 bytes File format: 0/0 Write protection: mmc: Using 2097152 cycles data timeout (DTOR=0x72) ...... ** Unable to read "/boot/uImage" from mmc 0:1 **
Answer: Newer versions of ext2 filesystem code use by default 256 byte inodes (and thus, newer versions of Linux). However, the current u-boot code (as of 2008.10) seems to not handle this, and this issue can be solved by creating the ext2 filesystems with 128 byte inodes via the -I 128 option. If you have an old version of linux, it probably already worked because it may not have supported 256 byte inodes.
