New IT forum
11 August 2022, 12:00:40 am *
Welcome, %1$s. Please login or register.

: PiHub now in stock.
 
Pages: [1]

Author Topic: Booting from external SD card, it works!  (Read 21523 times)

drasal

  • Newbie
  • *
  • Posts: 7
Booting from external SD card, it works!
« on: 19 April 2011, 09:17:12 am »

Interesting enough the Dreamplug comes from the factory (2011-03-01 version) without this functionality, U-Boot will not recognize an external SD card, however, their downloadable U-Boot (2011-03-28 version) DOES, go figure.

The update process is a little tricky since it uses a different kind of FLASH, but similar to the Guruplug.

First, the new bootloader is from their website:
http://code.google.com/p/dreamplug/downloads/list

Download the file "dream_burn_spi.tar.bz2"

This is the factory reflashing and testing utility I believe.
This also has the openocd program in it too to recover from a "bricked" Dreamplug through the JTAG interface, however, we are just interested in the U-Boot image right now.

Inside the archive, extract the following file and place it in a folder you can access from TFTP*
dream_burn_spi/testenv/sheevaplug/openocd.binaries/bin/u-boot-kwb

This should be the March 28th, 2011 release, however, it does not include EXT2/3 support, so you will still need to use a FAT partition to load the initial kernel, however, it is a start to having a fully self-contained operating system on a single external SD card.

Connect it up to your serial port and open up minicom (or other terminal emulation software).
Powerup the device and interrupt the boot sequence by pressing any key (have about 3 seconds).

