Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Android Devices > enTourage eDGe

Notices

Reply
 
Thread Tools Search this Thread
Old 10-27-2011, 01:44 AM   #31
perldude69
Fun-ologist
perldude69 began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Oct 2011
Device: Pocket Edge, Galaxy S
They have an image that will restore the root partition. The uboot we have has about half the commands as the vanilla version.

-- Jim
perldude69 is offline   Reply With Quote
Old 10-27-2011, 05:46 AM   #32
vicinc
Guru
vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.
 
Posts: 733
Karma: 443
Join Date: May 2011
Location: UK
Device: Pocket Edgex2(1unborked), Alex, Nook B&W, Nook Color, Nook STR
give me the filename and try to search for it
vicinc is offline   Reply With Quote
Advert
Old 10-28-2011, 03:33 AM   #33
perldude69
Fun-ologist
perldude69 began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Oct 2011
Device: Pocket Edge, Galaxy S
Looking through the update.zip, I see all the files we need. We have the filesystem image (ramdisk.android.gz.crc), the zimage and the uboot image. It should just be a matter of rewriting the NAND.
I stayed up late again last night and learned a lot.
The command to tftp a file from your tftpserver:
tftp 0x7D00000 ramdisk.android.gz.crc

This writes the file to DRAM starting at the 128 MB address.

To write the image to the PE NAND:

nand write 0x7D00000 0x1200000 C0000

0x7D00000 is the starting address of ramdisk.android.gz.crc

C0000 is the size of the data chunk to write to NAND.

This worked, but was not successful. I think I need to do something differednt with C0000. This should be the file size rounded up to the nearest 512 byte chunk.....

Hopefully I will have time to work more on it tonight. I will also get that howto online for setting up a TFTP server via Ubuntu.

-- Jim

Last edited by perldude69; 10-28-2011 at 03:37 AM. Reason: Forgot some stuff.....
perldude69 is offline   Reply With Quote
Old 10-28-2011, 09:15 AM   #34
GlutinFreeMan
Junior Member
GlutinFreeMan began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2011
Location: Detroit, MI
Device: Entourage Pocket Edge
Hi -- I'm late to the party, but have essentially the same problem.

Mine's slightly different in that it boots and runs properly, but simply won't update. I made a serial cable and am getting the same kernel panic that vicinc and perldude69 are reporting when I try "run boot_user".

Here's my understanding of the root cause (may be wrong, but it makes sense to me):
There are (at least) two boot images stored in flash. One is used for normal operation and runs out of flash. The other is only used for maintenance and reflashing. The reflashing kernel is copied into RAM and runs from there. The reason it runs out of RAM is because it's not possible to flash the device the OS is running on (that way lies madness).

The problem we're all seeing is that the reflashing kernel has become corrupt for some reason, so it can't run out of RAM after copying it there (it won't unzip). When that happens, the PE then reboots from the normal kernel, and runs from flash. That's fine, except that it won't allow us to reflash ANYTHING.

To fix it we need to either:
1) boot a kernel from another device than onboard flash. An external SD card, USB drive, or network drive should all work.
2) fix the corrupted image, so that it can then be copied to RAM, unzipped, and executed there, so we can then proceed with reflashing.

It sounds like perldude69 is on the right path, trying to rewrite the nand memory. I don't know whether tftp is required though - he should be able to get the same files from the SD card or USB drive (it might be easier that way).

Last night, I tried "run boot_maintsd" from the serial port, and it hung up waiting for the SD card. I didn't have a boot image available on the card at the time. Tonight I think I'll try it again, with a copy of ramdisk.android.gz.crc on the SD card, and see if I can get it to boot. I think if we can a kernel running outside of normal flash, we should be able to repair the corrupted image.

I think we're close.
GlutinFreeMan is offline   Reply With Quote
Old 10-28-2011, 10:42 AM   #35
vicinc
Guru
vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.
 
Posts: 733
Karma: 443
Join Date: May 2011
Location: UK
Device: Pocket Edgex2(1unborked), Alex, Nook B&W, Nook Color, Nook STR
thanks guys. please if you succeed make this accessible to mortals. if we can get a fail proof recovery like in cyanogen mods will be great.
vicinc is offline   Reply With Quote
Advert
Old 10-28-2011, 05:52 PM   #36
nikkie
Guru
nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40
 
nikkie's Avatar
 
Posts: 614
Karma: 73700
Join Date: Oct 2009
Location: WA, USA
Device: Android, Kindle Paperwhite, lots of ancient readers
Perldude and Glutinman - definitely on the right track. You know that u-boot already has an entry set up for booting from tftp, right? Check the environment variables in u-boot and you can see it. You should just be able to modify the existing command to boot from your IP, without having to do hacky things with RAM locations.
nikkie is offline   Reply With Quote
Old 10-28-2011, 06:12 PM   #37
perldude69
Fun-ologist
perldude69 began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Oct 2011
Device: Pocket Edge, Galaxy S
I made progress. I can boot again past the initial screen. I was able to write the maint image and regular boot image back to the PE.

Here is the beef:
Connect to a TFTP server. Copy ramdisk.android.gz.crc and ramdisk.maint.gz.crc into the tftp share folder
Boot into the uboot menu and run the following commands:

Quote:
//Restore regular boot
tftp 0x7D00000 ramdisk.android.gz.crc
nand erase 0x1200000 0x140000
nand write 0x7D00000 0x1200000 0x100000


//Restore boot_user (PE Restore Mode)
tftp 0x7D00000 ramdisk.maint.gz.crc
nand erase 0x1300000 0x700000
nand write 0x7D00000 0x1300000 0x6C0000
run boot_user
I still can't boot all the way into the PE, but I see that the adb service has started, so I am currently installing the Android SDK for Linux on my Ubuntu box.
I will post my results before I go to bed in..... Crap it is already after midnight.... I guess it will be a late one again.

--Jim
perldude69 is offline   Reply With Quote
Old 10-28-2011, 07:48 PM   #38
vicinc
Guru
vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.
 
Posts: 733
Karma: 443
Join Date: May 2011
Location: UK
Device: Pocket Edgex2(1unborked), Alex, Nook B&W, Nook Color, Nook STR
keep us posted. maybe you find a way to replace the maintenance partition with something that will enable quick writing of roms from any media and fail safe restore for bork masters like me
vicinc is offline   Reply With Quote
Old 10-28-2011, 09:12 PM   #39
Gunnerp245
Gadget Freak
Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.
 
Gunnerp245's Avatar
 
Posts: 1,169
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: EE, Note 8
This is exciting work, though my devices are fully functional, well as designed, I believe you all are on the verge of a big break through. I am rooting (pun intended) for you!!!!

Last edited by Gunnerp245; 10-29-2011 at 12:41 PM.
Gunnerp245 is offline   Reply With Quote
Old 10-28-2011, 09:34 PM   #40
GlutinFreeMan
Junior Member
GlutinFreeMan began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2011
Location: Detroit, MI
Device: Entourage Pocket Edge
perldude69 -- it sounds like you might be done. Even if you can't boot all the way, if you can get to the point where "run boot_user" works, you should be able to reflash using an existing image (I'd suggest the golden update, so it'll wipe whatever you've got first).
GlutinFreeMan is offline   Reply With Quote
Old 10-28-2011, 10:07 PM   #41
GlutinFreeMan
Junior Member
GlutinFreeMan began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Oct 2011
Location: Detroit, MI
Device: Entourage Pocket Edge
No love for me tonight. I can't get it to boot a maintenance image from the SD card.
I'm probably guessing at the wrong files, or wrong file structure.
Here's as far as I've been able to get:
Code:
[    3.291102] mmc0: new SD card at address 0d49
[    3.295940] mmcblk0: mmc0:0d49 SD02G 1.83 GiB 
[    3.300557]  mmcblk0: p1
[    6.320545] mmc1: new high speed SDIO card at address 0001
[   15.454642] VFS: Mounted root (vfat filesystem) on device 179:1.
[   15.460878] Freeing init memory: 896K
[   15.465080] Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[   15.477580] Rebooting in 1 seconds..
Time for bed - maybe more tomorrow.
GlutinFreeMan is offline   Reply With Quote
Old 10-29-2011, 01:05 AM   #42
nikkie
Guru
nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40nikkie is slicker than a case of WD-40
 
nikkie's Avatar
 
Posts: 614
Karma: 73700
Join Date: Oct 2009
Location: WA, USA
Device: Android, Kindle Paperwhite, lots of ancient readers
Quote:
Originally Posted by perldude69 View Post
I made progress. I can boot again past the initial screen. I was able to write the maint image and regular boot image back to the PE.

Here is the beef:
Connect to a TFTP server. Copy ramdisk.android.gz.crc and ramdisk.maint.gz.crc into the tftp share folder
Boot into the uboot menu and run the following commands:



I still can't boot all the way into the PE, but I see that the adb service has started, so I am currently installing the Android SDK for Linux on my Ubuntu box.
I will post my results before I go to bed in..... Crap it is already after midnight.... I guess it will be a late one again.

--Jim
Looking forward to seeing your logs. Good work!
nikkie is offline   Reply With Quote
Old 10-29-2011, 03:55 AM   #43
perldude69
Fun-ologist
perldude69 began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Oct 2011
Device: Pocket Edge, Galaxy S
Status report:
adb works, but I can't get a shell because /system/bin/sh does not exist. The mdt partitions still don't exist. I need to find the memory location that android_ubi.img.crc gets written to. In update.zip it is pushed via executables in busybox.
..... I just need to restore the MTD partitions somehow.......

-- Jim
perldude69 is offline   Reply With Quote
Old 10-29-2011, 06:01 AM   #44
perldude69
Fun-ologist
perldude69 began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Oct 2011
Device: Pocket Edge, Galaxy S
Fixed@!

Solved: (For me at least)
Jim dances a jig........
I tricked the update.sh into recovering the mtd partitions for me.
Here are the changes I made to the update.sh:
@Line 199
# Jim - Force update.sh to use dd instead of mtd_debug
dd if=$1 of=$3 bs=$4 count=1 >> $TMP_LOG 2>&1
@Line 216
# Jim - Force update.sh to use dd instead of mtd_debug
dd if=$3 of=$1 bs=64K >> $TMP_LOG 2>&1
@ Line 286
# Jim - Removed check for mtd device
if [[ -e $4 ]];
@ Line 329
# Jim - Removed check for mtd device
if [[ -e $4 ]];
@ Line 372
# Jim - Removed check for mtd device
if [ -e /dev/ubi0 ];
@ Line 612
# Jim - Removed check for Flash mismatch / update.sh delete
#if [ "$UPDATE_DEVICE" != "$TARGET_DEVICE" ];
@ Line 1084
# Jim - Changed == t0 != to fool update.sh into factory reimage of mtd partitions
if [ $UPDATE_TYPE != "golden" ];
@ Line 1130
# Jim Edit - Makes update.sh think this is a factory update.
if [ $UPDATE_ORIGIN != "factory" ];

It deletes everything byte by byte, and restores the image to factory default.

Enjoy!

-- Jim

For those interested, here is the whole update.sh

Quote:

#!/bin/bash

# This script contains the sequence of steps required to complete
# the software update process.
# This script was edited by perldude69@gmail.com (Jim) to factory reinstall the PE Image.
# update defaults
UPDATE_TYPE=normal
UPDATE_ORIGIN=user

# code/image - to - device/volume mapping
# ntim
NTIM_FILENAME=ntim.bin.crc
NTIM_DEV=/dev/mtd8
NTIM_OFFSET=0x00000000
NTIM_ERASE_BLKS=2

# bootloader
LOADER_FILENAME=bootloader.bin.crc
LOADER_DEV=/dev/mtd8
LOADER_OFFSET=0x00020000
LOADER_ERASE_BLKS=2

# u-boot
BOOT_FILENAME=u-boot.bin.crc
BOOT_DEV=/dev/mtd9
BOOT_OFFSET=0x00000000
BOOT_ERASE_BLKS=8

# primary kernel
KERNEL_FILENAME=zImage.crc
KERNEL_DEV=/dev/mtd11
KERNEL_OFFSET=0x00000000
KERNEL_ERASE_BLKS=48

# android ramdisk
RD_ANDROID_FILENAME=ramdisk.android.gz.crc
RD_ANDROID_DEV=/dev/mtd5
RD_ANDROID_OFFSET=0x00000000
RD_ANDROID_ERASE_BLKS=2

# maint ramdisk
RD_MAINT_FILENAME=ramdisk.maint.gz.crc
RD_MAINT_DEV=/dev/mtd5
RD_MAINT_OFFSET=0x00100000
RD_MAINT_ERASE_BLKS=48

# android - system (see edge_fs/android_ubinize.cfg)
SYSTEM_DEV_NUM=6
SYSTEM_MTD_DEVICE=/dev/mtd$SYSTEM_DEV_NUM
SYSTEM_VOL_NAME=system
USERDATA_VOL_NAME=userdata
CACHE_VOL_NAME=cache
VFAT_VOL_NAME=storage
CONTENT_VOL_NAME=userdata
UBI_FILENAME=android_ubi.img.crc
VFAT_IMG_FILENAME=vfat.img
VFAT_NUM_BLOCKS=2617152

# flash device specific
SPI_NOR_BLK_SIZE=64K

UPDATE_SH=update.sh

TMP_LOG=/tmp/update.log
LOG_FILE_PATH=recovery
LOG_FILE_NAME=update.log
LOG_FILE_VOL_NAME=$CACHE_VOL_NAME
CMD_FILE_NAME=recovery/command

# zip names
BOOT_ZIP=boot.zip
ROOT_ZIP=root.zip
SYSTEM1_ZIP=system1.zip
SYSTEM2_ZIP=system2.zip
DATA_ZIP=data.zip
SDCARD_ZIP=sdcard.zip
CONTENT_ZIP=content.zip
TOOLS_ZIP=tools.zip

# script/executable names
SHOW_PROGRESS=show_progress
PRE_UPDATE=pre_update.sh
POST_UPDATE=post_update.sh

SRC_DIR=/tmp
SRC_MOUNT_POINT=/srcmnt
DST_MOUNT_POINT=/mnt
VFAT_MOUNT_POINT=/vfatmnt

SYSTEM_DST_DIR=$DST_MOUNT_POINT
USERDATA_DST_DIR=$DST_MOUNT_POINT
CONTENT_DST_DIR=$DST_MOUNT_POINT
SDCARD_DST_DIR=$DST_MOUNT_POINT

# for crc'ing images
CRC_OK=false
UBI_CRC_OK=false
EXIST_AND_CRC_OK=false
EXIST_OK=false
TMP_FILE1=tmp1.img
TMP_FILE2=tmp2.img

# from boot command, figure out where update file is...
BOOT_COMMAND=$1
for i in $BOOT_COMMAND
do
case $i in
"--update_package=CACHE:update.zip"*)
UPDATE_FILE=update.zip
UPDATE_SRC_DEV=ubi:cache
UPDATE_SRC_FS=ubifs
;;

"--update_package=SDESI:update.zip"*)
UPDATE_FILE=update.golden.zip
UPDATE_SRC_DEV=/dev/mmcblk0p1
UPDATE_SRC_FS=auto
UPDATE_ORIGIN=factory
;;

"--update_package=SDCARD:update.zip"*)
UPDATE_FILE=update.zip
UPDATE_SRC_DEV=/dev/mmcblk0p1
UPDATE_SRC_FS=vfat
;;

"--update_package=USB:update.zip"*)
UPDATE_FILE=update.zip
UPDATE_SRC_DEV=/dev/sda1
UPDATE_SRC_FS=vfat
;;

"user"*)
UPDATE_FILE=update.zip
UPDATE_SRC_DEV=$2
UPDATE_SRC_FS=auto
;;

*)
echo "unknown command '$i' ..."
reboot
sleep 5
exit 1
;;
esac
done

echo "fn=$UPDATE_FILE, dev=$UPDATE_SRC_DEV, fs=$UPDATE_SRC_FS" >> $TMP_LOG
echo "fn=$UPDATE_FILE, dev=$UPDATE_SRC_DEV, fs=$UPDATE_SRC_FS"

# ---------------------------------------------
# checks execution status of unzip.
#
# arg1 : Execution status
# arg2 : reboot (0), ignore (1)
# arg3 : string for error reporting
# usage: status $? 1
# ---------------------------------------------
status ()
{
if [ $1 -ne 0 ] ;
then
# an error occurred, handle it
# "11" (no matching files found) is OK in some cases
if [ $1 -eq 11 ];
then
if [ $2 -eq 1 ];
then
# ignore this error
echo "file $3 not found ($1), but that's OK..."
return
fi
fi

# else we've got a problem
echo "error extracting $3 ($1), rebooting..."
umount $SRC_MOUNT_POINT
umount $DST_MOUNT_POINT
umount $VFAT_MOUNT_POINT
reboot
sleep 5
exit 1
fi
}

# --------------------------------------------------
# Raw read from SPI NOR flash
#
# arg1 : mtd device
# arg2 : offset within mtd device
# arg3 : filename to read image in to
# arg4 : size (in bytes) to read
# usage: raw_nor_read /dev/mtd8 0x40000 tmp.img 12345
# --------------------------------------------------
raw_nor_read ()
{

# try mtd_debug instead
# Jim - Force update.sh to use dd instead of mtd_debug
dd if=$1 of=$3 bs=$4 count=1 >> $TMP_LOG 2>&1

# mtd_debu way
#mtd_debug read $1 $2 $4 $3
}

# --------------------------------------------------
# Raw write to SPI NOR flash
#
# arg1 : mtd device
# arg2 : offset within mtd device
# arg3 : filename of image to burn
# usage: raw_nor_write /dev/mtd8 0x40000 u-boot.bin
# --------------------------------------------------
raw_nor_write ()
{
# try mtd_debug instead
# Jim - Force update.sh to use dd instead of mtd_debug
dd if=$3 of=$1 bs=64K >> $TMP_LOG 2>&1

# mtd_debug way
#WR_LEN=`stat -c %s $3`
#mtd_debug write $1 $2 $WR_LEN $3
}

# --------------------------------------------------
# crc32 check on image
# - requires that image have appended crc32
#
# arg1 : filename of image to verify
# usage: crc_check tmp.img
# --------------------------------------------------
crc_check ()
{
CRC=`ubicrc32 $1`
if [ "$CRC" == "0x00000000" ];
then
CRC_OK=true
echo "crc OK ($1)"
echo "crc OK ($1)" >> $TMP_LOG
else
CRC_OK=false
echo "crc FAILED ($1, $CRC)"
echo "crc FAILED ($1, $CRC)" >> $TMP_LOG
fi
}

# --------------------------------------------------
# check for existence of file and crc it
# - requires that image have appended crc32
#
# arg1 : filename of image to verify
# usage: existence_and_crc_check tmp.img
# --------------------------------------------------
existence_and_crc_check ()
{
if [ -e $1 ];
then
EXIST_OK=true
crc_check $1
if [ "$CRC_OK" == "true" ];
then
EXIST_AND_CRC_OK=true
else
EXIST_AND_CRC_OK=false
fi
else
EXIST_OK=false
fi
}

# --------------------------------------------------
# Burns code to SPI NOR flash and verifies CRC32
# - requires that image have appended crc32
#
# arg1 : mtd device
# arg2 : offset within mtd device
# arg3 : number of blocks to erase
# arg4 : filename of image to burn
# usage: nor_burn /dev/mtd8 0x40000 4 u-boot.bin
# --------------------------------------------------
nor_burn ()
{
echo "nor_burn: entry: $1 $2 $3 $4"
echo "nor_burn: entry: $1 $2 $3 $4" >> $TMP_LOG

# Jim - Removed check for mtd device
if [[ -e $4 ]];
then
SIZE=`stat -c %s $4`
# start of erase/burn/verify loop
for i in {1..3}
do
echo "NOR erasing ($i)..."
echo "NOR erasing ($i)..." >> $TMP_LOG
flash_erase $1 $2 $3
echo "NOR burning ($i)..."
echo "NOR burning ($i)..." >> $TMP_LOG
raw_nor_write $1 $2 $4
echo "NOR verifying ($i)..."
echo "NOR verifying ($i)..." >> $TMP_LOG
raw_nor_read $1 $2 $TMP_FILE1 $SIZE
crc_check $TMP_FILE1
rm $TMP_FILE1
if [ "$CRC_OK" == "true" ];
then
break
fi
done
rm $4
else
echo "nor_burn: $1 or $4 does not exist, skipping"
echo "nor_burn: $1 or $4 does not exist, skipping" >> $TMP_LOG
fi
}

# --------------------------------------------------
# Burns code to NAND flash
#
# arg1 : mtd device
# arg2 : offset within mtd device
# arg3 : number of blocks to erase
# arg4 : filename of image to burn
# usage: nand_burn /dev/mtd5 0x0000 2 ramdisk.android.gz
# --------------------------------------------------
nand_burn ()
{
echo "nand_burn: entry: $1 $2 $3 $4"
echo "nand_burn: entry: $1 $2 $3 $4" >> $TMP_LOG

# Jim - Removed check for mtd device
if [[ -e $4 ]];
then
SIZE=`stat -c %s $4`
# start of erase/burn/verify loop
for i in {1..3}
do
echo "NAND erasing ($i)..."
echo "NAND erasing ($i)..." >> $TMP_LOG
flash_erase $1 $2 $3
echo "NAND burning ($i)..."
echo "NAND burning ($i)..." >> $TMP_LOG
nandwrite -s $2 -p $1 $4 >> $TMP_LOG 2>&1
echo "NAND verifying ($i)..."
echo "NAND verifying ($i)..." >> $TMP_LOG
nanddump -o -b -l $SIZE -s $2 -f $TMP_FILE1 $1 >> $TMP_LOG 2>&1
# truncate file to actual size, not 4k multiple of nanddump
dd if=$TMP_FILE1 of=$TMP_FILE2 bs=$SIZE count=1
crc_check $TMP_FILE2
rm $TMP_FILE1
rm $TMP_FILE2
if [ "$CRC_OK" == "true" ];
then
break
fi
done
rm $4
else
echo "nand_burn: $1 or $4 does not exist, skipping"
echo "nand_burn: $1 or $4 does not exist, skipping" >> $TMP_LOG
fi
}

# --------------------------------------------------
# Burns ubi image to NAND flash
#
# arg1 : mtd device
# arg2 : filename of image to burn
# usage: ubi_burn /dev/mtd5 android_ubi.img
# --------------------------------------------------
ubi_burn ()
{
# must be detached first
# Jim - Removed check for mtd device
if [ -e /dev/ubi0 ];
then
ubidetach /dev/ubi_ctrl -m $SYSTEM_DEV_NUM
sleep 1
fi

if [[ -e $2 ]];
then
CRC_BEFORE=`ubicrc32 $2`
SIZE=`stat -c %s $2`
for i in {1..3}
do
echo "UBI erasing..."
echo "UBI erasing..." >> $TMP_LOG
# could erase only up to size only, but let's be safe
flash_erase /dev/mtd$SYSTEM_DEV_NUM 0 7864
echo "UBI formatting..."
echo "UBI formatting..." >> $TMP_LOG
ubiformat $1 -s 4096 -f $2
echo "UBI verifying..."
echo "UBI verifying..." >> $TMP_LOG
# not enough ram for orig file and tmp file
rm $2
nanddump -o -b -l $SIZE -s 0 -f $TMP_FILE1 $1 >> $TMP_LOG 2>&1
CRC_AFTER=`ubicrc32 $TMP_FILE1`
rm $TMP_FILE1
if [ $CRC_BEFORE == $CRC_AFTER ];
then
UBI_CRC_OK=true
echo "crc OK ($2, $CRC_AFTER)"
echo "crc OK ($2, $CRC_AFTER)" >> $TMP_LOG
else
UBI_CRC_OK=false
echo "crc FAILED ($2, $CRC_AFTER)"
echo "crc FAILED ($2, $CRC_AFTER)" >> $TMP_LOG
fi
# break after one pass, pass or fail
break
done
else
echo "ubi_burn: $1 or $2 does not exist, skipping"
echo "ubi_burn: $1 or $2 does not exist, skipping" >> $TMP_LOG
fi
}

# --------------------------------------------------
# Strips 4 bytes (crc) from a file
#
# arg1 : filename to truncate
# arg2 : num bytes to strip
# usage: truncate android_ubi.img
# --------------------------------------------------
truncate ()
{
SIZE=`stat -c %s $1`
FINAL_SIZE=$(($SIZE - $2))
echo "size=$SIZE, final_size=$FINAL_SIZE"
dd if=/dev/null of=$1 seek=1 bs=$FINAL_SIZE
}


# initrd/.../edge_update already did this, but, just for good measure...
# lets put some fire behind that LCD to let the man know we're here (0-255)...
LCD_BRIGHTNESS=/sys/devices/platform/pxa168-pwm.0/pwm-backlight.0/backlight/pwm-backlight/brightness
echo 225 > $LCD_BRIGHTNESS

# ensure mount points exist
mkdir -p $SRC_MOUNT_POINT
mkdir -p $DST_MOUNT_POINT
mkdir -p $VFAT_MOUNT_POINT

# timestamp the start
BUILD_DATE_STR=`date`
echo "start: $BUILD_DATE_STR ($UPDATE_ORIGIN)" >> $TMP_LOG
echo "start: $BUILD_DATE_STR ($UPDATE_ORIGIN)"

# begin
echo "executing update script..."

# first, for legacy code (coyote-1.0 or older), remove reboot cmd from env
################################################## ########################
echo "removing reboot_cmd from env..."
echo "removing reboot_cmd from env..." >> $TMP_LOG
fw_setenv reboot_cmd

# find and access update.zip file
#################################
mount -t $UPDATE_SRC_FS $UPDATE_SRC_DEV $SRC_MOUNT_POINT
if [ ! -e $SRC_MOUNT_POINT/$UPDATE_FILE ];
then
echo "$UPDATE_FILE does not exist on $UPDATE_SRC_DEV"
echo "$UPDATE_FILE does not exist on $UPDATE_SRC_DEV" >> $TMP_LOG
rm -rf $SRC_MOUNT_POINT/$CMD_FILE_NAME
umount $SRC_MOUNT_POINT
reboot
sleep 5
exit 1
else
echo "$UPDATE_FILE exists on $UPDATE_SRC_DEV"
echo "$UPDATE_FILE exists on $UPDATE_SRC_DEV" >> $TMP_LOG
# verification already done in edge_update
fi

# extract tools
###############
echo "unpacking tools in "`pwd`"..."
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $TOOLS_ZIP >> $TMP_LOG 2>&1
status $? 0 $TOOLS_ZIP
unzip -o $TOOLS_ZIP >> $TMP_LOG 2>&1
status $? 0 $TOOLS_ZIP
rm $TOOLS_ZIP
sync

# show progess if present (run in background)
#############################################
# first get 'flipped' switch from cmdline
FLIP_FOUND=0
FLIP_SWITCH=
FLIP_COMMAND="`cat /proc/cmdline`"
for i in $FLIP_COMMAND
do
case $i in
# handle "--flipped" (legacy) and "flipped" (current)
"flipped=1")
FLIP_SWITCH=-f
FLIP_FOUND=1
;;
"flipped=0")
FLIP_FOUND=1
;;
esac
done

# legacy (coyote-1.0 and older) support: get 'flipped' switch from command file
if [ $FLIP_FOUND -eq 0 ];
then
echo "legacy flipped handling..."
FLIP_COMMAND="`cat $SRC_MOUNT_POINT/$CMD_FILE_NAME`"
for i in $FLIP_COMMAND
do
case $i in
"--flipped=1")
FLIP_SWITCH=-f
;;
esac
done
fi

if [ -e $SHOW_PROGRESS ];
then
echo "show progress..."
chmod +x $SHOW_PROGRESS
./$SHOW_PROGRESS -p img-update $FLIP_SWITCH &
fi

# check device type of target vs. update.zip
############################################
# build.prop is part of tools.zip, which is unzipped into /tmp
# check it against build.prop in ubi:system
# ALSO, use this as an opportunity to get other pertinent info from build.prop
UPDATE_DEVICE=unknown
NEW_VER=unknown
DEVICE_NAME="ro.product.device="
DESCRIPTION_NAME="ro.build.description="
BUILD_TYPE=none
BUILD_TYPE_NAME="ro.build.type="
while read line
do
case $line in
"$DEVICE_NAME"*)
UPDATE_DEVICE=${line#*$DEVICE_NAME}
;;

"$DESCRIPTION_NAME"*)
NEW_VER=${line#*$DESCRIPTION_NAME}
;;

"$BUILD_TYPE_NAME"*)
BUILD_TYPE=${line#*$BUILD_TYPE_NAME}
;;
esac
done < /tmp/build.prop

# now get the target the update is for by either
# a) looking in usb:system/build.prop or
# b) reading boot version from /dev/mtd8

TARGET_DEVICE=unknown
OLD_VER=unknown
mount -t ubifs ubi:$SYSTEM_VOL_NAME $DST_MOUNT_POINT
if [ -e $DST_MOUNT_POINT/build.prop ];
then
# use ubi:system/build.prop to ID hardware
while read line
do
case $line in
"$DEVICE_NAME"*)
TARGET_DEVICE=${line#*$DEVICE_NAME}
;;

"$DESCRIPTION_NAME"*)
OLD_VER=${line#*$DESCRIPTION_NAME}
;;
esac
done < $DST_MOUNT_POINT/build.prop
umount $DST_MOUNT_POINT
else
# use boot code to ID hardware
BOOT_ID=unknown
raw_nor_read /dev/mtd9 0x20 boot.id 4#
BOOT_ID=$(< boot.id)
echo "boot_id = $BOOT_ID"
if [ "$BOOT_ID" == "ES01" ];
then
TARGET_DEVICE=edge
fi
if [ "$BOOT_ID" == "ES02" ];
then
TARGET_DEVICE=edgejr
fi
echo "BOOT_ID = $BOOT_ID"
echo "BOOT_ID = $BOOT_ID" >> $TMP_LOG
fi

echo "UPDATE_DEVICE = $UPDATE_DEVICE"
echo "UPDATE_DEVICE = $UPDATE_DEVICE" >> $TMP_LOG
echo "TARGET_DEVICE = $TARGET_DEVICE"
echo "TARGET_DEVICE = $TARGET_DEVICE" >> $TMP_LOG
echo "BUILD_TYPE = $BUILD_TYPE"
echo "BUILD_TYPE = $BUILD_TYPE" >> $TMP_LOG

echo "************************************************* ********************"
echo " current: $OLD_VER"
echo " new: $NEW_VER"

echo "************************************************* ********************" >> $TMP_LOG
echo " current: $OLD_VER" >> $TMP_LOG
echo " new: $NEW_VER" >> $TMP_LOG

# Jim - Removed check for Flash mismatch / update.sh delete
#if [ "$UPDATE_DEVICE" != "$TARGET_DEVICE" ];
#then
# echo " MISMATCH: aborting update"
# echo " MISMATCH: aborting update" >> $TMP_LOG
# echo "************************************************* ********************"
# rm $SRC_MOUNT_POINT/$CMD_FILE_NAME
# rm $SRC_MOUNT_POINT/$UPDATE_FILE
# sync
# umount $SRC_MOUNT_POINT
## reboot
# sleep 5
# exit 1
#fi

echo "************************************************* ********************"
echo "************************************************* ********************" >> $TMP_LOG

# debug
#exit

# perform special pre-processing if applicable
##############################################
if [ -e $PRE_UPDATE ];
then
echo "executing pre-processing..."
echo "executing pre-processing..." >> $TMP_LOG
chmod +x $PRE_UPDATE
./$PRE_UPDATE
echo "pre-processing done..."
echo "pre-processing done..." >> $TMP_LOG
fi

# start unpacking and updating...

# boot files
############
echo "extracting boot files..."
echo "extracting boot files..." >> $TMP_LOG
# get only desired zip from update.zip
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $BOOT_ZIP >> $TMP_LOG 2>&1
status $? 1 $BOOT_ZIP
if [ -e $BOOT_ZIP ];
then
echo "updating boot files..."
echo "updating boot files..." >> $TMP_LOG
unzip -o $BOOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $BOOT_ZIP

# ntim
for i in {1..3}
do
existence_and_crc_check $NTIM_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
nor_burn $NTIM_DEV $NTIM_OFFSET $NTIM_ERASE_BLKS $NTIM_FILENAME
break
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$NTIM_FILENAME not included in package"
echo "$NTIM_FILENAME not included in package" >> $TMP_LOG
break
fi
echo "crc check ($i) FAILED on file $NTIM_FILENAME"
# unzip again and start over
unzip -o $BOOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $BOOT_ZIP
done
###

# bootloader
for i in {1..3}
do
existence_and_crc_check $LOADER_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
nor_burn $LOADER_DEV $LOADER_OFFSET $LOADER_ERASE_BLKS $LOADER_FILENAME
break
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$LOADER_FILENAME not included in package"
echo "$LOADER_FILENAME not included in package" >> $TMP_LOG
break
fi
echo "crc check ($i) FAILED on file $LOADER_FILENAME"
# unzip again and start over
unzip -o $BOOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $BOOT_ZIP
done
###

# u-boot
for i in {1..3}
do
existence_and_crc_check $BOOT_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
nor_burn $BOOT_DEV $BOOT_OFFSET $BOOT_ERASE_BLKS $BOOT_FILENAME
break
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$BOOT_FILENAME not included in package"
echo "$BOOT_FILENAME not included in package" >> $TMP_LOG
break
fi
echo "crc check ($i) FAILED on file $BOOT_FILENAME"
# unzip again and start over
unzip -o $BOOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $BOOT_ZIP
done
###

# kernel
for i in {1..3}
do
existence_and_crc_check $KERNEL_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
nor_burn $KERNEL_DEV $KERNEL_OFFSET $KERNEL_ERASE_BLKS $KERNEL_FILENAME
break
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$KERNEL_FILENAME not included in package"
echo "$KERNEL_FILENAME not included in package" >> $TMP_LOG
break
fi
echo "crc check ($i) FAILED on file $KERNEL_FILENAME"
# unzip again and start over
unzip -o $BOOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $BOOT_ZIP
done
###

rm $BOOT_ZIP
sync
sleep 1
else
echo "$BOOT_ZIP not included in package."
echo "$BOOT_ZIP not included in package." >> $TMP_LOG
fi

# root files
############
echo "extracting root files..."
echo "extracting root files..." >> $TMP_LOG
# get only desired zip from update.zip
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $ROOT_ZIP >> $TMP_LOG 2>&1
status $? 1 $ROOT_ZIP
if [ -e $ROOT_ZIP ];
then
echo "updating root files..."
echo "updating root files..." >> $TMP_LOG
unzip -o $ROOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $ROOT_ZIP
# ramdisk.android
for i in {1..3}
do
existence_and_crc_check $RD_ANDROID_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
nand_burn $RD_ANDROID_DEV $RD_ANDROID_OFFSET $RD_ANDROID_ERASE_BLKS $RD_ANDROID_FILENAME
break
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$RD_ANDROID_FILENAME not included in package"
echo "$RD_ANDROID_FILENAME not included in package" >> $TMP_LOG
break
fi
echo "crc check ($i) FAILED on file $RD_ANDROID_FILENAME"
# unzip again and start over
unzip -o $ROOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $ROOT_ZIP
done
###

# ramdisk.maint
for i in {1..3}
do
existence_and_crc_check $RD_MAINT_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
nand_burn $RD_MAINT_DEV $RD_MAINT_OFFSET $RD_MAINT_ERASE_BLKS $RD_MAINT_FILENAME
break
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$RD_MAINT_FILENAME not included in package"
echo "$RD_MAINT_FILENAME not included in package" >> $TMP_LOG
break
fi
echo "crc check ($i) FAILED on file $RD_MAINT_FILENAME"
# unzip again and start over
unzip -o $ROOT_ZIP >> $TMP_LOG 2>&1
status $? 0 $ROOT_ZIP
done
###

rm $ROOT_ZIP
sync
sleep 1
else
echo "$ROOT_ZIP not included in package."
echo "$ROOT_ZIP not included in package." >> $TMP_LOG
fi

# from here on, everything is on UBI device
###########################################

# determine is this is a normal update, or a golden (destructive) update
################################################## ######################
echo "checking system image source file..."
echo "checking system image source file..." >> $TMP_LOG
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $UBI_FILENAME >> $TMP_LOG 2>&1
status $? 1 $UBI_FILENAME
if [ -e $UBI_FILENAME ];
then
echo "performing a golden update..."
echo "performing a golden update..." >> $TMP_LOG
UPDATE_TYPE=golden
fi

# GOLDEN (destructive) update
#############################

if [ $UPDATE_TYPE == "golden" ];
then
echo "*** GOLDEN update ***"
echo "*** GOLDEN update ***" >> $TMP_LOG

echo "updating system ubi image..."
echo "updating system ubi image..." >> $TMP_LOG
# don't need to extract from zip again, already done above
# android_ubi.img
# check crc first
for i in {1..5}
do
existence_and_crc_check $UBI_FILENAME
if [ "$EXIST_AND_CRC_OK" == "true" ];
then
# FIRST, must strip 4-byte crc from end or ubiformat is unhappy
truncate $UBI_FILENAME 4
echo "UBI updating ($i)..."
echo "UBI updating ($i)..." >> $TMP_LOG
ubi_burn $SYSTEM_MTD_DEVICE $UBI_FILENAME
if [ "$UBI_CRC_OK" == "true" ];
then
break
else
echo "ubi_burn failed for $UBI_FILENAME"
fi
fi
if [ "$EXIST_OK" == "false" ];
then
echo "$UBI_FILENAME not included in package"
echo "$UBI_FILENAME not included in package" >> $TMP_LOG
break
fi
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $UBI_FILENAME >>$TMP_LOG 2>&1
status $? 0 $UBI_FILENAME
done

sleep 1
ubiattach /dev/ubi_ctrl -m $SYSTEM_DEV_NUM
sleep 1

# now mount storage and create vfat image file
mount -t ubifs ubi:$VFAT_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
echo "creating vfat image..."
echo "creating vfat image..." >> $TMP_LOG
mkfs.vfat -F 32 -n eDGe -C $DST_MOUNT_POINT/$VFAT_IMG_FILENAME $VFAT_NUM_BLOCKS >> $TMP_LOG 2>&1
sync
umount $DST_MOUNT_POINT
sleep 1
else
echo "*** NORMAL update ***"
echo "*** NORMAL update ***" >> $TMP_LOG

### CORRECT, there is no "fi" here
### see below for end of this "if" statement

# NORMAL (non-destructive) update
#################################

# FIRST, whack everything in system/xbin for release, i.e. "user" updates
# ...this is in an effort to harden against misuse and abuse
if [ "$BUILD_TYPE" == "user" ];
then
echo "removing eng binaries..."
echo "removing eng binaries..." >> $TMP_LOG
mount -t ubifs ubi:$SYSTEM_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
rm -rf $SYSTEM_DST_DIR/xbin
sync
umount $DST_MOUNT_POINT
fi

# system partition
# MULTIPLE zips - be careful!!!
###############################
echo "extracting system files..."
echo "extracting system files..." >> $TMP_LOG
# get only desired zip from update.zip
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $SYSTEM1_ZIP >> $TMP_LOG 2>&1
status $? 1 $SYSTEM1_ZIP
if [ -e $SYSTEM1_ZIP ];
then
echo "updating system files..."
echo "updating system files..." >> $TMP_LOG
mount -t ubifs ubi:$SYSTEM_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
unzip -o $SYSTEM1_ZIP -d $SYSTEM_DST_DIR >> $TMP_LOG 2>&1
status $? 0 $SYSTEM1_ZIP
# zip/unzip does not preserve file permissions
chmod -R 755 $SYSTEM_DST_DIR/esi
rm $SYSTEM1_ZIP
sync
df -h $DST_MOUNT_POINT >> $TMP_LOG
umount $DST_MOUNT_POINT
sleep 1
else
echo "$SYSTEM1_ZIP not included in package"
echo "$SYSTEM1_ZIP not included in package" >> $TMP_LOG
fi

echo "extracting more system files..."
echo "extracting more system files..." >> $TMP_LOG
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $SYSTEM2_ZIP >> $TMP_LOG 2>&1
status $? 1 $SYSTEM2_ZIP
if [ -e $SYSTEM2_ZIP ];
then
echo "updating more system files..."
echo "updating more system files..." >> $TMP_LOG
mount -t ubifs ubi:$SYSTEM_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
unzip -o $SYSTEM2_ZIP -d $SYSTEM_DST_DIR >> $TMP_LOG 2>&1
status $? 0 $SYSTEM2_ZIP
# zip/unzip does not preserve file permissions
chmod -R 755 $SYSTEM_DST_DIR/bin
rm $SYSTEM2_ZIP
sync
df -h $DST_MOUNT_POINT >> $TMP_LOG
umount $DST_MOUNT_POINT
sleep 1
else
echo "$SYSTEM2_ZIP not included in package"
echo "$SYSTEM2_ZIP not included in package" >> $TMP_LOG
# mount/unmount to handle any "unrecovered" condition
mount -t ubifs ubi:$SYSTEM_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
sleep 2
umount $DST_MOUNT_POINT
fi

# data partition
################
echo "extracting data files..."
echo "extracting data files..." >> $TMP_LOG
# get only desired zip from update.zip
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $DATA_ZIP >> $TMP_LOG 2>&1
status $? 1 $DATA_ZIP
if [ -e $DATA_ZIP ];
then
echo "updating data files..."
echo "updating data files..." >> $TMP_LOG
mount -t ubifs ubi:$USERDATA_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
unzip -o $DATA_ZIP -d $USERDATA_DST_DIR >> $TMP_LOG 2>&1
status $? 0 $DATA_ZIP
rm $DATA_ZIP
sync
df -h $DST_MOUNT_POINT >> $TMP_LOG
umount $DST_MOUNT_POINT
sleep 1
else
echo "$DATA_ZIP not included in package"
echo "$DATA_ZIP not included in package" >> $TMP_LOG
# mount/unmount to handle any "unrecovered" condition
mount -t ubifs ubi:$USERDATA_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
sleep 2
umount $DST_MOUNT_POINT
fi

### finally, the end of the if (UPDATE_TYPE == golden) statement
fi

# sdcard
########
# At this time, "sdcard" is destined for wherever the library is located.
# This content is not put into the library at build time so it's not permanently
# in the OTA update.zip, but selectively added via add_content.

echo "extracting sdcard files..."
echo "extracting sdcard files..." >> $TMP_LOG
# get only desired zip from update.zip
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $SDCARD_ZIP >> $TMP_LOG 2>&1
status $? 1 $SDCARD_ZIP
if [ -e $SDCARD_ZIP ];
then
echo "determine library location..."
echo "determine library location..." >> $TMP_LOG
mount -t ubifs ubi:$USERDATA_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
if [ -e $DST_MOUNT_POINT/property/persist.sys.esi_is_external ];
then
IS_EXTERNAL=`cat $DST_MOUNT_POINT/property/persist.sys.esi_is_external`
else
IS_EXTERNAL=0
fi
umount $DST_MOUNT_POINT
if [ "$IS_EXTERNAL" == "1" ];
then
echo "library is external..."
echo "library is external..." >> $TMP_LOG
DST_DEV=/dev/mmcblk0p1
else
echo "library is internal..."
echo "library is internal..." >> $TMP_LOG
mount -t ubifs ubi:$VFAT_VOL_NAME $VFAT_MOUNT_POINT >> $TMP_LOG 2>&1
DST_DEV=$VFAT_MOUNT_POINT/$VFAT_IMG_FILENAME
fi
if [ -e $DST_DEV ];
then
echo "updating sdcard files..."
echo "updating sdcard files..." >> $TMP_LOG
mount -t vfat $DST_DEV $DST_MOUNT_POINT >> $TMP_LOG 2>&1
unzip -o $SDCARD_ZIP -d $SDCARD_DST_DIR >> $TMP_LOG 2>&1
status $? 0 $SDCARD_ZIP
rm $SDCARD_ZIP
sync
df -h $DST_MOUNT_POINT >> $TMP_LOG
umount $DST_MOUNT_POINT
else
echo "$DST_DEV does not exist..."
echo "$DST_DEV does not exist..." >> $TMP_LOG
fi
if [ "$IS_EXTERNAL" != "1" ];
then
umount $VFAT_MOUNT_POINT >> $TMP_LOG 2>&1
fi
sleep 1
fi

# content partition
###################
# At this time, "content" is destined for /data
# This content is not put into /data at build time so it's not permanently
# in the OTA update.zip, but selectively added via add_content.
# If and when we have content destined for /fridge, duplicate this code

echo "extracting content files..."
echo "extracting content files..." >> $TMP_LOG
# get only desired zip from update.zip
unzip -o $SRC_MOUNT_POINT/$UPDATE_FILE $CONTENT_ZIP >> $TMP_LOG 2>&1
status $? 1 $CONTENT_ZIP
if [ -e $CONTENT_ZIP ];
then
echo "updating content files..."
echo "updating content files..." >> $TMP_LOG
mount -t ubifs ubi:$CONTENT_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
# FIRST, blow away old content - not really
# rm -rf $CONTENT_DST_DIR/.edge/.esi-data
unzip -o $CONTENT_ZIP -d $CONTENT_DST_DIR >> $TMP_LOG 2>&1
status $? 0 $CONTENT_ZIP
rm $CONTENT_ZIP
sync
df -h $DST_MOUNT_POINT >> $TMP_LOG
umount $DST_MOUNT_POINT
sleep 1
fi

# all done
sync

# Jim - Changed == t0 != to fool update.sh into factory reimage of mtd partitions
if [ $UPDATE_TYPE != "golden" ];
then
# removing update.zip and getting outta here
############################################
echo "removing command and update files..."
echo "removing command and update files..." >> $TMP_LOG
#rm $SRC_MOUNT_POINT/$CMD_FILE_NAME
#rm $SRC_MOUNT_POINT/$UPDATE_FILE
sync
fi

umount $SRC_MOUNT_POINT
sleep 1

# perform special post-processing if applicable
###############################################
if [ -e $POST_UPDATE ];
then
echo "executing post-processing..."
echo "executing post-processing..." >> $TMP_LOG
chmod +x $POST_UPDATE
./$POST_UPDATE
echo "post-processing done..."
echo "post-processing done..." >> $TMP_LOG
fi

# timestamp the finish
BUILD_DATE_STR=`date`
echo "finish: $BUILD_DATE_STR" >> $TMP_LOG
echo "finish: $BUILD_DATE_STR"
echo "" >> $TMP_LOG

# saving partitioning log
#########################
mount -t ubifs ubi:$LOG_FILE_VOL_NAME $DST_MOUNT_POINT >> $TMP_LOG 2>&1
mkdir -p $DST_MOUNT_POINT/$LOG_FILE_PATH
cp $TMP_LOG $DST_MOUNT_POINT/$LOG_FILE_PATH/$LOG_FILE_NAME
sync
umount $DST_MOUNT_POINT
sleep 2

# detach UBI device
ubidetach /dev/ubi_ctrl -m $SYSTEM_DEV_NUM

sleep 1
# Jim Edit - Makes update.sh think this is a factory update.
if [ $UPDATE_ORIGIN != "factory" ];
then
echo "updating $UPDATE_DEVICE EPD waveform file..."
echo "updating $UPDATE_DEVICE EPD waveform file..." >> $TMP_LOG
# automatically burn embedded EPD waveform to eeprom
# NOTE: this burns the waveform contained in maint FS on golden SD card,
# NOT what was just burned as ramdisk.maint.gz
# (they should be identical)
if [ "$UPDATE_DEVICE" == "edge" ];
then
cd /usr/esi/edge2
./burn_edge2_epd_flash.sh ./*.epdflash >> $TMP_LOG 2>&1
else
cd /usr/esi/pocket
./burn_pocket_epd_flash.sh ./*.epdflash >> $TMP_LOG 2>&1
fi
fi

# done
echo "update done."

if [ $UPDATE_ORIGIN == "factory" ];
then
# for factory, power down (otherwise there is no indicator we're done)
echo "factory update: powering down..."
poweroff
sleep 20
else
# for user, just reboot
echo "user update: rebooting..."
echo ""
reboot
fi

Last edited by perldude69; 10-29-2011 at 06:03 AM. Reason: Forgot something!
perldude69 is offline   Reply With Quote
Old 10-29-2011, 11:24 AM   #45
vicinc
Guru
vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.vicinc has a complete set of Star Wars action figures.
 
Posts: 733
Karma: 443
Join Date: May 2011
Location: UK
Device: Pocket Edgex2(1unborked), Alex, Nook B&W, Nook Color, Nook STR
jim can you attach the update.sh to a post.
also where do you run this from? adb, with the update.zip on the usb or sdcard?
is any other wizardry needed?

should I understand that you edited the golden update only and did a recovery via serial?

Last edited by vicinc; 10-29-2011 at 11:26 AM.
vicinc is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
the official "see a device in a café near you" hookup thread zelda_pinwheel Which one should I buy? 259 03-08-2013 09:43 AM
[Old Thread] Slow to 'get list of books on device' for Kindle DX tklaus Devices 4 03-10-2011 12:11 PM
MobileRead Official MobileRead Book Club: Welcome thread/November's book choice thread PsyDocJoanne Book Clubs 151 02-08-2009 08:42 PM


All times are GMT -4. The time now is 04:18 AM.


MobileRead.com is a privately owned, operated and funded community.