--> ap/xxxxx

* __

The Art of the Interpreter of, the Modularity Complex (Parts Zero, One, and Two) (2007.01.02:3 atmegascheme#3 tech_notes#333 cpu#8 lisp#3 scheme#1)


further Scheme research:

icbins: from http://www.accesscom.com/~darius/

with further interesting code there...

from the README from icbins:

Here we have an exercise in stripping a Lisp to barest essentials, dropping the host tether early, and repeatedly changing and rebuilding, to practice evolving a self-hosted system. Only the garbage collector and the lowest-level Lisp primitives are in C. The source is an order of magnitude smaller than the already-lightweight UTS's. You might find this of interest if you want to do similar exercises or if you'd just like to read a tiny Lisp system with no magic (small self-hosting Lisps typically rely on powerful primitives like READ, PRINT, and GC). This could be cut down further; hopefully I'll come back to it someday.

no go chicken scheme -> avr-gcc (system heavy libraries) (2007.01.02:2 atmegascheme#2 arduino#2 tech_notes#332 cpu#7)

First steps for ATmega Scheme Interpreter: (2007.01.02:1 atmegascheme#1 arduino#1 tech_notes#331 cpu#6)

-a) checl we have ftdi_sio and usbserial modules built and loaded

a) we have the Arduino codebase

b) on Gentoo: emerge crossdev (had to first set PORTDIR_OVERLAY=/usr/portage in /etc/make.conf)

takes some time...

c) emerge avrdude programming utility AFTER b) succeeds

d) check out Makefile and modify as below

# Arduino makefile
# This makefile allows you to build sketches from the command line
# without the Arduino environment (or Java).
# The Arduino environment does preliminary processing on a sketch before
# compiling it.  If you're using this makefile instead, you'll need to do
# a few things differently:
#   - Give your program's file a .cpp extension (e.g. foo.cpp).
#   - Put this line at top of your code: #include <WProgram.h>
#   - Write prototypes for all your functions (or define them before you
#     call them).  A prototype declares the types of parameters a
#     function will take and what type of value it will return.  This
#     means that you can have a call to a function before the definition
#     of the function.  A function prototype looks like the first line of
#     the function, with a semi-colon at the end.  For example:
#     int digitalRead(int pin);
# Instructions for using the makefile:
#  1. Copy this file into the folder with your sketch.
#  2. Below, modify the line containing "TARGET" to refer to the name of
#     of your program's file without an extension (e.g. TARGET = foo).
#  3. Modify the line containg "ARDUINO" to point the directory that
#     contains the Arduino core (for normal Arduino installations, this
#     is the lib/targets/arduino sub-directory).
#  4. Modify the line containing "PORT" to refer to the filename
#     representing the USB or serial connection to your Arduino board
#     (e.g. PORT = /dev/tty.USB0).  If the exact name of this file
#     changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*).
#  5. At the command line, change to the directory containing your
#     program's file and the makefile.
#  6. Type "make" and press enter to compile/verify your program.
#  7. Type "make upload", reset your Arduino board, and press enter  to
#     upload your program to the Arduino board.
# $Id$



e) test code:


make: avr-g++: Command not found

next try: (after: http://www.arduino.cc/playground/Linux/Gentoo )

USE='-nocxx' emerge cross-avr/gcc cross-avr/avr-libc

make succeeds - we have a blink1.hex and so on

f) make upload


few changes to Makefile for avrdude and avrusb500 programmer, updated to new core Arduino necessitating more Makefile changes and now programs fine with 5v attached to ATmega on breadboard

g) pin mapping: http://www.arduino.cc/en/Hacking/

eg. digital pin 13 in blink LED example is true ATmega8 pin 19

// On the Arduino board, digital pins are also used
// for the analog output (software PWM).  Analog input
// pins are a separate set.

//             +-\/-+
//       PC6  1|    |28  PC5 (AI 5)
// (D 0) PD0  2|    |27  PC4 (AI 4)
// (D 1) PD1  3|    |26  PC3 (AI 3)
// (D 2) PD2  4|    |25  PC2 (AI 2)
// (D 3) PD3  5|    |24  PC1 (AI 1)
// (D 4) PD4  6|    |23  PC0 (AI 0)
//       VCC  7|    |22  GND
//       GND  8|    |21  AREF
//       PB6  9|    |20  AVCC
//       PB7 10|    |19  PB5 (D 13)
// (D 5) PD5 11|    |18  PB4 (D 12)
// (D 6) PD6 12|    |17  PB3 (D 11) PWM
// (D 7) PD7 13|    |16  PB2 (D 10) PWM
// (D 8) PB0 14|    |15  PB1 (D 9) PWM
//             +----+

h) one problem with Scheme/Arduino plan is presented by wiring.c which wraps setup and loop into main function.. but we could easily replace this

USB UART for interface to the ATMega: (2006.12.28:2)


further Atmel - programming (2006.12.21:1 cpu#4 tech_notes#321)

Using the AVR programmer USB, stk500 V2 compatible from:


(with thanks to Guido)

Further documentation online at:


and also for avr-gcc:



mkdir /tmp/mnt
mount -o loop /mnt/cdrom/KNOPPIX/tgr/avr.img /tmp/mnt
cd /tmp/mnt
find avr* | cpio -dump /usr/local/
cd ; umount /tmp/mnt

# and add bin to PATH.

export PATH

Makefile is at:


and uses avr-gcc, avr-objcopy and prg_load_uc shell script which references:

avrdude -p m8 -c avrusb500 -e -U flash:w:"$pfile"

prg_fusebit_uc is also used to "read and write fuse bits of the atmega8"

more arduino/cpu thoughts: (2006.12.19:1 cpu#3 tech_notes#320)


# This makefile allows you to build sketches from the command line
# without the Arduino environment (or Java).
# The Arduino environment does preliminary processing on a sketch before
# compiling it.  If you're using this makefile instead, you'll need to do
# a few things differently:

then compiles and links with Arduino library .c (and .cpp) files

and further compiles using avr-gcc, avr-objcopy and so on and uploads with avrdude.

or rather:

an interpreter or vm (virtual machine) in flash


as in:

amforth is a distribution of Forth running on the AVR ATmega microcontroller. Once put into flash, it needs only a serial connection to the host computer. New words are compiled directly into flash, thus extending the dictionary immediately. It is ans94 Forth oriented with some minor exclusions and a few words from the extension word sets. It is written in assembly language and Forth itself. The main development uses ATmega8 and ATmega32 controllers; other ATmega controllers should work with small adjustments.

Atmel ATmega8 (a la Arduino) as basis for our CPU: (2006.12.18:2)

See particularly for commandline use:


AVR programmer USB, stk500 V2 compatible






more links for our CPU: (2006.12.03:1 cpu#1 research#113)



The Pathetic Instruction Set Computer is a model processor constructed entirely of discrete logic, illustrating the principles of both hardwired and microprogrammed CPUs. Requiring only 22 standard TTL chips (excluding memory)...


and a relation:

Mark 2 FORTH Computer


and some lists of links: