Setup Bash under Win 10 to build stm32 boards

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ST58
Posts: 16
Joined: Fri Mar 10, 2017 4:56 pm

Setup Bash under Win 10 to build stm32 boards

Post by ST58 » Thu Nov 09, 2017 9:40 am

This is a setup for build the stm32 boards under windows using Bash for Win 10
I find this more convenient than using a Linux vm under windows as it is easier to get at the final hex/dfu files and then use STMLINK or the STM DFU app under windows to flash the boards

Install Bash under Win 10 - I followed this link:
https://www.howtogeek.com/249966/how-to ... indows-10/
I installed as root - so you don't need passwords or to prefix commands with sudo

when installed open bash and..

sudo apt-get install build-essential libreadline-dev libffi-dev git
git clone https://github.com/micropython/micropython.git


sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded

On the VM build with a 'full' version of UBUNTU you needed to first remove the binutils or arm gcc, but these are not installed on the
bash version

Now you can set the directory to the portts/unix directory and
make axtls
then back to the micrpython directory and build the cross compiler
'make -C mpy-cross'

Now everything is set up to allow builds of the stm boards
Change to ports/stm32
and then
make BOARD=[name of board from boards directory]
At the end of a scuccessfull build in the stm32 directory you will have a folder for the build, in there you will find the firmware.hex and firmware.dfu
start up either stflash (from wndows) or if you can set boot0 etc on the stmboard and get it in dfu mode) use the stm dfu example app.
STLINK:
Connect to the board to the pc using the st link usb ( the one that powers it up on a nucleo board) and then erase the flash, then browse to the firmware.hex file and program the board. Reset it and then plug usb into the 'other' usb connector - and you should see the flash file system etc as normal.
Or if you can get the board into dfu mode, then use the stm dfu utility and use the firmware.dfu file to flash.

Regards to all

ST58
Posts: 16
Joined: Fri Mar 10, 2017 4:56 pm

Re: Setup Bash under Win 10 to build stm32 boards

Post by ST58 » Thu Nov 09, 2017 4:39 pm

Its not quite right yet!!!!
I did the tests on my test pc, which is using win10 build 1607 - when you install bash under win10 it downloads and install Ubuntu 14.04 - and the above package install sequence works just fine.
However, when I went to repeat the installation on my production machine - which is win10 version 1703, install bash under win10 pulls down Ubuntu 16.04. When you try and install the above packages there are a few problems, but if you follow the instructions on the package download data these seem to get fixed.
I can make the unix axtls. But when I try to make the mpy-cross it throws the following error:
"make: python: Command not found
../py/py.mk:269: recipe for target 'build/genhdr/mpversion.h' failed
make: *** [build/genhdr/mpversion.h] Error 127"

I'm guessing that whats happening here is it is trying to run a python script and not finding python. If I list packages it shows that I have python3.5.2 installed. If I type "python" I get a message saying python can be found in the following packages python-minimal and python3. But if I type 2python" on the machine with 14.04, it opens python 2.7.6.

So when you make mpy-cross - in the make file ( py.mk line 269) with the error it refers to :
$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
$(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@
So $(PYTHON) must be some sort of env. setting - most likely calling 'python' = which on the 16.04 version will fail.

SO what version of python do I need installed to build mpy-cross, and what do I have to do to make sure the make process can call it?

I hope this all make sense to one of you Linux guys - remember I know next to nothing about Linux!!

If anyone can help I will be very grateful

Regards

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Setup Bash under Win 10 to build stm32 boards

Post by jickster » Thu Nov 09, 2017 9:49 pm

ST58 wrote:
Thu Nov 09, 2017 4:39 pm
Its not quite right yet!!!!
I did the tests on my test pc, which is using win10 build 1607 - when you install bash under win10 it downloads and install Ubuntu 14.04 - and the above package install sequence works just fine.
However, when I went to repeat the installation on my production machine - which is win10 version 1703, install bash under win10 pulls down Ubuntu 16.04. When you try and install the above packages there are a few problems, but if you follow the instructions on the package download data these seem to get fixed.
I can make the unix axtls. But when I try to make the mpy-cross it throws the following error:
"make: python: Command not found
../py/py.mk:269: recipe for target 'build/genhdr/mpversion.h' failed
make: *** [build/genhdr/mpversion.h] Error 127"

I'm guessing that whats happening here is it is trying to run a python script and not finding python. If I list packages it shows that I have python3.5.2 installed. If I type "python" I get a message saying python can be found in the following packages python-minimal and python3. But if I type 2python" on the machine with 14.04, it opens python 2.7.6.

So when you make mpy-cross - in the make file ( py.mk line 269) with the error it refers to :
$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
$(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@
So $(PYTHON) must be some sort of env. setting - most likely calling 'python' = which on the 16.04 version will fail.

SO what version of python do I need installed to build mpy-cross, and what do I have to do to make sure the make process can call it?

I hope this all make sense to one of you Linux guys - remember I know next to nothing about Linux!!

If anyone can help I will be very grateful

Regards
First you don't need Linux. I'm building it under Windows 10 and I've installed some GNU utils but for you, it may be easier to stay in the Linux VM.

You don't need a specific version of python. It looks like you haven't installed it at all. If you type "python -h" on terminal, what does it do?

ST58
Posts: 16
Joined: Fri Mar 10, 2017 4:56 pm

Re: Setup Bash under Win 10 to build stm32 boards

Post by ST58 » Fri Nov 10, 2017 3:18 pm

Don't know how the post mysteriously moved to 'other boards'. It was under development of micropython!

Anyway the problem of getting python setup that works with the build files has been solved. See the new thread in 'development of micropython' which explains how to install the tools and config system.
Don't know how to link directly to another forum thread on this forum so heres a link instead:
viewtopic.php?f=3&t=4035

Post Reply