Cross Compiler only

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
slzatz
Posts: 92
Joined: Mon Feb 09, 2015 1:09 am

Re: Cross Compiler only

Post by slzatz » Thu Aug 25, 2016 1:35 pm

The new WSL (Windows Subsystem for Linux) on Windows 10 compiles the esp-open-sdk without a problem if that is helpful information.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Cross Compiler only

Post by dhylands » Thu Aug 25, 2016 3:50 pm

Yeah - it does run linux binaries, and uses apt to install stuff.

They've emulated the serial ports so that you can get to the MicroPython REPL, but they don't have USB support yet, so you can't program via DFU. There is some network support (regular socket stuff works - ICMP requires Administrator privledges).

Llwy
Posts: 34
Joined: Thu Mar 10, 2016 7:43 am

Re: Cross Compiler only

Post by Llwy » Fri Aug 26, 2016 8:45 pm

Dear Robert,
I am happy to report that the cross compiler could be built on windows bash.
The cross compiler successfully froze some test modules which could be imported on your firmware.

This is very nice, thank you so much.

Llwy

HRD
Posts: 4
Joined: Sat Dec 24, 2016 1:52 am

Re: Cross Compiler only

Post by HRD » Sat Jan 14, 2017 4:10 am

Windows NOOB: How to build MPY-CROSS on your Windows system.

First, thanks for all the great work by everyone working on Micropython!

OK, a little green and using Windows (Win7). Took me a while, but I finally figured out how to pull the necessary pieces together to be able to create (make) MPY-CROSS (since I did not have Unix or a GCC Compiler installed yet). I thought I'd document the steps so others in my predicament may take advantage of this (and any other tools that need to be created with the Unix MAKE) on a Windows box... (BTW: I'm sure that there are other/better ways, but this worked for me, so not advocating one way/software over another. Experts please way in.)

A) Get Micropython code tree (if you don't already have it):
1) Get the Micropython source code. Go to https://github.com/micropython/micropython which is the top level for Micropython.
2) There should be a green 'Clone or download' button on the top right. Click on it and select 'Download Zip'.
3) Once it has been downloaded, unzip it to your hard drive.

B) Get Python (if you don't already have it):
4) Make sure you have a copy of Python installed on your computer. Go to https://www.python.org/downloads/ I had Python2.7 installed, so that is what I used.
5) Run the Python installer. (If you are doing an install, make sure 'add Python to PATH' is checked. If not, we will check it in a later step.)

C) Get MinGW and MSYS GCC Compiler/environment:
6) Install MinGW and MSYS native Windows port of the GNU Compiler Collection (GCC). Go to: http://www.mingw.org/download/installer. (Note this will install the 32-bit version, as I could not get the 64-bit version to load, but it still seem to work.)
7) Run the MinGW setup (mingw-get-setup.exe). Note, if you change the default location, DO NOT put spaces in the directory name.
8) Once the setup is complete, you will go to the 'MinGW Installation Manager' (If you ever need to run it again, it is 'mingw-get.exe' located in the 'bin' subdirectory under the MingGW installation directory.)
9) On the left hand panel, select 'Basic Setup'. Under the 'Packages' on the upper right hand panel select 'mingw32- base', 'mingw-32-gcc-g++', and 'msys-base'. (Click on the checkbox next to the name and select 'Mark for Installation'.)
10) Once the 3 packages are selected,click on the 'Installation' menu and select 'Apply Changes'. The packages will be downloaded and installed.

Update system PATH (most difficult part):
11) You need to tell Windows where all the stuff is that you downloaded and update the system PATH variable. Go to 'Start', 'Settings', 'Control panel' and select 'System' and then 'Advanced Systems Settings'.
12) In the 'System Properties' dialog, click on 'Environment Variables'.
13) In the bottom 'System Variables' window, scroll down and click on the entry 'Path' and click 'Edit' and the Edit System Variable window should appear with the current path selected. (Hit end to get the cursor to appear at the end of the field.)
14) You need to add the paths for 'Python' (if it was not done during the installation), the MinGW 'bin' directory and the MSYS 'bin' directory. (Suggestion: Press CTRL-A (select all) and CTRL-C (copy) and paste the current path variable value into Notepad. It is easier (and safer) to edit it there and then copy the full edited path back in the variable value field.) As an example, the location of my python.exe was C:\python27\, the location of my MinGW bin directory was C:\MinGW\bin\ and the location of my MSYS bin directory was C:\MinGW\msys\1.0\bin\, so I added ';C:\python27\;C:\MinGW\bin\;C:\MinGW\msys\1.0\bin\' to the end of my path. Note the ';' at the beginning and between each path, the '\' at the end of the path names, and don't add the single quotes. DO NOT CHANGE ANY OTHER ITEMS IN THE PATH (OR DELETE IT) OR SOME OF YOUR EXISTING SOFTWARE MAY STOP WORKING.
15) Once the path has been updated in the Edit System Variable window, click on 'OK', 'OK' and 'OK'. You can also close the Control Panel window.

Make MPY-CROSS:
16) Go to Start button, select Run, and enter cmd and click on OK.
17) You can check your path variable is correct (only have to do this once) by typing 'path' and press enter. You should see the additional path entries for Python, MinGW and MSYS near the end of the PATH string. (Don't be alarmed if there is also stuff after it.)
18) Navigate to where you unzipped the Micropython code tree zip file and go to the MPY-CROSS subdirectory.
19) Type 'make' and press enter.
20) After a while, the build process should complete. Note, mine completed with an error regarding 'strip.exe' and a file not found, but the file 'mpy-cross.exe' existed anyway.

You are done! You can now turn .py libraries into (smaller) .mpy libraries.

FYI - I ran MPY-CROSS against 3 .py files I had:
-a 4157 byte .py file became a 855 byte .mpy
-a 8269 byte .py file became a 6132 byte .mpy
-a 5087 byte .py file became a 1463 byte .mpy

Thanks again for all the great work.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Cross Compiler only

Post by pythoncoder » Sat Jan 14, 2017 7:04 am

Alas this suggestion is well out of date: the builds were last updated on 24th Sept 2016. It was a useful service.

Building the toolchain is OK if you set up a Linux VM specifically for the purpose. That avoids dependency hell, but you do need a patience, even with a fast machine.
Peter Hinch
Index to my micropython libraries.

Post Reply