2008年9月9日 星期二

Freerunner booting from SD

I want try Qtopia image to boot from SD first....

  1. The "ext2load" command is broken on u-boot binary earlier than "20080723", and my u-boot is of 080402, which requires u-boot updated.
    http://wiki.openmoko.org/wiki/Flashing_the_Neo_FreeRunner
    1. Download u-boot and dfu-util from http://downloads.openmoko.org/releases/Om2008.8-update/
    2. Diaconnect the USB cable from the PC to your FR
    3. Boot the FR from NOR Flash (AUX+POWER), connect USB from PC to FR, and execute the following on PC:
      dfu-util -a u-boot -R -D uboot.bin
    4. Reboot, Boot the FR from NAND flash (POWER+AUX).
  2. Download Qtopia Image, and uncompress it,
    http://www.qtopia.net/modules/mydownloads/index.php
    ->ROM flash images
    http://qtopia.net/downloads/neo/qtopia-4.3.2-gta02-flash.tgz
    http://qtopia.net/downloads/neo/qtopia-4.3.3-snapshot-09012242-gta02-flash.tgz

  3. Mounting the JFFS2 image on a loop back device (Block Memory MTD Emulation)
    http://wiki.openmoko.org/wiki/Userspace_root_image
    http://wiki.openmoko.org/wiki/Userspace_root_image#Mounting_the_JFFS2_image_on_a_loop_back_device_.28Block_Memory_MTD_Emulation.29


    rootfs=<rootfs.jffs2>
    mountpoint=jffsmountpoint;
    export loop=$(losetup -f);
    losetup $loop $rootfs;
    modprobe block2mtd block2mtd=$loop,131072;
    modprobe jffs2;
    modprobe mtdblock;
    mkdir $mountpoint -p;
    mount -t jffs2 -o ro /dev/mtdblock0 $mountpoint;
  4. fdisk, and format (mkfs.ext2) the SD partition, then copy the contents of jffs2 image to SD.
    http://wiki.openmoko.org/wiki/Booting_from_SD#Prepare_the_SD_card
  5. http://wiki.openmoko.org/wiki/Uboot#Bootloader_prompt
    Connect the USB cable from FR to PC, and execute the following command on PC:
    chown uucp.uucp /dev/ttyACM0;cu -l /dev/ttyACM0
    Then, you are connected to u-boot via cu, a u-boot terminal.
    the bootcmd is a variable that contain the default command to run while PWR pressed. Leaving it empty wouldn't let it go to NAND u-boot menu, but just hang forever, so choose one of the boot command in the menu. I choose the to boot from uSD,p1,ext, which is the scripts of menu_2 here. Setting bootcmd to \${menu_1} would hang too, because there is a title field in the command. So just choose one of the menu item, and copy the script part to bootcmd to be your default boot command. Execute the following in cu:
    setenv boot_menu_timeout 99999;

    setenv bootcmd setenv kpart ${part}\;setenv root /dev/mmcblk0p\${kpart}\;setenv rootfstype ext2\;setenv kfile uImage.bin\;setenv bootargs console=ttySAC2,115200 console=tty0 loglevel=8 regular_boot rootfstype=\${rootfstype} root=\${root} rootdelay=5 mtdparts=physmap-flash:-(nor)\\\;neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00800000(kernel),0x000a0000(splash),0x00040000(factory),0x0f6a0000(rootfs) ro\;mmcinit\; \${rootfstype}load mmc 1:\${kpart} 0x32000000 \${kfile}\; bootm 0x32000000\;;


    setenv menu_1 Boot from NAND: setenv bootargs \${bootargs_base} \${mtdparts}\; nand read.e 0x32000000 kernel 0x200000\; bootm 0x32000000;

    setenv part 1;setenv menu_2 Boot from microSD (p${part},ext2): setenv kpart ${part}\;setenv root /dev/mmcblk0p\${kpart}\;setenv rootfstype ext2\;setenv kfile uImage.bin\;setenv bootargs console=ttySAC2,115200 console=tty0 loglevel=8 regular_boot rootfstype=\${rootfstype} root=\${root} rootdelay=5 mtdparts=physmap-flash:-(nor)\\\;neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00800000(kernel),0x000a0000(splash),0x00040000(factory),0x0f6a0000(rootfs) ro\;mmcinit\; \${rootfstype}load mmc 1:\${kpart} 0x32000000 \${kfile}\; bootm 0x32000000\;;

    setenv part 2;setenv menu_3 Boot from microSD (p${part},ext2): setenv kpart ${part}\;setenv root /dev/mmcblk0p\${kpart}\;setenv rootfstype ext2\;setenv kfile uImage.bin\;setenv bootargs console=ttySAC2,115200 console=tty0 loglevel=8 regular_boot rootfstype=\${rootfstype} root=\${root} rootdelay=5 mtdparts=physmap-flash:-(nor)\\\;neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00800000(kernel),0x000a0000(splash),0x00040000(factory),0x0f6a0000(rootfs) ro\;mmcinit\; \${rootfstype}load mmc 1:\${kpart} 0x32000000 \${kfile}\; bootm 0x32000000\;;

    setenv part 3;setenv menu_4 Boot from microSD (p${part},ext2): setenv kpart ${part}\;setenv root /dev/mmcblk0p\${kpart}\;setenv rootfstype ext2\;setenv kfile uImage.bin\;setenv bootargs console=ttySAC2,115200 console=tty0 loglevel=8 regular_boot rootfstype=\${rootfstype} root=\${root} rootdelay=5 mtdparts=physmap-flash:-(nor)\\\;neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00800000(kernel),0x000a0000(splash),0x00040000(factory),0x0f6a0000(rootfs) ro\;mmcinit\; \${rootfstype}load mmc 1:\${kpart} 0x32000000 \${kfile}\; bootm 0x32000000\;;
    setenv part 4;setenv menu_5 Boot from microSD (p${part},ext2): setenv kpart ${part}\;setenv root /dev/mmcblk0p\${kpart}\;setenv rootfstype ext2\;setenv kfile uImage.bin\;setenv bootargs console=ttySAC2,115200 console=tty0 loglevel=8 regular_boot rootfstype=\${rootfstype} root=\${root} rootdelay=5 mtdparts=physmap-flash:-(nor)\\\;neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00800000(kernel),0x000a0000(splash),0x00040000(factory),0x0f6a0000(rootfs) ro\;mmcinit\; \${rootfstype}load mmc 1:\${kpart} 0x32000000 \${kfile}\; bootm 0x32000000\;;

    setenv menu_6 Set console to USB: setenv stdin usbtty\; setenv stdout usbtty\; setenv stderr serial\;printenv\;saveenv\;;
    setenv menu_7 Set console to serial: setenv stdin serial\; setenv stdout serial\; setenv stderr serial\;printenv\;saveenv\;;
    setenv menu_8 Reboot: reset\;;
    setenv menu_9 Power off: neo1973 power-off\;;
    setenv part;saveenv;neo1973 power-off;

  6. Reboot, boot from NAND flash (POWER+AUX), choose the "Boot from microSD - ext2" by AUX, then go by POWER

