[Armadeus-commitlog] armadeus branch, master, updated. armadeus-4.1-42-g3069d4a
Brought to you by:
sszy
|
From: jorasse <jo...@us...> - 2012-02-12 23:52:31
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 3069d4accd17f29b2a210594e6020491065ad0cc (commit)
from e09bbaa83698e97f7755564d5382106703888a37 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3069d4accd17f29b2a210594e6020491065ad0cc
Author: Eric Jarrige <eri...@ar...>
Date: Mon Feb 13 00:51:54 2012 +0100
[UBOOT] update u-boot_recover to restore boards through USB link only - do not need Ethernet anymore to recover UBoot
-----------------------------------------------------------------------
Summary of changes:
software/uboot_recover/apf28-u-boot-spl | Bin 0 -> 193422 bytes
software/uboot_recover/apf28-u-boot.sb | Bin 407136 -> 410112 bytes
software/uboot_recover/apf28-u-boot_recover.bd | 20 ++
software/uboot_recover/apf28_recover.py | 342 ++++++------------------
4 files changed, 102 insertions(+), 260 deletions(-)
create mode 100755 software/uboot_recover/apf28-u-boot-spl
create mode 100644 software/uboot_recover/apf28-u-boot_recover.bd
diff --git a/software/uboot_recover/apf28-u-boot-spl b/software/uboot_recover/apf28-u-boot-spl
new file mode 100755
index 0000000..22f34e5
Binary files /dev/null and b/software/uboot_recover/apf28-u-boot-spl differ
diff --git a/software/uboot_recover/apf28-u-boot.sb b/software/uboot_recover/apf28-u-boot.sb
index 2240fe6..4fefc54 100644
Binary files a/software/uboot_recover/apf28-u-boot.sb and b/software/uboot_recover/apf28-u-boot.sb differ
diff --git a/software/uboot_recover/apf28-u-boot_recover.bd b/software/uboot_recover/apf28-u-boot_recover.bd
new file mode 100644
index 0000000..4d53b25
--- /dev/null
+++ b/software/uboot_recover/apf28-u-boot_recover.bd
@@ -0,0 +1,20 @@
+sources {
+ u_boot_spl="apf28-u-boot-spl";
+ u_boot_env="apf28_env_recover.txt";
+ u_boot_sb="apf28-u-boot.sb";
+}
+
+section (0) {
+ //----------------------------------------------------------
+ // SPL Initialization: power supply & DDR2 memory
+ //----------------------------------------------------------
+ load u_boot_spl;
+ load ivt (entry = u_boot_spl:board_init_ll) > 0x8000;
+ hab call 0x8000;
+
+ //----------------------------------------------------------
+ // Load U-Boot and env script to setup NAND flash
+ //----------------------------------------------------------
+ load u_boot_sb > 0x40000000;
+ load u_boot_env > 0x41000100;
+}
diff --git a/software/uboot_recover/apf28_recover.py b/software/uboot_recover/apf28_recover.py
index 65750b7..a90c53b 100644
--- a/software/uboot_recover/apf28_recover.py
+++ b/software/uboot_recover/apf28_recover.py
@@ -63,230 +63,6 @@ class Error(Exception):
return self.level
-class apf28Bootloader:
-
- statuscode = { 0x8D: 'data specified is out of bounds',
- 0x55: 'error during assert verification',
- 0x36: 'hash verification failed',
- 0x33: 'certificate parsing failed or the certificate contained an unsupported key',
- 0x35: 'signature verification failed',
- 0x47: 'Super-Root key installation failed',
- 0x39: 'Failure not matching any other description',
- 0x4B: 'CSF command sequence contains unsupported command identifier',
- 0x4E: 'absence of expected CSF header',
- 0x4D: 'CSF length is unsupported',
- 0x2E: 'CSF TYPE does not match processor TYPE',
- 0x2D: 'CSF UID does not match either processor UID or generic UID',
- 0x3A: 'CSF customer/product code does not match processor customer/product code',
- 0x87: 'key indexis either unsupported, or an attempt is made to overwrite the SRK from a CSF command',
- 0xF0: 'successful operation completion',
- 0x17: 'SCC unexpectedly not in secure state',
- 0x1E: 'secureRAM secret key invalid',
- 0x1D: 'secureRAM initialization failure',
- 0x1B: 'secureRAM self test failure',
- 0x2B: 'secureRAM internal failure',
- 0x27: 'secureRAM secrect key unexpectedly in use',
- 0x3C: 'SAHARA failure',
- 0x59: 'SAHARA/SCC connectivity failure',
- 0xA3: 'All RTIC regions are allocated',
- 0x93: 'RTIC/SCC connectivity failure',
- 0x0F: 'SHW is not enabled',
- 0x8B: 'an attempt is made to read a key from the list of subordinate public keys at a location where no key is installed',
- 0x8E: 'algorithm type is either invalid or ortherwise unsupported',
- 0x66: 'write operation to register failed',
- 0x88: 'Successful download completion' }
-
- def __init__(self, serialDevice):
- self.serdev = serialDevice
-
- def getStatus(self):
- self.serdev.flushInput()
- self.serdev.write(self.buildcmd("0505", "00000000", "l", "00000000", "00000000", "0"))
- result = self.serdev.read(4)
- if len(result) > 0:
- try:
- if self.serdev.port == 'USB':
- status = result[0]
- else:
- status = ord(result[0])
-
- print "Status: %s" % self.statuscode[status]
- #for i in range(len(result)):
- # print '%02x' % result[i],
- except KeyError,e:
- print "Unknown status " + str(status)
- else:
- print '\nTimeout while asking for status'
-
- def __displayProgress(self, text):
- sys.stdout.write(chr(13))
- print text,
- sys.stdout.flush()
-
- def get(self, addr, count, mode):
- """
- addr: address to read
- count: number of bytes to read
- mode: b, w, l for byte, word, long
- """
- assert len(addr) <= 8, 'address too long'
- assert int(count,16) > 0, 'zero length get'
- assert int(count,16) < 0xffffffff, 'Too long get, should be < 31 bytes'
- self.serdev.write(self.buildcmd("0101" ,addr, mode, count.zfill(9-len(count)), "00000000", "0"))
-
- #nbbyte = 1
- #if mode == 'w':
- # nbbyte = 2
- #if mode == 'l':
- # nbbyte = 4
-
- #nbbyte = nbbyte * int(count)
- temp = self.serdev.read(int(count)+4) # read n+4 char
- if len(temp) == 0:
- print 'read timeout'
- return
- #print '\nread ACK:',
- #for i in range (len(temp)):
- # print '%02x' % ord(temp[i]),
-
- #print 'read data:',
- result = []
- for i in range (4,len(temp)):
-
- result += '%02x' % ord(temp[len(temp)-i+3]),
- print ''.join(result)
- return ''.join(result)
-
- def put(self, addr, data, mode):
- """
- addr: address where the data have to be written
- data: data to write. must match the given mode
- mode: b, w, l for byte, word, long
- """
- assert len(data) > 0, 'zero length put'
- assert len(addr) == 8, 'address too long'
- self.serdev.write(self.buildcmd("0202", addr,mode, "00000000", data, "0"))
- result = self.serdev.read(4) #ack
- if len(result) == 0:
- print 'read timeout'
- return
- #print ' \nwrite ACK:',
- # for i in range (len(result)):
- # print '%02x' % ord(result[i]),
-
- result = self.serdev.read(4)
- if len(result) == 0:
- print 'read timeout'
- return
-
- #print '\nwrite success:',
- #for i in range (len(result)):
- #print '%02x' % ord(result[i]),
-
- def download(self, addr, data, size, type):
- assert size > 0, 'file empty'
- f = open(data, 'rb')
- self.serdev.write(self.buildcmd("0404", addr, "x", size, "00000000", type))
- result = self.serdev.read(4) #ack
- if len(result) == 0:
- print '\nread timeout'
- return
-
- data = f.read(16)
- count = int(size,16)
- oldcount = count
- total = 0
- b = 0
- print '\nTransfering:'
- while count >= 0: #len(data):
- n = len(data)
- b = 16-n # ensure always 4 bytes
- #tr = unpack('B'*n,data)
- self.serdev.write(data)
- count = count - 16
- if count < 16:
- total = total + count
- else:
- total = total + 16
- if (oldcount - count) >= 4096:
- self.__displayProgress("%06d bytes" % total)
- oldcount = count
- data = f.read(16)
- self.__displayProgress("%d bytes transfered" % total)
- print ""
- f.close()
- return
-
- def buildcmd(self, cmd, addr, ds, cnt, data, ft):
- if ds == 'b':
- datatmp = ('%c' % int('00',16)) + ('%c' % int('00',16)) + ('%c' % int('00',16)) + ('%c' % int(data[0:2],16))
- datasize = "08"
- elif ds == 'w':
- datasize = "10"
- datatmp = ('%c' % int('00',16)) + ('%c' % int('00',16)) + ('%c' % int(data[0:2],16)) + ('%c' % int(data[2:4],16))
- elif ds == 'l':
- datasize = "20"
- datatmp = ('%c' % int(data[0:2],16)) + ('%c' % int(data[2:4],16)) + ('%c' % int(data[4:6],16)) + ('%c' % int(data[6:8],16))
- else:
- datasize = "00"
- datatmp = ('%c' % int(data[0:2],16)) + ('%c' % int(data[2:4],16)) + ('%c' % int(data[4:6],16)) + ('%c' % int(data[6:8],16))
-
- result = ('%c' % int(cmd[0:2],16)) + ('%c' % int(cmd[2:4],16)) + \
- ('%c' % int(addr[0:2],16)) + ('%c' % int(addr[2:4],16)) + ('%c' % int(addr[4:6],16)) + ('%c' % int(addr[6:8],16)) + \
- ('%c' % int(datasize,16)) + \
- ('%c' % int(cnt[0:2],16)) + ('%c' % int(cnt[2:4],16)) + ('%c' % int(cnt[4:6],16)) + ('%c' % int(cnt[6:8],16)) + \
- datatmp + ('%c' % int(ft,16))
-
- # for i in range(len(result)):
- # print '%02x' % ord(result[i]),
- #print cnt
- return result
-
-
- def consoleDump(tid):
- while 1:
- sys.stdout.write(tid.read(1))
- # print '%s' % tid.read(1),
-
-
-class USBDevice:
- """
- """
- def __init__(self, idVendor=0x15a2, idProduct=0x0041):
- # find our device
- dev = self.findDevice(idVendor, idProduct)
- # was it found?
- if dev is None:
- raise ValueError('MX28 not found')
- self.__dev = dev
-
- handle = dev.open()
- handle.setConfiguration(1) # choose the first configuration
- handle.claimInterface(0) # choose the first interface
- print('Found i.MX28')
-
- self.__devhandle = handle
- self.__epBulkIn = 0x82
- self.__epBulkOut = 1
- self.port = 'USB'
-
- def findDevice(self, idVendor, idProduct):
- """Find a USB device by product and vendor id."""
- for bus in usb.busses():
- for device in bus.devices:
- if device.idVendor == idVendor and device.idProduct == idProduct:
- return device
- return None
-
- def read(self, length):
- data = self.__devhandle.bulkRead(self.__epBulkIn, length, 100)
- return data
-
- def write(self, data):
- self.__devhandle.bulkWrite(self.__epBulkOut, data, 100)
-
- def flushInput(self):
- pass
class UBoot:
@@ -297,42 +73,60 @@ class UBoot:
def __getOutput(self, error_msg=None):
""" This function waits for U-Boot answer and returns it"""
- #debugser = serial.Serial("/dev/tty0",115200,timeout=1)
response = ""
while not re.search(r'BIOS>', response):
char = self.serial.read(1)
if char == '':
- raise Error(response)
+ print "serial timeout"
+ raise response
response = response + char
if error_msg!=None:
if re.search(error_msg,response):
raise Error("getOutput error")
-
sys.stdout.write(response)
- #debugser.write(char)
- #debugser.close()
return response
def resetEnv(self):
self.serial.write("run flash_reset_env\n")
return self.__getOutput()
+ def importEnv(self, addr, size):
+ self.serial.write("env import -t %08x %08x\n" % (addr, size))
+ return self.__getOutput()
+
def waitForPrompt(self):
time.sleep(1)
self.serial.write("\n")
- return self.__getOutput()
+ ret = self.__getOutput()
+ self.serial.flushInput()
+ return ret
def flash(self):
""" Ask U-Boot to flash itself """
- self.serial.write("run update_uboot\n")
+ time.sleep(1)
+ self.serial.flushInput()
+ self.serial.write("run flash_uboot\n")
try:
ret = self.__getOutput()
+ print ret
except Error,e:
raise Error("Flashing U-Boot")
if not re.search(r'uboot succeed',ret):
print ret
raise Error("U-Boot flash failed",0)
return ret
+
+ def reset(self):
+ """ Ask U-Boot to flash itself """
+ time.sleep(1)
+ self.serial.flushInput()
+ self.serial.write("reset\n")
+ try:
+ ret = self.__getOutput()
+ print ret
+ except Error,e:
+ raise Error("Reseting U-Boot")
+ return ret
if __name__ == "__main__":
@@ -340,6 +134,10 @@ if __name__ == "__main__":
SPEED = 115200
BINARY = "apf28-u-boot.sb"
USB_DOWNLOAD_APP = "../../buildroot/output/host/usr/bin/gnet-imx28-usb-downloader"
+ ELFTOSB_APP = "../../buildroot/output/host/usr/bin/elftosb"
+ NAND_BINARY = "apf28_nand_recover.sb"
+ ENV_RECOVER = "apf28_env_recover.txt"
+ ENV_DOWNLOAD = 0x41000100
print "\n--- APF28 Bootstrap Tool ---\n"
print "Procedure to follow:"
@@ -348,11 +146,8 @@ if __name__ == "__main__":
print "3] Power on your board"
print "4] Connect a USB cable from your PC to the APF28Dev OTG miniUSB connector"
print "5] Connect a USB cable from your PC to the APF28Dev console miniUSB connector"
- print "6] Connect an Ethernet cable (it is a temporary requirement for the current version)"
- print "7] Be sure to have a %s image in current dir too)" % BINARY
- print "8] Be sure to have built the APF28 BSP: make apf28_defconfig; make"
- print "9] Be sure to have installed apf28-u-boot.bin in your /tftpboot/"
- print "10] Have launched this script as root (sudo)\n"
+ print "6] Be sure to have built the APF28 BSP: make apf28_defconfig; make"
+ print "7] Have launched this script as root (sudo)\n"
port = raw_input('--- Enter serial port number or device name to use for console (/dev/ttyACM0 under Linux (default) or COMx under Window$): ')
if port is '':
port = '/dev/ttyACM0'
@@ -360,51 +155,78 @@ if __name__ == "__main__":
if not os.path.exists(USB_DOWNLOAD_APP):
raise Error("gnet-imx28-usb-downloader is not present: please compile Armadeus first ",0)
- #usb = USBDevice()
- #apfBootloader = apf28Bootloader(usb)
-
- #apfBootloader.getStatus()
- #clear configuration request
-
+ if not os.path.exists(ELFTOSB_APP):
+ raise Error("elftosb is not present: please compile Armadeus first ",0)
- #print "--- Successfully initialized APF28, now loading U-Boot"
if not os.path.exists(BINARY):
raise Error("file "+BINARY+" doesn't exit",0)
-
- fsize = "%08x" % os.path.getsize(BINARY) #os.stat(filesize)[6]
- print "Loading %s, size = %d bytes" % (BINARY, os.path.getsize(BINARY))
-
- #apfBootloader.download("90000000", BINARY, fsize, "AA")
+ print "Opening serial port %s.." % port
try:
- os.system(USB_DOWNLOAD_APP + " -f " + BINARY)
+ ser = serial.Serial(port, SPEED, timeout=4)
except Exception, msg:
- print "Failed to upload image file to the target !"
+ print "Unable to open serial port %s !" % port
print msg
sys.exit()
+ ser.flush()
+ uboot = UBoot(ser)
+
+ print "Building NAND image file %s.." % NAND_BINARY
+
+ fsize = "%08x" % os.path.getsize(BINARY)
+ envfile = open(ENV_RECOVER, 'w')
+ envfile.write("fileaddr=40000000\n")
+ envfile.write("filesize=%s\n" % fsize)
+ envfile.close()
+
+
try:
- ser = serial.Serial(port, SPEED, timeout=2)
+ os.system(ELFTOSB_APP + " -zdf imx28 -c apf28-u-boot_recover.bd -o " + NAND_BINARY)
except Exception, msg:
- print "Unable to open serial port %s !" % port
+ print "Failed to build build NAND image filet !"
print msg
+ os.remove(NAND_BINARY);
+ os.remove(ENV_RECOVER);
sys.exit()
- ser.flush()
- uboot = UBoot(ser)
+ print "Downloading NAND image file %s.." % NAND_BINARY
+ try:
+ os.system(USB_DOWNLOAD_APP + " -f " + NAND_BINARY)
+ except Exception, msg:
+ print "Failed to upload NAND image file to the target !"
+ print msg
+ os.remove(NAND_BINARY);
+ os.remove(ENV_RECOVER);
+ sys.exit()
- # execute loaded code:
- #apfBootloader.put("90000000", "90000004", "l")
- #self.bootstrap.getStatus() ?
+ os.remove(NAND_BINARY);
+
+ print "--- Successfully initialized APF28, now loading U-Boot"
+
+ print "Loading %s, size = %d bytes.." % (BINARY, os.path.getsize(BINARY))
+ time.sleep(4)
+
+ try:
+ os.system(USB_DOWNLOAD_APP + " -f " + BINARY)
+ except Exception, msg:
+ print "Failed to upload image file to the target !"
+ print msg
+ sys.exit()
uboot.waitForPrompt()
eraseAll = raw_input('\n--- Would you like to erase the environment variables ? y/N: ')
if eraseAll == 'y':
uboot.resetEnv()
- updateFlash = raw_input('\n--- Would you like to write U-Boot in Flash ? Y/n: ')
- if updateFlash != 'n':
- uboot.flash()
+
+ uboot.importEnv(ENV_DOWNLOAD, os.path.getsize(ENV_RECOVER))
+
+ os.remove(ENV_RECOVER);
+
+ print "Programming U-Boot in NAND flash.."
+ uboot.flash()
+
print "\n--- U-Boot successfully recovered !"
print "--- Now you can remove miniUSB OTG cable and bootstrap jumper. Your board is running..."
hooks/post-receive
--
armadeus
|