-
Notifications
You must be signed in to change notification settings - Fork 0
Micro Python on Mac OSX
Micro Python supports OSX as well as it does Linux: once the necessary software dependencies are installed on an OSX system, development and usage is essentially the same on both platforms, so no special 'tricks' are required to work with Micro Python on OSX. (If any discrepancies are found, they should be reported here or on the user forum.)
Specifically, this means that both the unix and stmhal (pyboard) ports of Micro Python can be compiled on Mac OSX directly from the master branch without any alteration. This article aims to describe which software packages are required to build Micro Python and how to install them on your OSX system. I use Macports so this article will focus on that; it is also possible to Homebrew to install the required software dependencies.
This article is targeted towards Micro Python developers using OSX, it will address OSX specific issues rather than general development questions.
Recent modifications to the build scripts have made the build process for the unix port on OSX the same as it is that on Linux, despite the fact that Micro Python is built using gcc on Linux and clang on OSX. In order to compile on OSX you will need the following software packages installed:
- A relatively recent version of Xcode to provide the clang compiler (micropython has been confirmed to compile under clang versions 3.1 and 4.2)
- Macports for the next commands
- libffi (minimum version 3.1-4 from Macports)
sudo port install libffi - pkgconfig
sudo port install pkgconfig - Python >= 3.3
sudo port install python34 - git - to keep local source tree up to date
Same as on Linux - go to micropython/unix and run make (or make -B or make clean; make if rebuilding.
Go to micropython/tests and run the test script ./run-tests
The test script will look for the executable in ../unix/micropython and will compare the output of the micropython executable to the locally installed version of Python3
- If your Python3 executable is named
python3.xthen it may be necessary to create a link namedpython3to this executable - All tests should pass on OSX, however it may be necessary to set the encoding in the terminal to 'UTF-8' if the unicode tests are failing
Required software:
- mac version of gcc-arm-none-eabi, version >= 4.8
- dfu-util >= 0.7 to load firmware to pyboard
- Python3 >= 3.3
- pyserial package for Python3
TODO: building stmhal
TODO: Using test scripts to run tests on pyboard
cd micropython/tests
./run-tests --pyboard --device /dev/tty.usbmodem*
Using pyboard.py to run python scripts residing on the mac:
python3 tools/pyboard.py --device /dev/tty.usbmodem* FILE
Type screen /dev/tty.usbmodem* with * replaced by your specific device number; use ls /dev/tty.usbmodem* to find the name of your device.
To exit from 'screen' type 'Ctl-a, k'; and then answer 'y' to exit
Development workflow on mac is the same as for Linux; see DevelWorkflow for recommended workflow practices and usage of git.
TODO: Issues that may be encountered using previous versions of pyboard firmware (USB mass storage issue) that can be fixed with firmware upgrade