New IT forum Follow us on Twitter
17 May 2012, 04:32:46 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: EFIKA MX reviewed in Linux User & Developer issue 104
 
   Home   SHOP Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Making a duplicate SD Boot Card  (Read 6615 times)
smarkus
Newbie
*
Posts: 3


« on: 09 December 2009, 04:16:41 pm »

Hi - I am very pleased with my Sheevaplug, happily running Squeezeserver for a couple of weeks now with no problems. One thing I would like to do though, is to make a backup of the SD card that the device came with. The Sheevaplug is the variant that boots from the SD card, and I'm not sure how to do this - would I have to do this with the Sheevaplug turned off i.e. read the card using another device. I'm also not sure how to make sure I capture all the boot information.

Any help greatly appreciated!

Thanks,
Steve.
Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #1 on: 09 December 2009, 07:55:54 pm »

In summary:

(1). Boot from the internal NAND drive.
(2). Insert the SD card and a USB storage device (hdd or memory stick)
(3). Copy data from the SD card to the USB storage.
(4). Revert environment variables to those required for SD booting.

Probably (1) and (3) require some expansion.

(1). (Temporarily) revert the U-Boot environment variables to the original values. See our thread describing the SD card configuration.

(3). Blunt instrument: use
Code:
dd if=/dev/mmcblk0 of=/mnt/usb-drive/my-backup-image.img

Other alternatives are available for step (3), but that's how we do it.

I'll be posting some details of multi-booting within the next 24 hours. This would probably be your ideal solution, and it requires slightly different environment variable values.
Logged
smarkus
Newbie
*
Posts: 3


« Reply #2 on: 10 December 2009, 03:34:26 pm »

Hi Marcus, and thanks for your reply.

I'll wait until I see what's involved in the dual-boot config I think - that as you say sounds like the ideal solution, although I will still make a backup of the SD card.

Thanks again for your help.
Steve.
Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #3 on: 22 December 2009, 07:54:16 pm »

Hi Marcus, and thanks for your reply.

I'll wait until I see what's involved in the dual-boot config I think - that as you say sounds like the ideal solution, although I will still make a backup of the SD card.

Thanks again for your help.
Steve.

See our booting board for the environment variables that are used for each configuration. You could change your environment variables to be similar to our multi-boot solution. Not identical, because you'd need to combine the original nand boot settings with the alternate SD (mmc) settings (because the NAND configuration on our multi-boot systems is UBIFS, whereas yours is not IIRC). Presumably you would need to use your current bootargs and bootcmd settings for bootargs_root_nand and bootargs_nand in place of:

Code:
bootargs_root_nand=ubi.mtd=1 root=ubi0:rootfs rootfstype=ubifs
bootcmd_nand=setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root_nand); nand read.e 0x00800000 0x00100000 0x00400000; bootm 0x00800000


Logged
Cestrian
Newbie
*
Posts: 12


« Reply #4 on: 30 December 2009, 04:22:00 pm »

Hi Marcus,

This is my first post on here so please bear with me!  Embarrassed I'm a newcomer to the Sheeva plug and still in the early stages of digesting all that is presented here on this forum and on the others.

First of all I think this is a GREAT product! Thanks for making this available to us!  Cool

I am moving along well with my project for the Plug but I _do_ want to be able to make a bootable backup copy of the SD card that NewIT supplied with the OS on. My plug was bought around 4th Nov 2009 so it does not have the dual-boot configuration. I bought the Ubuntu SD card variant.

I've read the topics on the various boot parameters to get the plug to boot to it's NAND based Linux so that I can do the copy over of the SD card's file system to USB stick and back but I can't seem to find the right set of parameters to get the plug to boot from the internal memory. I get as far as it telling me it's about to boot the kernel but then it stops.

My question then really is whether I should expect my variant of the plug to have Linux loaded onto the NAND flash already? How can I tell? It seems to be telling me that kernel 2.6.22.18 is in there...

(I used these parameters:

setenv bootargs_root ubi.mtd=1 root=ubi0:rootfs rootfstype=ubifs
setenv mtdpartitions mtdparts=orion_nand:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
setenv console console=ttyS0,115200 mtdparts=nand_mtd:0xc0000@0(uboot)ro,0x1ff00000@0x100000(root)
setenv bootdelay 3
setenv bootcmd setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root); nand read.e 0x00800000 0x00100000 0x00400000; bootm 0x00800000
)

NAND read: device 0 offset 0x100000, size 0x400000

Reading data from 0x4ff800 -- 100% complete.
 4194304 bytes read: OK
## Booting image at 00800000 ...
   Image Name:   Linux-2.6.22.18
   Created:      2009-03-19   9:18:16 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2106696 Bytes =  2 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

(then it stops there)

Is there a simple method for me to swap out the enviroment parameters quickly (temporarily) so that I can boot it to do the SD card backup? You mention the dual-boot settings, I assume from what you said that these only work for the 3.4.23 version of the u-Boot? Or can I make use of this feature with the 3.4.19 that I have loaded?

I'm sorry if I'm just going over things that are already answered on the forum but there comes a time after following links around and around when your eyes go blurry that perhaps asking a question seems like the right thing to do!  Wink  Grin

Many thanks!
Tony



Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #5 on: 31 December 2009, 10:51:26 am »

These are the parameters that define your boot process:

http://www.newit.co.uk/forum/index.php/topic,136.0.html

Code:
bootargs_console=console=ttyS0,115200
bootargs_root=root=/dev/mmcblk0p2 rootdelay=5
bootcmd=setenv bootargs $(bootargs_console) $(bootargs_root); mmcinit; ext2load mmc 0:1 0x800000 /uImage; bootm 0x00800000

You should be able to use our multi-boot settings, except changing bootargs_nand and bootcmd_nand to those values required by your system:

http://www.newit.co.uk/forum/index.php/topic,194.0.html

Code:
bootargs_nand=console=ttyS0,115200 mtdparts=nand_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=10.4.50.4:10.4.50.5:10.4.50.5:255.255.255.0:DB88FXX81:eth0:none
bootcmd_nand=nand read.e 0x800000 0x100000 0x400000; bootm 0x800000

You'll also need to set mainlineLinux=no for NAND booting, maybe wipe arcNumber too.

I don't think your U-Boot version is an issue; 3.4.19 is sufficient for SD booting IIRC. If it has the mmcinit command that would confirm it.
Logged
Cestrian
Newbie
*
Posts: 12


« Reply #6 on: 31 December 2009, 05:54:34 pm »

Hi Marcus,

Thanks for your quick reply! I'm still struggling though. Is it usual for the boot process to get to the point where it's loaded the kernel and then about to boot the kernel and then stop for this to mean that there's something wrong with the boot parameters?

I've been just using setenv to change the key parameters and then when I enter the line

"setenv bootcmd setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root); nand read.e 0x00800000 0x00100000 0x00400000; bootm 0x00800000"

it flies off and reads the NAND and attempts to boot it.

Am I doing this incorrectly? Should I be also using saveenv? (I didn't want to do this in case I got into a state where I couldn't boot at all)

Failing getting this working, is there another way to duplicate the SD card's contents in such a manner that it will be bootable and contain all the file system? I tried AllImage on a Windows PC but the resulting card boots but I get a kernel panic:

Waiting 5sec before mounting root device...
VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00            1024 mtdblock0 (driver?)
1f01            4096 mtdblock1 (driver?)
1f02          519168 mtdblock2 (driver?)
b300        15859712 mmcblk0 driver: mmcblk
  b301        15855616 mmcblk0p1
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,2)
[<c00309c0>] (unwind_backtrace+0x0/0xe0) from [<c003db50>] (panic+0x50/0x120)
[<c003db50>] (panic+0x50/0x120) from [<c0008ec0>] (mount_block_root+0x1d4/0x214)
[<c0008ec0>] (mount_block_root+0x1d4/0x214) from [<c0009168>] (prepare_namespace+0x16c/0x1c4)
[<c0009168>] (prepare_namespace+0x16c/0x1c4) from [<c0008734>] (kernel_init+0xc0/0xec)
[<c0008734>] (kernel_init+0xc0/0xec) from [<c0040b3c>] (do_exit+0x0/0x6ac)

(This was a 16Gb card rather than the 4Gb one supplied if that has a bearing?)

Any help gratefully received!
Thanks,
Tony

Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #7 on: 02 January 2010, 12:25:36 am »

Hi Marcus,

Thanks for your quick reply! I'm still struggling though. Is it usual for the boot process to get to the point where it's loaded the kernel and then about to boot the kernel and then stop for this to mean that there's something wrong with the boot parameters?

Usually, that's exactly the reason.

I've been just using setenv to change the key parameters and then when I enter the line

"setenv bootcmd setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root); nand read.e 0x00800000 0x00100000 0x00400000; bootm 0x00800000"

it flies off and reads the NAND and attempts to boot it.

Am I doing this incorrectly? Should I be also using saveenv? (I didn't want to do this in case I got into a state where I couldn't boot at all)

Ultimately, yes, you'll need to use saveenv. If you test the changes, and they work, you should repeat the settings, and finish with saveenv.

Your setenv command isn't right. The semicolon separates commands, therefore you are executing a setenv followed by a nand read. That's why your plug is booting (or trying to).

Try:

setenv 'bootcmd setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_root); nand read.e 0x00800000 0x00100000 0x00400000; bootm 0x00800000'


Failing getting this working, is there another way to duplicate the SD card's contents in such a manner that it will be bootable and contain all the file system? I tried AllImage on a Windows PC but the resulting card boots but I get a kernel panic:

Waiting 5sec before mounting root device...
VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00            1024 mtdblock0 (driver?)
1f01            4096 mtdblock1 (driver?)
1f02          519168 mtdblock2 (driver?)
b300        15859712 mmcblk0 driver: mmcblk
  b301        15855616 mmcblk0p1
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,2)
[<c00309c0>] (unwind_backtrace+0x0/0xe0) from [<c003db50>] (panic+0x50/0x120)
[<c003db50>] (panic+0x50/0x120) from [<c0008ec0>] (mount_block_root+0x1d4/0x214)
[<c0008ec0>] (mount_block_root+0x1d4/0x214) from [<c0009168>] (prepare_namespace+0x16c/0x1c4)
[<c0009168>] (prepare_namespace+0x16c/0x1c4) from [<c0008734>] (kernel_init+0xc0/0xec)
[<c0008734>] (kernel_init+0xc0/0xec) from [<c0040b3c>] (do_exit+0x0/0x6ac)

(This was a 16Gb card rather than the 4Gb one supplied if that has a bearing?)

Any help gratefully received!
Thanks,
Tony

cp -ax is used and recommended elsewhere.

We never managed to get a Windows utility to copy images correctly, possibly due to the readers we have, possibly due to the software.
Logged
Cestrian
Newbie
*
Posts: 12


« Reply #8 on: 03 January 2010, 10:50:43 am »

Hi Marcus,

Lots to learn!  Huh

Sorry for being a pain but I'm still struggling to get the plug to boot to the NAND based OS. I tried the single quotes as you suggested and sure enough that allowed me to set all the env variables and then use the "boot" command but the result was the same, booting kernel, unzip and then nothing so I'll continue to look in close detail at my env variables when I get a chance.

