Modify

Opened 5 years ago

Closed 4 years ago

Last modified 2 years ago

#10539 closed defect (fixed)

sysupgrade with keeping config fails on wrt54gl1.1 / brc47xx squashfs

Reported by: anonymous Owned by: hauke
Priority: high Milestone: Barrier Breaker 14.07
Component: base system Version: Trunk
Keywords: Cc:

Description

trunk: ATTITUDE ADJUSTMENT (bleeding edge, r29366)
reproducable sysupgrade fails, with -n option update works

root@ffweimar-adhoc-dhcp-9:/tmp sysupgrade fw.trx
Collected errors:
 * opkg_conf_load: Could not create lock file /var/lock/opkg.lock: No
such file or directory.
Saving config files...
Sending TERM to remaining processes ... syslogd klogd hotplug2 crond sh
dnsmasq dnsmasq olsrd rcS logger sleep
Sending KILL to remaining processes ...
Switching to ramdisk...
Performing system upgrade...
Unlocking linux ...

Writing from <stdin> to linux ...
Appending jffs2 data from /tmp/sysupgrade.tgz to linux...
Writing from <stdin> to linux ...
Upgrade completed
Rebooting system...
Restarting system.
Please stand by while rebooting the system...


CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Mon Oct 26 16:57:52 HKT 2009 (crazy@sw1)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.

Initializing Arena
Initializing Devices.

No DPN
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 3.90.37.0
CPU type 0x29008: 200MHz
Total memory: 16384 KBytes

Total memory used by CFE:  0x80300000 - 0x803A4010 (671760)
Initialized Data:          0x80339E70 - 0x8033C630 (10176)
BSS Area:                  0x8033C630 - 0x8033E010 (6624)
Local Heap:                0x8033E010 - 0x803A2010 (409600)
Stack Area:                0x803A2010 - 0x803A4010 (8192)
Text (code) segment:       0x80300000 - 0x80339E70 (237168)
Boot area (physical):      0x003A5000 - 0x003E5000
Relocation Factor:         I:00000000 - D:00000000

Boot version: v3.7
The boot is CFE

mac_init(): Find mac [C0:C1:C0:A2:8A:AE] in location 0
Nothing... 

No eou key find
Device eth0:  hwaddr C0-C1-C0-A2-8A-AE, ipaddr 192.168.1.1, mask
255.255.255.0
        gateway not set, nameserver not set
Boot program checksum is invalid
Reading :: Failed.: Timeout occured

Attachments (0)

Change History (13)

comment:1 Changed 5 years ago by anonymous

with: http://downloads.openwrt.org/snapshots/trunk/brcm47xx/openwrt-brcm47xx-squashfs.trx
the same error.
LOG:

root@ffweimar-adhoc-dhcp-9:/tmp sysupgrade fwor.trx
Saving config files...
Sending TERM to remaining processes ... syslogd klogd hotplug2 dnsmasq dnsmasq sh crond sh local.fw-fff+ sleep sh sleep scheduler /sbin/sysupgrade: line 133: can't open /proc/5944/stat: no such file
/sbin/sysupgrade: line 133: can't open /proc/5946/stat: no such file

Sending KILL to remaining processes ...
Switching to ramdisk...
Performing system upgrade...
Unlocking linux ...

Writing from <stdin> to linux ...
Appending jffs2 data from /tmp/sysupgrade.tgz to linux...
Writing from <stdin> to linux ...
Upgrade completed
Rebooting system...

comment:2 follow-up: Changed 5 years ago by nlh

This is the same issue I encountered; notice the second "Writing from <stdin> to linux ..." message following the writing of jffs2 data. See: https://lists.openwrt.org/pipermail/openwrt-devel/2011-December/013062.html

comment:3 follow-up: Changed 5 years ago by Bastian Bittorf <bittorf@…>

this addon after "v 'Upgrade completed'" works forme:

partition="$( fgrep "linux" /proc/mtd | cut -d':' -f1 )"
mtd fixtrx /dev/$partition

whats strange to me:

if I fire this command in normal working state, it's

also fixing the crc? IMHO the crc should be always valid?

comment:4 in reply to: ↑ 3 Changed 5 years ago by m.adam--openwrt@…

I encountered the same issue and am successfully using a workaround similar to the one Bastian Bittorf posted.

Replying to Bastian Bittorf <bittorf@…>:

if I fire this command in normal working state, it's
also fixing the crc? IMHO the crc should be always valid?

mtd fixtrx calculates the crc for the whole partition (including the jffs part); while on reboot, the mtd driver calculates crc for the kernel and rom (squashfs) parts only and changes partition sizes accordingly. Otherwise the "Boot program checksum is invalid" would appear whenever the jffs overlay is being modified (if I remember correctly, didn't try it now).

comment:5 Changed 5 years ago by Bastian Bittorf <bittorf@…>

the big question:

is the workaround potentially harmful or is it safe to apply, till the real fix in mtd is done?

IMHO it is very important to have a working sysupgrade command as soon as possible.

comment:6 in reply to: ↑ 2 Changed 5 years ago by anonymous

Replying to nlh:

This is the same issue I encountered; notice the second "Writing from <stdin> to linux ..." message following the writing of jffs2 data. See: https://lists.openwrt.org/pipermail/openwrt-devel/2011-December/013062.html

the patch does not work for me

comment:7 Changed 5 years ago by nlh

This may be a silly question, but did you try upgrading to the patched build multiple times? The patch would not change anything on the initial upgrade; only on subsequent upgrades (that is, your router already has to be running the patched build in order for it to work).

comment:8 Changed 5 years ago by hauke

  • Owner changed from developers to hauke
  • Status changed from new to accepted

comment:9 Changed 4 years ago by radek.nemec

https://lists.openwrt.org/pipermail/openwrt-devel/2011-December/013062.html this patch works perfectly, I have used it many times now. Of course it works only on subsequent updates, because first (unpatched) sysupgrade has the old code.

comment:9 Changed 4 years ago by radek.nemec

https://lists.openwrt.org/pipermail/openwrt-devel/2011-December/013062.html this patch works perfectly, I have used it many times now. Of course it works only on subsequent updates, because first (unpatched) sysupgrade has the old code.

comment:10 Changed 4 years ago by Scott Shambarger <scott-openwrt@…>

OK, so I finally got cracking on this issue, and tracked down the root of the problem.

Basically, the host application 'trx' is creating .trx files with a checksum including the jffs2 EOF marker... so when the saved configuration is written to the firmware, the checksum becomes invalid.

The simplest fix is to create a .trx file with a checksum only covering up to the end of the squashfs section, and not including any of the jffs2 section.

I've patched the 'trx' program to do the right thing when passed the -F (rather than the -A) flag for the jffs2 fs_mark... and updated the appropriate target Makefiles to use correct flag. My patch also fixes a glaring bug in the target's 'mtd' command when fixtrx is used... although this doesn't directly affect the issue here.

I built a new .trx file, and flashed it using sysupgrade (with saved config), and it worked perfectly (and for the first time ever on my Asus). Hopefully this will find it's way into the tree :) -- note: this works by changing how the .trx file is created (not how it's flashed) so the first upgrade with a "correct" .trx file should work.

--- trunk.old/package/mtd/src/trx.c	2012-07-18 20:56:23.181963653 -0700
+++ trunk/package/mtd/src/trx.c	2012-07-18 21:18:24.394088356 -0700
@@ -154,15 +154,15 @@ mtd_fixtrx(const char *mtd, size_t offse
 	if (quiet < 2)
 		fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
 
-	block_offset = offset & ~(erasesize - 1);
-	offset -= block_offset;
-
 	fd = mtd_check_open(mtd);
 	if(fd < 0) {
 		fprintf(stderr, "Could not open mtd device: %s\n", mtd);
 		exit(1);
 	}
 
+	block_offset = offset & ~(erasesize - 1);
+	offset -= block_offset;
+
 	if (block_offset + erasesize > mtdsize) {
 		fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
 		exit(1);
--- trunk.old/package/mtd/src/imagetag.c	2012-07-18 20:56:23.181963653 -0700
+++ trunk/package/mtd/src/imagetag.c	2012-07-18 21:18:40.270142599 -0700
@@ -210,15 +210,15 @@ mtd_fixtrx(const char *mtd, size_t offse
 	if (quiet < 2)
 		fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
 
-	block_offset = offset & ~(erasesize - 1);
-	offset -= block_offset;
-
 	fd = mtd_check_open(mtd);
 	if(fd < 0) {
 		fprintf(stderr, "Could not open mtd device: %s\n", mtd);
 		exit(1);
 	}
 
+	block_offset = offset & ~(erasesize - 1);
+	offset -= block_offset;
+
 	if (block_offset + erasesize > mtdsize) {
 		fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
 		exit(1);
--- trunk.old/target/linux/brcm47xx/image/Makefile	2012-07-18 21:00:40.637579219 -0700
+++ trunk/target/linux/brcm47xx/image/Makefile	2012-07-18 21:01:03.845971555 -0700
@@ -58,7 +58,7 @@ define trxalign/jffs2-64k
 -a 0x10000 -f $(KDIR)/root.$(1)
 endef
 define trxalign/squashfs
--a 1024 -f $(KDIR)/root.$(1) $(if $(2),-f $(2)) -a 0x10000 -A $(KDIR)/fs_mark
+-a 1024 -f $(KDIR)/root.$(1) $(if $(2),-f $(2)) -a 0x10000 -F $(KDIR)/fs_mark
 endef
 
 define Image/Build/trxV2
--- trunk.old/target/linux/adm5120/image/Makefile	2012-07-18 21:36:18.081350778 -0700
+++ trunk/target/linux/adm5120/image/Makefile	2012-07-18 21:36:30.595085750 -0700
@@ -85,7 +85,7 @@ define trxalign/jffs2-64k
 endef
 
 define trxalign/squashfs
--a 1024 -f $(KDIR)/root.squashfs -a 0x10000 -A $(JFFS2BLOCK)
+-a 1024 -f $(KDIR)/root.squashfs -a 0x10000 -F $(JFFS2BLOCK)
 endef
 
 define Image/Build/TRX
--- trunk.old/tools/firmware-utils/src/trx.c	2012-07-18 20:58:18.820527257 -0700
+++ trunk/tools/firmware-utils/src/trx.c	2012-07-18 21:04:27.023334227 -0700
@@ -273,11 +273,10 @@ int main(int argc, char **argv)
 	}
 
 	p->crc32 = crc32buf((char *) &p->flag_version,
-						(fsmark)?fsmark:cur_len - offsetof(struct trx_header, flag_version));
+			    (fsmark ? fsmark : cur_len) - offsetof(struct trx_header, flag_version));
 	p->crc32 = STORE32_LE(p->crc32);
 
-	p->len = STORE32_LE((fsmark) ? fsmark : cur_len);
-	p->len = STORE32_LE(p->len);
+	p->len = STORE32_LE(fsmark ? fsmark : cur_len);
 
 	/* restore TRXv2 bin-header */
 	if (trx_version == 2) {

comment:11 Changed 4 years ago by nbd

  • Resolution set to fixed
  • Status changed from accepted to closed

fix from the list committed in r32866

comment:12 Changed 2 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.