Build Failed For Micro Python With STM32F407 Discovery

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
digiPixel
Posts: 3
Joined: Thu Jun 26, 2014 1:21 am

Build Failed For Micro Python With STM32F407 Discovery

Post by digiPixel » Thu Jun 26, 2014 1:27 am

Attempting to build Micro Python for the STM32F407 Discovery but end up with the following errors:


make BOARD=STM32F4DISC

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
CPP ../py/qstrdefs.h
In file included from ../py/mpconfig.h:31:0,
from ../py/qstrdefs.h:27:
./mpconfigport.h:106:20: fatal error: alloca.h: No such file or directory
#include <alloca.h>
^
compilation terminated.
make: *** [build-STM32F4DISC/genhdr/qstrdefs.generated.h] Error 1



Following the instructions from the official wiki on a page titled Board STM32F407 Discovery.

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

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by dhylands » Thu Jun 26, 2014 4:20 am

Hmm.

It seems to be working fine for me.

Are you on the latest tree?

Try running:

Code: Select all

git rev-parse HEAD
f3de62e6c248a4ac6db9e68ed9534e0ec1093a2e
to see what version you're on and let us know. f3de62... is the latest as of the time I wrote this message.

I normally do:

Code: Select all

git status
to make sure I don't have any edited files, and then:

Code: Select all

git checkout master
git pull
and that should update to the latest.

Then do:

Code: Select all

make BOARD=STM32F4DISC clean
make BOARD=STM32F4DISC
Which version of arm-none-eabi-gcc do you have?
Mine reports:

Code: Select all

arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release) [ARM/embedded-4_8-branch revision 205641]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Executing this command (under linux):

Code: Select all

find $(dirname $(type -p arm-none-eabi-gcc))/.. -name alloca.h
should find an alloca.h file. Mine was here:

Code: Select all

/home/dhylands/stm/gcc-arm-none-eabi-4_8-2013q4/bin/../arm-none-eabi/include/alloca.h
If it doesn't find one, then there is something wrong with your toolchain installation (well perhaps - it may depend on the actual location of you arm-none-eabi-gcc)

digiPixel
Posts: 3
Joined: Thu Jun 26, 2014 1:21 am

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by digiPixel » Thu Jun 26, 2014 9:33 pm

Using the following version of the GCC compiler for ARM:

arm-none-eabi-gcc (4.8.2-14ubuntu1+6) 4.8.2


The find command found alloca.h in /usr/bin/../arm-linux-gnueabi/include. Already using the latest Git revision of the Micro Python repository. Tried running make again but ended up with the same errors.

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

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by dhylands » Fri Jun 27, 2014 1:04 am

This is very strange.

On my ubuntu 14.04 machine, I did:

Code: Select all

sudo apt-get install gcc-arm-none-eabi
And it reports:

Code: Select all

arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.8.2-14ubuntu1+6) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Perhaps you could try the following:

Code: Select all

make BOARD=STM32F4DISC V=1
and report back the output.

It's starting to sound like you have an environment variable set which is overriding the compiler or something.

Perhaps try (just in case it got screwed up):

Code: Select all

sudo apt-get install libnewlib-arm-none-eabi
I took a look in buid-STM32F4DISC/file.P and it reports alloca.h is in /usr/include/newlib/alloca.h

On my other computer I did something like this:

Code: Select all

mkdir ~/stm
cd ~/stm
wget 'https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q2-update/+download/gcc-arm-none-eabi-4_8-2014q2-20140609-linux.tar.bz2'
tar xf gcc-arm-none-eabi-4_8-2014q2-20140609-linux.tar.bz2
and added ~/stm/gcc-arm-none-eabi-4_8-2014q2/bin to my PATH

digiPixel
Posts: 3
Joined: Thu Jun 26, 2014 1:21 am

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by digiPixel » Fri Jun 27, 2014 10:37 pm

Installing the libnewlib-arm-none-eabi package did the trick :)

billybumbler
Posts: 4
Joined: Sat Nov 08, 2014 1:44 am

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by billybumbler » Sat Nov 08, 2014 2:38 am

