Building for STM32 on Linux

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
philcl
Posts: 4
Joined: Sun Jun 17, 2018 2:35 pm

Building for STM32 on Linux

Post by philcl » Sun Jun 17, 2018 3:41 pm

Hi, So I'm new to micropython and was wondering exactly what I need to do to set up a build system on Linux to build firmware for STM32.

I want to set up a VirtualBox Linux guest OS on a Windows 10 host and was wondering what the easiest Linux distribution to work with would be? Does it need to be 32bit, 64bit or does it not matter?

Much of the (terse) documentation on the subject seems to be out of date (still referring to the stmhal directory when this has been moved and renamed ports\stm32 in the latest source).

Exactly which toolchains are needed to accomplish this?

Any advice would be much appreciated!

Phil

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

Re: Building for STM32 on Linux

Post by dhylands » Sun Jun 17, 2018 6:24 pm

It should work under either 32-bit or 64-bit, although recent distros are typically only offered in 64-bit. I use 64-bit native.

I use the launchpad gcc from here: https://launchpad.net/gcc-arm-embedded
Any version should work. I tend to use am older version and Damien tends to use a really new version.

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

Re: Building for STM32 on Linux

Post by pythoncoder » Mon Jun 18, 2018 8:33 am

For an easy Linux distro I recommend (and currently use) Mint 64 bit.
Peter Hinch

philcl
Posts: 4
Joined: Sun Jun 17, 2018 2:35 pm

Re: Building for STM32 on Linux

Post by philcl » Mon Jun 18, 2018 3:07 pm

Hi All

Thankyou so much for your support, it is much appreciated!

For the record, I have this building now. This is what I did, in baby steps, just in case anyone else wants to tread a similar path!

Installed Oracle VM VirtualBox 5.2.12 on Windows 10

Installed Raspberry Pi Desktop (32-bit Debian 9 (Stretch) with Pixel)
into a new virtual machine with 2Gb RAM and 32Gb Disk

( !!! git clone https://github.com/micropython/micropython.git does NOT work for me !!! --
LWIP folder seems to be empty)

downloaded micropython-1.9.4.tar.xz from https://micropython.org/download using Ras Pi web browser

open terminal session:

cd /home/pi/Downloads

uncompress using:

tar xf micropython-1.9.4.tar.xz

using Ras Pi file manager:

move micropython-1.9.4 from /home/pi/Downloads to /home/pi

in terminal session:

cd /home/pi

rename the micropython folder:

mv micropython-1.9.4 micropython

install the toolchain:

sudo apt-get install gcc-arm-none-eabi

try to build micropython cross-compiler tools:

cd /home/pi/micropython/mpy-cross

make

try to build micropython for ST32F4DISC board:

cd /home/pi/micropython/ports/stm32

make BOARD=STM32F4DISC

output is in /home/pi/micropython/ports/stm32/build-STM32F4DISC and is called firmware.hex

Best Regards

philcl

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

Re: Building for STM32 on Linux

Post by dhylands » Mon Jun 18, 2018 6:59 pm

philcl wrote:
Mon Jun 18, 2018 3:07 pm
( !!! git clone https://github.com/micropython/micropython.git does NOT work for me !!! --
LWIP folder seems to be empty)
That's because the lwip directory is actually from another git repository.

When you execute this command:

Code: Select all

git submodule update --init
then it will populate all of the submodules. This shows all of the directories which come from other repositories:

Code: Select all

$ git submodule status
 43a6e6bd3bbc03dc501e16b89fba0ef042ed3ea0 lib/axtls (remotes/origin/micropython-2.1.3)
 35aaec4418ad78628a3b935885dd189d41ce779b lib/berkeley-db-1.xx (remotes/origin/embedded)
 e9de7e35f2339598b16cbb375f9992643ed81209 lib/libffi (v3.2.1-146-ge9de7e3)
 92f23d6ca0971a32f2085b9480e738d34174417b lib/lwip (STABLE-2_0_3_RELEASE)
 1fe30d1446f2eba3730dc4b05e9ac0cf03bcf9bf lib/stm32lib (F0-1.9.0+F4-1.16.0+F7-1.7.0+H7-1.2.0+L4-1.8.1-10-g1fe30d1)

philcl
Posts: 4
Joined: Sun Jun 17, 2018 2:35 pm

Re: Building for STM32 on Linux

Post by philcl » Tue Jun 19, 2018 9:09 am

Thanks for clearing that mystery up Dave, I'll give it another try when I get a minute!

Best Regards

Phil

philcl
Posts: 4
Joined: Sun Jun 17, 2018 2:35 pm

Re: Building for STM32 on Linux

Post by philcl » Tue Jun 19, 2018 10:38 am

This is all working as advertised now, thanks again.

Now, time to dig in and get to grips with MicroPython properly!

Best Regards

Phil :D

Post Reply