Cross compiling to arm-linux

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
jjlong
Posts: 5
Joined: Tue Feb 24, 2015 9:36 pm

Cross compiling to arm-linux

Post by jjlong » Wed Mar 16, 2016 7:24 am

I'm trying to cross-compile to use MicroPython on an embedded linux device. Following the instructions on github, on an ubuntu machine i've tried the following:

Code: Select all

 git submodule update --init
 make CROSS_COMPILE=arm-linux-gnueabihf- deplibs
 
This appears to work, but when I then run:

Code: Select all

 git submodule update --init
 make CROSS_COMPILE=arm-linux-gnueabihf-
 
it fails with the following message:
modffi.c:32:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.

When I inspect lib/libffi/build_dir/include, the file 'ffi.h' is there. Any ideas? Are there additional steps required to cross-compile?

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

Re: Cross compiling to arm-linux

Post by dhylands » Wed Mar 16, 2016 7:29 am

This is looking for ffi.h typically in /usr/include someplace. You either need to install libffi-dev or disable ffi by setting building with

Code: Select all

make MICROPY_PY_FFI=0

jjlong
Posts: 5
Joined: Tue Feb 24, 2015 9:36 pm

Re: Cross compiling to arm-linux

Post by jjlong » Wed Mar 16, 2016 8:33 am

I do have libffi installed, but I would have thought it shouldn't matter if I am trying to cross-compile for a different target, and using make deplibs to try to satisfy the dependencies. For the finish, referencing https://github.com/micropython/micropython/issues/253, I ran this command which solved the issue:

Code: Select all

PKG_CONFIG_PATH=~/micropython/lib/libffi/build_dir/ make CROSS_COMPILE=arm-linux-gnueabihf- MICROPY_PY_FFI=1

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

Re: Cross compiling to arm-linux

Post by dhylands » Wed Mar 16, 2016 4:31 pm

If you're cross compiling then you need the cross-compiled libffi installed as well.

So if you on an x86 machine, and have x86 libffi, that can only be used for x86 targets.
If you're cross compiling for arm, then you need the arm libffi installed in a place that the cross compiler will find it.

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: Cross compiling to arm-linux

Post by jgriessen » Mon Jun 27, 2016 12:58 am

Hello Dave, I've been looking things up in the docs getting ready to use my nucleo-F401RE board and later to develop some new stmhal platforms. I came across your write-up https://github.com/micropython/micropyt ... g-st-flash by googling. It is not easy to find any link to it from the main wiki. I'd like to get wiki writing privileges and help. I can write up my first time experiences and it will help others get to it quickly even on a weekend when the forum is quiet. There is not much about development mentioned from the micropython.org docs -- either developing micropython, or using micropython to develop apps on an ARM micro that is not a pyboard. The github page section called "The STM version" is inadequate for a beginner to get results with because of partly defined terms like: To build: $ cd stmhal -- from where though? It is not step by step -- it assumes you've got helpers on the forum to get past the parts that are not written.

So I'll make myself available to write some of this unwritten documentation. John Griessen
John Griessen blog.kitmatic.com

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

Re: Cross compiling to arm-linux

Post by dhylands » Mon Jun 27, 2016 3:51 am

I think you just need a github account to edit the wiki.

SUBBU3881
Posts: 17
Joined: Mon Dec 04, 2017 10:46 am

Re: Cross compiling to arm-linux

Post by SUBBU3881 » Mon Apr 09, 2018 11:45 am

Hello,
Nice discussion. I am also trying to port micropython on to Beagle-Bone Black Linux board. I am facing <b> ffi.h not found<b> issue.
dhylands wrote:
Wed Mar 16, 2016 7:29 am
This is looking for ffi.h typically in /usr/include someplace. You either need to install libffi-dev or disable ffi by setting building with

Code: Select all

make MICROPY_PY_FFI=0
Will MICROPY_PY_FFI=0 solve the issue.?
does Building micropython on to Beagle-Bone not needed MICROPY_PY_FFI.?

Please respond as soon as possible.


Thanks and Regards,
Siva Prakash Reddy

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

Re: Cross compiling to arm-linux

Post by dhylands » Mon Apr 09, 2018 5:27 pm

It isn't really a case of whether MicroPython needs FFI, its a case of whether your code calls any functions which need it.

Many of the functions in micropython-lib call into libc or other shared libraries using FFI. If you don't need to call those functions then you don't need FFI.

Post Reply