Permalink
Browse files

Merge branch 'fix/remove_jump_cmd'

  • Loading branch information...
blastur committed Sep 3, 2011
2 parents ae77297 + 1fa69c0 commit fe66f2e370019d90b9e70fccbdda5b82feceb535
Showing with 12 additions and 31 deletions.
  1. +5 −11 README
  2. +3 −10 magboot.c
  3. +4 −10 magboot.py
View
16 README
@@ -92,20 +92,14 @@ flashes a LED at 2 Hz (connected on Port B, PB5). Begin by building the testapp:
Proceed by uploading it using the python-script:
./magboot.py /dev/ttyUSB0 atmega328p -i -a 0x0 -w testapp/testapp.bin -a 0x0 -j
./magboot.py /dev/ttyUSB0 atmega328p -z -w testapp/testapp.bin -r
Magboot will execute the following commands:
- Verify device signature
- Set address to 0x0.
- Write file 'testapp/testapp.bin' to address (which we've set to 0x0 above)
- Set address to 0x0 again (write file will autoincrement)
- Jump to address (which we've set to 0x0)
- Wait for device to appear on /dev/ttyUSB0
- Write file 'testapp/testapp.bin' to beginning of flash memory
- Reset the device
If the jump succeeded and your device starts flashing at 2 Hz, the flash write
was successfull!
Optionally, the device may be reset using -r. This will cause the device to
reboot and bypass the bootloader.
If your device starts flashing at 2 Hz, the operation was successfull!
Software serial port support (ADVANCED)
================================================================================
View
@@ -88,7 +88,7 @@ static bool cmd_device_id(void)
return fail;
}
static bool cmd_jump(uint16_t addr)
static void jump(uint16_t addr)
{
jump_t func;
@@ -101,8 +101,6 @@ static bool cmd_jump(uint16_t addr)
wdt_disable();
func = (jump_t) addr;
func();
return false; /* Unreachable */
}
static bool cmd_reset(void)
@@ -114,12 +112,12 @@ static bool cmd_reset(void)
}
int main(void) {
uint16_t addr = JUMP_ADDR;
uint16_t addr = 0;
bool fail;
if (bit_is_clear(MCUSR, EXTRF)) {
/* Bypass magboot if reset caused by watchdog, power-on or brown-out */
cmd_jump(JUMP_ADDR);
jump(0);
} else
MCUSR &= ~(_BV(EXTRF));
@@ -151,11 +149,6 @@ int main(void) {
fail = cmd_reset();
break;
/* Jump to address */
case 'J':
fail = cmd_jump(addr);
break;
default:
fail = true;
break;
View
@@ -7,10 +7,8 @@
usage: magboot <port> <device> <[command1] [command2] ... [commandN]>
commands:
-a <addr> Load (byte) address (autoincremented by -w)
-w <file> Write contents of <file> to loaded address (use - for stdin)
-w <file> Write contents of <file> to beginning of flash (use - for stdin)
-i Verify device signature
-j Jump to loaded address
-r Reset device (will bypass bootloader on next boot)
-z Wait for device to appear on <port>
@@ -82,7 +80,7 @@ def cmd_device_id():
def cmd_load_addr(addr):
print "LOAD_ADDR"
# Little-endian, 16-bit uint load address
load_addr = pack('<H', int(addr, 16))
load_addr = pack('<H', addr)
do_cmd('A' + load_addr)
def cmd_write_file(fname):
@@ -94,6 +92,8 @@ def cmd_write_file(fname):
f = open(fname, "rb")
eof = False
cmd_load_addr(0);
while (not eof):
buf = array('c')
@@ -118,10 +118,6 @@ def cmd_reset():
print "RESET"
do_cmd('R', False)
def cmd_jump():
print "JUMP"
do_cmd('J', False)
def cmd_wait():
print "WAIT"
while True:
@@ -154,10 +150,8 @@ def cmd_wait():
ser.flushOutput()
for o, a in opts:
if o == '-a': cmd_load_addr(a)
if o == '-w': cmd_write_file(a)
if o == '-i': cmd_device_id()
if o == '-j': cmd_jump()
if o == '-r': cmd_reset()
if o == '-z': cmd_wait()

0 comments on commit fe66f2e

Please sign in to comment.