-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from Gregwar/bootloader-option
Adding BOOTLOADER option to support Robotis bootloader different ROM
- Loading branch information
Showing
9 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MEMORY | ||
{ | ||
ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K | ||
rom (rx) : ORIGIN = 0x08003000, LENGTH = 108K | ||
} |
5 changes: 5 additions & 0 deletions
5
support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MEMORY | ||
{ | ||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K | ||
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MEMORY | ||
{ | ||
ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K | ||
rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/python | ||
|
||
# This script sends a program on a robotis board (OpenCM9.04 or CM900) | ||
# using the robotis bootloader (used in OpenCM IDE) | ||
# | ||
# Usage: | ||
# python robotis-loader.py <serial port> <binary> | ||
# | ||
# Example: | ||
# python robotis-loader.py /dev/ttyACM0 firmware.bin | ||
# | ||
# https://github.com/Gregwar/robotis-loader | ||
|
||
import serial, sys, os, time | ||
|
||
print('~~ Robotis loader ~~') | ||
print('') | ||
|
||
# Reading command line | ||
if len(sys.argv) != 3: | ||
exit('! Usage: robotis-loader.py <serial-port> <binary>') | ||
pgm, port, binary = sys.argv | ||
|
||
# Helper to prints a progress bar | ||
def progressBar(percent, precision=65): | ||
threshold=precision*percent/100.0 | ||
sys.stdout.write('[ ') | ||
for x in xrange(0, precision): | ||
if x < threshold: sys.stdout.write('#') | ||
else: sys.stdout.write(' ') | ||
sys.stdout.write(' ] ') | ||
sys.stdout.flush() | ||
|
||
# Opening the firmware file | ||
try: | ||
stat = os.stat(binary) | ||
size = stat.st_size | ||
firmware = file(binary, 'rb') | ||
print('* Opening %s, size=%d' % (binary, size)) | ||
except: | ||
exit('! Unable to open file %s' % binary) | ||
|
||
# Opening serial port | ||
try: | ||
s = serial.Serial(port, baudrate=115200) | ||
except: | ||
exit('! Unable to open serial port %s' % port) | ||
|
||
print('* Resetting the board') | ||
s.setRTS(True) | ||
s.setDTR(False) | ||
time.sleep(0.1) | ||
s.setRTS(False) | ||
s.write('CM9X') | ||
s.close() | ||
time.sleep(1.0); | ||
|
||
print('* Connecting...') | ||
s = serial.Serial(port, baudrate=115200) | ||
s.write('AT&LD') | ||
print('* Download signal transmitted, waiting...') | ||
|
||
# Entering bootloader sequence | ||
while True: | ||
line = s.readline().strip() | ||
if line.endswith('Ready..'): | ||
print('* Board ready, sending data') | ||
cs = 0 | ||
pos = 0 | ||
while True: | ||
c = firmware.read(2048) | ||
if len(c): | ||
pos += len(c) | ||
sys.stdout.write("\r") | ||
progressBar(100*float(pos)/float(size)) | ||
s.write(c) | ||
for k in range(0,len(c)): | ||
cs = (cs+ord(c[k]))%256 | ||
else: | ||
break | ||
print('') | ||
s.setDTR(True) | ||
print('* Checksum: %d' % (cs)) | ||
s.write(chr(cs)) | ||
print('* Firmware was sent') | ||
else: | ||
if line == 'Success..': | ||
print('* Success, running the code') | ||
print('') | ||
s.write('AT&RST') | ||
s.close() | ||
exit() | ||
else: | ||
print('Board -> '+line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters