-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure continuous integration builds
- Loading branch information
Showing
3 changed files
with
199 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
language: cpp | ||
|
||
os: | ||
- linux | ||
|
||
dist: trusty | ||
|
||
compiler: | ||
- gcc | ||
|
||
env: | ||
matrix: | ||
- PPA=terry.guo/gcc-arm-embedded | ||
|
||
before_install: | ||
- 'sudo add-apt-repository -y ppa:$PPA' | ||
|
||
install: | ||
- 'sudo apt-get -qy install gcc-arm-none-eabi' | ||
- 'sudo pip install IntelHex' | ||
|
||
script: | ||
- 'make' | ||
- 'export VERS=pt1-v$(git describe --tags)' | ||
- 'RELDIR=$TRAVIS_BUILD_DIR/release/$VERS' | ||
- 'mkdir -p $RELDIR' | ||
- 'cp $TRAVIS_BUILD_DIR/main.bin $RELDIR/$VERS.bin' | ||
- '$TRAVIS_BUILD_DIR/scripts/dfu-convert -i $TRAVIS_BUILD_DIR/main.hex $RELDIR/$VERS.dfu' | ||
- 'md5sum $RELDIR/$VERS.bin > $RELDIR/$VERS.bin.md5' | ||
- 'md5sum $RELDIR/$VERS.dfu > $RELDIR/$VERS.dfu.md5' | ||
- 'cd $TRAVIS_BUILD_DIR/release' | ||
- 'tar czvf $VERS.tar.gz $VERS' | ||
|
||
deploy: | ||
- provider: s3 | ||
access_key_id: AKIAJGQ2AT747PZ7POLA | ||
secret_access_key: | ||
secure: Fye3aL47jgbarsxwHaEqjJZwDqNDc6hsJQCW3y7fFCzA1COSpBOHCiExnBFRPY1t9SQkFCWq4NWX0Vgcs6KzlmPBiAV/oqagfk8UM6LObRTxIkYfly9Qjwge/vMZzU5mHlEqTKRsose1C5ds+Lp5P0anq3LrKidROBKYIHloQsxg0M0BNHlPltPeNhKczQlrvcx/QW1uRsAO1b0B1bmcKK3Djd/E384KpprqzhlS/GEwlsWYMaNcksUlW+TMNNrHez1vOL+GpCVa9Ec80Tvrhuz65ss9nOWDpi8I5Gci6SXoskLWxfDj5B8T00tOTibuWfe7+yU57STpZ5qIiJuC8tJrjkialFfAY8N/2TdjLtA4kIPetuJXg3Wu9E/qCCl+6L10S2RRryRMC7z9RQKo245HwiQtPnNqzlVTOwJ78glbSlJ2ut9c/PU5ToWfhUr4rj2UBcUh22WkhYgZbtW6wt7dSskAglwKej2weng6OjVCB65lDdUPvjb7Ps4cXQuBu1EnbSVBcqgdPlh0mS5AjvCt6Ncet4aYz/dW2RVDu1eH24QrrepGZfmLn0t/NaiobNtAOoetgfAWAZ/izZYWPQbq+ytGBInCl1Hv9LWvUpGATbH4Uzvv5p6CVsipkHdijf27U/ql4Pbcc3aJqnhsCnxCOlw5RwPi3VImMfDTMJI= | ||
bucket: groupgets-ci | ||
local-dir: ${TRAVIS_BUILD_DIR}/release | ||
upload-dir: purethermal1-firmware/${TRAVIS_BRANCH} | ||
acl: public_read | ||
skip_cleanup: true | ||
on: | ||
repo: groupgets/purethermal1-firmware | ||
all_branches: true | ||
- provider: releases | ||
api_key: | ||
secure: g+72wZw5mIlxA9h4GvxXeHJMbAQUqmvuhZDbqr30uEO74xnMbe0Txqy/yPYJLlM/dB2deS8QypKqHa8AOjjYpFKk/7tfdVM3QAM2tDkOuLuIiTP4cY3FYAcqCcSN47ZMFatxfTKGGvrxgQ/4/FlC2Y6y+ydjTJrxAyo8Nx6zEgHK4gBY9MMEJZLAQQ1w5o6u1ITZ+d8Aq9fXGj6uzX02qwNpToinUeetUpykKubk1IUSH/ZeOi+IDbTh4KbyIoWCEDZUn9LZ1TrEpW4SjGBXr3GlZ8qWAlnqtWg/74KM8Ov/EcZNE0P1NZEdUdvBLvh6IQVYVcVgHAzH14fcuZmledo0p9Z2y59pbiJFomG4Kk4yaaATlPlXsFFuzcDMy9odVja3Av9ZKmzZmDWyo1Q+cKaeJcODOx7JhFBB8kV+XAf56ahdZZ2x7MjCRAMRIvaGXVOgDOPPSEcdB+2jebZ0s0oW0InF6Jy+nZzJMwboZ8HrH6S2U4zLOHnbj/sluMTDsqV/5U9HqxuCYwvAYlapYfLdYSAUnlI5phKrzFdLZjHgUETAKu3oh7cNc2KgfZm1JNysAEsqTh4eYHT2/UGx7a6lz1BKhKMntAM9JkuWZS7Aq3DVTA8QU1F3XZKi6XQWeGUPFajq9xMBNfGcU1CXJL1dnaWSPJh/XDWxUMGUejc= | ||
file_glob: true | ||
file: "${TRAVIS_BUILD_DIR}/release/*.tar.gz" | ||
skip_cleanup: true | ||
on: | ||
repo: groupgets/purethermal1-firmware | ||
tags: true |
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,142 @@ | ||
#!/usr/bin/env python | ||
|
||
# Written by Antonio Galea - 2010/11/18 | ||
# Distributed under Gnu LGPL 3.0 | ||
# see http://www.gnu.org/licenses/lgpl-3.0.txt | ||
|
||
import sys,struct,zlib,os | ||
from optparse import OptionParser | ||
from intelhex import IntelHex | ||
|
||
DEFAULT_DEVICE="0x0483:0xdf11" | ||
|
||
def named(tuple,names): | ||
return dict(zip(names.split(),tuple)) | ||
def consume(fmt,data,names): | ||
n = struct.calcsize(fmt) | ||
return named(struct.unpack(fmt,data[:n]),names),data[n:] | ||
def cstring(string): | ||
return string.split('\0',1)[0] | ||
def compute_crc(data): | ||
return 0xFFFFFFFF & -zlib.crc32(data) -1 | ||
|
||
def parse(file,dump_images=False): | ||
print 'File: "%s"' % file | ||
data = open(file,'rb').read() | ||
crc = compute_crc(data[:-4]) | ||
prefix, data = consume('<5sBIB',data,'signature version size targets') | ||
print '%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix | ||
for t in range(prefix['targets']): | ||
tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') | ||
tprefix['num'] = t | ||
if tprefix['named']: | ||
tprefix['name'] = cstring(tprefix['name']) | ||
else: | ||
tprefix['name'] = '' | ||
print '%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix | ||
tsize = tprefix['size'] | ||
target, data = data[:tsize], data[tsize:] | ||
for e in range(tprefix['elements']): | ||
eprefix, target = consume('<2I',target,'address size') | ||
eprefix['num'] = e | ||
print ' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix | ||
esize = eprefix['size'] | ||
image, target = target[:esize], target[esize:] | ||
if dump_images: | ||
out = '%s.target%d.image%d.bin' % (file,t,e) | ||
open(out,'wb').write(image) | ||
print ' DUMPED IMAGE TO "%s"' % out | ||
if len(target): | ||
print "target %d: PARSE ERROR" % t | ||
suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') | ||
print 'usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix | ||
if crc != suffix['crc']: | ||
print "CRC ERROR: computed crc32 is 0x%08x" % crc | ||
data = data[16:] | ||
if data: | ||
print "PARSE ERROR" | ||
|
||
def build(file,targets,device=DEFAULT_DEVICE): | ||
data = '' | ||
for t,target in enumerate(targets): | ||
tdata = '' | ||
for image in target: | ||
tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] | ||
tdata = struct.pack('<6sBI255s2I','Target',0,1,'ST...',len(tdata),len(target)) + tdata | ||
data += tdata | ||
data = struct.pack('<5sBIB','DfuSe',1,len(data)+11,len(targets)) + data | ||
v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) | ||
data += struct.pack('<4H3sB',0,d,v,0x011a,'UFD',16) | ||
crc = compute_crc(data) | ||
data += struct.pack('<I',crc) | ||
open(file,'wb').write(data) | ||
|
||
if __name__=="__main__": | ||
usage = """ | ||
%prog [-d|--dump] infile.dfu | ||
%prog {-b|--build} address:file.bin [-b address:file.bin ...] [{-D|--device}=vendor:device] outfile.dfu | ||
%prog {-i|--ihex} file.hex [-i file.hex ...] [{-D|--device}=vendor:device] outfile.dfu""" | ||
|
||
parser = OptionParser(usage=usage) | ||
parser.add_option("-b", "--build", action="append", dest="binfiles", | ||
help="build a DFU file from given BINFILES", metavar="BINFILES") | ||
parser.add_option("-i", "--ihex", action="append", dest="hexfiles", | ||
help="build a DFU file from given HEXFILES", metavar="HEXFILES") | ||
parser.add_option("-D", "--device", action="store", dest="device", | ||
help="build for DEVICE, defaults to %s" % DEFAULT_DEVICE, metavar="DEVICE") | ||
parser.add_option("-d", "--dump", action="store_true", dest="dump_images", | ||
default=False, help="dump contained images to current directory") | ||
(options, args) = parser.parse_args() | ||
|
||
if (options.binfiles or options.hexfiles) and len(args)==1: | ||
target = [] | ||
|
||
if options.binfiles: | ||
for arg in options.binfiles: | ||
try: | ||
address,binfile = arg.split(':',1) | ||
except ValueError: | ||
print "Address:file couple '%s' invalid." % arg | ||
sys.exit(1) | ||
try: | ||
address = int(address,0) & 0xFFFFFFFF | ||
except ValueError: | ||
print "Address %s invalid." % address | ||
sys.exit(1) | ||
if not os.path.isfile(binfile): | ||
print "Unreadable file '%s'." % binfile | ||
sys.exit(1) | ||
target.append({ 'address': address, 'data': open(binfile,'rb').read() }) | ||
|
||
if options.hexfiles: | ||
for hex in options.hexfiles: | ||
ih = IntelHex(hex) | ||
address = ih.minaddr() | ||
data = ih.tobinstr() | ||
try: | ||
address = address & 0xFFFFFFFF | ||
except ValueError: | ||
print "Address %s invalid." % address | ||
sys.exit(1) | ||
target.append({ 'address': address, 'data': data }) | ||
|
||
outfile = args[0] | ||
device = DEFAULT_DEVICE | ||
if options.device: | ||
device=options.device | ||
try: | ||
v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) | ||
except: | ||
print "Invalid device '%s'." % device | ||
sys.exit(1) | ||
build(outfile,[target],device) | ||
elif len(args)==1: | ||
infile = args[0] | ||
if not os.path.isfile(infile): | ||
print "Unreadable file '%s'." % infile | ||
sys.exit(1) | ||
parse(infile, dump_images=options.dump_images) | ||
else: | ||
parser.print_help() | ||
sys.exit(1) | ||
|