Latest u-boot.bin containing MUSB gadget mode code for U-Boot

All,

Anyone who cares to test usb gadget mode in u-boot, can try the gzipped image at:

http://groups.google.com/group/beagleboard/web/musb_gadget-u-boot.bin.gz

This image was built using the latest code on the omap3-dev-usb branch + the latest patches on the mailing list (that should get added to the branch soon). To read a little more about what this is doing, read: http://elinux.org/U-boot_musb_gadget_support - specifically the setting of the stdin, out, err.

-Atin

Hi,

I just try to test your u-boot.bin but seem to have miss something...
because my board is not booting any more.

Here what I have done

Old version at bootup:
U-Boot 1.3.3 (Jul 10 2008 - 16:33:09)

First switch beagleboard power, remove SD and insert into SD slot of
your PC. The SD partition are mounted:
cd ~/u-boot-omap3
cp u-boot.bin /media/boot/
ls -lh /media/boot/
total 3.4M
-rwx------ 1 kapare root 701K 2008-12-18 22:36 flash-uboot.bin
-rwx------ 1 kapare root 17K 2008-12-18 22:26 MLO
-rwx------ 1 kapare root 172K 2009-01-23 14:39 u-boot.bin
-rwx------ 1 kapare root 2.5M 2009-01-19 18:16 uImage
-rwx------ 1 kapare root 20K 2008-12-18 22:30 x-load.bin.ift

sudo umount /media/boot /media/rootfs

Second remove SD from PC and insert it into beagle board.

minicom

Plug beagle board power.

OMAP3 beagleboard.org # nand unlock
device 0 whole chip
nand_unlock: start: 00000000, length: 268435456!
NAND flash successfully unlocked
OMAP3 beagleboard.org # nand erase 80000 160000

NAND erase: device 0 offset 0x80000, size 0x160000
Erasing at 0x1c0000 -- 100% complete.
OK
OMAP3 beagleboard.org # nand write.i 80000000 80000 160000

NAND write: device 0 offset 0x80000, size 0x160000

Writing data at 0x1df800 -- 100% complete.
1441792 bytes written: OK
OMAP3 beagleboard.org #

Reboot

Texas Instruments X-Loader 1.41
Starting OS Bootloader...
......NOTHING HAPPEN!

""Reboot your board and keep the user button pressed while applying
power (see Known bugs). ""

Oups I was pressing user button and I remove the power cable :frowning:

So what should I do to fix that ?

Regards

kap

Hi Kapare,

This happen to me once, and was that for some configuration my board
was loading the code at 82000000 instead of 80000000 as the
instructions assume. Please try to do recovery with the MMC recovery
procedure documented here:

http://elinux.org/BeagleBoardRecovery

I have actually been loading this u-boot off the MMC rather than
writing it into NAND since I keep modifying the u-boot code. I have
only written MLO (x-load) to nand, and let u-boot load off the MMC.
This gets me around the times when I do something bad to the code and
the beagle doesn't boot anymore!

-Atin

Hi,

This is what I have achieved until now!

1- Nothing changed the board is stock trying to start the Bootloader.
2- I create a script that shows the steps that I have done, see
attachment update_sd.sh
3- MLO_restore I used the one from BeagleBoardRecovery - eLinux.org
4- I could try BeagleBoardRecovery - eLinux.org ?
But I will wait for your suggestions.

Regards

kap

OUTPUT FROM SERIAL:

Welcome to minicom 2.3

OPTIONS: I18n
Compiled on Oct 24 2008, 06:37:44.
Port /dev/ttyUSB0

                 Press CTRL-A Z for help on special
keys

40T

Texas Instruments X-Loader
1.41
Starting OS Bootloader...

Texas Instruments X-Loader 1.41
Starting OS Bootloader...
40T

Texas Instruments X-Loader 1.41
Starting OS Bootloader...

----------------------------------------> start update_sd.sh

#!/bin/sh -x

# Environment variables
SD_PATH="/dev/mmcblk0"
SD_P1_PATH="/dev/mmcblk0p1"
SD_P2_PATH="/dev/mmcblk0p2"

# SD validation.
SD_INSERT="SD insert test: "

if [ -e $SD_PATH ]
then
    echo "--> ${SD_INSERT} OK"
else
    echo "--> ${SD_INSERT} FAILED"
    echo "--> SD not inserted!"
    exit $?
fi

# Mount validation for p1.
MOUNT_P1="SD P1 mount test: "

if [ -n "`mount | grep /dev/mmcblk0p1`" ]
then
    echo "--> ${MOUNT_P1} FAILED"
    echo "--> sudo umount ${SD_P1_PATH}"
    sudo umount $SD_P1_PATH
else
    echo "--> ${MOUNT_P1} OK"
fi

# Mount validation for p1.
MOUNT_P2="SD P2 mount test: "

if [ -n "`mount | grep /dev/mmcblk0p2`" ]
then
    echo "--> ${MOUNT_P2} FAILED"
    echo "--> sudo umount ${SD_P2_PATH}"
    sudo umount $SD_P2_PATH
else
    echo "--> ${MOUNT_P2} OK"
fi

# Disk /dev/mmcblk0: 1977 MB, 1977614336 bytes
# 1977614336/255/63/512 = 240.431248055 = FLOOR = 240
# Create partition backup: sfdisk -H 255 -S 63 -C 240 --d /dev/mmcblk0

sd-beagleboard-partition.out

# Create partition
echo "--> Create SD partition: sfdisk -H 255 -S 63 -C 240 --force /dev/
mmcblk0 < sd-beagleboard-partition.out"
sfdisk -H 255 -S 63 -C 240 --force /dev/mmcblk0 < sd-beagleboard-
partition.out

# Format the partitions
echo "--> Format SD P1 into FAT32: sudo mkfs.msdos -F 32 /dev/
mmcblk0p1 -n boot"
sudo mkfs.msdos -F 32 /dev/mmcblk0p1 -n boot

echo "--> Format SD P2 into ext3: sudo mkfs.ext3 -L rootfs /dev/
mmcblk0p2"
sudo mkfs.ext3 -L rootfs /dev/mmcblk0p2

# Mount newly formated partition:
echo "--> Mount newly formated partition"
sudo mount /dev/mmcblk0p1 /media/boot
sudo mount /dev/mmcblk0p2 /media/rootfs

# IMPORTANT TO DO THIS BEFORE ANY OTHER FILES ARE COPIED:
# Copy the MLO file that you downloaded to the Beagle_Boot partition.
# The MLO file must be the first file copied to the partition after re-
formatting.
cp /home/kapare/beagleboard/sd/boot/MLO_restore /media/boot/MLO
cp /home/kapare/beagleboard/sd/boot/musb_gadget-u-boot.bin /media/boot/
u-boot.bin

----------------------------------------> end update_sd.sh

Hi Again,

I try multiple variation with those event just the MLO_restore only.

I didnt used my script doing step by step
http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat
http://elinux.org/BeagleBoardRecovery#USB_recovery

After Partitionning, formating, reinserting the SD, coping MLO_restore
+ flash-uboot.bin etc...
sudo cp /home/kapare/beagleboard/sd/boot/MLO_restore /media/boot/MLO
sudo cp /home/kapare/beagleboard/sd/boot/MLO_revb /media/boot/MLO
sudo cp /home/kapare/beagleboard/sd/boot/musb_gadget-u-boot.bin /media/
boot/u-boot.bin
sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin.Angstrom /media/
boot/u-boot.bin
sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin_autoflash /media/
boot/u-boot.bin
sudo cp /home/kapare/beagleboard/sd/boot/flash-uboot.bin /media/boot/u-
boot.bin

I see the ...40T... but no output about MMC like in the
http://elinux.org/BeagleBoardRecovery#MMC_recovery

Like this::::

...40T.........

Texas Instruments X-Loader 1.41
Starting on with MMC
Reading boot sector

150832 Bytes Read from MMC
Starting OS Bootloader from MMC...

Hi Again,

I encourage you to sign-up on the mailing list to avoid having all of
your messages moderated. You can sign-up and opt for no e-mail.

I try multiple variation with those event just the MLO_restore only.

I didnt used my script doing step by stephttp://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormathttp://elinux.org/BeagleBoardRecovery#USB_recovery

After Partitionning, formating, reinserting the SD, coping MLO_restore
+ flash-uboot.bin etc...
sudo cp /home/kapare/beagleboard/sd/boot/MLO_restore /media/boot/MLO
sudo cp /home/kapare/beagleboard/sd/boot/MLO_revb /media/boot/MLO

If you overwrite the MLO_restore, then it won't work. MLO must be the
first file copied after freshly formatting the SD card per the
instructions. You cannot alter it after you copy it or it won't
work. You'd need to start over again by formatting the card again.