Commands to run a particular image in uSD directly in u-boot
kpart: uSD partition that contains kernel
kernel and rootfs is assumed to be in the same uSD partition, and kernel image is at /uImage.bin
setenv kpart 3;setenv root /dev/mmcblk0p${kpart};setenv rootfstype ext2;setenv kfile uImage.bin;setenv bootargs console=ttySAC2,115200 console=tty0 loglevel=8 regular_boot rootfstype=${rootfstype} root=${root} rootdelay=5 mtdparts=physmap-flash:-(nor)\;neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00800000(kernel),0x000a0000(splash),0x00040000(factory),0x0f6a0000(rootfs) ro;mmcinit; ${rootfstype}load mmc 1:${kpart} 0x32000000 ${kfile}; bootm 0x32000000;


If you still can't keyin any characters into console, nothing happen after "Connected".
root@test-laptop:~# chown uucp.uucp /dev/ttyACM0;cu -l /dev/ttyACM0
Connected.

(nothing no matter what you press)
It is maybe you set the console to serial somehow, set it to USB by the boot menu would fix this problem.





Error:
GTA02v6 # mmcinit
cmd 0x8, arg 0x1aa flags 0x75
Error after cmd: 0xfffffffc
Card Type: SD
Manufacturer: 0x1b, OEM "SM"
Product name: "SMI ", revision 1.0
Serial number: 91656424
Manufacturing date: 11/2007
MMC/SD size: 497MiB
GTA02v6 # ext2load mmc 0 0x32000000 uImage.bin
bad MBR sector signature 0x0000
** Bad partition 1 **
GTA02v6 #

ok, I didn't fdisk /dev/mmcblk0, just mkfs.ext2 /dev/mmcblk0...

I have done fdisk, mkfs.ext2, then this error:
GTA02v6 # mmcinit
cmd 0x8, arg 0x1aa flags 0x75
Error after cmd: 0xfffffffc
Card Type: SD
Manufacturer: 0x1b, OEM "SM"
Product name: "SMI ", revision 1.0
Serial number: 91656424
Manufacturing date: 11/2007
MMC/SD size: 497MiB

GTA02v6 # ext2load mmc 1 0x32000000 uImage.bin
data abort
pc : [<33fa2838>] lr : [<33fa282e>]
sp : 33ed8074 ip : 00000400 fp : 33ed80c0
r10: 33ed8070 r9 : 00000000 r8 : 33edbfdc
r7 : 00000001 r6 : 33f268b0 r5 : 067db00e r4 : 33ed85fc
r3 : 00000001 r2 : 00000004 r1 : 33ed8468 r0 : 00000001
Flags: nZCv IRQs on FIQs off Mode SVC_32
Resetting CPU ...

GTA02v6 # ext2load mmc 0 0x32000000 uImage.bin
data abort
pc : [<33fa2838>] lr : [<33fa282e>]
sp : 33ed8074 ip : 00000400 fp : 33ed80c0
r10: 33ed8070 r9 : 00000000 r8 : 33edbfdc
r7 : 00000001 r6 : 33f268b0 r5 : 067db00e r4 : 33ed85fa
r3 : 00000001 r2 : 00000004 r1 : 33ed8468 r0 : 00000001
Flags: nZCv IRQs on FIQs off Mode SVC_32
Resetting CPU ...

GTA02v6 # ext2load mmc 0:1 0x32000000 uImage.bin
data abort
pc : [<33fa2838>] lr : [<33fa282e>]
sp : 33ed8074 ip : 00000400 fp : 33ed80c0
r10: 33ed8070 r9 : 00000000 r8 : 33edbfdc
r7 : 00000001 r6 : 33f268d8 r5 : 067db00e r4 : 33ed85fc
r3 : 00000001 r2 : 00000004 r1 : 33ed8468 r0 : 00000001
Flags: nZCv IRQs on FIQs off Mode SVC_32
Resetting CPU ...

GTA02v6 # ext2load mmc 0:0 0x32000000 uImage.bin

** Unable to read "uImage.bin" from mmc 0:0 **

GTA02v6 # ext2load mmc 1:0 0x32000000 uImage.bin

** Unable to read "uImage.bin" from mmc 1:0 **
I think I'm bothered by bug 799, my u-boot version shows:
U-Boot 1.3.2-rc2-dirty-moko12 (Apr 2 2008 - 09:31:05)
http://wiki.openmoko.org/wiki/Booting_from_SD#Loading_the_Kernel
NOTE: The "ext2load" command is broken on u-boot binary earlier than "20080723", including the one shipped with the first batch of FreeRunners, are affected by bug #799. If you update your U-Boot and kernel packages you can use direct ext2 / 3 boot all in one partition.


test@test-laptop:~/Desktop$ dfu-util -l
dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Found Runtime: [0x1d50:0x5119] devnum=0, cfg=0, intf=2, alt=0, name="UNDEFINED"

root@test-laptop:~/Desktop# dfu-util -a u-boot -R -D gta02v5_and_up-u-boot.bin
dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=5, cfg=0, intf=0, alt=1, name="u-boot"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
bytes_per_hash=4330
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
root@test-laptop:~/Desktop#


080826 u-boot ext2ls result
GTA02v6 # ext2ls mmc 0
<DIR> 1024 .
<DIR> 1024 ..
<DIR> 12288 lost+found
<DIR> 2048 bin
<DIR> 1024 boot
<DIR> 2048 dev
<DIR> 2048 etc
<DIR> 1024 home
<DIR> 1024 lib
<DIR> 1024 media
<DIR> 1024 mnt
<DIR> 1024 opt
<DIR> 1024 proc
<DIR> 2048 sbin
<DIR> 1024 sys
<SYM> 7 tmp
<DIR> 1024 usr
<DIR> 1024 var
1963976 uImage.bin
GTA02v6 # ext2ls mmc 1
<DIR> 1024 .
<DIR> 1024 ..
<DIR> 12288 lost+found
<DIR> 2048 bin
<DIR> 1024 boot
<DIR> 2048 dev
<DIR> 2048 etc
<DIR> ..
<DIR> 1024 lib
<DIR> 1024 media
<DIR> 1024 mnt
<DIR> 1024 opt
<DIR> 1024 proc
<DIR> 2048 sbin
<DIR> 1024 sys
<SYM> 7 tmp
<DIR> 1024 usr
<DIR> 1024 var
1963976 uImage.bin
GTA02v6 # ext2ls mmc 0:0
GTA02v6 # ext2ls mmc 0:1
<DIR> 1024 .
<DIR> 1024 ..
<DIR> 12288 lost+found
<DIR> 2048 bin
<DIR> 1024 boot
<DIR> 2048 dev
<DIR> 2048 etc
<DIR> 1024 home
<DIR> 1024 lib
<DIR> 1024 media
<DIR> 1024 mnt
<DIR> 1024 opt
<DIR> 1024 proc
<DIR> 2048 sbin
<DIR> 1024 sys
<SYM> 7 tmp
<DIR> 1024 usr
<DIR> 1024 var
1963976 uImage.bin
GTA02v6 # ext2ls mmc 1:0
GTA02v6 # ext2ls mmc 1:1
<DIR> 1024 .
<DIR> 1024 ..
<DIR> 12288 lost+found
<DIR> 2048 bin
<DIR> 1024 boot
<DIR> 2048 dev
<DIR> 2048 etc
<DIR> 1024 home
<DIR> 1024 lib
<DIR> 2048 bin
<DIR>
<DIR> 1024 mnt
<DIR> 1024 opt
<DIR> 1024 proc
<DIR> 2048 sbin
<DIR> 1024 sys
<SYM> 7 tmp
<DIR> 1024 usr
<DIR> 1024 var
1963976 uImage.bin
GTA02v6 #



http://wiki.openmoko.org/wiki/Flashing_the_Neo_FreeRunner

沒有留言: