Repair Lacie Cloudbox after failed install of latest firmwar

Post Reply
dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Thu Aug 06, 2015 9:55 pm

Yes, normal access... unless by a bug from Windows 7, can't Disconnect the old Mapping Drive
Family(\\Cloudbox) (Z:)

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Thu Aug 06, 2015 9:58 pm

I guess I should try to send the ubootenv file again... with the 1-0. What do you think?

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Thu Aug 06, 2015 9:59 pm

Looking into the code I found this:

Code: Select all

ERROR: There is a global environment variable with the same name.
Loading file "/boot/uImage" from ide device 0:5 (gpt5
)
7183376 bytes read
What it means?

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Thu Aug 06, 2015 10:04 pm

That error is caused because we have set the root_part variable manually. It will go away if we don't do that.

yes I suggest you do that upload the ubootenv file 1-0 again.
Then reboot and interrupt with u-boot console
But before giving the nexus_boot command I suggest you read in u_boot console again the variables

Code: Select all

ext2get ide 0:${nexus_nv_part} /ubootenv boot_count saved_entry
If that still gives a wrong value we can try this in u-boot console to set the right value

Code: Select all

ide reset
ext2set ide 0:${nexus_nv_part} /ubootenv saved_entry 1

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Thu Aug 06, 2015 10:13 pm

Errors...

Code: Select all

provided by fvdw
waiting for u-boot..
starting u-boot net console click on window and press enter


Marvell>> ext2get ide 0:${nexus_nv_part} /ubootenv boot_count saved_entry
ext2get ide 0:${nexus_nv_part} /ubootenv boot_count saved_entry
** Bad partition 3 **
Marvell>> ide reset
ide reset

Reset IDE:
Marvell Serial ATA Adapter

Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode (5)
  Device 0 @ 0 0:
Model: ST2000DM001-1CH164                       Firm: CC44     Ser#:             Z2F0VEJ3
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
PCIe SATA:ffffffff

Marvell>> ext2get ide 0:${nexus_nv_part} /ubootenv boot_count saved_entry
ext2get ide 0:${nexus_nv_part} /ubootenv boot_count saved_entry

** bad crc : env data may be corrupted
Marvell>> cat ubootenv
cat ubootenv
Unknown command 'cat' - try 'help'
Marvell>>

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Thu Aug 06, 2015 10:22 pm

so editing that file it does not like and it is not classified as corrupt
Then put back the original 0-0 file
and do in u-boot console this to try to set the right value

Code: Select all

ide reset
ext2set ide 0:${nexus_nv_part} /ubootenv saved_entry 1
After setting it in u-boot try to read it agin to see if it hen returns the corrected value

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Thu Aug 06, 2015 10:38 pm

it seems that the first characters in the file are a crc checksum and a termination character, if we modify the file with an editor we must also adapt that checksum. Hopefully that ext2set command will do that for us..

this is the relevant part in ext2set code were CRC check is done

Code: Select all

	filePos=0;
	if (ext2fs_read_pos(buffer, 0, filelen) != filelen) {
		printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
		ext2fs_close();
		if(buffer){
			free (buffer);
		}
		return(1);
	}

env=(env_t*)buffer;
	readCrc = env->crc;
	sizeCrc = 0;
	for(i=offsetof(env_t, data); ((i+1)<filelen) && ((buffer[i]!='\0') || (buffer[i+1]!='\0')); i++)
		;

	if((i+1)==(filelen) && ((buffer[i]!='\0') || (buffer[i+1]!='\0'))){
		/*error : did not find termination char*/
		printf("\n** Unable to locate env termination char\n");
		ext2fs_close();
		if(buffer){
			free (buffer);
		}
		return(1);
	}else{
		sizeCrc = (i+2) * sizeof(char) - offsetof(env_t, data);
	}
	/*calculate crc*/
	calculatedCrc = crc32(0, (unsigned char*)(env->data), sizeCrc);

	/*compare crc*/
	if(calculatedCrc != readCrc){ 
		/*bad crc*/
		printf("\n** bad crc : env data may be corrupted\n");
		ext2fs_close();
		if(buffer){
			free (buffer);
		}
		return(1);
	}
Last edited by fvdw on Fri Aug 07, 2015 9:14 am, edited 1 time in total.

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Thu Aug 06, 2015 10:57 pm

I guess I can't copy it back...

Code: Select all

Marvell>> ext2set ide 0:${nexus_nv_part} /ubootenv saved_entry 1
ext2set ide 0:${nexus_nv_part} /ubootenv saved_entry 1

** bad crc : env data may be corrupted
Marvell>>

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Thu Aug 06, 2015 10:59 pm

Do you still have the original file, I guess I lost it, because I can't find it in my PC.

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Thu Aug 06, 2015 11:14 pm

I will post on plugout, if we cannot write to that one we need to find a way to edit the file properly, the cloudbox u-boot code should give enough info to do that

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Thu Aug 06, 2015 11:21 pm

I don't have to post it it is already there as you posted it yourself

http://plugout.net/viewtopic.php?f=28&t ... 310#p19303

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Thu Aug 06, 2015 11:23 pm

dmiyabara wrote:I guess I can't copy it back...

Code: Select all

Marvell>> ext2set ide 0:${nexus_nv_part} /ubootenv saved_entry 1
ext2set ide 0:${nexus_nv_part} /ubootenv saved_entry 1

** bad crc : env data may be corrupted
Marvell>>
To write to it you must first put back the original file (do not use a modified one)

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Fri Aug 07, 2015 12:08 am

Tried other commands...

Code: Select all

Marvell>> ${bootcmd}
${bootcmd}
## Error: "nexus_boot;" not defined
Marvell>>

fvdw
Posts: 777
Joined: Wed Mar 18, 2009 11:13 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by fvdw » Fri Aug 07, 2015 9:35 am

I am trying to understand how the crc check works

First we need to know what env_t type is as it is used in the code
This is defined as follow:

Code: Select all

#define ENV_SIZE (CFG_ENV_SIZE - ENV_HEADER_SIZE)

typedef	struct environment_s {
	unsigned long	crc;		/* CRC32 over data bytes	*/
#ifdef CFG_REDUNDAND_ENVIRONMENT
	unsigned char	flags;		/* active/obsolete flags	*/
#endif
	unsigned char	data[ENV_SIZE]; /* Environment data		*/
} env_t;
So the first 8 bytes of such variabele(=length ulong) contains crc, Assuming we have not a redundant environment, the rest of that array contains the data
This seems also to be the setup of the ubootenv file, a crc then the data over which the crc is calculated and two termination characters (\0\0)

In ext2get function the sequence is as follows to read the content of this file and check crc.

1. it reads the content of the file (filelen is the length of the file opened)

Code: Select all

	filePos=0;
	if (ext2fs_read_pos(buffer, 0, filelen) != filelen) {
		printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
		ext2fs_close();
		if(buffer){
			free (buffer);
		}
		return(1);
	}
2. then it puts what it has read in variabele env (this defined as env_t type) and it sets readCrc to the value found in the first 8 bytes as env->crc is stored in first 8 bytes and sets sizeCRC to 0.
SizeCrc seems to be the length of the data over which the crc must be calculated. So as next step it determines that length.

Code: Select all

	env=(env_t*)buffer;
	readCrc = env->crc;
	sizeCrc = 0;
3. Then it seems to determine the length of data string to calculate the crc itself for comparison

Code: Select all

	for(i=offsetof(env_t, data); ((i+1)<filelen) && ((buffer[i]!='\0') || (buffer[i+1]!='\0')); i++)
		;

	if((i+1)==(filelen) && ((buffer[i]!='\0') || (buffer[i+1]!='\0'))){
		/*error : did not find termination char*/
		printf("\n** Unable to locate env termination char\n");
		ext2fs_close();
		if(buffer){
			free (buffer);
		}
		return(1);
	}else{
		sizeCrc = (i+2) * sizeof(char) - offsetof(env_t, data);

3. Then it calculates the crc form the data string

Code: Select all

	/*calculate crc*/
	calculatedCrc = crc32(0, (unsigned char*)(env->data), sizeCrc);
4. and compares it with what it found in the bigenning of the file

Code: Select all

	if(calculatedCrc != readCrc){ 
		/*bad crc*/
		printf("\n** bad crc : env data may be corrupted\n");
		ext2fs_close();
		if(buffer){
			free (buffer);
		}
		return(1);
What puzzles me is that in the ubootenv file you have sent the crc seems to be only 4 bytes long..???
to be continued, I have vistors right now, will be back later.
If we find out how this works then we can recreate the ubootenv file in the correct way.

dmiyabara
Posts: 61
Joined: Thu Jul 09, 2015 9:33 pm

Re: Repair Lacie Cloudbox after failed install of latest fir

Post by dmiyabara » Fri Aug 07, 2015 11:02 am

That's right, when I changed the ubootenv file with this command, I don't know why my backup files have changed as well. I don't copied the file ubootenv over the ubootenv.old.

Post Reply