From f88dcfc14562d73a3a7d8191a8c2c4c3062a8599 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Mon, 14 Dec 2009 09:49:26 +0100 Subject: [PATCH] Revert "added receivebyte with timeout. sometimes it will just hang," This reverts commit 97455c66228fca7dfc8d0b1f397e01e98f1e3b6c. --- pkernel/kernel.py | 38 ++++++++++++++++---------------------- pkernel/main.c | 16 +++++----------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/pkernel/kernel.py b/pkernel/kernel.py index afadfcd..e495a86 100755 --- a/pkernel/kernel.py +++ b/pkernel/kernel.py @@ -11,22 +11,6 @@ def recvByte(): i = tty.read() return ord(i) -def recvByteTO(b): #with timeout - j = 0 - i = tty.read() - while len(i)==0 and j < 400: - time.sleep(0.03) - i = tty.read() - j = j + 1 - if j == 400: - print "ack it!" - sendByte(0x23) - if(recvByte() != 0xaa): - raise Exception #ok, something really failed - else: - if(ord(i) != b): - raise Exception - def sendByte(byte): time.sleep(0.005) # just to get sure, wait 5ms tty.write(chr(byte)) @@ -66,16 +50,28 @@ def pkernWRITE(address, size, data): print "address:", hex(address), "size:", size # send WRITE command sendByte(0x13) - recvByteTO(0x37) - + if (recvByte() != 0x37): + raise Exception # tell desired address and size sendDWord(address) sendWord(size) + if (recvByte() != 0x04): + raise Exception + print "Received Metadata." + # write binary stream of data for i in range(0, size): sendByte(data[i]) + if (recvByte() != 0x08): + raise Exception + print "Received Data." + + if (recvByte() != 0x28): + raise Exception + print "Flashing done." + class FlashSequence(object): def __init__(self, address, data): @@ -148,8 +144,6 @@ for seq in flashseqs: print "Flashing", len(seq.data), "bytes at address", hex(seq.address) pkernWRITE(seq.address, len(seq.data), seq.data) -#sendByte(0x99); #exit and wait -#print "Reset your board now to run code from Flash" - +sendByte(0x99); -sendByte(0x97); #exit and restart +print "Reset your board now to run code from Flash" diff --git a/pkernel/main.c b/pkernel/main.c index ac9c20b..c40924f 100644 --- a/pkernel/main.c +++ b/pkernel/main.c @@ -1,12 +1,13 @@ #include "mb91465k.h" #include "flash.h" -#define BUFSIZE 0x10 +#define BUFSIZE 0x20 #define cleardata() memset(data,0,BUFSIZE) static void increaseled(void) { PDR14 = ~(((~PDR14)+1)%256); + HWWD_CL = 0; } static unsigned char recvbyte(void) @@ -67,7 +68,6 @@ void main(void) while(running) { cleardata(); increaseled(); - switch(recvbyte()) { case 0x15: //chip erase Putch4(0x45); @@ -106,11 +106,13 @@ void main(void) size = recvword(); increaseled(); + Putch4(0x04); //Received Metadata. PDR14 = 0xff; for(i=0; i