Of course nothing is ever simple. First I used the online compiler at mbed.org It would be fine if not for paying for internet access by the byte! Not to mention that it goes off completely for a while several times a week. Usually when I am in the middle of something.
So I began searching for ways to develop, compile and download the code locally on my own machine. There are several web pages describing various commercial and open source IDEs (Integrated Development Environments) all of which are either too limited, don't support the ST micros or only run on Windows! We all know I don't do Windows!
First I tried using the STM32CubeF4 and STM32F4-Discovery_FW_V1.1.0 from st.com according to http://regalis.com.pl/en/arm-cortex-stm32-gnulinux
I didn't have much luck with anything but the blinky Helloworld program. So on with more. I found https://github.com/mbedmicro/mbed a version of the mbed libraries to use locally. After several days I decided I missed something in the fine print.
So I tried gcc4mbed both stand alone and inside of eclipse, which I also downloaded. No luck for several weeks. I went back to th eonline and suffered some more.
Decided to try off-line one more time when I ran across this instruction page It worked! Well, almost. The compiler and linker can't find all the mbed libraries in Debug mode. But they can in Checked mode, which still includes the debug code! Great, I am now standalone!!!
So I have 4 different installed copies of gcc for ARM, 5 libraries of code for the STM32-arm micros, 2 manual/Makefile setups with no working makefile except delivered demos and 2 IDEs.
Also I have several utility programs that I'm not sure about, openocd to download and manage a debug session over USB to the micro, stlink to reinstall firmware in the STM32 micros and mri to actively debug the micro over the USB and single step the code. Also have a couple terminal emulators for monitoring output from the print statements in the micro. And 4 workspaces with various non-working pieces of code... I should clean them up.
Summary:
- follow instructions at http://developer.mbed.org/cookbook/eclipse-for-building-and-debugging
- Next: https://github.com/adamgreen/gcc4mbed/blob/master/notes/porting.creole#readme
- then from mbed.org convert the mbed include to a library
- export the project for Nucleo target and GCC (ARM embedded) as the IDE
- I had to make a ../build/NUCLEO_F401RE-device.mk
and samples/NucIMU_test/makefile is more than just the name change
the first make compiled all of mbed for NUCLEO. I copied parts out of the exported Makefile to find the answers for both the device.mk and the project makefile.
Here is the device makefile
NUCLEO_F401RE-device.mk
# Vendor/device for which the library should be built.
MBED_DEVICE := NUCLEO_F401RE
MBED_TARGET := NUCLEO_F4XX
MBED_CLEAN := $(MBED_DEVICE)-MBED-clean
# Some libraries (mbed and rtos) have device specific source folders.
HAL_TARGET_SRC := $(MBED_SRC_ROOT)/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE
HAL_TARGET_SRC += $(MBED_SRC_ROOT)/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/TARGET_MBED_NUCLEO_F401RE
CMSIS_TARGET_SRC := $(MBED_SRC_ROOT)/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE
CMSIS_TARGET_SRC += $(MBED_SRC_ROOT)/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_GCC_ARM
RTX_TARGET_SRC := $(GCC4MBED_DIR)/external/mbed/libraries/rtos/rtx/TARGET_M4/TOOLCHAIN_GCC
ETH_TARGET_SRC := $(GCC4MBED_DIR)/external/mbed/libraries/net/eth/lwip-eth/arch/TARGET_STM
# Compiler flags which are specifc to this device.
GCC_DEFINES := -DTARGET_NUCLEO_F401RE -DTARGET_M4 -DTARGET_STM -DTARGET_NUCLEO_F401RE -DTARGET_MBED_NUCLEO_F401RE
GCC_DEFINES += -D__CORTEX_M4 -DARM_MATH_CM4 -D__FPU_PRESENT=1 -DTARGET_FF_ARDUINO -DTARGET_FF_MORPHO
C_FLAGS := -mcpu=cortex-m4 -mthumb -mthumb-interwork
ASM_FLAGS := -mcpu=cortex-m4 -mthumb
LD_FLAGS := -mcpu=cortex-m4 -mthumb
# Linker script to be used. Indicates what code should be placed where in memory.
LSCRIPT=$(GCC4MBED_DIR)/external/mbed/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/TOOLCHAIN_GCC_ARM/NUCLEO_F401RE.ld
include $(GCC4MBED_DIR)/build/device-common.mk
*** UPDATE * Jan 25, 2015 ****
The above makefile has problems with the single precision floating point hardware. Correct the *_FLAGS to this:
C_FLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb-interwork
ASM_FLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
LD_FLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
And the project makefile:
PROJECT := NucIMU_test
DEVICES := NUCLEO_F401RE
GCC4MBED_DIR := ../..
#NO_FLOAT_SCANF := 0
#NO_FLOAT_PRINTF := 0
OBJECTS = ./main.o ./ADXL345/ADXL345.o ./HMC5883L/HMC5883L.o ./TextLCD/TextLCD.o ./ITG3200/ITG3200.o
INCLUDE_PATHS = -I. -I./ADXL345 -I./HMC5883L -I./TextLCD -I./mbed -I./mbed/TARGET_NUCLEO_F401RE -I./mbed/TARGET_NUCLEO_F401RE/TARGET_STM -I./mbed/TARGET_NUCLEO_F401RE/TARGET_STM/TARGET_NUCLEO_F401RE -I./ITG3200
include $(GCC4MBED_DIR)/build/gcc4mbed.mk
Now if only the code got the right answer!
No comments:
Post a Comment