MicroPython for AmigaOS (m68k)
==============================
A port of MicroPython v1.27 (compatible Python 3.4) to AmigaOS,
targeting Motorola 68020+ processors. Runs on classic Amiga hardware
(A1200, A3000, A4000) and emulators (WinUAE, FS-UAE).
This port was developed by Fabrice with coding assistance from Claude
(Anthropic's AI), under Fabrice's direct supervision: architecture
decisions, implementation strategy, testing on real hardware/emulator,
and bug reports are all driven by Fabrice. Every change is reviewed
and validated before being committed.
Requirements
------------
- AmigaOS 3.0 or higher
- Motorola 68020 CPU or higher
- 2 MB RAM minimum for simple scripts
- 4 MB RAM recommended for networking and TLS
- AmiSSL (optional, required for HTTPS/TLS support)
Usage
-----
micropython ; interactive REPL
micropython script.py ; run a Python script
micropython script.mpy ; run precompiled bytecode
micropython -c "print(2**32)" ; run inline code
micropython -m 512 script.py ; run with 512 KB heap
The default heap size is 128 KB. Use -m to allocate more memory
(in KB). For example, downloading a web page may require 4 MB
of heap: micropython -m 4096 script.py
Press Ctrl-C at any time to interrupt a running script or a
time.sleep() call.
Features
--------
- Full Python 3.4 compatibility (ROM_LEVEL_EVERYTHING):
f-strings, set operations, OrderedDict, advanced slicing,
descriptors, async/await, and more
- Interactive REPL with readline support (cursor keys, history)
- Script execution and inline code (-c option)
- Configurable heap size (-m option)
- Precompiled bytecode: import and execute .mpy files compiled
with mpy-cross, either via import or directly from the command
line (micropython script.mpy)
- Ctrl-C (KeyboardInterrupt) support during script execution,
loops, and time.sleep()
- input() builtin for interactive user prompts
- sys.stdin / sys.stdout / sys.stderr standard streams
Modules included:
re, json, math, struct, binascii, base64, time, datetime,
random, hashlib (sha256), errno, platform, socket, ssl,
urequests, deflate, gzip, zlib, zipfile, arexx, gc, sys, io
File system support:
Full open/read/write/close via VFS_POSIX. os.listdir,
os.getcwd, os.chdir, os.mkdir, os.rmdir, os.remove,
os.rename, os.stat, os.chmod, os.getprotect, os.setprotect,
os.makedirs, os.walk, os.getenv, os.putenv, os.unsetenv,
os.path with AmigaOS volume:path conventions.
Networking:
TCP/UDP sockets, DNS resolution via bsdsocket.library.
HTTP client (urequests) with HTTP/1.1, chunked transfer
encoding, gzip decompression.
TLS/SSL (requires AmiSSL):
HTTPS support via AmiSSL. The amissl.library must be
installed on the Amiga. 4 MB RAM minimum is recommended
when using TLS.
ARexx IPC:
Inter-process communication with AmigaOS applications via
ARexx message ports. arexx.send() for one-shot commands,
arexx.exists() to check port availability, arexx.ports()
to list active ports, and arexx.Port() persistent client
with context manager for efficient multi-command sessions.
Platform detection:
platform.amiga_info() shows CPU, FPU, chipset, Kickstart
version, and available memory.
AmigaOS Path Conventions
------------------------
AmigaOS uses ":" to separate volumes from paths and "/" for
subdirectories:
>>> import os
>>> os.getcwd()
'DH0:Work'
>>> os.path.join("DH0:", "work", "scripts")
'DH0:work/scripts'
>>> os.path.isabs("DH0:file.py")
True
Release history
---------------
Build 219
---------
- Critical fix: force heap allocation for iterators on m68k.
The mp_obj_iter_buf_t struct on the C stack was misaligned on
68k, causing "object isn't an iterator" crashes on for loops,
the 'in' operator, list comprehensions, unpacking, and builtins
like sum(), min(), max(), sorted(), etc. Fixed in 13 locations
across 7 core MicroPython files.
- Fix: ARexx WaitPort is now interruptible by Ctrl-C. Previously,
arexx.send() would hang indefinitely if the target application
did not reply. Now waits with SIGBREAKF_CTRL_C and raises
KeyboardInterrupt after the reply is safely received.
- Fix: avoid double close(fd) in SSLSocket.__del__. The fd is
owned by the underlying Python socket; closing it twice could
corrupt the libnix fd table.
- Fix: avoid double inet_ntoa() call in same expression. The
static buffer was overwritten between calls, causing incorrect
addresses in socket_accept(), socket_recvfrom(), and
mod_getaddrinfo().
- Fix: cache timezone offset from locale.library instead of
opening/closing the library on every localtime()/strftime() call.
- Fix: close ARexx library in crash handlers (nlr_jump_fail,
__assert_func) to prevent resource leaks on fatal errors.
- Use _exit() consistently in all exit/crash paths.
Build 209
---------
- os.getenv(), os.putenv(), os.unsetenv(): environment variable
management via AmigaOS GetVar/SetVar/DeleteVar
- zlib module: CPython-compatible compress, decompress, crc32
- zipfile module: read/write ZIP archives (stored + deflated),
CRC32 verification, extractall support
- Timezone support: time.localtime() now returns local time
using the timezone offset from AmigaOS locale.library
(loc_GMTOffset). time.gmtime() returns UTC.
- datetime.strftime(): format datetime objects with standard
format codes (%Y, %m, %d, %H, %M, %S, %A, %a, %B, %b,
%I, %p, %j, %f, %y, %%)
- time.strftime(): format time tuples with the same codes,
implemented in C via MICROPY_PY_TIME_INCLUDEFILE
- datetime.now() returns microseconds (1/50s resolution)
- input() builtin: interactive user input with proper raw/cooked
console mode switching
- sys.stdin, sys.stdout, sys.stderr: standard I/O streams
- os.chmod() now accepts Unix-style permission modes (0o755,
0o666, etc.) and converts them to AmigaOS protection bits
automatically. os.setprotect()/os.getprotect() remain
available for direct access to AmigaOS native bits.
- os.stat() st_mode now reflects real file permissions
(converted from AmigaOS fib_Protection)
- sys.path[0] is set to the script's directory when running
a script, matching CPython behavior for relative imports
Build 186
---------
- ARexx IPC module: send commands to and communicate with any
ARexx-aware application (IBrowse, Directory Opus, etc.)
- os.chmod(): set AmigaOS file protection flags
- os.getprotect(): read AmigaOS file protection flags
- Ctrl-C support: KeyboardInterrupt now works during script
execution, loops, and time.sleep() calls
- Direct .mpy execution: run precompiled bytecode files from
the command line (micropython script.mpy)
- Import .mpy files: precompiled bytecode modules can be
imported alongside regular .py modules
Build 169
---------
- Initial release of this port
Known Limitations
-----------------
- time.ticks_ms() returns 0 (no high-res timer yet)
- hashlib only supports SHA256
- Sockets are always blocking
- No multithreading
- re module: {n} quantifiers are not supported (use explicit
repeated characters instead, e.g. "..." instead of ".{3}")
Source Code
-----------
The full source code is available on GitHub:
https://github.com/OoZe1911/micropython-amiga-port
Latest build can be downloadded here :
https://github.com/OoZe1911/micropython-amiga-port/blob/main/ports/amiga/build/micropython
License
-------
MicroPython is licensed under the MIT License.
|