Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tenbaht committed Feb 13, 2017
0 parents commit d47efd3
Show file tree
Hide file tree
Showing 247 changed files with 20,632 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
*.bak
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Windows tools for using sduino

This collection of files helps to use the
[sdunio](https://github.com/tenbaht/sduino) environment on Windows systems.

Windows is lacking all the needed tools, a package system to
install them and even a file system concept where to store them. For
convinience, I collected the bare minimum of needed tools here.

I didn't write any of the tools contained in this repository. The only
purpose of this compilation is to save you some work downloading them
separately (which I still recommand over using these older versions).


## Usage

Download the repostory and copy the directory tree into your sduino
directory. Add the sduino/tools/bin directory to your path or move the files
in there to a directory that is already in your path.



## The individual pieces

All the tools in the convinience package are 32 bit. If you need the 64 bit
versions you might have to collect them yourself.

You need SDCC, `make` with some basic tools and maybe `stm8flash`. Get SDCC
from the project website. `make` is a standard tool included in either
MinGW/Msys or cygwin. Both are fine, MinGW/Msys is smaller. `stm8flash` from
the [stm8flash repository](https://github.com/vdudouyt/stm8flash).



#### SDCC

1. Download the lastest snapshot build from http://sdcc.sourceforge.net/snap.php
2. unzip into c:\sdcc (use a path name without whitespace)

You only need support for the stm8. You can safely delete all the files
related to the pic1x CPUs (that safes more than 90% of the used disk space
and leaves only 20MB out of 240MB)


#### MinGW

[MinGW/MSys](http://www.mingw.org/wiki/MSYS) and
[cygwin](https://www.cygwin.com/) are both fine. cygwin aims to be an almost
complete POSIX environment (which is nice, but we don't need it here). MinGW
wants to be more compact and works with the native Windows API. That is good
enough for this purpose.

1. Check the
[MinGW Installation Notes](http://www.mingw.org/wiki/Getting_Started)
2. Download
[mingw-get-setup.exe](https://sourceforge.net/projects/mingw/files/Installer/)
from https://sourceforge.net/projects/mingw/files/Installer/
3. Start it. You can safely deactivate the graphical option.
4. Add this at the end to your path: `;c:\mingw\bin;c:\mingw\msys\1.0\bin`
(follow the instructions in "Environment Setting" on the [Installation
Notes page[(http://www.mingw.org/wiki/Getting_Started))
5. Open a command line and install the package msys-base by issuing this
command: `mingw-get install msys-base`
6. Now `ls` or `make` should work.

For efficiency, the Makefile is configured to use dash instead of bash as a
shell. `egrep` is replaced by `grep -E`. The bare minimum of tools you will
need to run the Arduino.mk makefile:

dash make
awk cat cut expr grep head ls mkdir sed tr uname which




#### stm8flash

A precompiled windows binary was in the stm8flash repository for a while but
got removed at one point. I used an
[old version](https://github.com/vdudouyt/stm8flash/raw/39b1a9ec1dd26030065c3e476fc3b7b89626e21d/stm8flash.exe)
of the file. You might prefer to compile your own version from the
[stm8flash repository](https://github.com/vdudouyt/stm8flash) using either
MinGW or cygwin. For compiling, you will need the libusb windows binary:
http://libusb.info/ (I used the MinGW32 dll)




## General problems using Windows

It works, but using the Arduino.mk makefile with Windows is slow. **Very**
slow. Painfully slow. Compiling-the-Blink-example-takes-about-40-seconds
kind of slow. Yes, seriously. No kidding. 40 seconds. Measured on a 3GHz
machine with 4GB RAM.

There is no easy fix, the underlying problem is a fundamental one. It is not
about the compilation itself, it is the way Makefiles are written and
executed. The whole concept relies on forking subprocesses for all the shell
calls. Unfortunately, there is nothing like a fork in Windows and to work
around that is painfully slow.

It would be great if somebody could manage to modify the original Arduino
build system to support non-C++-builds. Or to integrate it somehow into the
STVD IDE. Or replace the painfully slow parameter checking part of the
makefile (that causes the majority of forking) by a single shell script that
gets called by the makefile and delivers the results in no time. Or use
[cmake](www.cmake.org). Or whatever.

Until than the least annoying way out might be using a virtual machine
running a simple Linux system. Ubuntu Mate or a basic Debian install for
example. Virtual Box is great for this purpose and freely available.



## Possible improvements

### All-inclusive packages

One of the big convinience points of the Arduino project are the
easy-to-install all-inclusive packages without any external dependencies.
They don't require any prior knowledge to set up a full cross-compiler tool
chain.

Something like that would be very nice for the STM8 as well, but I didn't go
that far. You still have to do some work yourself. You definitly need the
compiler SDCC. `stm8flash` is a simple tool to transfer the compiled program
to the CPU, but any other flash tool supporting the SWIM protocol will do.
The build process is controlled by `make`. It is a standard tool with any
UNIX system but available for windows as well.

Alternative ways of controlling the build process exist, but then you are
on your own to set it up.
178 changes: 178 additions & 0 deletions hardware/tools/stm8/bin/as2gbmap.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
@setlocal enabledelayedexpansion && python -x "%~f0" %* & exit /b !ERRORLEVEL!
#!/usr/bin/env python

# as2gbmap - asxxxx to gb map file converter
#
# Copyright (c) 2010 Borut Razem
#
# This file is part of sdcc.
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# Borut Razem
# borut.razem@siol.net

import sys
import os
import re
from optparse import OptionParser
import operator

def main():
'''asxxxx to gb map file converter'''
usage = "usage: %prog [options] [<input_asxxxx_map_file> [<output_gb_file>]]"
parser = OptionParser(usage = usage, version = "1.0")
parser.set_defaults(no_gmb = False)
parser.add_option("-j", "--no$gmb", action = "store_true", dest = "no_gmb", help = "generate no$gmb symbol file (default: rrgb)")
(options, args) = parser.parse_args()

if len(args) > 0 and args[0] != "-":
try:
fin = open(args[0], "r")
except IOError, (errno, strerror):
print >> sys.stderr, "%s: can't open %s: %s" % (os.path.basename(sys.argv[0]), args[0], strerror)
return 1
else:
fin = sys.stdin

if len(args) > 1 and args[1] != "-":
try:
fout = open(args[1], "w")
except IOError, (errno, strerror):
print >> sys.stderr, "%s: can't create %s: %s" % (os.path.basename(sys.argv[1]), args[1], strerror)
return 1
else:
fout = sys.stdout;

areas = []
modules = []
libraries = []
ubads = []

radix = 'HEX'
state = None
area = None

# process asxxxx map file
for line in fin:
if re.match(r"^Hexadecimal$", line):
radix = 'HEX';
continue

if re.match(r"^Area +Addr +Size +Decimal +Bytes +\(Attributes\)$", line):
line = fin.next()
if re.match(r"^[- ]+$", line):
line = fin.next()
m = re.match(r"^([^ ]+) +([0-9A-Fa-f]{4}) +([0-9A-Fa-f]{4}) += +\d+\. +\w+ +\(([^\)]+)\)$", line)
if m:
if area:
if m.group(1) != area['area']:
areas.append(area)
area = {'area': m.group(1), 'radix': radix, 'base': int(m.group(2), 16), 'size': int(m.group(3), 16), 'attrib': m.group(4).replace(',', ' '), 'globals': []}
else:
area = {'area': m.group(1), 'radix': radix, 'base': int(m.group(2), 16), 'size': int(m.group(3), 16), 'attrib': m.group(4).replace(',', ' '), 'globals': []}
state = 'IN_AREA'
continue

m = re.match(r"^ +([0-9A-Fa-f]{4}) +([^ ]+) +$", line)
if state == 'IN_AREA' and m:
area['globals'].append({'value': int(m.group(1), 16), 'global': m.group(2)})
continue

m = re.match(r"Files Linked +\[ module\(s\) \]$", line)
if m:
state = 'IN_MODULES'
continue

m = re.match(r"Libraries Linked +\[ object file \]$", line)
if m:
state = 'IN_LIBRARIES'
continue

m = re.match(r"User Base Address Definitions$", line)
if m:
state = 'IN_UBAD'
continue

m = re.match(r"^([^ ]+) +\[ ([^ ]*) \]$", line)
if m:
if state == 'IN_MODULES':
modules.append({'file': m.group(1), 'name': m.group(2)})
continue

if state == 'IN_LIBRARIES':
libraries.append({'library': m.group(1), 'module': m.group(2)})
continue

m = re.match(r"^([^ ]+) += +0x([0-9A-Fa-f]{4})$", line)
if state == 'IN_UBAD' and m:
ubads.append({'symbol': m.group(1), 'value': m.group(2)})
continue

if area:
areas.append(area)


if options.no_gmb:
# generate no$gmp map file
print >> fout, '; no$gmb format .sym file'
print >> fout, '; Generated automagically by %s' % os.path.basename(sys.argv[0])
for e in areas:
print >> fout, '; Area: %s' % e['area']
if e['globals']:
e['globals'].sort(key = operator.itemgetter('value'))
for g in e['globals']:
if g['global'][0:3] != 'l__':
if g['value'] > 0x7FFF:
print >> fout, '00:%04X %s' % (g['value'], g['global'])
else:
print >> fout, '%02X:%04X %s' % (g['value'] // 16384, g['value'], g['global'])
else:
# generate rrgb map file
for e in areas:
print >> fout, 'AREA %s' % e['area']
print >> fout, '\tRADIX %s' % e['radix']
print >> fout, '\tBASE %04X' % e['base']
print >> fout, '\tSIZE %04X' % e['size']
print >> fout, '\tATTRIB %s' % e['attrib']
if e['globals']:
e['globals'].sort(key = operator.itemgetter('value'))
print >> fout, '\tGLOBALS'
for g in e['globals']:
print >> fout, '\t\t%s\t%04X' % (g['global'], g['value'])

if modules:
print >> fout, 'MODULES'
for m in modules:
print >> fout, '\tFILE %s' % m['file']
if m['name']:
print >> fout, '\t\tNAME %s' % m['name']

if libraries:
print >> fout, 'LIBRARIES'
for m in libraries:
print >> fout, '\tLIBRARY %s' % m['library']
print >> fout, '\t\tMODULE %s' % m['module']

if ubads:
print >> fout, 'USERBASEDEF'
for m in ubads:
print >> fout, '\t%s = 0x%04X' % (m['symbol'], int(m['value'], 16))
return 0

if __name__ == '__main__':
sys.exit(main())
Binary file added hardware/tools/stm8/bin/libusb-1.0.dll
Binary file not shown.
Binary file added hardware/tools/stm8/bin/makebin.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/packihx.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdar.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdas390.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdas6808.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdas8051.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdasgb.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdasrab.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdasstm8.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdasz80.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdcc.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdcclib.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdcpp.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdld.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdld6808.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdldgb.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdldstm8.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdldz80.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdnm.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdobjcopy.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/sdranlib.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin/stm8flash.exe
Binary file not shown.
Binary file added hardware/tools/stm8/bin64/libusb-1.0.dll
Binary file not shown.
45 changes: 45 additions & 0 deletions hardware/tools/stm8/include/asm/stm8/features.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*-------------------------------------------------------------------------
features.h - STM8 specific features.
Copyright (C) 2001, Michael Hope, 2013, Philipp Klaus Krause
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library; see the file COPYING. If not, write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
As a special exception, if you link this library with other files,
some of which are compiled with SDCC, to produce an executable,
this library does not by itself cause the resulting executable to
be covered by the GNU General Public License. This exception does
not however invalidate any other reasons why the executable file
might be covered by the GNU General Public License.
-------------------------------------------------------------------------*/

#ifndef __SDCC_ASM_STM8_FEATURES_H
#define __SDCC_ASM_STM8_FEATURES_H 1

#define _REENTRANT
#define _CODE
#define _AUTOMEM
#define _STATMEM

#define _SDCC_MANGLES_SUPPORT_FUNS 1
#define _SDCC_Z80_STYLE_LIB_OPT 1

#define _SDCC_PORT_PROVIDES_MEMCPY 0
#define _SDCC_PORT_PROVIDES_STRCMP 0
#define _SDCC_PORT_PROVIDES_STRCPY 0

#endif

Loading

0 comments on commit d47efd3

Please sign in to comment.