Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Modifying the Makefile

Posted by Monish Sunku Prabhakar on June 16, 2009
Hi all,
I wanted to modify makefile so that I have the freertos.out file along with the freertos.bin

Modifying the Makefile

Posted by Monish Sunku Prabhakar on June 16, 2009
Some guidelines on how to obtain the freertos.out file would be really helpful. I need the .out file for debugging purposes for AT91SAM7256 processor. Currently I am using eclipse.

Thanks in advance,

RE: Modifying the Makefile

Posted by MEdwards on June 16, 2009
You need to use the objcopy command that comes with GCC. Take a look at the binutils manual which you will find somewhere on the gnu.org site. Or simply type "arm-none-eabi-objcopy /?" or "arm-elf-gcc /?" depending on the version of gcc being used.

RE: Modifying the Makefile

Posted by Monish Sunku Prabhakar on June 17, 2009
Thanks Edwards. I referred the binutils manual in GNU.org but I am still skeptical of the usage considering that I am not an expert. So here is the Makefile.


# CFLAGS common to both the THUMB and ARM mode builds

-I. \
-I./drivers \
-I./tasks \
-I./armlib \
-I./armlib/arch/at91 \
-I./fatfs \
-I../Common/include \
-I../../Source/include \
-I../../Source/portable/GCC/ARM7_AT91SAM7S \
-Wall \
-mthumb-interwork \
-mcpu=arm7tdmi \
$(DEBUG) \
$(OPTIM) \
#-Wextra \
#-Wstrict-prototypes \
#-Wmissing-prototypes \
#-Wmissing-declarations \
#-Wno-strict-aliasing \

#-I./wifi \
#-I./wifi/wlan \
#-I./wifi/tcpuip \
#-I./wifi/tcpuip/dhcp \
#-I./wifi/tcpuip/resolv \
#-I./wifi/wlan \
#-I./wifi/wlan/WhizFi \

LINKER_FLAGS=-Xlinker -ofreertos.elf -Xlinker -M -Xlinker -Map=freertos.map

# Source files that can be built to THUMB mode.
../../Source/tasks.c \
../../Source/queue.c \
../../Source/list.c \

../../Source/portable/MemMang/heap_2.c \
main.c \
drivers/ad8400.c \
drivers/ads8341e.c \
drivers/wave.c \
drivers/common.c \
drivers/sd-mmc.c \
drivers/spigate.c \
tasks/airTasks.c \
tasks/recordTasks.c \
armlib/rprintf.c \
armlib/arch/at91/processor.c \
armlib/arch/at91/uart.c \
fatfs/ff.c \
#drivers/spi.c \
#armlib/arch/at91/spi.c \
#wifi/common.c \
#wifi/debug.c \
#wifi/flash_opp.c \
#wifi/wln_config.c \
#wifi/tcpuip/nic.c \
#wifi/tcpuip/tcp_config.c \
#wifi/tcpuip/uip_arp.c \
#wifi/tcpuip/uip_split.c \

# Source files that must be built to ARM mode.
# Generally, ISRs and the like -MikeG
tasks/pioIsr.c \
../../Source/portable/GCC/ARM7_AT91SAM7S/portISR.c \

# Define all object files.
ARM_OBJ = $(ARM_SRC:.c=.o)

all: freertos.bin freertos.hex

freertos.bin : freertos.elf
$(OBJCOPY) freertos.elf -O binary freertos.bin

freertos.hex : freertos.elf
$(OBJCOPY) freertos.elf -O ihex freertos.hex

freertos.elf : $(ARM_OBJ) $(DEMO_APP_THMUB_OBJ) $(FREERTOS_THUMB_OBJ) $(CRT0) Makefile FreeRTOSConfig.h

$(DEMO_APP_THMUB_OBJ) : %.o : %.c $(LDSCRIPT) Makefile FreeRTOSConfig.h
$(CC) -c $(THUMB_FLAGS) $(CFLAGS) $< -o $@

$(FREERTOS_THUMB_OBJ) : %.o : %.c $(LDSCRIPT) Makefile FreeRTOSConfig.h
$(CC) -c $(THUMB_FLAGS) $(CFLAGS) $< -o $@

$(ARM_OBJ) : %.o : %.c $(LDSCRIPT) Makefile FreeRTOSConfig.h
$(CC) -c $(CFLAGS) $< -o $@

#clean :
#touch Makefile

# make target called by Eclipse (Project -> Clean ...)
-rm $(ARM_OBJ) $(FREERTOS_THUMB_OBJ) $(DEMO_APP_THMUB_OBJ) freertos.elf freertos.bin freertos.map freertos.hex

# **********************************************************************************************
# Alternate make target for flash programming only
# You must create a special Eclipse make target (program) to run this part of the makefile
# (Project -> Create Make Target... then set the Target Name and Make Target to "program")
# OpenOCD is run in "batch" mode with a special configuration file and a script file containing
# the flash commands. When flash programming completes, OpenOCD terminates.
# Note that the script file of flash commands (script.ocd) is part of the project
# Programmers: Martin Thomas, Joseph M Dupre, James P Lynch
# Modifies:Gabriele Brosulo, 22/08/2007
# **********************************************************************************************

# specify output filename here (must be *.bin file)
TARGET = freertos.bin

# specify the directory where openocd executable and configuration files reside
OPENOCD_DIR = '/usr/local/OpenOCD/src/'

# specify OpenOCD executable (pp is for the wiggler, ftd2xx is for the USB debuggers)

# specify OpenOCD configuration file (pick the one for your device)
OPENOCD_CFG = OpenOCD/at91sam7s256-wiggler-flash-program.cfg

# program the AT91SAM7S256 internal flash memory
program: $(TARGET)
@echo "Flash Programming with OpenOCD..."# display a message on the console
sudo $(OPENOCD) -f $(OPENOCD_CFG)# program the onchip FLASH here
@echo "Flash Programming Finished."# display a message on the console

So is
-freertos.out : freertos.out
-$(OBJCOPY) freertos.elf -O srec freertos.out

The right way to get a .out file in our Makefile?


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner