I am using STM32F4 Discovery board to develop a simple application to on-board accelerometer while simultaneously lighting respective LEDs mounted around the accelerometer device. I want to use any RTOS but I am unable to decide which one since I am new to using RTOS.

If anyone could elaborate the steps to start this project by using Linux and some Makefiles, that would be appreciated.

1

There are 1 answers

3
jmlemetayer On BEST ANSWER

Here are the steps to start your project using Linux and Makefiles:

Step 1: Get a toolchain

On Ubuntu:

apt-get install gcc-arm-none-eabi

Or on launchpad:

wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q1-update/+download/gcc-arm-none-eabi-4_9-2015q1-20150306-linux.tar.bz2
tar xjf gcc-arm-none-eabi-4_9-2015q1-20150306-linux.tar.bz2

Step 2: Get the needed sources

Step 2.1: The standard library

You can choose the STM32F4 DSP and standard peripherals library

Or, you can also use another library like libopencm3.

Step 2.2: The RTOS

The most common is to use FreeRTOS.

Step 3: Create the Makefile

Just do something like that:

CROSS_COMPILE=arm-none-eabi-

SRC := myapp.c
SRC += <the needed library files>
SRC += <the needed freertos files>

myapp.elf: myapp.bin
        $(CROSS_COMPILE)objcopy -Obinary $@ $<

myapp.bin: $(SRC:%.c=%.o)
        $(CROSS_COMPILE)gcc -mthumb -nostartfiles -Wl,--gc-sections $^ -o $@

%.o: %.c
        $(CROSS_COMPILE)gcc -mthumb -ffunction-sections -fdata-sections -fno-common -Os -c $< -o $@

You should add some -I or -L to fix the include issue.

The needed FreeRTOS files are: list.c, queue.c, tasks.c, portable/MemMang/heap_4.c, portable/GCC/ARM_CM4F/port.c

There is a example project in the Demo/CORTEX_M4F_STM32F407ZG-SK which can help you.

Step 4: Build

Add your toolchain directory in the path and run your Makefile:

export PATH="$PATH:/path/to/toochain/bin"
make

Step 5: Flash

You have to use the DFU mode of the STM32F4.

Install the tool on Ubuntu with apt-get install dfu-util then you can flash your elf file by using:

sudo dfu-util -a 0 -s 0x08000000 -D myapp.elf