[CLOSED] Custom Micropython build

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
RustleOfCicada
Posts: 2
Joined: Mon Dec 16, 2019 12:25 pm

[CLOSED] Custom Micropython build

Post by RustleOfCicada » Mon Dec 16, 2019 12:38 pm

[CLOSED] Windows Bash solved the issue.
Basically, I want to make my own changes in Micropython source code e.g. change pin of HW_LED_1 (one of four LEDs mounted to the board). I follow the instructions that are listed in README.md here: (https://github.com/micropython/micropyt ... orts/stm32)
So far I was able to:
- install Git
- install msys-make (as make path)
- install arm-none-eabi-gcc (as gcc path)

Now when I follow the instructions, almost every command I write returns error:

Code: Select all

-Cannot openmake: *** [build/genhdr/mpversion.h] Error 1
or

Code: Select all

make: *** No children. Stop
Instructions I tried:
make -C mpy-cross (in master)
make (in mpy-cross)

Also in ports/stm32 I get an error:

Code: Select all

error: pathspec '../../lib/lwip' did not match any file(s) known to git
for four libraries (names respectively) that have to be updated

It seems that Git has no permissions or something. Any ideas will be helpful :)

My operating system - Windows 10
Build for - STM32F405 (PYBV11)
Last edited by RustleOfCicada on Tue Dec 24, 2019 9:56 am, edited 2 times in total.

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

Re: Custom Micropython build

Post by pythoncoder » Tue Dec 17, 2019 7:52 am

How did you clone the source? What is msys-make? I'm not familiar with Windows but under Linux the makefile executable is simply "make".

You should be able to go into the ports/stm32 directory on your PC and issue

Code: Select all

make BOARD=PYBV11
Peter Hinch

stijn
Posts: 406
Joined: Thu Apr 24, 2014 9:13 am

Re: Custom Micropython build

Post by stijn » Tue Dec 17, 2019 9:02 am

or four libraries (names respectively) that have to be updated
Doesn't this mean you forgot to use 'make submodules', which would get the needed libraries from git?

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

Re: Custom Micropython build

Post by pythoncoder » Tue Dec 17, 2019 4:45 pm

I have never issued make submodules. To update my local repo prior to building I issue

Code: Select all

git checkout master
git pull origin master
git submodule update --init
Peter Hinch

User avatar
jimmo
Posts: 1156
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Custom Micropython build

Post by jimmo » Tue Dec 17, 2019 10:36 pm

'make submodules' was recently added as an alias for 'git submodule update' but it only fetches the submodules relevant to the port.

(Mostly this was done to simplify CI builds, but the README files were also updated to recommend this instead)

chrismas9
Posts: 134
Joined: Wed Jun 25, 2014 10:07 am

Re: Custom Micropython build

Post by chrismas9 » Sun Dec 22, 2019 3:00 am

You need to install the full MSYS2, not just make. There are various utils like SED that are needed. You need to set the MSYS2 path before windows\system32 because it has to replace some Windows utilities.

I find it easier to use WSL for building MicroPython with Windows tools for managing source code (Ultraedit or Notepad++, Tortoise GIT, Winmerge and grepwin).

stijn
Posts: 406
Joined: Thu Apr 24, 2014 9:13 am

Re: Custom Micropython build

Post by stijn » Sun Dec 22, 2019 10:08 am

You need to set the MSYS2 path before windows\system32 because it has to replace some Windows utilities
Possibly, but you should be launching via msys2.exe which takes care of all that.

But indeed if you're cross-compiling anyway and have Windows 10 it would be crazy not to use WSL. Don't get me wrong, I've used Cygwin and msys2 for years but that's really only because a) they have an ssh command and b) it's way more convenient than having to reboot into unix :)

Anyway: I cannot reproduce the OP's issue. There are other problems though but that might be my mistake, but I can get a binary built. I started from an existing msys2 installation (note the '2', there's also plain msys but that is not what you want) so don't have exact steps for all installed packages but it should be something like:

Code: Select all

pacman -S make python3 git mingw-w64-x86_64-gcc
git clone
cd micropython
git -C mpy-cross STRIP=echo SIZE=echo
The last step effectively skips the strip/size steps, because otherwise the build fails because makefile looks for mpy-cross but the output is mpy-cross.exe. This is a known problem.

Then download arm gcc zip file from https://developer.arm.com/tools-and-sof ... /downloads, unpack it to msys2 root, make the msys2 environment aware of it:

Code: Select all

export CFLAGS="-I/gcc-arm-none-eabi/include"
export LDFLAGS="-L/gcc-arm-none-eabi/lib -mthreads"
export PATH="/gcc-arm-none-eabi/bin:$PATH"
(not 100% sure if this is the best 'msys2 way' but it works) then build

Code: Select all

cd ports/stm32
make BOARD=PYBV11 CROSS_COMPILE=arm-none-eabi-
This creates build-PYBV11/firmware.elf without problems.
No mention of any of the errors you have though, so more information is needed. E.g. this doesn't even build anything lwip related, so without knowing exact build modifications it's hard to figure out what goes wrong.

RustleOfCicada
Posts: 2
Joined: Mon Dec 16, 2019 12:25 pm

Re: Custom Micropython build

Post by RustleOfCicada » Tue Dec 24, 2019 9:38 am

Thank you all for the replies :)
After many days of fixing Windows version of 'make' I found Windows Bash (Ubuntu terminal) and there everything works just fine :). I have successfully build Micropython.

Post Reply