README.md 3.04 KB
Newer Older
Damien George's avatar
Damien George committed
1
<img src="https://travis-ci.org/micropython/micropython.png?branch=master" alt="build status"/>
2

Damien's avatar
Damien committed
3
4
The Micro Python project
========================
5
<p align="center">
6
  <img src="https://raw2.github.com/micropython/micropython/master/logo/upython-with-micro.jpg" alt="MicroPython Logo"/>
7
</p>
Damien's avatar
Damien committed
8

Damien's avatar
Damien committed
9
This is the Micro Python project, which aims to put an implementation
10
of Python 3.x on a microcontroller.
Damien's avatar
Damien committed
11

12
13
WARNING: this project is in its early stages and is subject to large
changes of the code-base, including project-wide name changes and API
Damien George's avatar
Damien George committed
14
changes.
15

16
See the repository www.github.com/micropython/pyboard for the Micro
Damien George's avatar
Damien George committed
17
Python board.
18
19

Major components in this repository:
Damien's avatar
Damien committed
20
21
- py/ -- the core Python implementation, including compiler and runtime.
- unix/ -- a version of Micro Python that runs on Unix.
Damien George's avatar
Damien George committed
22
23
- stmhal/ -- a version of Micro Python that runs on the Micro Python board
  with an STM32F405RG (using ST's new Cube HAL drivers).
Damien George's avatar
Damien George committed
24
25
- teensy/ -- a version of Micro Python that runs on the Teensy 3.1
  (preliminary but functional).
Damien's avatar
Damien committed
26

Damien's avatar
Damien committed
27
Additional components:
Damien George's avatar
Damien George committed
28
29
30
31
- bare-arm/ -- a bare minimum version of Micro Python for ARM MCUs.  Start
  with this if you want to port Micro Python to another microcontroller.
- stm/ -- obsolete version of Micro Python for the Micro Python board
  that uses ST's old peripheral drivers.
Damien's avatar
Damien committed
32
33
- unix-cpy/ -- a version of Micro Python that outputs bytecode (for testing).
- tests/ -- test framework and test scripts.
Damien George's avatar
Damien George committed
34
- tools/ -- various tools, including the pyboard.py module.
Damien George's avatar
Damien George committed
35
- examples/ -- a few example Python scripts.
Damien's avatar
Damien committed
36

37
"make" is used to build the components, or "gmake" on BSD-based systems.
Damien George's avatar
Damien George committed
38
You will also need bash and Python (at least 2.7 or 3.3).
Damien's avatar
Damien committed
39

Damien's avatar
Damien committed
40
The Unix version
Damien's avatar
Damien committed
41
42
----------------

Damien George's avatar
Damien George committed
43
The "unix" port requires a standard Unix environment with gcc and GNU make.
44
x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well
45
as ARMv7. Porting to other architectures require writing some assembly code
46
for the exception handling.
Damien's avatar
Damien committed
47
48

To build:
Damien's avatar
Damien committed
49

Damien's avatar
Damien committed
50
51
52
53
    $ cd unix
    $ make

Then to test it:
Damien's avatar
Damien committed
54

55
    $ ./micropython
Damien's avatar
Damien committed
56
57
    >>> list(5 * x + y for x in range(10) for y in [4, 2, 1])

58
59
Debian/Ubuntu/Mint derivative Linux distros will require build-essentials and
libreadline-dev packages installed. To build FFI (Foreign Function Interface)
60
61
module, libffi-dev package is required. If you have problems with some
dependencies, they can be disabled in unix/mpconfigport.mk .
Dr-Syn's avatar
Dr-Syn committed
62

Damien's avatar
Damien committed
63
The STM version
Damien's avatar
Damien committed
64
65
---------------

Damien George's avatar
Damien George committed
66
The "stmhal" port requires an ARM compiler, arm-none-eabi-gcc, and associated
Damien's avatar
Damien committed
67
68
69
70
71
bin-utils.  For those using Arch Linux, you need arm-none-eabi-binutils and
arm-none-eabi-gcc packages from the AUR.  Otherwise, try here:
https://launchpad.net/gcc-arm-embedded

To build:
Damien's avatar
Damien committed
72

Damien George's avatar
Damien George committed
73
    $ cd stmhal
Damien's avatar
Damien committed
74
75
    $ make

Damien George's avatar
Damien George committed
76
77
78
79
80
You then need to get your board into DFU mode.  On the pyboard, connect the
3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other
on the bottom left of the board, second row from the bottom).

Then to flash the code via USB DFU to your device:
Damien's avatar
Damien committed
81

Damien's avatar
Damien committed
82
83
84
    $ dfu-util -a 0 -D build/flash.dfu

You will need the dfu-util program, on Arch Linux it's dfu-util-git in the AUR.