├── scripts ├── README.md ├── path_env.sh └── release_serial.sh ├── bin ├── README.md ├── install_node.sh ├── install_elua_bin.sh ├── install_espruino_bin.sh └── install_toolchain.sh ├── src ├── tools │ ├── arminarm.tcl │ ├── stm32control.py │ ├── espruino_cmd │ ├── arminarm │ └── stm32loader.py ├── update_libopencm3-prj.sh ├── update_cmsis_stdperiph.sh ├── update_elua.sh ├── update_espruino.sh ├── update_libmaple.sh ├── update_dfu-util.sh ├── update_stm32flash.sh ├── update_esp_cli.sh ├── update_openocd.sh ├── update_stlink.sh └── README.md ├── .gitignore ├── README.md ├── setup └── LICENSE /scripts/README.md: -------------------------------------------------------------------------------- 1 | This is the directory for generic install scripts. 2 | 3 | - release serial 4 | - /opt/arminarm/bin + /opt/arminarm/tools in PATH 5 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | This is the directory where the precompiled, binary files are downloaded 2 | 3 | - arm-none-eabi toolchain 4 | - elua.bin 5 | - espruino.bin 6 | - node.js 7 | -------------------------------------------------------------------------------- /src/tools/arminarm.tcl: -------------------------------------------------------------------------------- 1 | source [find /usr/share/openocd/scripts/interface/sysfsgpio-raspberrypi.cfg] 2 | set _CHIPNAME stm32f1x 3 | 4 | source [find /usr/share/openocd/scripts/target/stm32f1x.cfg] 5 | $_TARGETNAME configure -event gdb-attach { reset init } 6 | -------------------------------------------------------------------------------- /bin/install_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #https://learn.adafruit.com/raspberry-pi-hosting-node-red/setting-up-node-dot-js 4 | #http://howtonode.org/introduction-to-npm 5 | 6 | wget http://node-arm.herokuapp.com/node_latest_armhf.deb 7 | sudo dpkg -i node_latest_armhf.deb 8 | 9 | node -v 10 | 11 | #sudo npm -g install express 12 | -------------------------------------------------------------------------------- /src/update_libopencm3-prj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d libopencm3-prj ]; then 4 | echo "Directory exists: updating" 5 | cd libopencm3-prj 6 | git pull 7 | else 8 | echo "First time git clone: installing" 9 | git clone https://github.com/ARMinARM/libopencm3-prj 10 | cd libopencm3-prj 11 | fi 12 | 13 | ./bootstrap.sh 14 | 15 | cd .. 16 | -------------------------------------------------------------------------------- /src/update_cmsis_stdperiph.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d CMSIS_StdPeriph ]; then 4 | echo "Directory exists: updating" 5 | cd CMSIS_StdPeriph 6 | git pull 7 | # make 8 | cd .. 9 | 10 | else 11 | echo "First time git clone: installing" 12 | git clone https://github.com/ARMinARM/CMSIS_StdPeriph/ 13 | cd CMSIS_StdPeriph 14 | # make 15 | cd .. 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/arm-toolchain-bin* 2 | bin/espruino* 3 | bin/node* 4 | bin/elua* 5 | 6 | scripts/rpi-serial-console 7 | 8 | src/CMSIS_StdPeriph/ 9 | src/elua/ 10 | src/esp-cli/ 11 | src/Espruino/ 12 | src/libmaple/ 13 | src/libopencm3-examples/ 14 | src/libopencm3-prj/ 15 | src/openocd-arminarm/ 16 | src/openocd/ 17 | src/stlink/ 18 | src/stm32flash/ 19 | src/dfu-util/ 20 | -------------------------------------------------------------------------------- /bin/install_elua_bin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ELUA=elua_lua_arminarm.bin 4 | URL=https://github.com/ARMinARM/arminarm-bin/raw/master/$ELUA 5 | 6 | if [ ! -f $ELUA ]; then 7 | echo "elua_lua_arminarm.bin not found. Getting it from github." 8 | wget $URL 9 | fi 10 | 11 | if [ -f $ELUA ]; then 12 | echo "Found elua_lua_arminarm.bin" 13 | arminarm flash $ELUA 14 | fi 15 | -------------------------------------------------------------------------------- /scripts/path_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #export PATH=$PATH:/opt/arminarm/bin 4 | #export PATH=$PATH:/opt/arminarm/tools 5 | 6 | cd ~ 7 | echo -n ".bashrc: " 8 | if [ -f .bashrc.bak ]; then 9 | echo "Backup exists: not overwriting" 10 | echo $PATH 11 | else 12 | cp -a .bashrc .bashrc.bak 13 | echo "PATH=\$PATH:/opt/arminarm" >> .bashrc 14 | echo $PATH 15 | fi 16 | -------------------------------------------------------------------------------- /src/update_elua.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d elua ]; then 4 | echo "Directory exists: updating" 5 | cd elua 6 | # git checkout arminarm 7 | git pull 8 | # make 9 | cd .. 10 | 11 | else 12 | echo "First time git clone: installing" 13 | git clone https://github.com/ARMinARM/elua/ 14 | cd elua 15 | # git checkout arminarm 16 | # make 17 | cd .. 18 | fi 19 | 20 | -------------------------------------------------------------------------------- /bin/install_espruino_bin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ESPRUINO=espruino_1v83_ARMinARM.bin 4 | URL=https://github.com/ARMinARM/arminarm-bin/raw/master/$ESPRUINO 5 | 6 | if [ ! -f $ESPRUINO ]; then 7 | echo "espruino_ARMinARM.bin not found. Getting it from github." 8 | wget $URL 9 | fi 10 | 11 | if [ -f $ESPRUINO ]; then 12 | echo "Found espruino_ARMinARM.bin" 13 | arminarm flash $ESPRUINO 14 | fi 15 | -------------------------------------------------------------------------------- /src/update_espruino.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d Espruino ]; then 4 | echo "Directory exists: updating" 5 | cd Espruino 6 | git pull 7 | else 8 | echo "First time git clone: installing" 9 | git clone https://github.com/espruino/Espruino/ 10 | cd Espruino 11 | fi 12 | 13 | #release 1v83 14 | #git checkout aca85851976cc26fb452e867f17975ec0c9dbe8d 15 | ARMINARM=1 RELEASE=1 make 16 | cd .. 17 | -------------------------------------------------------------------------------- /src/update_libmaple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d libmaple ]; then 4 | echo "Directory exists: updating" 5 | else 6 | echo "First time git clone: installing" 7 | git clone https://github.com/ARMinARM/libmaple 8 | fi 9 | 10 | cd libmaple 11 | git checkout arminarm 12 | git pull 13 | cd .. 14 | 15 | # usage: 16 | # Have your main.cpp in the root libmaple directory 17 | # make BOARD=arminarm MEMORY_TARGET=jtag 18 | # arminarm flash build/arminarm.bin 19 | 20 | -------------------------------------------------------------------------------- /src/update_dfu-util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d dfu-util ]; then 4 | echo "Directory exists: updating" 5 | cd dfu-util 6 | make maintainer-clean 7 | git pull 8 | ./autogen.sh 9 | ./configure 10 | make 11 | sudo make install 12 | cd .. 13 | 14 | else 15 | echo "First time git clone: installing" 16 | git clone git://git.code.sf.net/p/dfu-util/dfu-util 17 | cd dfu-util 18 | ./autogen.sh 19 | ./configure 20 | make 21 | sudo make install 22 | cd .. 23 | fi 24 | 25 | -------------------------------------------------------------------------------- /src/update_stm32flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d stm32flash ]; then 4 | echo "Directory exists: updating" 5 | cd stm32flash 6 | make clean 7 | git pull 8 | else 9 | echo "First time git clone: installing" 10 | # git clone https://gitorious.org/stm32flash/stm32flash.git 11 | # git clone https://github.com/ARMinARM/stm32flash 12 | git clone git://git.code.sf.net/p/stm32flash/code stm32flash 13 | cd stm32flash 14 | fi 15 | 16 | make 17 | sudo make install 18 | 19 | cd .. 20 | -------------------------------------------------------------------------------- /src/update_esp_cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # http://howtonode.org/introduction-to-npm 4 | 5 | if [ -d esp-cli ]; then 6 | echo "Directory exists: updating" 7 | cd esp-cli 8 | git checkout arminarm 9 | git pull 10 | npm update serialport 11 | npm update async 12 | else 13 | echo "First time git clone: installing" 14 | git clone https://github.com/ARMinARM/esp-cli/ 15 | cd esp-cli 16 | git checkout arminarm 17 | git pull 18 | npm install serialport 19 | npm install async 20 | fi 21 | 22 | sudo npm link 23 | cd .. 24 | -------------------------------------------------------------------------------- /scripts/release_serial.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #from: https://github.com/asb/raspi-config/blob/master/raspi-config 4 | 5 | do_serial() { 6 | if [ ! -f /etc/inittab ]; then 7 | touch /etc/inittab 8 | fi 9 | 10 | RET=$1 11 | if [ $RET -eq 1 ]; then 12 | sed -i /etc/inittab -e "s|^.*:.*:respawn:.*ttyAMA0|#&|" 13 | sed -i /boot/cmdline.txt -e "s/console=ttyAMA0,[0-9]\+ //" 14 | echo "Serial is now disabled. Please reboot!" 15 | elif [ $RET -eq 0 ]; then 16 | sed -i /etc/inittab -e "s|^#\(.*:.*:respawn:.*ttyAMA0\)|\1|" 17 | if ! grep -q "^T.*:.*:respawn:.*ttyAMA0" /etc/inittab; then 18 | printf "T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100\n" >> /etc/inittab 19 | fi 20 | if ! grep -q "console=ttyAMA0" /boot/cmdline.txt; then 21 | sed -i /boot/cmdline.txt -e "s/root=/console=ttyAMA0,115200 root=/" 22 | fi 23 | echo "Serial is now enabled. Please reboot!" 24 | else 25 | return $RET 26 | fi 27 | } 28 | 29 | do_serial $1 30 | -------------------------------------------------------------------------------- /src/update_openocd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d openocd ]; then 4 | echo "Directory exists: updating" 5 | cd openocd 6 | git pull 7 | # assume we're already bootstrapped and configured 8 | else 9 | echo "First time git clone: installing" 10 | git clone git://git.code.sf.net/p/openocd/code openocd 11 | cd openocd 12 | 13 | wget https://raw.githubusercontent.com/ARMinARM/openocd-arminarm/master/tcl/interface/sysfsgpio-raspberrypi.cfg 14 | mv sysfsgpio-raspberrypi.cfg tcl/interface 15 | 16 | wget https://raw.githubusercontent.com/ARMinARM/openocd-arminarm/master/tcl/interface/raspberrypi-native.cfg 17 | mv raspberrypi-native.cfg tcl/interface 18 | 19 | ./bootstrap 20 | ./configure --enable-sysfsgpio --enable-bcm2835gpio --enable-buspirate --prefix=/usr 21 | fi 22 | 23 | make 24 | sudo make install 25 | 26 | cd .. 27 | 28 | # usage: 29 | # sudo openocd -s /usr/share/openocd/scripts -f /opt/arminarm/tools/arminarm.tcl 30 | 31 | # arm-none-eabi-gdb 32 | # target extended-remote localhost:3333 33 | # [do your thing] 34 | 35 | -------------------------------------------------------------------------------- /bin/install_toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROCESSOR=`cat /proc/cpuinfo | grep Hardware | awk '{ print $3 }'` 4 | 5 | if [ "$PROCESSOR" == "BCM2708" ]; then 6 | echo "$PROCESSOR found: Pi 1" 7 | ARMINARM=arm-toolchain-bin-2014-06-20-raspbian.tar.gz 8 | elif [ "$PROCESSOR" == "BCM2709" ]; then 9 | echo "$PROCESSOR found: Pi 2" 10 | #ARMINARM=arm-toolchain-bin-2015-02-04-raspbian.tar.gz 11 | ARMINARM=arm-toolchain-bin-2014-06-20-raspbian.tar.gz 12 | else 13 | echo "unknown processor" 14 | ARMINARM=arm-toolchain-bin-2014-06-20-raspbian.tar.gz 15 | exit 16 | fi 17 | 18 | URL=https://raw.githubusercontent.com/ARMinARM/arminarm-bin/master/$ARMINARM 19 | 20 | if [ ! -f $ARMINARM ]; then 21 | echo "toolchain tar.gz not found. Getting it from github." 22 | wget $URL 23 | fi 24 | 25 | if [ -f $ARMINARM ]; then 26 | echo "Found toolchain tar.gz" 27 | mkdir arminarm 28 | cd arminarm 29 | tar -xzvf ../$ARMINARM || { echo "Error extracting "$ARMINARM; exit; } 30 | cd .. 31 | sudo rm -rf /opt/arminarm/ 32 | sudo mv arminarm/ /opt/ 33 | export PATH=$PATH:/opt/arminarm/bin 34 | echo "Installed OK" 35 | fi 36 | -------------------------------------------------------------------------------- /src/update_stlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # http://www.support.code-red-tech.com/CodeRedWiki/HardwareDebugConnections 4 | 5 | # Pin # CN2 # Designation 6 | # 1 VDD_TARGET # VDD from application # ( = VDD, DNC when powered from Pi) 7 | # 2 SWCLK # SWD clock # ( = JTCK / PA14) 8 | # 3 GND # Ground # ( = GND) 9 | # 4 SWDIO # SWD data input/output # ( = TMS / PA13) 10 | # 5 NRST # RESET of target MCU # ( = NRST) 11 | # 6 SWO # Reserved # ( = JTDO / PB3 (optional)) 12 | 13 | #sudo apt-get install autoconf 14 | #sudo apt-get install libusb-1.0-0-dev 15 | 16 | git clone https://github.com/texane/stlink 17 | cd stlink 18 | ./autogen.sh 19 | ./configure 20 | make 21 | sudo make install 22 | 23 | sudo cp 49-stlinkv2.rules /etc/udev/rules.d/ 24 | sudo udevadm control --reload-rules 25 | # unplug + replug st-link v2 usb device 26 | 27 | 28 | 29 | #For flashing with an ST-Link V2 or Fx-Discovery. 30 | #st-flash --reset write build/leds.bin 0x08000000 31 | 32 | #For debugging with an ST-Link V2 or Fx-Discovery. 33 | #st-util 34 | 35 | #In another terminal: 36 | #arm-none-eabi-gdb 37 | #(gdb) target extended-remote :4242 38 | #(gdb) load build/leds.elf 39 | #(gdb) r 40 | -------------------------------------------------------------------------------- /src/tools/stm32control.py: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | import time, sys 3 | import RPi.GPIO as GPIO 4 | 5 | GPIO.setmode(GPIO.BOARD) 6 | GPIO.setwarnings(False) 7 | 8 | NRST = 7 #GPIO4 9 | BOOT0 = 26 #GPIO7 10 | 11 | SHORT = 0.1 12 | LONG = 0.5 13 | VERYLONG = 1.0 14 | 15 | 16 | def setup(): 17 | print "GPIO version: " + str(GPIO.VERSION) 18 | print "Pi revision " + str(GPIO.RPI_REVISION) 19 | 20 | 21 | def clean(): 22 | print "cleaning up..." 23 | GPIO.cleanup() 24 | print "done." 25 | 26 | 27 | def reset_stm32(): 28 | GPIO.setup(NRST, GPIO.OUT) # False for reset 29 | 30 | #print "NRST" 31 | GPIO.output(NRST, False) 32 | time.sleep(SHORT) 33 | GPIO.output(NRST, True) 34 | GPIO.setup(NRST, GPIO.IN) # back to input 35 | time.sleep(SHORT) 36 | 37 | 38 | def enterbootloader(): 39 | GPIO.setup(BOOT0, GPIO.OUT) # True for system bootloader 40 | 41 | #print "BOOT0" 42 | GPIO.output(BOOT0, True) 43 | time.sleep(SHORT) 44 | 45 | reset_stm32() 46 | 47 | time.sleep(SHORT) 48 | 49 | GPIO.output(BOOT0, False) 50 | time.sleep(SHORT) 51 | 52 | GPIO.setup(BOOT0, GPIO.IN) # back to input 53 | 54 | 55 | def main(): 56 | pass 57 | 58 | if __name__ == "__main__": 59 | sys.exit(main()) 60 | -------------------------------------------------------------------------------- /src/tools/espruino_cmd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This file is part of Espruino, a JavaScript interpreter for Microcontrollers 4 | # 5 | # Copyright (C) 2013 Gordon Williams 6 | # 7 | # This Source Code Form is subject to the terms of the Mozilla Public 8 | # License, v. 2.0. If a copy of the MPL was not distributed with this 9 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | # 11 | # ---------------------------------------------------------------------------------------- 12 | # Simple example code for sending a command to Espruino 13 | # ---------------------------------------------------------------------------------------- 14 | 15 | import time 16 | import serial 17 | import sys 18 | import json 19 | 20 | def espruino_cmd(command): 21 | ser = serial.Serial( 22 | port='/dev/ttyAMA0', # or /dev/ACM0 for serial over USB on linux 23 | baudrate=9600, 24 | parity=serial.PARITY_NONE, 25 | stopbits=serial.STOPBITS_ONE, 26 | bytesize=serial.EIGHTBITS, 27 | xonxoff=0, rtscts=0, dsrdtr=0, 28 | ) 29 | ser.isOpen() 30 | ser.write(command+"\n") 31 | endtime = time.time()+0.2 # wait 0.2 sec 32 | result = "" 33 | while time.time() < endtime: 34 | while ser.inWaiting() > 0: 35 | result=result+ser.read(1) 36 | ser.close() 37 | return result 38 | 39 | # Read 1 analog 40 | #print espruino_cmd("print(analogRead(A1))").strip() 41 | # Read 3 analogs into an array 42 | #print espruino_cmd("print([analogRead(A1),analogRead(A2),analogRead(A3)])").strip().split(',') 43 | 44 | if len(sys.argv)!=2: 45 | print "USAGE: espruino_cmd "+'"'+"print('hello')"+'"' 46 | exit(1) 47 | 48 | print espruino_cmd(sys.argv[1]).strip() 49 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | Libraries for the ARMinARM board 2 | ================================ 3 | 4 | The ARMinARM board can be used with a variety of different libraries. It's up to you how you want to use your board and what software you want to run on it. 5 | 6 | Currently, the following projects/libraries are supported: 7 | 8 | * CMSIS/StdPeriph (vendor supplied libraries) 9 | * Espruino + esp-cli (javascript interpreter) 10 | * eLua (Lua interpreter) 11 | * libmaple (Arduino compatible library) 12 | * libopencm3 (abstraction layer for CMSIS) 13 | 14 | For debugging, you can use: 15 | 16 | * OpenOCD (JTAG debugging on the Raspberry Pi) 17 | * ST-Link (SWD debugging with extra hardware) 18 | 19 | You can run low level 'bare metal' code with or without the help of CMSIS, the StdPeriph library or libopencm3. You can debug your code with either OpenOCD's sysfsgpio interface on the Raspberry Pi itself, or attach an external ST-LinkV2 compatible debugger and use stlink. 20 | 21 | A little bit easier to program would be to use the libmaple library. Libmaple is developed by Leaflabs, and uses the same syntax as Arduino. You'll write c and/or c++, but if you're familiar with Arduino, you'll feel right at home. 22 | 23 | A precompiled eLua binary (and the source code) is provided for those into Lua. 24 | 25 | And then there's Espruino. A fairly new project, but very promising. Event based programming in javascript. It doesn't get easier than that. 26 | 27 | In general -unless specifically stated otherwise- these projects are already in, or downloaded to the 'arminarm/src' directory. After you've selected the project to Install/Update in 'setup' and it has finished downloading and updating, navigate to the project in the 'src' directory, and run 'make'. For example: 28 | 29 | cd src/CMSIS_StdPeriph/examples/leds 30 | make 31 | 32 | Upload the resulting .bin file with the 'arminarm' tool. 33 | 34 | arminarm flash build/leds.bin 35 | -------------------------------------------------------------------------------- /src/tools/arminarm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CMD="$1" 4 | FILE="$2" 5 | TOOL="stm32flash" 6 | 7 | PORT=/dev/ttyAMA0 8 | BAUD=115200 9 | STM32FLASH=/usr/local/bin/stm32flash 10 | STM32LOADER=/opt/arminarm/stm32loader.py 11 | 12 | usage() 13 | { 14 | echo "Usage: arminarm [options] 15 | 16 | [options] is any of the following: 17 | -f flash uploads to ARMinARM board 18 | -r reset reset to Flash start (0x8000000) 19 | -b bootloader reset to SRAM (bootloader mode) 20 | -l loader use stm32loader.py (stm32flash is default) 21 | -d debug start openocd server on localhost:3333 22 | -h help show this info 23 | 24 | deprecated (but still works): 25 | arminarm flash please use: -f 26 | arminarm reset please use: -r 27 | arminarm bootloader please use: -b 28 | arminarm openocd please use: -d 29 | 30 | stm32loader.py fallback: 31 | arminarm -lf blinky.bin upload using stm32loader.py 32 | arminarm -lr reset to Flash using stm32loader.py 33 | arminarm -lb reset to SRAM using stm32loader.py 34 | 35 | suggested usage: 36 | arminarm -f blinky.bin upload using stm32flash 37 | arminarm -r reset to Flash start (0x8000000) 38 | arminarm -b reset to SRAM (bootloader mode) 39 | arminarm -d start openocd server on localhost:3333 40 | arminarm -h show this info 41 | " 42 | } 43 | 44 | 45 | while getopts ":hlbrdf:" opt; do 46 | case $opt in 47 | h) 48 | CMD="help" 49 | ;; 50 | l) 51 | #TOOL was "stm32flash" 52 | TOOL="stm32loader.py" 53 | ;; 54 | b) 55 | CMD="bootloader" 56 | ;; 57 | r) 58 | CMD="reset" 59 | ;; 60 | d) 61 | CMD="openocd" 62 | ;; 63 | f) 64 | CMD="flash" 65 | FILE="$OPTARG" 66 | ;; 67 | \?) 68 | echo "Invalid option: -$OPTARG" 69 | CMD="$OPTARG" 70 | usage 71 | exit 1 72 | ;; 73 | :) 74 | echo "Option -$OPTARG requires an argument." 75 | usage 76 | exit 1 77 | ;; 78 | esac 79 | done 80 | 81 | if [ "$CMD" == "reset" ]; then 82 | if [ "$TOOL" == "stm32flash" ]; then 83 | echo "reset using stm32flash" 84 | sudo $STM32FLASH -b $BAUD $PORT -i 7,-4,4:-7,-4,4 -R 85 | else 86 | echo "reset using stm32loader" 87 | sudo $STM32LOADER -p $PORT -t 88 | fi 89 | elif [ "$CMD" == "bootloader" ]; then 90 | if [ "$TOOL" == "stm32flash" ]; then 91 | echo "reset to bootloader using stm32flash" 92 | sudo $STM32FLASH -b $BAUD $PORT -i 7,-4,4:-7,-4,4 93 | else 94 | echo "reset to bootloader using stm32loader" 95 | sudo $STM32LOADER -p $PORT -o 96 | fi 97 | elif [ "$CMD" == "flash" ]; then 98 | if [ "$TOOL" == "stm32flash" ]; then 99 | echo "flashing $FILE using stm32flash" 100 | sudo $STM32FLASH -b $BAUD $PORT -i 7,-4,4:-7,-4,4 -v -w $FILE -R 101 | else 102 | echo "flashing $FILE using stm32loader" 103 | sudo $STM32LOADER -p $PORT -e -v -w $FILE 104 | fi 105 | elif [ "$CMD" == "openocd" ]; then 106 | sudo openocd -s /usr/share/openocd/scripts -f /opt/arminarm/tools/arminarm.tcl 107 | elif [ "$CMD" == "help" ]; then 108 | usage 109 | elif [ "$CMD" == "" ]; then 110 | usage 111 | else 112 | echo CMD = "${CMD}" 113 | echo TOOL = "${TOOL}" 114 | echo FILE = "${FILE}" 115 | echo "" 116 | 117 | usage 118 | fi 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ARMinARM software install scripts 2 | ================================= 3 | 4 | The ARMinARM installation scripts assume you're running an up-to-date Raspbian Jessie distribution on your Raspberry Pi. Other distributions will probably also work, but you may need to install additional software. 5 | 6 | sudo apt-get update 7 | sudo apt-get upgrade 8 | 9 | You'll want to install the following additional packages on Raspbian Jessie 2015-11-21 or newer: 10 | 11 | sudo apt-get install minicom screen autoconf libusb-1.0-0-dev libtool libftdi-dev texinfo 12 | 13 | Setup and install software for the ARMinARM board by cloning the repository from github, and run setup. 14 | 15 | git clone https://github.com/ARMinARM/arminarm 16 | cd arminarm 17 | ./setup 18 | 19 | When you run setup, you'll see a menu. 20 | 21 | ####################################################################### 22 | # ARMinARM # 23 | ####################################################################### 24 | 25 | Essentials: 26 | 0) Update Self 27 | 1) Update/Install ARMinARM + GCC Toolchain 28 | 2) Add /opt/arminarm* to PATH env (needs reboot) 29 | 3) Disable serial port (required for ARMinARM board, needs reboot) 30 | 4) Enable serial port (for booting RPI over serial port, default) 31 | 32 | Fast start: 33 | 10) Upload espruino.bin to ARMinARM board 34 | 11) Upload elua.bin to ARMinARM board 35 | 36 | Source code: 37 | a) Update/Install CMSIS_StdPeriph Examples 38 | b) Update/Install Espruino source code 39 | c) Update/Install esp-cli 40 | d) Update/Install eLua source code 41 | e) Update/Install libmaple 42 | f) Update/Install libopencm3-prj 43 | g) Update/Install OpenOCD 44 | h) Update/Install ST-Link 45 | i) Update/Install dfu-util 46 | j) Update/Install stm32flash 47 | 48 | q) Quit 49 | 50 | Enter your choice: 51 | 52 | You'll want to run the numeric options (0-3) at least once, to install all the basic tools and make the serial port available. 53 | 54 | The alfabetic options (a-j) installs optional tools, frameworks or projects. Install all of them, or pick and choose as you like. If you want to start right away, choose option 10 (espruino) or 11 (elua). After you uploaded one of them, start 'minicom' or 'screen' to start an interactive session. Espruino communicates on 9600 baud, elua on 115200. Both use /dev/ttyAMA0 as the serial port. 55 | 56 | Toolchain (arm-none-eabi-gcc) 57 | ============================= 58 | 59 | Since Raspbian Jessie, the toolchain that's installed is arm-none-eabi-gcc from the standard Jessie repositories (gcc, gdb, binutils, newlib). This is recommended. 60 | 61 | If you must use Wheezy, run `install_toolchain.sh` in the `bin` directory manually in stead of installing the toolchain from the setup menu. 62 | 63 | Tools 64 | ===== 65 | A set of tools for uploading firmware to the STM32 on the ARMinARM board come with the toolchain. The tool 'arminarm' is automatically installed to /opt/arminarm when you install the toolchain from the 'setup' menu. It uses the default bootloader that's available on every STM32 chip. 66 | 67 | Under the hood, communicating with the bootloader is done with one of two tools: [stm32flash](https://code.google.com/p/stm32flash/), or a modified [stm32loader.py](https://github.com/jsnyder/stm32loader). They both work well, but you may find stm32flash has a somewhat cleaner interface, and handles errors a little better. The default is to use stm32flash. When adding the -l flag, stm32loader.py is used. 68 | 69 | Whatever firmware you have compiled (say 'blinky.bin'), you can upload it with: 70 | 71 | arminarm flash path/to/blinky.bin # deprecated 72 | arminarm -f path/to/blinky.bin # use stm32flash 73 | arminarm -lf path/to/blinky.bin # use stm32loader.py 74 | 75 | To reset the STM32 on the ARMinARM board: 76 | 77 | arminarm reset # deprecated 78 | arminarm -r # use stm32flash 79 | arminarm -lr # use stm32loader.py 80 | 81 | To put the STM32 in bootloader mode: 82 | 83 | arminarm bootloader # deprecated 84 | arminarm -b # use stm32flash 85 | arminarm -lb # use stm32loader.py 86 | 87 | To start openocd server using sysfsgpio interface: 88 | 89 | arminarm openocd # deprecated 90 | arminarm -d 91 | 92 | Connect to it in arm-none-eabi-gdb using: 93 | 94 | (gdb) target extended-remote localhost:3333 95 | 96 | You can only use the tool 'arminarm' if the path to it (/opt/arminarm/tools) is added to your PATH environment variable. There's a menu option in 'setup' to do this for you. You only have to run this option once. The path is remembered even after reboots. 97 | 98 | Put jumpers on the first 2 and last 2 set of pins on the CONN header on the board (BOOT0, NRST, RX, TX). 99 | 100 | Uploading firmware 101 | ================== 102 | 103 | Using the 'arminarm' tool to upload firmware with stm32flash looks like this: 104 | 105 | pi@raspberrypi ~ $ arminarm -f myfirmware.bin 106 | stm32flash 0.4 107 | 108 | http://stm32flash.googlecode.com/ 109 | 110 | Using Parser : Raw BINARY 111 | Interface serial_posix: 115200 8E1 112 | Version : 0x22 113 | Option 1 : 0x00 114 | Option 2 : 0x00 115 | Device ID : 0x0414 (High-density) 116 | - RAM : 64KiB (512b reserved by bootloader) 117 | - Flash : 512KiB (sector size: 2x2048) 118 | - Option RAM : 16b 119 | - System RAM : 2KiB 120 | Write to memory 121 | Erasing memory 122 | Wrote and verified address 0x080004a4 (100.00%) Done. 123 | 124 | Starting execution at address 0x08000000... done. 125 | 126 | Adding the '-l' flag to use stm32loader.py, it will look like this: 127 | 128 | pi@raspberrypi ~ $ arminarm -lf myfirmware.bin 129 | GPIO version: 0.5.7 130 | Pi revision 3 131 | Open port /dev/ttyAMA0, baud 115200 132 | initChip 133 | ACK 134 | Bootloader version 22 135 | Chip id ['0x4', '0x14'] 136 | Write 256 bytes at 0x8000000 137 | Write 256 bytes at 0x8000100 138 | Write 256 bytes at 0x8000200 139 | Write 256 bytes at 0x8000300 140 | Write 256 bytes at 0x8000400 141 | Read 256 bytes at 0x8000000 142 | Read 256 bytes at 0x8000100 143 | Read 256 bytes at 0x8000200 144 | Read 256 bytes at 0x8000300 145 | Read 256 bytes at 0x8000400 146 | Verification OK 147 | cleaning up... 148 | done. 149 | 150 | Run 'arminarm' without any flags, or '-h' will show all options. 151 | -------------------------------------------------------------------------------- /setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #ROOTDIR=`pwd` 4 | 5 | #sudo apt-get update 6 | #sudo apt-get upgrade 7 | #sudo apt-get install -y minicom screen autoconf libusb-1.0-0-dev libtool libftdi-dev texinfo 8 | 9 | install_node() 10 | { 11 | echo "INSTALL NODE" 12 | cd bin 13 | ./install_node.sh 14 | cd .. 15 | } 16 | 17 | update_esp_cli() 18 | { 19 | echo "UPDATE ESP_CLI" 20 | cd src 21 | ./update_esp_cli.sh 22 | cd .. 23 | } 24 | 25 | update_elua() 26 | { 27 | echo "UPDATE ELUA" 28 | cd src 29 | ./update_elua.sh 30 | cd .. 31 | } 32 | 33 | update_cmsis_stdperiph() 34 | { 35 | echo "UPDATE CMSIS STDPERIPH" 36 | cd src 37 | ./update_cmsis_stdperiph.sh 38 | cd .. 39 | } 40 | 41 | update_dfu-util() 42 | { 43 | echo "UPDATE DFU-UTIL" 44 | cd src 45 | ./update_dfu-util.sh 46 | cd .. 47 | } 48 | 49 | update_espruino() 50 | { 51 | echo "UPDATE ESPRUINO" 52 | cd src 53 | ./update_espruino.sh 54 | cd .. 55 | } 56 | 57 | update_libmaple() 58 | { 59 | echo "UPDATE LIBMAPLE" 60 | cd src 61 | ./update_libmaple.sh 62 | cd .. 63 | } 64 | 65 | update_libopencm3() 66 | { 67 | echo "UPDATE LIBOPENCM3-PRJ" 68 | cd src 69 | ./update_libopencm3-prj.sh 70 | cd .. 71 | } 72 | 73 | update_openocd() 74 | { 75 | echo "UPDATE OPENOCD" 76 | cd src 77 | ./update_openocd.sh 78 | cd .. 79 | } 80 | 81 | update_stlink() 82 | { 83 | echo "UPDATE STLINK" 84 | cd src 85 | ./update_stlink.sh 86 | cd .. 87 | } 88 | 89 | update_stm32flash() 90 | { 91 | echo "UPDATE STM32FLASH" 92 | cd src 93 | ./update_stm32flash.sh 94 | cd .. 95 | } 96 | 97 | rpi_serial_console_disable() 98 | { 99 | echo "DISABLE SERIAL" 100 | cd scripts 101 | sudo ./release_serial.sh 1 102 | cd .. 103 | } 104 | 105 | rpi_serial_console_enable() 106 | { 107 | echo "ENABLE SERIAL" 108 | cd scripts 109 | sudo ./release_serial.sh 0 110 | cd .. 111 | } 112 | 113 | path_env() 114 | { 115 | echo "SET PATH ENV" 116 | cd scripts 117 | ./path_env.sh 118 | cd .. 119 | } 120 | 121 | upload_espruino() 122 | { 123 | echo "UPLOADING ESPRUINO.BIN" 124 | cd bin 125 | ./install_espruino_bin.sh 126 | echo "espruino communicates on 9600 baud on /dev/ttyAMA0" 127 | cd .. 128 | } 129 | 130 | upload_elua() 131 | { 132 | echo "UPLOADING ELUA.BIN" 133 | cd bin 134 | ./install_elua_bin.sh 135 | echo "eLua communicates on 115200 baud on /dev/ttyAMA0" 136 | cd .. 137 | } 138 | 139 | update_toolchain_jessie() 140 | { 141 | # update_self 142 | 143 | echo "UPDATE TOOLCHAIN" 144 | if [ -d /opt/arminarm ]; then 145 | echo "Directory exists: updating" 146 | fi 147 | 148 | #binutils-arm-none-eabi - GNU assembler, linker and binary utilities for ARM Cortex-A/R/M processors 149 | #gcc-arm-none-eabi - GCC cross compiler for ARM Cortex-A/R/M processors 150 | #gdb-arm-none-eabi - GNU debugger for ARM Cortex-A/R/M processors 151 | #libnewlib-arm-none-eabi - C library and math library compiled for bare metal using Cortex A/R/M 152 | #libstdc++-arm-none-eabi-newlib - GNU Standard C++ Library v3 for ARM Cortex-A/R/M processors (newlib) 153 | 154 | sudo apt-get install -y binutils-arm-none-eabi gcc-arm-none-eabi gdb-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib 155 | 156 | sudo mkdir -p /opt/arminarm 157 | sudo cp -r src/tools/* /opt/arminarm/ 158 | 159 | update_stm32flash 160 | } 161 | 162 | update_toolchain() 163 | { 164 | # update_self 165 | 166 | echo "UPDATE TOOLCHAIN WHEEZY" 167 | if [ -d /opt/arminarm ]; then 168 | echo "Directory exists: updating" 169 | fi 170 | 171 | cd bin 172 | ./install_toolchain.sh 173 | cd .. 174 | 175 | if [ -d /opt/arminarm/tools ]; then 176 | echo "Directory exists: updating" 177 | else 178 | echo "Tools not found: installing" 179 | fi 180 | 181 | sudo cp -r src/tools /opt/arminarm/ 182 | 183 | update_stm32flash 184 | } 185 | 186 | update_self() 187 | { 188 | echo "UPDATE SELF" 189 | git pull 190 | 191 | sudo cp -r src/tools /opt/arminarm/ 192 | } 193 | 194 | 195 | show_options() 196 | { 197 | echo "" 198 | echo "#######################################################################" 199 | echo "# ARMinARM #" 200 | echo "#######################################################################" 201 | echo "" 202 | echo "Essentials:" 203 | echo " 0) Update Self" 204 | echo " 1) Update/Install ARMinARM + GCC Toolchain" 205 | echo " 2) Add /opt/arminarm* to PATH env (needs reboot)" 206 | echo " 3) Disable serial port (required for ARMinARM board, needs reboot)" 207 | echo " 4) Enable serial port (for booting RPI over serial port, default)" 208 | # echo " 5) Update/Install node.js" 209 | echo "" 210 | echo "Fast start:" 211 | echo " 10) Upload espruino.bin to ARMinARM board" 212 | echo " 11) Upload elua.bin to ARMinARM board" 213 | echo "" 214 | echo "Source code:" 215 | echo " a) Update/Install CMSIS_StdPeriph Examples" 216 | echo " b) Update/Install Espruino source code" 217 | echo " c) Update/Install esp-cli" 218 | echo " d) Update/Install eLua source code" 219 | echo " e) Update/Install libmaple" 220 | echo " f) Update/Install libopencm3-prj" 221 | echo " g) Update/Install OpenOCD" 222 | echo " h) Update/Install ST-Link" 223 | echo " i) Update/Install dfu-util" 224 | echo " j) Update/Install stm32flash" 225 | echo "" 226 | echo " q) Quit" 227 | echo "" 228 | } 229 | 230 | 231 | OPTION="0" 232 | 233 | while [ "$OPTION" != "q" ]; do 234 | 235 | show_options 236 | 237 | echo "Enter your choice:" 238 | read OPTION 239 | 240 | if [ "$OPTION" == "0" ]; then 241 | update_self 242 | OPTION="q" 243 | echo "Updated. Please run setup again." 244 | elif [ "$OPTION" == "1" ]; then 245 | #update_toolchain 246 | update_toolchain_jessie 247 | elif [ "$OPTION" == "2" ]; then 248 | path_env 249 | elif [ "$OPTION" == "3" ]; then 250 | rpi_serial_console_disable 251 | OPTION="q" 252 | elif [ "$OPTION" == "4" ]; then 253 | rpi_serial_console_enable 254 | OPTION="q" 255 | elif [ "$OPTION" == "5" ]; then 256 | install_node 257 | 258 | 259 | elif [ "$OPTION" == "10" ]; then 260 | upload_espruino 261 | elif [ "$OPTION" == "11" ]; then 262 | upload_elua 263 | 264 | 265 | elif [ "$OPTION" == "a" ]; then 266 | update_cmsis_stdperiph 267 | elif [ "$OPTION" == "b" ]; then 268 | update_espruino 269 | elif [ "$OPTION" == "c" ]; then 270 | update_esp_cli 271 | elif [ "$OPTION" == "d" ]; then 272 | update_elua 273 | elif [ "$OPTION" == "e" ]; then 274 | update_libmaple 275 | elif [ "$OPTION" == "f" ]; then 276 | update_libopencm3 277 | elif [ "$OPTION" == "g" ]; then 278 | update_openocd 279 | elif [ "$OPTION" == "h" ]; then 280 | update_stlink 281 | elif [ "$OPTION" == "i" ]; then 282 | update_dfu-util 283 | elif [ "$OPTION" == "j" ]; then 284 | update_stm32flash 285 | 286 | elif [ "$OPTION" == "q" ]; then 287 | echo "Bye!" 288 | else 289 | echo "'$OPTION' is an unkown option." 290 | fi 291 | 292 | done 293 | -------------------------------------------------------------------------------- /src/tools/stm32loader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # -*- coding: utf-8 -*- 4 | # vim: sw=4:ts=4:si:et:enc=utf-8 5 | 6 | # Author: Ivan A-R 7 | # Project page: http://tuxotronic.org/wiki/projects/stm32loader 8 | # 9 | # This file is part of stm32loader. 10 | # 11 | # stm32loader is free software; you can redistribute it and/or modify it under 12 | # the terms of the GNU General Public License as published by the Free 13 | # Software Foundation; either version 3, or (at your option) any later 14 | # version. 15 | # 16 | # stm32loader is distributed in the hope that it will be useful, but WITHOUT ANY 17 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | # for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with stm32loader; see the file COPYING3. If not see 23 | # . 24 | 25 | import sys, getopt 26 | import serial 27 | import time 28 | from stm32control import * 29 | 30 | try: 31 | from progressbar import * 32 | usepbar = 1 33 | except: 34 | usepbar = 0 35 | 36 | # Verbose level 37 | QUIET = 20 38 | 39 | def mdebug(level, message): 40 | if(QUIET >= level): 41 | print >> sys.stderr , message 42 | 43 | 44 | class CmdException(Exception): 45 | pass 46 | 47 | 48 | class CommandInterface: 49 | def open(self, aport='/dev/ttyAMA0', abaudrate=115200) : 50 | self.sp = serial.Serial( 51 | port=aport, 52 | baudrate=abaudrate, # baudrate 53 | bytesize=8, # number of databits 54 | parity=serial.PARITY_EVEN, 55 | stopbits=1, 56 | xonxoff=0, # enable software flow control 57 | rtscts=0, # disable RTS/CTS flow control 58 | timeout=5 # set a timeout value, None for waiting forever 59 | ) 60 | 61 | 62 | def _wait_for_ask(self, info = ""): 63 | # wait for ask 64 | try: 65 | ask = ord(self.sp.read()) 66 | except: 67 | raise CmdException("Can't read port or timeout") 68 | else: 69 | if ask == 0x79: 70 | # ACK 71 | return 1 72 | else: 73 | if ask == 0x1F: 74 | # NACK 75 | raise CmdException("NACK "+info) 76 | else: 77 | # Unknow responce 78 | raise CmdException("Unknow response. "+info+": "+hex(ask)) 79 | 80 | 81 | def reset(self): 82 | enterbootloader() 83 | 84 | 85 | def connect(self): 86 | try: 87 | ask = ord(self.sp.read()) 88 | except: 89 | print "None" 90 | return 0 91 | else: 92 | if ask == 0x79: 93 | # ACK 94 | print "ACK" 95 | return 1 96 | else: 97 | if ask == 0x1F: 98 | # NACK 99 | print "NACK" 100 | return 1 101 | else: 102 | # unknown response 103 | print "NONE" 104 | return 0 105 | 106 | 107 | def initChip(self): 108 | print "initChip" 109 | self.reset() 110 | self.sp.write("\x7F") # Sync 111 | ack = self.connect() 112 | while 1: 113 | if ack == 1: 114 | return 1 115 | else: 116 | self.sp.write("\x7F") 117 | ack=self.connect() 118 | else: 119 | #print "initChip1" 120 | return 1 121 | 122 | def releaseChip(self): 123 | reset_stm32() 124 | 125 | 126 | def cmdGeneric(self, cmd): 127 | self.sp.write(chr(cmd)) 128 | self.sp.write(chr(cmd ^ 0xFF)) # Control byte 129 | return self._wait_for_ask(hex(cmd)) 130 | 131 | 132 | def cmdGet(self): 133 | if self.cmdGeneric(0x00): 134 | mdebug(10, "*** Get command"); 135 | len = ord(self.sp.read()) 136 | version = ord(self.sp.read()) 137 | mdebug(10, " Bootloader version: "+hex(version)) 138 | dat = map(lambda c: hex(ord(c)), self.sp.read(len)) 139 | mdebug(10, " Available commands: "+str(dat)) 140 | self._wait_for_ask("0x00 end") 141 | return version 142 | else: 143 | raise CmdException("Get (0x00) failed") 144 | 145 | 146 | def cmdGetVersion(self): 147 | if self.cmdGeneric(0x01): 148 | mdebug(10, "*** GetVersion command") 149 | version = ord(self.sp.read()) 150 | self.sp.read(2) 151 | self._wait_for_ask("0x01 end") 152 | mdebug(10, " Bootloader version: "+hex(version)) 153 | return version 154 | else: 155 | raise CmdException("GetVersion (0x01) failed") 156 | 157 | 158 | def cmdGetID(self): 159 | if self.cmdGeneric(0x02): 160 | mdebug(10, "*** GetID command") 161 | len = ord(self.sp.read()) 162 | id = self.sp.read(len+1) 163 | self._wait_for_ask("0x02 end") 164 | return id 165 | else: 166 | raise CmdException("GetID (0x02) failed") 167 | 168 | 169 | def _encode_addr(self, addr): 170 | byte3 = (addr >> 0) & 0xFF 171 | byte2 = (addr >> 8) & 0xFF 172 | byte1 = (addr >> 16) & 0xFF 173 | byte0 = (addr >> 24) & 0xFF 174 | crc = byte0 ^ byte1 ^ byte2 ^ byte3 175 | return (chr(byte0) + chr(byte1) + chr(byte2) + chr(byte3) + chr(crc)) 176 | 177 | 178 | def cmdReadMemory(self, addr, lng): 179 | assert(lng <= 256) 180 | if self.cmdGeneric(0x11): 181 | mdebug(10, "*** ReadMemory command") 182 | self.sp.write(self._encode_addr(addr)) 183 | self._wait_for_ask("0x11 address failed") 184 | N = (lng - 1) & 0xFF 185 | crc = N ^ 0xFF 186 | self.sp.write(chr(N) + chr(crc)) 187 | self._wait_for_ask("0x11 length failed") 188 | return map(lambda c: ord(c), self.sp.read(lng)) 189 | else: 190 | raise CmdException("ReadMemory (0x11) failed") 191 | 192 | 193 | def cmdGo(self, addr): 194 | if self.cmdGeneric(0x21): 195 | mdebug(10, "*** Go command") 196 | self.sp.write(self._encode_addr(addr)) 197 | self._wait_for_ask("0x21 go failed") 198 | else: 199 | raise CmdException("Go (0x21) failed") 200 | 201 | 202 | def cmdWriteMemory(self, addr, data): 203 | assert(len(data) <= 256) 204 | if self.cmdGeneric(0x31): 205 | mdebug(10, "*** Write memory command") 206 | self.sp.write(self._encode_addr(addr)) 207 | self._wait_for_ask("0x31 address failed") 208 | #map(lambda c: hex(ord(c)), data) 209 | lng = (len(data)-1) & 0xFF 210 | mdebug(10, " %s bytes to write" % [lng+1]); 211 | self.sp.write(chr(lng)) # len really 212 | crc = 0xFF 213 | for c in data: 214 | crc = crc ^ c 215 | self.sp.write(chr(c)) 216 | self.sp.write(chr(crc)) 217 | self._wait_for_ask("0x31 programming failed") 218 | mdebug(10, " Write memory done") 219 | else: 220 | raise CmdException("Write memory (0x31) failed") 221 | 222 | 223 | def cmdEraseMemory(self, sectors = None): 224 | if self.cmdGeneric(0x43): 225 | mdebug(10, "*** Erase memory command") 226 | if sectors is None: 227 | # Global erase 228 | self.sp.write(chr(0xFF)) 229 | self.sp.write(chr(0x00)) 230 | else: 231 | # Sectors erase 232 | self.sp.write(chr((len(sectors)-1) & 0xFF)) 233 | crc = 0xFF 234 | for c in sectors: 235 | crc = crc ^ c 236 | self.sp.write(chr(c)) 237 | self.sp.write(chr(crc)) 238 | self._wait_for_ask("0x43 erasing failed") 239 | mdebug(10, " Erase memory done") 240 | else: 241 | raise CmdException("Erase memory (0x43) failed") 242 | 243 | 244 | def cmdWriteProtect(self, sectors): 245 | if self.cmdGeneric(0x63): 246 | mdebug(10, "*** Write protect command") 247 | self.sp.write(chr((len(sectors)-1) & 0xFF)) 248 | crc = 0xFF 249 | for c in sectors: 250 | crc = crc ^ c 251 | self.sp.write(chr(c)) 252 | self.sp.write(chr(crc)) 253 | self._wait_for_ask("0x63 write protect failed") 254 | mdebug(10, " Write protect done") 255 | else: 256 | raise CmdException("Write Protect memory (0x63) failed") 257 | 258 | 259 | def cmdWriteUnprotect(self): 260 | if self.cmdGeneric(0x73): 261 | mdebug(10, "*** Write Unprotect command") 262 | self._wait_for_ask("0x73 write unprotect failed") 263 | self._wait_for_ask("0x73 write unprotect 2 failed") 264 | mdebug(10, " Write Unprotect done") 265 | else: 266 | raise CmdException("Write Unprotect (0x73) failed") 267 | 268 | 269 | def cmdReadoutProtect(self): 270 | if self.cmdGeneric(0x82): 271 | mdebug(10, "*** Readout protect command") 272 | self._wait_for_ask("0x82 readout protect failed") 273 | self._wait_for_ask("0x82 readout protect 2 failed") 274 | mdebug(10, " Read protect done") 275 | else: 276 | raise CmdException("Readout protect (0x82) failed") 277 | 278 | 279 | def cmdReadoutUnprotect(self): 280 | if self.cmdGeneric(0x92): 281 | mdebug(10, "*** Readout Unprotect command") 282 | self._wait_for_ask("0x92 readout unprotect failed") 283 | self._wait_for_ask("0x92 readout unprotect 2 failed") 284 | mdebug(10, " Read Unprotect done") 285 | else: 286 | raise CmdException("Readout unprotect (0x92) failed") 287 | 288 | 289 | def readMemory(self, addr, lng): 290 | data = [] 291 | if usepbar: 292 | widgets = ['Reading: ', Percentage(),', ', ETA(), ' ', Bar()] 293 | pbar = ProgressBar(widgets=widgets,maxval=lng, term_width=79).start() 294 | 295 | while lng > 256: 296 | if usepbar: 297 | pbar.update(pbar.maxval-lng) 298 | else: 299 | mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) 300 | data = data + self.cmdReadMemory(addr, 256) 301 | addr = addr + 256 302 | lng = lng - 256 303 | if usepbar: 304 | pbar.update(pbar.maxval-lng) 305 | pbar.finish() 306 | else: 307 | mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) 308 | data = data + self.cmdReadMemory(addr, lng) 309 | return data 310 | 311 | 312 | def writeMemory(self, addr, data): 313 | lng = len(data) 314 | if usepbar: 315 | widgets = ['Writing: ', Percentage(),' ', ETA(), ' ', Bar()] 316 | pbar = ProgressBar(widgets=widgets, maxval=lng, term_width=79).start() 317 | 318 | offs = 0 319 | while lng > 256: 320 | if usepbar: 321 | pbar.update(pbar.maxval-lng) 322 | else: 323 | mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) 324 | self.cmdWriteMemory(addr, data[offs:offs+256]) 325 | offs = offs + 256 326 | addr = addr + 256 327 | lng = lng - 256 328 | if usepbar: 329 | pbar.update(pbar.maxval-lng) 330 | pbar.finish() 331 | else: 332 | mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) 333 | self.cmdWriteMemory(addr, data[offs:offs+lng] + ([0xFF] * (256-lng)) ) 334 | 335 | 336 | def __init__(self) : 337 | pass 338 | 339 | 340 | def usage(): 341 | print """Usage: %s [-hqVewvrto] [-l length] [-p port] [-b baud] [-a addr] [file.bin] 342 | -h This help 343 | -q Quiet 344 | -V Verbose 345 | -e Erase 346 | -w Write 347 | -v Verify 348 | -r Read 349 | -t Reset 350 | -o Bootloader 351 | -l length Length of read 352 | -p port Serial port (default: /dev/tty.usbserial-ftCYPMYJ) 353 | -b baud Baud speed (default: 115200) 354 | -a addr Target address 355 | 356 | ./stm32loader.py -e -w -v example/main.bin 357 | 358 | """ % sys.argv[0] 359 | 360 | 361 | if __name__ == "__main__": 362 | # print info about Pi and RPi.GPIO version 363 | setup() 364 | 365 | # make sure we can always access the STM32, even if there are USART interrupts taking 'control' 366 | enterbootloader() 367 | 368 | try: 369 | import psyco 370 | psyco.full() 371 | print "Using Psyco..." 372 | except ImportError: 373 | pass 374 | 375 | conf = { 376 | 'port': '/dev/ttyAMA0', 377 | 'baud': 115200, 378 | 'address': 0x08000000, 379 | 'erase': 0, 380 | 'write': 0, 381 | 'verify': 0, 382 | 'read': 0, 383 | 'rst': 0, 384 | 'bt': 0, 385 | } 386 | 387 | try: 388 | opts, args = getopt.getopt(sys.argv[1:], "hqVewvrtop:b:a:l:") 389 | except getopt.GetoptError, err: 390 | # print help information and exit: 391 | print str(err) # will print something like "option -a not recognized" 392 | usage() 393 | sys.exit(2) 394 | 395 | QUIET = 5 396 | 397 | for o, a in opts: 398 | if o == '-V': 399 | QUIET = 10 400 | elif o == '-q': 401 | QUIET = 0 402 | elif o == '-h': 403 | usage() 404 | sys.exit(0) 405 | elif o == '-e': 406 | conf['erase'] = 1 407 | elif o == '-w': 408 | conf['write'] = 1 409 | elif o == '-v': 410 | conf['verify'] = 1 411 | elif o == '-r': 412 | conf['read'] = 1 413 | elif o == '-t': 414 | conf['rst'] = 1 415 | elif o == '-o': 416 | conf['bt'] = 1 417 | elif o == '-p': 418 | conf['port'] = a 419 | elif o == '-b': 420 | conf['baud'] = eval(a) 421 | elif o == '-a': 422 | conf['address'] = eval(a) 423 | elif o == '-l': 424 | conf['len'] = eval(a) 425 | else: 426 | assert False, "unhandled option" 427 | 428 | cmd = CommandInterface() 429 | cmd.open(conf['port'], conf['baud']) 430 | mdebug(0, "Open port %(port)s, baud %(baud)d" % {'port':conf['port'], 'baud':conf['baud']}) 431 | try: 432 | try: 433 | #print "cmd.initChip" 434 | cmd.initChip() 435 | 436 | except: 437 | print "Can't init. Ensure all jumpers are placed correctly and there's no UART session open already." 438 | 439 | bootversion = cmd.cmdGet() 440 | mdebug(0, "Bootloader version %X" % bootversion) 441 | mdebug(0, "Chip id %s" % str(map(lambda c: hex(ord(c)), cmd.cmdGetID()))) 442 | #cmd.cmdGetVersion() 443 | #cmd.cmdGetID() 444 | #cmd.cmdReadoutUnprotect() 445 | #cmd.cmdWriteUnprotect() 446 | #cmd.cmdWriteProtect([0, 1]) 447 | 448 | if conf['rst']: 449 | reset_stm32() 450 | 451 | if conf['bt']: 452 | enterbootloader() 453 | 454 | if (conf['write'] or conf['verify']): 455 | data = map(lambda c: ord(c), file(args[0]).read()) 456 | 457 | if conf['erase']: 458 | cmd.cmdEraseMemory() 459 | 460 | if conf['write']: 461 | cmd.writeMemory(conf['address'], data) 462 | 463 | if conf['verify']: 464 | verify = cmd.readMemory(conf['address'], len(data)) 465 | if(data == verify): 466 | print "Verification OK" 467 | else: 468 | print "Verification FAILED" 469 | print str(len(data)) + ' vs ' + str(len(verify)) 470 | for i in xrange(0, len(data)): 471 | if data[i] != verify[i]: 472 | print hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i]) 473 | 474 | if not conf['write'] and conf['read']: 475 | rdata = cmd.readMemory(conf['address'], conf['len']) 476 | file(args[0], 'wb').write(''.join(map(chr,rdata))) 477 | 478 | finally: 479 | #cmd.releaseChip() 480 | if not conf['bt']: 481 | #print "attempting reset" 482 | reset_stm32() 483 | clean() 484 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. --------------------------------------------------------------------------------