Issue these commands (don't worry we are not saving them, they disapear on reboot).
setenv ipaddr 192.168.1.10 (ipaddress you want to set for the Dreamplug)
setenv serverip 192.168.1.1 (ipaddress of the workstation running TFTP server)

***now we are going to TFTP the new uboot into DRAM
tftp 0x6400000 u-boot.kwb

Make note of how much transfered (in hex) will need it later, of course you can overwrite all the flash but I prefer only writing the necessary parts, so just keep track of it.
I got 150544 (24c10 hex)

***the file should copy over
***issue the following command to erase the current bootloader
***if you powercycle between the erase and write commands your device will have no bootloader, aka bricked, complete the erase and write commands quickly.
sf probe 0
sf erase 0x0 0x100000
sf write 0x6400000 0x0 0x24c10

***reset the device, if all went well you will see it restart
reset

***below is what I had on my screen through the process from start to end
Code: [Select]
U-Boot 2011.06-02334-g8f495d9-dirty (Mar 28 2011 - 05:21:06)
Marvell-DreamPlug

SoC:   Kirkwood 88F6281_A0
DRAM:  512 MiB
SF: Detected MX25L1606 with page size 256, total 1 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0, egiga1
88E1121 Initialized on egiga0
88E1121 Initialized on egiga1
Hit any key to stop autoboot:  0
Marvell>> setenv ipaddr 192.168.1.19
Marvell>> setenv serverip 192.168.1.11
Marvell>> tftp 0x6400000 u-boot.kwb
Using egiga0 device
TFTP from server 192.168.1.11; our IP address is 192.168.1.19
Filename 'u-boot.kwb'.
Load address: 0x6400000
Loading: ###########
done
Bytes transferred = 150544 (24c10 hex)
Marvell>> sf probe 0
SF: Detected MX25L1606 with page size 256, total 1 MiB
1024 KiB MX25L1606 at 0:0 is now current device
Marvell>> sf erase 0x0 0x100000
Marvell>> sf write 0x6400000 0x0 0x24c10
Marvell>> reset
resetting ...


U-Boot 2011.06-02334-g8f495d9-dirty (Mar 28 2011 - 05:21:06)
Marvell-DreamPlug

SoC:   Kirkwood 88F6281_A0
DRAM:  512 MiB
SF: Detected MX25L1606 with page size 256, total 1 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0, egiga1
88E1121 Initialized on egiga0
88E1121 Initialized on egiga1
Hit any key to stop autoboot:  0
Marvell>>


The help and error messages are not very useful in this version of U-Boot.
Now, to get your external SD card booting, you will need to make some changes to the enviornment settings.  Your SD card will need to have a FAT partition since the bootloader (U-Boot) can't read EXT2/3 (yet!).  The first partition on the SD card needs to hold the kernel (fat16, I think fat32 works too).  The partition only needs to be about 5MB in size, just enough for the kernel.  If you want to store multiple kernels, then you can make it bigger.  The next partition is the root filesystem.  This can be EXT2/3 since after the kernel boots it will be able to mount it.

If you want to just see if the kernel CAN load without actually booting it, insert your SD card and issue the command "usb start" at the "Marvell>>" prompt.  It should tell you what it detects.  The commands "usb tree" and "usb info" may also help.  I don't know how devices will switch around (sda, sdb, sdc, etc) when a USB stick is also plugged in.

I suggest backing up what you have, use printenv to print them out.
This is what my printout looked like:

Code: [Select]
Marvell>> printenv
bootcmd=setenv ethact egiga0; ${x_bootcmd_ethernet}; setenv ethact egiga1; ${x;
bootdelay=3
baudrate=115200
x_bootcmd_ethernet=ping 192.168.2.1
x_bootcmd_usb=usb start
x_bootcmd_kernel=fatload usb 0 0x6400000 uImage
x_bootargs=console=ttyS0,115200
x_bootargs_root=root=/dev/sda2 rootdelay=10
stdin=serial
stdout=serial
stderr=serial
ethaddr=F0:AD:4E:00:73:AC
ethact=egiga0
eth1addr=F0:AD:4E:00:73:AD

Environment size: 524/4092 bytes
Marvell>>

You will need to issue the following commands:
editenv x_bootcmd_kernel
***enter this text when it prompts
fatload usb 1 0x6400000 uImage

editenv x_bootargs_root
***enter this text when it prompts
root=/dev/sdb2 rootdelay=10

***set your network interface machine (MAC) addresses, they are erased when you load a new U-Boot
***they are found on the label on the bottom of the Dreamplug, the last byte was changed to xx incase someone just does a copy/paste, and mine is not duplicated by mistake.
setenv ethaddr=F0:AD:4E:00:73:xx
setenv eth1addr=F0:AD:4E:00:73:xx

***save the enviornment variables
saveenv

***issue the reset
reset

I don't know why the USB device does not show up in the tree, however, you can still use "ffatload usb 1 0x6400000 uImage" and it will read off the external SD card.
Here is the printout from some commands for reference:
Code: [Select]
Marvell>> usb start
(Re)start USB...
USB:   Register 10011 NbrPorts 1
USB EHCI 1.00
scanning bus for devices... 4 USB Device(s) found
       scanning bus for storage devices... 2 Storage Device(s) found
Marvell>> usb tree

Device Tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 100mA)
    |   USB 2.0 Hub
    |
    +-3  Mass Storage (480 Mb/s, 500mA)
    |     USB Storage 000000009910
    |  
    +-4  Audio (12 Mb/s, 500mA)
          C-Media USB Headphone Set  
      
Marvell>> usb info
1: Hub,  USB Revision 2.0
 - u-boot EHCI Host Controller
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

2: Hub,  USB Revision 2.0
 -  USB 2.0 Hub
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x1a40  Product 0x0101 Version 1.17
   Configuration: 1
   - Interfaces: 1 Self Powered Remote Wakeup 100mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 1 Interval 12ms

3: Mass Storage,  USB Revision 2.0
 -  USB Storage 000000009910
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x05e3  Product 0x0726 Version 153.16
   Configuration: 1
   - Interfaces: 1 Bus Powered 500mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 2
     - Class Mass Storage, Transp. SCSI, Bulk only
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512

4: Audio,  USB Revision 1.10
 -  C-Media USB Headphone Set  
 - Class: (from Interface) Audio
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0d8c  Product 0x000c Version 1.0
   Configuration: 1
   - Interfaces: 4 Bus Powered Remote Wakeup 500mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 0
     - Class Audio
     Interface: 1
     - Alternate Setting 0, Endpoints: 0
     - Class Audio
     - Endpoint 1 Out Isochronous MaxPacket 200
     Interface: 2
     - Alternate Setting 0, Endpoints: 0
     - Class Audio
     - Endpoint 2 In Isochronous MaxPacket 100
     Interface: 3
     - Alternate Setting 0, Endpoints: 1
     - Class Human Interface, Subclass: None
     - Endpoint 3 In Interrupt MaxPacket 4 Interval 32ms

Marvell>>

Hopefully this helps some people out, I have been doing a lot of work lately trying to figure out how these new Dreamplugs work, and have also figured out how to recover them if they "brick."  Also, to note, the original - original bootloader that is on them now is not available for download (as far as I can tell) but I have archived it off this Dreamplug if there is a need for it.  It is tricky to backup since the NOR FLASH can't be accessed through the linux operating system, it has to be dumped using the U-Boot bootloader.
« Last Edit: 20 April 2011, 07:56:31 pm by drasal »
Logged

kerber

  • Newbie
  • *
  • Posts: 3
Re: Booting from external SD card, it works!
« Reply #1 on: 29 April 2011, 03:28:35 pm »

Well, I flashed uboot successfully, but now, I am dealing with this error...

Code: [Select]
Marvell>> usb start
(Re)start USB...
USB:   Register 10011 NbrPorts 1
USB EHCI 1.00
scanning bus for devices... 4 USB Device(s) found
       scanning bus for storage devices... Device NOT ready
   Request Sense returned 03 30 00
2 Storage Device(s) found
Marvell>> fatls usb 1
** Can't read from device 1 **

** Unable to use usb 1:1 for fatls **
Marvell>>

It randomly won't recognize the external and internal USB. Any thoughts? Any chance you could post the original uboot you pulled off?
Logged

kerber

  • Newbie
  • *
  • Posts: 3
Re: Booting from external SD card, it works!
« Reply #2 on: 29 April 2011, 03:57:25 pm »

After a few restarts and reseating the SD card, I was able to boot from the external SD card. Here is what I was greated by in the boot process...

Code: [Select]
U-Boot 2011.06-02334-g8f495d9-dirty (Mar 28 2011 - 05:21:06)
Marvell-DreamPlug

SoC:   Kirkwood 88F6281_A0
DRAM:  512 MiB
SF: Detected MX25L1606 with page size 256, total 1 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0, egiga1
88E1121 Initialized on egiga0
88E1121 Initialized on egiga1
Hit any key to stop autoboot:  0
(Re)start USB...
USB:   Register 10011 NbrPorts 1
USB EHCI 1.00
scanning bus for devices... 4 USB Device(s) found
       scanning bus for storage devices... Device NOT ready
   Request Sense returned 03 30 00
2 Storage Device(s) found
reading uImage

2712400 bytes read
## Booting kernel from Legacy Image at 06400000 ...
   Image Name:   Linux-2.6.33.6
   Created:      2011-02-08   8:18:48 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2712336 Bytes = 2.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

.
.
<uninteresting bit>
.
.

Waiting 10sec before mounting root device...
usb 1-1: new high speed USB device using orion-ehci and address 2
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
usb 1-1.1: new high speed USB device using orion-ehci and address 3
scsi0 : usb-storage 1-1.1:1.0
usb 1-1.4: new full speed USB device using orion-ehci and address 4
input: C-Media USB Headphone Set   as /devices/platform/orion-ehci.0/usb1/1-1/1-1.4/1-1.4:1.3/input/input0
generic-usb 0003:0D8C:000C.0001: input: USB HID v1.00 Device [C-Media USB Headphone Set  ] on usb-orion-ehci.0-1.4/input3
scsi 0:0:0:0: Direct-Access     Generic  STORAGE DEVICE   9910 PQ: 0 ANSI: 0
sd 0:0:0:0: Attached scsi generic sg0 type 0
scsi 0:0:0:1: Direct-Access     Generic  STORAGE DEVICE   9910 PQ: 0 ANSI: 0
sd 0:0:0:1: Attached scsi generic sg1 type 0
sd 0:0:0:1: [sdb] 3862528 512-byte logical blocks: (1.97 GB/1.84 GiB)
sd 0:0:0:1: [sdb] Write Protect is off
sd 0:0:0:1: [sdb] Assuming drive cache: write through
sd 0:0:0:1: [sdb] Assuming drive cache: write through
 sdb: sdb1 sdb2
sd 0:0:0:1: [sdb] Assuming drive cache: write through
sd 0:0:0:1: [sdb] Attached SCSI removable disk
sd 0:0:0:0: [sda] Unit Not Ready
sd 0:0:0:0: [sda] Sense Key : 0x3 [current]
sd 0:0:0:0: [sda] ASC=0x30 ASCQ=0x0
sd 0:0:0:0: [sda] READ CAPACITY failed
sd 0:0:0:0: [sda] Result: hostbyte=0x00 driverbyte=0x08
sd 0:0:0:0: [sda] Sense Key : 0x3 [current]
sd 0:0:0:0: [sda] ASC=0x30 ASCQ=0x0
sd 0:0:0:0: [sda] Test WP failed, assume Write Enabled
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Unit Not Ready
sd 0:0:0:0: [sda] Sense Key : 0x3 [current]
sd 0:0:0:0: [sda] ASC=0x30 ASCQ=0x0
sd 0:0:0:0: [sda] READ CAPACITY failed
sd 0:0:0:0: [sda] Result: hostbyte=0x00 driverbyte=0x08
sd 0:0:0:0: [sda] Sense Key : 0x3 [current]
sd 0:0:0:0: [sda] ASC=0x30 ASCQ=0x0
sd 0:0:0:0: [sda] Test WP failed, assume Write Enabled
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Attached SCSI removable disk

At this point, there is no card in the internal SD slot (sda). If I let it sit, it will get to the login prompt, but the console continues to print these sda messages.
Logged

drasal

  • Newbie
  • *
  • Posts: 7
Re: Booting from external SD card, it works!
« Reply #3 on: 02 May 2011, 06:50:32 pm »

Sorry for the delay, I was out of town for the weekend.
Here is the original original uboot that I pulled from my dreamplug, that does not seem to support external SD card booting.
The later dated file supports external SD card booting.

Also, the one without the KWB extension can't be used for booting from the FLASH, it lacks some important things that the .KWB file has.  The KWB file is safe to load into flash.

I would also make sure you are setup with a JTAG just incase.
If you need to reload the device and the U-Boot won't startup, you will need the openOCD system, which I am going to attach my working version, it is standalone and the latest version.  The runme.sh should be setup to reload the dreamplug (well boot it).  After it is booted you will need to manually copy the new bootloader to the flash.

Extract what I have here, and I hope you are using an Linux enviornment, take a look at the share/openocd/scripts/board/dreamplug.cfg file, this is where it loads the files from through the JTAG.

So, after you have those two files transfered to your dreamplug, make sure your terminal program (minicom or something) is open and interrupt the boot process.

Issue the following commands to copy the new U-Boot into FLASH.
sf probe 0
sf erase 0x0 0x100000
sf write 0x6400000 0x0 0x24c10

The last command "write", you have to make sure it writes at LEAST the amount that you transfered in (from your JTAG openocd output).  If you want to be safe safe and make sure you copy it ALL in, then do the following, however, you will write some "garbage" from the uninitialized DRAM into the FLASH, but it won't hurt anything because the processor will never look at it.

sf probe 0
sf erase 0x0 0x100000
sf write 0x6400000 0x0 0x100000

There is a way to erase the DRAM first if you want to initialize it first.
This command is MM
mm.b 0x6400000 0xff 0x200000
(write the pattern 0xff starting at 0x6400000 and write 0x200000 bytes)
One the DRAM is written, it will stay that way (even through resets) as long as the device does not lose power, since DRAM does not hold contents through power cycles.  That way you can initialize your RAM first, then use the JTAG to upload your new U-Boot if you wish.  You should be able to enter JTAG mode if you are sitting in a U-Boot prompt on the DreamPlug "Marvell>>" prompt.

The openocd that I attached was compiled from source for an x86 based system, should work just fine on x64 though.
If it doesn't run properly because of lib errors or something, I will have to look at how I built it.

Here is a U-Boot command summary that I found, however this U-Boot may or may not support all these commands:
http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBcQFjAA&url=http%3A%2F%2Fcache.freescale.com%2Ffiles%2F32bit%2Fdoc%2Fquick_ref_guide%2FLITE5200BUBPG%2FLITE5200BUBPG.pdf&ei=a_m-TaHHIcjiiALl9bgq&usg=AFQjCNHFDSF9keKuXWhcjPDKZE70E4nfZw

EDIT: I can't seem to attach a file bigger than 192kb... that is too small, could we get that adjusted??  The file I want to attach is 4.0mb, so I will have to host it outside this server...  If someone would like to upload it into this thread that doesn't suffer from this size restriction, please be my guest.

http://eecs.wsu.edu/~adrassal/openocd-0.4.0.tar.bz2
« Last Edit: 02 May 2011, 08:28:30 pm by drasal »
Logged

NewIT_Marcus

  • Hero Member
  • *****
  • Posts: 960
Re: Booting from external SD card, it works!
« Reply #4 on: 02 May 2011, 09:52:45 pm »

Here is the original original uboot that I pulled from my dreamplug, that does not seem to support external SD card booting.
The later dated file supports external SD card booting.

It's important to note that (if I understand correctly) you did not purchase your Dreamplug from New IT. As far as I know all of our first batch Dreamplugs are supplied with a U-Boot that shows:

Code: [Select]
U-Boot 2011.06-02334-g8f495d9-dirty (Mar 28 2011 - 05:21:06)

On the issue of x86 / AMD64, problems with openocd have been reported on the plug computer forum. There is an openocd binary in the [Sheevaplug] installer - possibly even different versions in the original installer compared to the newer graphical version (ESIA).
Logged

drasal

  • Newbie
  • *
  • Posts: 7
Re: Booting from external SD card, it works!
« Reply #5 on: 02 May 2011, 11:04:53 pm »

Here is the original original uboot that I pulled from my dreamplug, that does not seem to support external SD card booting.
The later dated file supports external SD card booting.

It's important to note that (if I understand correctly) you did not purchase your Dreamplug from New IT. As far as I know all of our first batch Dreamplugs are supplied with a U-Boot that shows:

Code: [Select]
U-Boot 2011.06-02334-g8f495d9-dirty (Mar 28 2011 - 05:21:06)

On the issue of x86 / AMD64, problems with openocd have been reported on the plug computer forum. There is an openocd binary in the [Sheevaplug] installer - possibly even different versions in the original installer compared to the newer graphical version (ESIA).

This is correct, the U-Boot that was on the DreamPlug that I have was initially an earlier version than the later releases.
Apparently some things were fixed in the later releases including the external SD card booting.

Actually the openocd that is posted above (by me) above has a depencency of needing libftdi installed at the moment, I am trying to resolve that and make it stand alone.

However, in the archive, the U-Boot that is linked above (the later version) is the same thing that Global Scale posted on their download page, it was just extracted from the deep folder structure it was in.  I think it is the same version that is shipping now.
Logged

kerber

  • Newbie
  • *
  • Posts: 3
Re: Booting from external SD card, it works!
« Reply #6 on: 03 May 2011, 03:14:29 pm »

I am able to access my uboot via jtag. Which file in your openocd archive is the original uboot image?

Also, any ideas on the sda garbage?
Logged

drasal

  • Newbie
  • *
  • Posts: 7
Re: Booting from external SD card, it works!
« Reply #7 on: 03 May 2011, 07:14:17 pm »

I am able to access my uboot via jtag. Which file in your openocd archive is the original uboot image?

Also, any ideas on the sda garbage?

The original that I got with mine is the "u-boot_dreamplug_oem_2011-03-01.kwb" dated file.
The KWB file is what would be loaded into the SPI NOR.

The later shipping versions that NewIT got were loaded with the "u-boot_dreamplug_oem_2011-03-28.kwb" version.
If you want to booot U-Boot from the JTAG, use the "u-boot_dreamplug_oem_2011-03-28" (without the extension) file.

I have not had time to get that uploaded openocd working, I was trying to build in the libftd2xx driver statically in but just have not gotten it working yet.  The openocd, as you have found, from the GlobalScale downloads section "dream_burn_spi.tar.bz2" works fine though.

The .HEX file is what I extracted out of my dreamplug and that is how the 2011-03-01 U-Boot was obtained.
I used the "md" command in U-Boot (after the sf read command) to literally dump the SPI NOR flash to the terminal screen, then copy/paste.
I wrote a perl script that coverted that HEX file into the KWB file so it could be loaded back into the DreamPlug.
The "u-bootenv_dreamplug_oem_2011-03-01" is something that slipped in by mistake I think, it is the internal NAND configuration of the GuruPlug that I was working on before.  It is just a text file.

However, I don't know exactly what is up with the musical boot device numbers, I don't have a DreamPlug at the moment because it had to go back for RMA, it had some bad RAM in it and would keep hanging.  When I get it back I will have a chance to play with it some more to see what is going on with that.

The firmware that came loaded from NewIT though should support the external SD card boot without issues.  I would really like to know how to compile a U-Boot for the DreamPlug but it is still a little new and has not gotten a lot of support from the U-Boot devs yet.
Logged
Pages: [1]
 
 

Powered by MySQL Powered by PHP SMF 2.0.10 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!