digiPixel wrote:Installing the libnewlib-arm-none-eabi package did the trick :)
I also had a problem building for the STM32F4 discovery board. :( I'm on Linux Mint 17 64bit. I installed the gcc-arm-none-eabi package which also installed binutils-arm-none-eabi.

The error I got was:

Code: Select all

$ make BOARD=STM32F4DISC
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-STM32F4DISC/genhdr
Create build-STM32F4DISC/pins_qstr.h
CPP ../py/qstrdefs.h
In file included from cmsis/inc/core_cm4.h:168:0,
                 from cmsis/devinc/stm32f407xx.h:184,
                 from cmsis/devinc/stm32f4xx.h:126,
                 from hal/inc/stm32f4xx_hal_def.h:48,
                 from hal/inc/stm32f4xx_hal_rcc.h:47,
                 from boards/STM32F4DISC/stm32f4xx_hal_conf.h:236,
                 from hal/inc/stm32f4xx_hal.h:48,
                 from ./mpconfigport.h:136,
                 from ../py/mpconfig.h:43,
                 from ../py/qstrdefs.h:27:
/usr/lib/gcc/arm-none-eabi/4.8.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
 # include_next <stdint.h>
                          ^
compilation terminated.
make: *** [build-STM32F4DISC/genhdr/qstrdefs.generated.h] Error 1
After installing libnewlib-arm-none-eabi...... Success :D

psturgeon54
Posts: 2
Joined: Wed Feb 11, 2015 9:57 pm

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by psturgeon54 » Wed Feb 11, 2015 10:18 pm

I saw this thread and figured it would help me fix my Micro Python build error:

root@hplinuxmint:/home/primo/MicroPython/micropython/stmhal# make
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
CPP ../py/qstrdefs.h
In file included from cmsis/inc/core_cm4.h:168:0,
from cmsis/devinc/stm32f405xx.h:181,
from cmsis/devinc/stm32f4xx.h:122,
from hal/inc/stm32f4xx_hal_def.h:48,
from hal/inc/stm32f4xx_hal_rcc.h:47,
from boards/PYBV10/stm32f4xx_hal_conf.h:236,
from hal/inc/stm32f4xx_hal.h:48,
from ./mpconfigport.h:182,
from ../py/mpconfig.h:45,
from ../py/qstrdefs.h:27:
/usr/lib/gcc/arm-none-eabi/4.8.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^
compilation terminated.
make: *** [build-PYBV10/genhdr/qstrdefs.generated.h] Error 1


Updating the arm library like so should do the trick, I hoped.

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


Unfortunately, no joy with this fix since apt-get has indigestion with libnewlib-arm-none-eabi:

root@hplinuxmint:/home/primo/MicroPython/micropython/stmhal# sudo apt-get install libnewlib-arm-none-eabi
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libnewlib-arm-none-eabi is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libnewlib-arm-none-eabi' has no installation candidate


Any suggestions gratefully received.

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

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by dhylands » Thu Feb 12, 2015 11:23 pm

I installed the toolchain found here: https://launchpad.net/gcc-arm-embedded and it works fine for me.

More specifically, I did:

Code: Select all

mkdir ~/stm
cd ~/stm
wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
tar xf gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
export PATH=$PATH:$HOME/stm/gcc-arm-none-eabi-4_9-2014q4/bin
cd ~/micropython/micropython/stmhal
make BOARD=STM32F4DISC
I normally edit my .bashrc file and add the export line from above so that it's done automatically for me everytime I launch a terminal.

psturgeon54
Posts: 2
Joined: Wed Feb 11, 2015 9:57 pm

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by psturgeon54 » Fri Feb 13, 2015 11:09 pm

Thanks for the speedy tip. I followed your recipe but I still fall at the last fence.
It seems to be something to do with file permissions which is beyond my understanding as a Linux cross-compilation newbie.

Code: Select all

primo@hplinuxmint:~/MicroPython/micropython$ mkdir ~/stm
primo@hplinuxmint:~/MicroPython/micropython$ cd ~/stm
primo@hplinuxmint:~/stm$ wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
--2015-02-13 22:33:12--  https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
Resolving launchpad.net (launchpad.net)... 91.189.89.222, 91.189.89.223
Connecting to launchpad.net (launchpad.net)|91.189.89.222|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://launchpadlibrarian.net/192227997/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2 [following]
--2015-02-13 22:33:12--  https://launchpadlibrarian.net/192227997/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
Resolving launchpadlibrarian.net (launchpadlibrarian.net)... 91.189.89.229, 91.189.89.228
Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.229|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 66355541 (63M) [application/x-tar]
Saving to: ‘gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2’

100%[==============================================================================================================================>] 66,355,541  1.07MB/s   in 42s    

2015-02-13 22:33:54 (1.51 MB/s) - ‘gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2’ saved [66355541/66355541]

primo@hplinuxmint:~/stm$ tar xf gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
primo@hplinuxmint:~/stm$ export PATH=$PATH:$HOME/stm/gcc-arm-none-eabi-4_9-2014q4/bin
primo@hplinuxmint:~/stm$ cd ~/MicroPython/micropython/stmhal
primo@hplinuxmint:~/MicroPython/micropython/stmhal$ make V=1 BOARD=STM32F4DISC
CPP ../py/qstrdefs.h
arm-none-eabi-gcc -E -I. -I.. -Ibuild-STM32F4DISC -Icmsis/inc -Icmsis/devinc -Ihal/inc -Iusbdev/core/inc -Iusbdev/class/cdc_msc_hid/inc -I../lib/fatfs -I../lib/mp-readline -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib  -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion -Os -DNDEBUG -Iboards/STM32F4DISC -fdata-sections -ffunction-sections ../py/qstrdefs.h -o build-STM32F4DISC/genhdr/qstrdefs.preprocessed.h
cc1: fatal error: opening output file build-STM32F4DISC/genhdr/qstrdefs.preprocessed.h: Permission denied
compilation terminated.
make: *** [build-STM32F4DISC/genhdr/qstrdefs.generated.h] Error 1
primo@hplinuxmint:~/MicroPython/micropython/stmhal$ 

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

Re: Build Failed For Micro Python With STM32F407 Discovery

Post by dhylands » Sat Feb 14, 2015 4:40 am

Perhaps you previously tried to do a make using sudo?

From within the stmhal directory, try doing:

Code: Select all

rm -rf build-STM32F4DISC
. If that gives a permission error then try doing:

Code: Select all

sudo rm -rf build-STM32F4DISC 
and then redo the make.

You should never have to use sudo with make (for micropython).

Once you get your build done, you may get permission errors trying to flash (make BOARD=STM32F4DISC deploy). If you add your user to the dialout group, logout an log back in again, then the deploy should work.

Post Reply