sudo cp /home/kapare/beagleboard/sd/boot/musb_gadget-u-boot.bin /media/
boot/u-boot.bin
sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin.Angstrom /media/
boot/u-boot.bin
sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin_autoflash /media/
boot/u-boot.bin

I think you only want to copy the _autoflash version if you are trying
to recover your board.

sudo cp /home/kapare/beagleboard/sd/boot/flash-uboot.bin /media/boot/u-
boot.bin

I see the ...40T... but no output about MMC like in thehttp://elinux.org/BeagleBoardRecovery#MMC_recovery

Like this::::

...40T.........

Texas Instruments X-Loader 1.41
Starting on with MMC
Reading boot sector

150832 Bytes Read from MMC
Starting OS Bootloader from MMC...

If you aren't seeing something like the above, then the MLO setup
didn't work or you aren't holding the USER button when you apply
power.

-------
So you said that "You need to make sure your beagle boots off SD since
the version in NAND is written into the wrong spot for your config."
This mean that my beagleboard is not booting like

USB -> UART -> MMC -> NAND

but always

NAND -> USB -> UART -> MMC

Actually, the 40T tells you that UART boot was attempted, so you
aren't booting directly from NAND flash.

I think I'm missing something and it is very stupid! Or maybe that my
MLO_restore that I copy was not ok!?

From my other attempts I found that after Formatting I need to
"Unplug, and replug in your SD card, and it should now automount the
two partitions that you created. "

You should only do that after performing a 'sync' to make sure the
cache is flushed on your system.

Hi,

> Hi Again,

I encourage you to sign-up on the mailing list to avoid having all of
your messages moderated. You can sign-up and opt for no e-mail.

I will, it was just easier for me to do this by email.

> I try multiple variation with those event just the MLO_restore only.

> I didnt used my script doing step by stephttp://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormathttp://e…

> After Partitionning, formating, reinserting the SD, coping MLO_restore
> + flash-uboot.bin etc...
> sudo cp /home/kapare/beagleboard/sd/boot/MLO_restore /media/boot/MLO
> sudo cp /home/kapare/beagleboard/sd/boot/MLO_revb /media/boot/MLO

If you overwrite the MLO_restore, then it won't work. MLO must be the
first file copied after freshly formatting the SD card per the
instructions. You cannot alter it after you copy it or it won't
work. You'd need to start over again by formatting the card again.

I always copy MLO_restore first and did not overwrite it. I just cut
paste the command that I used to show what I have tryand only one MLO
each try.

> sudo cp /home/kapare/beagleboard/sd/boot/musb_gadget-u-boot.bin /media/
> boot/u-boot.bin
> sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin.Angstrom /media/
> boot/u-boot.bin
> sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin_autoflash /media/
> boot/u-boot.bin

I think you only want to copy the _autoflash version if you are trying
to recover your board.

> sudo cp /home/kapare/beagleboard/sd/boot/flash-uboot.bin /media/boot/u-> boot.bin

> I see the ...40T... but no output about MMC like in thehttp://elinux.org/BeagleBoardRecovery#MMC_recovery

> Like this::::

> ...40T.........

> Texas Instruments X-Loader 1.41
> Starting on with MMC
> Reading boot sector

> 150832 Bytes Read from MMC
> Starting OS Bootloader from MMC...

If you aren't seeing something like the above, then the MLO setup
didn't work or you aren't holding the USER button when you apply
power.

Ok The USER button was pressed and hold each time, so this is what I
am now thinking that my setup did not work. But the question is what I
did wrong?

> -------
> So you said that "You need to make sure your beagle boots off SD since
> the version in NAND is written into the wrong spot for your config."
> This mean that my beagleboard is not booting like

> USB -> UART -> MMC -> NAND

> but always

> NAND -> USB -> UART -> MMC

Actually, the 40T tells you that UART boot was attempted, so you
aren't booting directly from NAND flash.

> I think I'm missing something and it is very stupid! Or maybe that my
> MLO_restore that I copy was not ok!?

> From my other attempts I found that after Formatting I need to
> "Unplug, and replug in your SD card, and it should now automount the
> two partitions that you created. "

You should only do that after performing a 'sync' to make sure the
cache is flushed on your system.

So you mean that I should do a sync just before doing sync, umount
then unplug? to be sure that file systems buffer are flush. If I don't
call sync before calling umount can this be a cause of my problem?

I will go on the chat to continue that discussion....

Regards

kap

Finally I fixed the board and had the chance to test the Atin u-
boot.bin with usb :))

kapare@vostro:~/beagleboard/sd$ ls /dev/ttyAC*
/dev/ttyACM0

dmesg | tail
[35388.720987] cdc_acm: This device cannot do calls on its own. It is
no modem.
[35388.721957] cdc_acm 7-3:1.0: ttyACM0: USB ACM device

and start minicom /dev/ttyACM0

The problem was that last cylinder of first partition was set to 50
and not to 51, hey!

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]

-----------script used----------
#!/bin/sh

# Environment variables
SD_PATH="/dev/mmcblk0"
SD_P1_PATH="/dev/mmcblk0p1"
SD_P2_PATH="/dev/mmcblk0p2"

# SD validation.
SD_INSERT="SD insert test: "

if [ -e $SD_PATH ]
then
    echo "--> ${SD_INSERT} OK"
else
    echo "--> ${SD_INSERT} FAILED"
    echo "--> SD not inserted!"
    exit $?
fi

# Mount validation for p1.
MOUNT_P1="SD P1 mount test: "

if [ -n "`mount | grep /dev/mmcblk0p1`" ]
then
    echo "--> ${MOUNT_P1} FAILED"
    echo "--> sudo umount ${SD_P1_PATH}"
    sudo umount $SD_P1_PATH
else
    echo "--> ${MOUNT_P1} OK"
fi

# Mount validation for p1.
MOUNT_P2="SD P2 mount test: "

if [ -n "`mount | grep /dev/mmcblk0p2`" ]
then
    echo "--> ${MOUNT_P2} FAILED"
    echo "--> sudo umount ${SD_P2_PATH}"
    sudo umount $SD_P2_PATH
else
    echo "--> ${MOUNT_P2} OK"
fi

# Disk /dev/mmcblk0: 1977 MB, 1977614336 bytes
# 1977614336/255/63/512 = 240.431248055 = FLOOR = 240
# Create partition backup: sfdisk -H 255 -S 63 -C 240 --d /dev/mmcblk0

sd-beagleboard-partition.out

# Create partition
# echo "--> Create SD partition: sfdisk -H 255 -S 63 -C 240 --force /
dev/mmcblk0 < sd-beagleboard-partition.out"
# sfdisk -H 255 -S 63 -C 240 --force /dev/mmcblk0 < sd-beagleboard-
partition.out

fdiskCommands()
{
   echo d
   echo 1
   echo d
   echo 2
   echo n
   echo p
   echo 1
   echo
   echo 51
   echo t
   echo c
   echo a
   echo 1
   echo n
   echo p
   echo 2
   echo
   echo
   echo t
   echo 2
   echo 83
   echo w
}

echo "--> Create partitions on SD card."
fdiskCommands | fdisk -C 240 -H 255 -S 63 /dev/mmcblk0

# Format the partitions
echo "--> Format SD P1 into FAT32: sudo mkfs.msdos -F 32 /dev/
mmcblk0p1 -n boot"
sudo mkfs.msdos -F 32 /dev/mmcblk0p1 -n boot

echo "--> Format SD P2 into ext3: sudo mkfs.ext3 -L rootfs /dev/
mmcblk0p2"
sudo mkfs.ext3 -L rootfs /dev/mmcblk0p2

# Mount newly formated partition:
echo "--> Mount newly formated partition"
sudo mount /dev/mmcblk0p1 /mnt/boot
sudo mount /dev/mmcblk0p2 /mnt/rootfs

# IMPORTANT TO DO THIS BEFORE ANY OTHER FILES ARE COPIED:
# Copy the MLO file that you downloaded to the Beagle_Boot partition.
# The MLO file must be the first file copied to the partition after re-
formatting.
echo "--> Copy MLO to boot partition."
sudo cp /home/kapare/beagleboard/sd/boot/MLO_restore /mnt/boot/MLO

echo "--> Copy u-boot to boot partition."
# sudo cp /home/kapare/beagleboard/sd/boot/u-boot.bin_autoflash /mnt/
boot/u-boot.bin
sudo cp /home/kapare/beagleboard/sd/boot/musb_gadget-u-boot.bin /mnt/
boot/u-boot.bin

echo "--> umount partitions."
sync
sudo umount /dev/mmcblk0p1 /dev/mmcblk0p2