[ell-i-developers] Re: Ellduino Emulator: Fixing issues for Linux (Ubuntu 12.04 LTS)

  • From: Asif Sardar <engr.asif.sardar@xxxxxxxxxxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Mon, 17 Feb 2014 05:08:28 +0200

Hi Pekka,





*Hmm.  This is very strange.  Are you sure you are using an i386 compiler,
i.e. a native Linux compiler? As Arduino is moving to arm-gcc 4.8.3 for
Arduino Due, and we will be moving to arm-gcc 4.8 for our board-native
binaries, for the emulator we must match that with an i386-gcc 4.8.x.  Or,
actually, i386-gcc 4.7.x is enough. I'm using myself gcc 4.7.1 because I'm
too lazy to move to 4.8 at the moment.  Hence, we will continue to support
gcc 4.7 for a while, too. Hence, you have to install gcc 4.8.3-latest (or
4.7.latest) as a native compiler to your Linux, and compile the emulator
with that.   I don't know Linux well enough so that I could help in that.*

I had been confused with the compilers that we are using separately for
board (embedded) and
for emulator (native Linux compiler). You were right, I was using wrong
compiler for emulator (arm-gcc same as I used for board).

Now my path contains native gcc-4.7 g++-4.7: you may see lines below from
CMD linux

asif@asif-Satellite-C655:~$ gcc --version
gcc (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04) 4.7.3

asif@asif-Satellite-C655:~$ g++ --version
g++ (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04) 4.7.3

*Note:*
I tried building the gcc-4.8.x from source, but its not ready yet and seems
to have dependencies and configuration issues that might need to be fixed
manually and may need quit advanced level unix/linux shell/scripting
knowledge. Luckily, I found the test-repositories from Ubuntu official
websites and installed and configured easily the packages gcc&g++ version
4.7 as instructed by them in the website.

*Firstly, you still have -std=c++98 there.  That is wrong, please go back
to C++11 standard.  You will hit problems later on, we *are* using C++11
constexpr and some other C++11 stuff, and those parts of the source won't
compile with c++98.*

Changed!

*Second, it looks very much like the g++ you are using on the command line
is an arm-gcc, not i386-gcc, as it seems to accept the -mthumb flag and
especially if it is complaining about -march=i386.*

*Hence, I'm suspecting that you are somehow using a wrong version of the
compiler.  Please check.*

I have now tried building emulator with gcc-4.7, but the compilation gets
stuck with:

asif@asif-Satellite-C655:~/Ell-i/Runtime/stm32/build$ make PLATFORM=emulator
make PLATFORM=emulator -f ../make/app.mk all
make[1]: Entering directory `/home/asif/Ell-i/Runtime/stm32/build'
g++ -c -std=c++11 -g -Os -Wall -ffunction-sections -fdata-sections
-fno-common -nostdlib  -mthumb -DF_CPU=48000000L -DARDUINO=1.5.4
-DELLI_STM32F051_ELLDUINO -DARDUINO_ARCH_STM32 -fno-rtti -fno-exceptions
-fno-threadsafe-statics -DEMULATOR -D__STM32F051__ -Dmain=emulated_main
-I../emulator/inc -I../cores/arduelli -I../system/stm32/inc
-I../system/stm32/CMSIS/Include -I../variants/ellduino    -c -o emulator.o
../emulator/src/emulator.cpp
g++: error: unrecognized command line option '-mthumb'
make[1]: *** [emulator.o] Error 1
make[1]: Leaving directory `/home/asif/Ell-i/Runtime/stm32/build'
make: *** [all] Error 2

When I remove -mthumb from platform.txt file (compiler.cflags.target=
-mcpu={build.mcu} -mthumb), I get:

g++ -c -std=c++11 -g -Os -Wall -ffunction-sections -fdata-sections
-fno-common -nostdlib  -DF_CPU=48000000L -DARDUINO=1.5.4
-DELLI_STM32F051_ELLDUINO -DARDUINO_ARCH_STM32 -DEMULATOR -D__STM32F051__
-Dmain=emulated_main -I../emulator/inc -I../cores/arduelli
-I../system/stm32/inc -I../system/stm32/CMSIS/Include
-I../variants/ellduino    -c -o system_init.o
../system/stm32/src/system_init.c
../system/stm32/src/system_init.c: In function 'void
SystemInitPeripherals()':
../system/stm32/src/system_init.c:113:50: error: cast from 'const
SystemInitRecordArray*' to 'uint32_t {aka unsigned int}' loses precision
[-fpermissive]
make[1]: *** [system_init.o] Error 1
make[1]: Leaving directory `/home/asif/Ell-i/Runtime/stm32/build'
make: *** [all] Error 2

Are these problems arising because of MAC related configurations for GCC or
due to MAC specific code? Or may be I am using 64-bit system and code runs
on 32-bit system ... In this particular case, what do you suggest?


On Sat, Feb 15, 2014 at 7:24 AM, Pekka Nikander <pekka.nikander@xxxxxx>wrote:

> >     1- With following line at emulator.txt file at path
> ....../Runtime/stm32/make/
> >         compiler.cflags.target=    -m32 -march=i386
> >
> >            I get errors:
> >            g++: error: unrecognized argument in option '-march=i386'
> >            g++: error: unrecognized command line option '-m32'
>
> Hmm.  This is very strange.  Are you sure you are using an i386 compiler,
> i.e. a native Linux compiler?
>
> As Arduino is moving to arm-gcc 4.8.3 for Arduino Due, and we will be
> moving to arm-gcc 4.8 for our board-native binaries, for the emulator we
> must match that with an i386-gcc 4.8.x.  Or, actually, i386-gcc 4.7.x is
> enough. I'm using myself gcc 4.7.1 because I'm too lazy to move to 4.8 at
> the moment.  Hence, we will continue to support gcc 4.7 for a while, too.
>
> Hence, you have to install gcc 4.8.3-latest (or 4.7.latest) as a native
> compiler to your Linux, and compile the emulator with that.   I don't know
> Linux well enough so that I could help in that.
>
> >     2- However, commenting above, I get .o for all emulator c++ code,
> except for emulator_pre.c and emulator_post.c. I get
> >         following error for these:
> > ...
> > make PLATFORM=emulator -f ../make/app.mk all
> > make[1]: Entering directory `/home/asif/Ell-i/Runtime/stm32/build'
> > g++ -c -std=c++98 -g -Os -Wall -ffunction-sections -fdata-sections
> -fno-common -nostdlib  -mthumb -DF_CPU=48000000L -DARDUINO=1.5.4
> -DELLI_STM32F051_ELLDUINO -DARDUINO_ARCH_STM32 -DEMULATOR -D__STM32F051__
> -Dmain=emulated_main -I../emulator/inc -I../cores/arduelli
> -I../system/stm32/inc -I../system/stm32/CMSIS/Include
> -I../variants/ellduino    -c -o emulator_pre.o
> ../emulator/src/emulator_pre.c
> >            /tmp/ccklpwuF.s: Assembler messages:
> >            /tmp/ccklpwuF.s:18: Error: character following name is not '#'
> >            make[1]: *** [emulator_pre.o] Error 1
>
> Firstly, you still have -std=c++98 there.  That is wrong, please go back
> to C++11 standard.  You will hit problems later on, we *are* using C++11
> constexpr and some other C++11 stuff, and those parts of the source won't
> compile with c++98.
>
> Second, it looks very much like the g++ you are using on the command line
> is an arm-gcc, not i386-gcc, as it seems to accept the -mthumb flag and
> especially if it is complaining about -march=i386.
>
> Hence, I'm suspecting that you are somehow using a wrong version of the
> compiler.  Please check.
>
> -----
>
> Hmm.  I expect this is quite normal and that we will encounter this many
> times as more people come along.  It is often very confusing with multiple
> compilers when working with embedded systems.
>
> Hence it would be very good to write a wiki page on the compilation
> environment, creating very clear instructions how to compile the arm-gcc
> cross compiler for the board-native binaries and how to compile the
> i386-gcc native compiler for the emulator binaries.
>
> Anyone wants to help Asif in creating such a wiki page?  Teemu?  Eero?
>  Ivan?
>
> --Pekka
>
>
>


-- 



*With Best Regards,Asif Sardar.+358 43 8265795*

Other related posts: