Lauszus / LaunchPadFlightController

TM4C123G based Flight Controller
78 stars 36 forks source link

PlatformIO integration #2

Closed Lauszus closed 9 years ago

Lauszus commented 9 years ago

Still work in progress.

Lauszus commented 9 years ago

@ivankravets I am trying to use PlatformIO for this project, but I am having trouble getting it to include the libaries inside the libs folder: https://github.com/Lauszus/LaunchPadFlightController/tree/PlatformIO/lib.

It does not seems like the lib folder is added to the include path:

src/Bluetooth.c:31:27: fatal error: inc/hw_memmap.h: No such file or directory
#include "inc/hw_memmap.h"

I want to use libopencm3 to compile it, so I can get rid of using Keil, which is not open source. Do you got any examples available on how to use PlatformIO for the lptm4c1230c3pm platform?

ivankravets commented 9 years ago

Do you got any examples available on how to use PlatformIO for the lptm4c1230c3pm platform?

Yes, we have a few examples for TI TIVA https://github.com/platformio/platformio/tree/develop/examples/titiva


@valeros Could you help @Lauszus to build this project using PlatformIO?

Lauszus commented 9 years ago

@ivankravets thanks, it got me this far:

arm-none-eabi-gcc -o .pioenvs/lptm4c1230c3pm/src/Bluetooth.o -c -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -MMD -DF_CPU=80000000L -DARDUINO=101 -DENERGIA=15 -DPLATFORMIO=020000 -I.pioenvs/lptm4c1230c3pm/FrameworkEnergia -I.pioenvs/lptm4c1230c3pm/FrameworkEnergiaVariant src/Bluetooth.c
In file included from src/MPU6500.h:23:0,
from src/Bluetooth.h:21,
from src/Bluetooth.c:23:
src/Types.h:21:0: warning: ignoring #pragma anon_unions  [-Wunknown-pragmas]
#pragma anon_unions
^
src/Bluetooth.c: In function 'initBluetooth':
src/Bluetooth.c:116:22: error: 'GPIO_PB0_U1RX' undeclared (first use in this function)
GPIOPinConfigure(GPIO_PB0_U1RX);
^
src/Bluetooth.c:116:22: note: each undeclared identifier is reported only once for each function it appears in
src/Bluetooth.c:117:22: error: 'GPIO_PB1_U1TX' undeclared (first use in this function)
GPIOPinConfigure(GPIO_PB1_U1TX);
^
src/Bluetooth.c:124:5: warning: implicit declaration of function 'UARTEchoSet1' [-Wimplicit-function-declaration]
UARTEchoSet1(false);
^
src/Bluetooth.c: In function 'readBluetoothData':
src/Bluetooth.c:133:5: warning: implicit declaration of function 'UARTRxBytesAvail1' [-Wimplicit-function-declaration]
if (UARTRxBytesAvail1() > strlen(commandHeader)) {
^
src/Bluetooth.c: In function 'findString':
src/Bluetooth.c:408:5: warning: implicit declaration of function 'UARTPeek1' [-Wimplicit-function-declaration]
int pos = UARTPeek1(*string); // Look for the first character
^
src/Bluetooth.c: In function 'readBytes':
src/Bluetooth.c:432:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (uint8_t i = 0; i < length; i++)
^
src/Bluetooth.c:432:5: note: use option -std=c99 or -std=gnu99 to compile your code
src/Bluetooth.c: In function 'sendData':
src/Bluetooth.c:452:5: warning: implicit declaration of function 'UARTFlushTx1' [-Wimplicit-function-declaration]
UARTFlushTx1(false); // Flush TX buffer
^
src/Bluetooth.c: In function 'getCheckSum':
src/Bluetooth.c:459:5: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < length; i++)
^
scons: *** [.pioenvs/lptm4c1230c3pm/src/Bluetooth.o] Error 1

It seems like driverlib/pin_map.h is not included properly.

I will also need to figure out how to enable C99 mode :)

Lauszus commented 9 years ago

I got C99 mode working:

build_flags = -std=c99
Lauszus commented 9 years ago

Almost got it compiling. Still need to figure out to make it work with my startup code:

src/startup_rvmdk.S: Assembler messages:
src/startup_rvmdk.S:1: Error: junk at end of line, first unrecognized character is `<'
src/startup_rvmdk.S:2: Error: junk at end of line, first unrecognized character is `*'
src/startup_rvmdk.S:4: Error: bad size 0 in type specifier
src/startup_rvmdk.S:4: Error: bad instruction `startup_rvmdk.s -Startup code for use with Keil115uVision.'
src/startup_rvmdk.S:6: Error: bad instruction `copyright (c)2012-2014 Texas Instruments Incorporated. All rights reserved.'
src/startup_rvmdk.S:7: Error: bad instruction `software License Agreement'
src/startup_rvmdk.S:9: Error: bad instruction `texas Instruments(TI)is supplying this software for use solely and'
src/startup_rvmdk.S:10: Error: bad instruction `exclusively on TI115microcontroller products. The software is owned by'
src/startup_rvmdk.S:11: Error: bad instruction `ti and/or its suppliers,and is protected under applicable copyright'
....
ivankravets commented 9 years ago

I'm going to look into your project now.

P.S: Do you have permission to merge my pull request here? https://github.com/shirriff/Arduino-IRremote/pull/141

Thanks in advance! :blush:

Lauszus commented 9 years ago

Thanks!

No unfortunately not.

Lauszus commented 9 years ago

@ivankravets I need to configure this as well somehow: https://github.com/Lauszus/LaunchPadFlightController/blob/master/LaunchPadFlightController.uvprojx#L401.

ivankravets commented 9 years ago

As for your problem with asm file, I'm trying to understand why PlatformIO/SCons doesn't use asm compiler for this file. I will answer here...

I need to configure this as well somehow

[env:...]
build_flags = -Wl,--entry Reset_Handler
Lauszus commented 9 years ago

@ivankravets thanks!

ivankravets commented 9 years ago

Have you resolved it? Because I can't compile this ".S" file :(

Lauszus commented 9 years ago

No I can't compile the .S file as well :(

ivankravets commented 9 years ago

In both cases compiler doesn't understand this file:

# treat as arm-none-eabi-gcc -x assembler-with-cpp
arm-none-eabi-gcc -x assembler-with-cpp -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib -MMD -DF_CPU=80000000L -DPART_TM4C123GH6PM -DUART_BUFFERED -DUART_BUFFERED1 -DUART_DEBUG=0 -DUSE_MAG=1 -DUSE_BARO=0 -DARDUINO=101 -DENERGIA=15 -DPLATFORMIO=020001 -I.pioenvs/lptm4c1230c3pm/FrameworkEnergia -I.pioenvs/lptm4c1230c3pm/FrameworkEnergiaVariant -c -o .pioenvs/lptm4c1230c3pm/src/startup_rvmdk.o src/startup_rvmdk.S
src/startup_rvmdk.S: Assembler messages:
src/startup_rvmdk.S:1: Error: junk at end of line, first unrecognized character is `<`

# native ASM
arm-none-eabi-as -o .pioenvs/lptm4c1230c3pm/src/startup_rvmdk.o src/startup_rvmdk.s
src/startup_rvmdk.s: Assembler messages:
src/startup_rvmdk.s:1: Error: junk at end of line, first unrecognized character is `<`

How does Keil compile that file? Could you give me console output from Keil build process?

P.S: See how SCons handles ASM files: https://bitbucket.org/scons/scons/src/c482dddeafc548feec6e4270a35676955c1f34d8/src/engine/SCons/Tool/as.py?at=default

P.S.S: I've just extended the list of ASM extensions: https://github.com/platformio/platformio/commit/8f65492d96be45ca97f6dfca3310853ddec7d90f

if you want to play with it, please use development version of PlatformIO: http://docs.platformio.org/en/latest/installation.html#development-version

Lauszus commented 9 years ago

@ivankravets yeah. It looks like a problem with PlatformIO?

Lauszus commented 9 years ago

@ivankravets okay. I will try the development version now.

ivankravets commented 9 years ago

@Lauszus I'm not sure that this is problem with PlatformIO. See the output of commands above.

Could you give me console output from Keil build process?

Lauszus commented 9 years ago

@ivankravets it's not that easy. It seems like they hide it away intentionally.

Anyway I tried to use the startup file used by Energia: https://github.com/energia/Energia/blob/master/hardware/lm4f/cores/lm4f/startup_gcc.c, but that is not working either:

.pioenvs/lptm4c1230c3pm/FrameworkEnergia/startup_gcc.c: In function '_sbrk':
.pioenvs/lptm4c1230c3pm/FrameworkEnergia/startup_gcc.c:545:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'asm'
extern char end asm ("end"); /* Defined by linker */
^
.pioenvs/lptm4c1230c3pm/FrameworkEnergia/startup_gcc.c:545:21: warning: implicit declaration of function 'asm' [-Wimplicit-function-declaration]
.pioenvs/lptm4c1230c3pm/FrameworkEnergia/startup_gcc.c:550:21: error: 'end' undeclared (first use in this function)
heap_end = &end; /* first ram address after bss and data */
^
.pioenvs/lptm4c1230c3pm/FrameworkEnergia/startup_gcc.c:550:21: note: each undeclared identifier is reported only once for each function it appears in
scons: *** [.pioenvs/lptm4c1230c3pm/FrameworkEnergia/startup_gcc.o] Error 1
ivankravets commented 9 years ago

@Lauszus Let's wait for @valeros. I hope he can help us :blush:

Lauszus commented 9 years ago

@ivankravets I think I might have found a bug in PlatformIO, as if I add the following to build_flags:

-Ilib

It adds the following to the command:

-Iscripts/lib

Or this intended?

Btw I switched back to using the libopencm3 framework, as I wan't to store the different libraries locally: https://github.com/Lauszus/LaunchPadFlightController/tree/master/lib.

Lauszus commented 9 years ago

I got further by using another startup file for gcc, that came with TivaWare, but I can't get it to include the driverlib: https://github.com/Lauszus/LaunchPadFlightController/tree/master/lib/driverlib/gcc.

I have tried adding the following:

-Llib/driverlib/gcc

But still no success. I will upload the newest code, so you can have a look.

Lauszus commented 9 years ago

I tried to get it working with the Energia framework again and I believe the reason why I get this error: https://github.com/Lauszus/LaunchPadFlightController/pull/2#issuecomment-104931014 is because it is not properly linked: https://github.com/astuder/Energia/blob/master/hardware/lm4f/cores/lm4f/lm4fcpp_blizzard.ld. Note it defines "end" here: https://github.com/astuder/Energia/blob/master/hardware/lm4f/cores/lm4f/lm4fcpp_blizzard.ld#L100.

valeros commented 9 years ago

Hello @Lauszus.

Can you try this platformio.ini:

[env:lptm4c1230c3pm]
platform = titiva
framework = libopencm3
board = lptm4c1230c3pm
build_flags = -lm -std=c99 -Dgcc -DPART_TM4C123GH6PM -DUART_BUFFERED -DUART_BUFFERED1 -DUART_DEBUG=0 -DUSE_MAG=1 -DUSE_BARO=0

With this modifed project: http://drp.io/f/m1DGiZSye

Thanks!

Lauszus commented 9 years ago

@valeros it tells me that the file is not found?

valeros commented 9 years ago

Try this one: http://bit.ly/1EsCPyV

Lauszus commented 9 years ago

Sorry, but I decided to just use Make instead, as I won't be using Energia or libopencm3 anyway.