Yes, the Windows program that I was attempting to use to copy the SD card (AllImage) only recognised and copied the first partition. (the boot) I plugged both cards (the one you supplied, plus the one I'd attempted to copy to) into a Suse 11 machine and _it_ sees two partitions on the real SD card and only the boot on the "backup". I attempted to dd from one to the other but for some reason it failed part way through (I/O error on writing to the backup card). Not sure why that was. I think I'll try copying to an image and then back again using the same USB card read/writer.

Thanks for your help.

Cheers,
Tony
Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #9 on: 03 January 2010, 10:52:43 pm »

Tony -

The simplest solution is for you to manually change the environment variables back to those of the factory settings:

http://www.newit.co.uk/forum/index.php/topic,134.0.html

And then when you are done with the backing up, manually change to the SD card settings:

http://www.newit.co.uk/forum/index.php/topic,136.0.html

I'll try to figure out collection of multi-boot settings for you during the week.
Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #10 on: 06 January 2010, 12:22:50 am »

Tony -

Sorry for the delay, I haven't forgotten about you.

I am still working on preparing a small set of environment variables that will add multi-boot functionality to your system, which was purchased as an SD-booting model (and only SD booting). The modification will boot from SD card (if available), or original NAND drive otherwise. I am close, but not quite there. Hopefully tomorrow...

Logged
Cestrian
Newbie
*
Posts: 12


« Reply #11 on: 06 January 2010, 10:51:36 am »

Hi Marcus,

Thanks very much for your help!

I have my plug running SqueezeboxServer nicely with my whole music collection, plus the initial draft of my "house control" system that I am dreaming up and it all works a treat. (I have already got a control system in place that's been running for a few years based on the picoFlash embedded controller with PIC microcontroller based I/O modules to control lights, aquarium feeder, etc, but the Plug will give me far better user interface and integration with webcams, web technology and generally loads more performance)

Cheers,
Tony
Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #12 on: 09 January 2010, 06:19:47 pm »

Tony -

Here's where I am at:

I wanted to set the bootcmd environment variable to:

Code:
run bootcmd_mmc; run bootcmd_factory;

with the intention of creating suitable bootcmd_mmc and bootcmd_factory variables.

Here's what I have been working on for bootcmd_factory:

Code:
bootargs_root_factory root=/dev/mtdblock2 ro
mtdpartitions_factory mtdparts=nand_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw
prepare_factory_settings setenv arcNumber;setenv mainlineLinux no; setenv run_diag no;setenv console console=ttyS0,115200;setenv cesvcid ULULULULULULPPULULULULULDA;
bootcmd_factory run prepare_factory_settings;setenv bootargs $(bootargs_console) $(mtdpartitions_factory);nand read.e 0x800000 0x100000 0x400000; bootm 0x800000


And bootcmd_mmc:

Code:
prepare_mmc_settings setenv mainlineLinux yes;setenv arcNumber 2097;setenv run_diag;
bootargs_root_mmc root=/dev/mmcblk0p2 rootdelay=5
bootcmd_mmc run prepare_mmc_settings;setenv bootargs $(bootargs_console) $(bootargs_root_mmc); mmcinit; ext2load mmc 0:1 0x800000 /uImage; bootm 0x00800000

(The syntax here is for openocd, so the first value is the U-Boot environment variable name, and the rest is its value).

However, this is only partly working. The environment variables need to be changed quite significantly, in particular, there are variables that are required in each configuration that should be omitted from the other configuration (ie mainlineLinux & run_diag). And I can't get a full, automated boot.

But what does work is executing the following from the U-Boot prompt:

Code:
run prepare_mmc_settings
saveenv
reset
run bootcmd_mmc
and:

Code:
run prepare_factory_settings
saveenv
reset
run bootcmd_factory

So if you create the environment variables that I have listed above (and here they are again, below, in the correct syntax for U-Boot, so you can copy & paste), you can at least manually boot from NAND, using factory settings, by interrupting U-Boot and executing the commands above.


Code:
setenv bootargs_root_factory 'root=/dev/mtdblock2 ro'
setenv mtdpartitions_factory 'mtdparts=nand_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw'
setenv prepare_factory_settings 'setenv arcNumber;setenv mainlineLinux no; setenv run_diag no;setenv console console=ttyS0,115200;setenv cesvcid ULULULULULULPPULULULULULDA;'
setenv bootcmd_factory 'run prepare_factory_settings;setenv bootargs $(bootargs_console) $(mtdpartitions_factory);nand read.e 0x800000 0x100000 0x400000; bootm 0x800000'

setenv prepare_mmc_settings 'setenv mainlineLinux yes;setenv arcNumber 2097;setenv run_diag;'
setenv bootargs_root_mmc 'root=/dev/mmcblk0p2 rootdelay=5'
setenv bootcmd_mmc 'run prepare_mmc_settings;setenv bootargs $(bootargs_console) $(bootargs_root_mmc); mmcinit; ext2load mmc 0:1 0x800000 /uImage; bootm 0x00800000'

I'd like to get this working automatically, since it would be useful to all our customers who purchased the same SD boot configuration. I will post here if there are any further developments.
Logged
Cestrian
Newbie
*
Posts: 12


« Reply #13 on: 10 January 2010, 12:58:03 pm »

Hi Marcus,

Thanks for all the work you've done, I did what you suggested and I am now able to boot the factory nand OS and I can back up my SD card using dd.

Of course a dual-boot would be nice but for what I want then this satisfies the requirements of being able to do a backup of the SD card for safekeeping in case of a failure or if I muck something up so badly that I need to get back to a working state.

Thanks for your help!

Cheers,
Tony
Logged
NewIT_Marcus
Administrator
Hero Member
*****
Posts: 960


« Reply #14 on: 10 January 2010, 07:51:02 pm »

Hi Marcus,

Thanks for all the work you've done, I did what you suggested and I am now able to boot the factory nand OS and I can back up my SD card using dd.

Of course a dual-boot would be nice but for what I want then this satisfies the requirements of being able to do a backup of the SD card for safekeeping in case of a failure or if I muck something up so badly that I need to get back to a working state.

Thanks for your help!

Cheers,
Tony


Tony -

I entirely understand the need. I concede that at the time we offered the first SD-boot options we didn't foresee the issue that this could create for customers of that configuration. On the one hand, we saved users the heartache of learning about the installer. On the other hand, there was no easy solution to O/S backup other than either manually changing environment variables, or learning how to use the installer, to put a more easily dual-bootable UBIFS system on the NAND. The second option is far worse than the first, and negates the reason why the customer chose the preconfigured option in the first place.

However, customers and prospective customers enquired about these alternatives, and (understandably) there is a demand from those who don't have the skills or time to use the installer. (It took me most of a weekend to get to grips with it - if you only have one plug to configure, you probably don't want to spend so much time on a one-off exercise).

It is everyone's interest that there is a simple backup solution - we've had a number of customers that have broken their SD configuration, and although we have supplied downloadable images to reset the SD contents, we strongly recommend that anyone booting from an SD card take steps to take regular backups of that card.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!