aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2014-04-29 19:56:39 -0700
committerMarti Bolivar <mbolivar@leaflabs.com>2014-04-29 19:56:39 -0700
commit746d6fecf86572c9fe95dbbffdf541a8d3875dd0 (patch)
tree8dc7170e295756116dcdc9e973dee028b9cb2454 /support
parent139e4b1a1ae547540d32aa66d47c4e69b1b57bbf (diff)
parent731e2ab24755b3706daf7d64eaa53f2ec0512277 (diff)
downloadlibrambutan-746d6fecf86572c9fe95dbbffdf541a8d3875dd0.tar.gz
librambutan-746d6fecf86572c9fe95dbbffdf541a8d3875dd0.zip
Merge pull request #89 from Gregwar/bootloader-option
Adding BOOTLOADER option to support Robotis bootloader different ROM
Diffstat (limited to 'support')
-rw-r--r--support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc5
-rw-r--r--support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc5
-rw-r--r--support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc5
-rw-r--r--support/make/board-includes/cm900.mk5
-rw-r--r--support/make/board-includes/opencm904.mk5
-rwxr-xr-xsupport/scripts/robotis-loader.py94
6 files changed, 119 insertions, 0 deletions
diff --git a/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc b/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc
new file mode 100644
index 0000000..2c03ea9
--- /dev/null
+++ b/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-flash.inc
@@ -0,0 +1,5 @@
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
+ rom (rx) : ORIGIN = 0x08003000, LENGTH = 108K
+}
diff --git a/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc b/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc
new file mode 100644
index 0000000..20fbec0
--- /dev/null
+++ b/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-jtag.inc
@@ -0,0 +1,5 @@
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
+ rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
+}
diff --git a/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc b/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc
new file mode 100644
index 0000000..f02453b
--- /dev/null
+++ b/support/ld/stm32/mem/sram_20k_flash_128k_robotis/mem-ram.inc
@@ -0,0 +1,5 @@
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K
+ rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K
+}
diff --git a/support/make/board-includes/cm900.mk b/support/make/board-includes/cm900.mk
index f9a09ac..9f70a1b 100644
--- a/support/make/board-includes/cm900.mk
+++ b/support/make/board-includes/cm900.mk
@@ -7,4 +7,9 @@ MCU_F1_LINE := performance
# This crap is due to ld-script limitations. If you know of a better
# way to go about this (like some magic ld switches to specify MEMORY
# at the command line), please tell us!
+ifeq ($(BOOTLOADER),maple)
LD_MEM_DIR := sram_20k_flash_128k
+endif
+ifeq ($(BOOTLOADER),robotis)
+LD_MEM_DIR := sram_20k_flash_128k_robotis
+endif
diff --git a/support/make/board-includes/opencm904.mk b/support/make/board-includes/opencm904.mk
index f3a4aa7..64d3351 100644
--- a/support/make/board-includes/opencm904.mk
+++ b/support/make/board-includes/opencm904.mk
@@ -7,4 +7,9 @@ MCU_F1_LINE := performance
# This crap is due to ld-script limitations. If you know of a better
# way to go about this (like some magic ld switches to specify MEMORY
# at the command line), please tell us!
+ifeq ($(BOOTLOADER),maple)
LD_MEM_DIR := sram_20k_flash_128k
+endif
+ifeq ($(BOOTLOADER),robotis)
+LD_MEM_DIR := sram_20k_flash_128k_robotis
+endif
diff --git a/support/scripts/robotis-loader.py b/support/scripts/robotis-loader.py
new file mode 100755
index 0000000..95d4e71
--- /dev/null
+++ b/support/scripts/robotis-loader.py
@@ -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)