Booting the Neo FreeRunner from SD via U-Boot

From Openmoko

Revision as of 10:03, 12 November 2007 by ScaredyCat (Talk | contribs)

Jump to: navigation, search

Here are the steps described to boot your system from an SD card.

Newer versions of u-boot don't work properly for booting from SD card. This one works, but as ever be careful when flashing u-boot as you can brick your device.

Contents

Step 1: Change your kernel settings

Kernel building is supposed to be done through OpenEmbedded. If you use the MokoMakefile open up $OMDIR/openmoko/trunk/oe/packages/linux/linux-gta01/defconfig-2.6.21.6-fic-gta01. If you are building OM-2007.2 open $OEDIR/openembedded/packages/linux/linux-openmoko/defconfig-2.6.22.5-fic-gta01. (Note that the kernel version may change in future versions.)

Now find the line saying:

CONFIG_MMC_S3C=m

and change it to:

CONFIG_MMC_S3C=y

If you want to use an ext2 file system on the SD, also find the line saying:

CONFIG_EXT2_FS=m

and change it to:

CONFIG_EXT2_FS=y

If you're using MokoMakfile, you can clean out your last kernel build (forcing a new build) by running:

make clean-package-linux-openmoko

Step 2: Building a tarfile distribution

If you are building OM-2007.2 you need to add "tar" to the image types in your local.conf:

IMAGE_FSTYPES = "jffs2 tar"

After building a new image by issuing bitbake openmoko-devel-image (or make openmoko-devel-image if you are using MokoMakefile) there will be a OpenMoko-....tar in the deploy directory.

Step 3: Populate SD card

Format partition 1 as ext3 (or better ext2 if enabled, see above). Mount your SD card somewhere and put your image on it:

mount /dev/sda1 /mnt/moko
tar -C /mnt/moko/ -xvf openmoko-devel-image-fic-gta01-20070313022035.rootfs.tar

Now we also want the kernel on there. In OM-2007.2 the last built kernel gets a special soft-link. Therefore you can copy it by doing:

cp uImage-fic-gta01-latest.bin /mnt/moko/boot/uImage

Step 3: Add uboot boot entry

On my Phase-1 Neo the boot menu entry existed already. If yours is missing it follow those instructions: Start uboot in bootmenu mode (= hold AUX while powering on) and add the following entry via serial console: (See Bootloader section on how to access an bootloader).

GTA01Bv4 # setenv menu_4 Boot from SD: setenv bootargs root=/dev/mmcblk0p1 rootdelay=5 console=ttySAC0,115200 console=tty0 loglevel=8 \${mtdparts}\; mmcinit\; ext2load mmc 0 0x32000000 /boot/\${sd_image_name}\; bootm 0x32000000
GTA01Bv4 # setenv sd_image_name uImage
GTA01Bv4 # saveenv

You can now easily boot a different kernel by changing the variable sd_image_name to the new name.

Step 4: Boot into the new system

Power off your device, insert the SD card and boot into the boot menu. You should have an entry called "Boot from SD" which does exactly that. :-)

Installing without removing your SD card

Being the lazy person that I am, at one point I tried copying an image over to the micro SD card while still in my phone. This didn't work so well, primarily due to bug 677.

Now that this bug has been resolved, the process becomes relatively simple:

  • Boot to your internal flash partition (not the SD card.) Make sure you're running a release that includes the fix to bug 677!
  • Plug in your USB and set up [USB Networking].
  • Clean off your currently installed microSD card and install the new image:
ssh root@192.168.0.202 "rm -rf /media/card/*"
cat openmoko-devel-image-fic-gta01-20070313022035.rootfs.tar | ssh root@192.168.0.202 tar -C /media/card -xv
scp uImage-fic-gta01-latest.bin root@192.168.0.202:/media/card/boot/uImage

Boot from SDHC

As SDHC is currently not supported in u-boot you can't use the Booting from SD guide. But there's a kind of workaround that is a good option to have at least your rootfs on the microSDHC:

First you can follow Step 1 to get an kernel-image with mmc- and ext2-support. But instead of copying the image to the rootfs you will have to flash it to the Neo's internal NAND-Flash (using Dfu-util). Now you can continue with Step 2 (like mentioned before you do not have to copy your uImage to the rootfs) and follow the instructions to Step 3. Instead of the setenv commands in Step 3 you have to enter the following:

GTA01Bv4 # setenv menu_5 Boot from SDHC: setenv  bootargs root=/dev/mmcblk0p1 console=tty0 loglevel=8 rootdelay=5 neo1973-nand:0x00040000(u-boot),0x00004000(u-boot_env),0x00200000(kernel),0x000a0000(splash)\; nand read.e 0x32000000 kernel\; bootm 0x32000000
GTA01Bv4 # saveenv

And that's it! Now you can use the newly created menu option "Boot from SDHC" to boot the internal kernel, using the root-filesystem on the microSDHC.

Autoboot from SDHC

Maybe you want to Boot automatically from SDHC: Set a new Bootmenu Entry for booting from NAND first

GTA01Bv4 # setenv menu_6 Boot from NAND: setenv bootargs ${bootargs_base} \${mtdparts}\; nand read.e 0x32000000 kernel\; bootm 0x32000000
GTA01Bv4 # saveenv

then Power-off, and enter the Bootmenu to test the new Entry.If you can boot from NAND, shutdown, enter Boot menu, connect to bootloader and set the (auto)bootcmd for boot from SDHC:

GTA01Bv4 # setenv bootcmd setenv bootargs root=/dev/mmcblk0p1 rootdelay=10 console=tty0 loglevel=8 neo1973-nand:0x00040000(u-boot),0x00004000(u-boot_env),0x00200000(kernel),0x000a0000(splash)\; nand read.e 0x32000000 kernel\; bootm 0x32000000 
GTA01Bv4 # saveenv

Now you boot from SDHC everytime you press the Power-Button or reboot and if you like to boot from NAND -just use the bootmenu.

Personal tools

Here are the steps described to boot your system from an SD card.

Newer versions of u-boot don't work properly for booting from SD card. This one works, but as ever be careful when flashing u-boot as you can brick your device.

Step 1: Change your kernel settings

Kernel building is supposed to be done through OpenEmbedded. If you use the MokoMakefile open up $OMDIR/openmoko/trunk/oe/packages/linux/linux-gta01/defconfig-2.6.21.6-fic-gta01. If you are building OM-2007.2 open $OEDIR/openembedded/packages/linux/linux-openmoko/defconfig-2.6.22.5-fic-gta01. (Note that the kernel version may change in future versions.)

Now find the line saying:

CONFIG_MMC_S3C=m

and change it to:

CONFIG_MMC_S3C=y

If you want to use an ext2 file system on the SD, also find the line saying:

CONFIG_EXT2_FS=m

and change it to:

CONFIG_EXT2_FS=y

If you're using MokoMakfile, you can clean out your last kernel build (forcing a new build) by running:

make clean-package-linux-openmoko

Step 2: Building a tarfile distribution

If you are building OM-2007.2 you need to add "tar" to the image types in your local.conf:

IMAGE_FSTYPES = "jffs2 tar"

After building a new image by issuing bitbake openmoko-devel-image (or make openmoko-devel-image if you are using MokoMakefile) there will be a OpenMoko-....tar in the deploy directory.

Step 3: Populate SD card

Format partition 1 as ext3 (or better ext2 if enabled, see above). Mount your SD card somewhere and put your image on it:

mount /dev/sda1 /mnt/moko
tar -C /mnt/moko/ -xvf openmoko-devel-image-fic-gta01-20070313022035.rootfs.tar

Now we also want the kernel on there. In OM-2007.2 the last built kernel gets a special soft-link. Therefore you can copy it by doing:

cp uImage-fic-gta01-latest.bin /mnt/moko/boot/uImage

Step 3: Add uboot boot entry

On my Phase-1 Neo the boot menu entry existed already. If yours is missing it follow those instructions: Start uboot in bootmenu mode (= hold AUX while powering on) and add the following entry via serial console: (See Bootloader section on how to access an bootloader).

GTA01Bv4 # setenv menu_4 Boot from SD: setenv bootargs root=/dev/mmcblk0p1 rootdelay=5 console=ttySAC0,115200 console=tty0 loglevel=8 \${mtdparts}\; mmcinit\; ext2load mmc 0 0x32000000 /boot/\${sd_image_name}\; bootm 0x32000000
GTA01Bv4 # setenv sd_image_name uImage
GTA01Bv4 # saveenv

You can now easily boot a different kernel by changing the variable sd_image_name to the new name.

Step 4: Boot into the new system

Power off your device, insert the SD card and boot into the boot menu. You should have an entry called "Boot from SD" which does exactly that. :-)

Installing without removing your SD card

Being the lazy person that I am, at one point I tried copying an image over to the micro SD card while still in my phone. This didn't work so well, primarily due to bug 677.

Now that this bug has been resolved, the process becomes relatively simple:

  • Boot to your internal flash partition (not the SD card.) Make sure you're running a release that includes the fix to bug 677!
  • Plug in your USB and set up [USB Networking].
  • Clean off your currently installed microSD card and install the new image:
ssh root@192.168.0.202 "rm -rf /media/card/*"
cat openmoko-devel-image-fic-gta01-20070313022035.rootfs.tar | ssh root@192.168.0.202 tar -C /media/card -xv
scp uImage-fic-gta01-latest.bin root@192.168.0.202:/media/card/boot/uImage

Boot from SDHC

As SDHC is currently not supported in u-boot you can't use the Booting from SD guide. But there's a kind of workaround that is a good option to have at least your rootfs on the microSDHC:

First you can follow Step 1 to get an kernel-image with mmc- and ext2-support. But instead of copying the image to the rootfs you will have to flash it to the Neo's internal NAND-Flash (using Dfu-util). Now you can continue with Step 2 (like mentioned before you do not have to copy your uImage to the rootfs) and follow the instructions to Step 3. Instead of the setenv commands in Step 3 you have to enter the following:

GTA01Bv4 # setenv menu_5 Boot from SDHC: setenv  bootargs root=/dev/mmcblk0p1 console=tty0 loglevel=8 rootdelay=5 neo1973-nand:0x00040000(u-boot),0x00004000(u-boot_env),0x00200000(kernel),0x000a0000(splash)\; nand read.e 0x32000000 kernel\; bootm 0x32000000
GTA01Bv4 # saveenv

And that's it! Now you can use the newly created menu option "Boot from SDHC" to boot the internal kernel, using the root-filesystem on the microSDHC.

Autoboot from SDHC

Maybe you want to Boot automatically from SDHC: Set a new Bootmenu Entry for booting from NAND first

GTA01Bv4 # setenv menu_6 Boot from NAND: setenv bootargs ${bootargs_base} \${mtdparts}\; nand read.e 0x32000000 kernel\; bootm 0x32000000
GTA01Bv4 # saveenv

then Power-off, and enter the Bootmenu to test the new Entry.If you can boot from NAND, shutdown, enter Boot menu, connect to bootloader and set the (auto)bootcmd for boot from SDHC:

GTA01Bv4 # setenv bootcmd setenv bootargs root=/dev/mmcblk0p1 rootdelay=10 console=tty0 loglevel=8 neo1973-nand:0x00040000(u-boot),0x00004000(u-boot_env),0x00200000(kernel),0x000a0000(splash)\; nand read.e 0x32000000 kernel\; bootm 0x32000000 
GTA01Bv4 # saveenv

Now you boot from SDHC everytime you press the Power-Button or reboot and if you like to boot from NAND -just use the bootmenu.