Modifying the Makefile

monishsp wrote on Tuesday, June 16, 2009:

Hi all,
         I wanted to modify makefile so that I have the freertos.out file along with the freertos.bin

monishsp wrote on Tuesday, 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,
Monish

edwards3 wrote on Tuesday, 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.

monishsp wrote on Wednesday, 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.

CC=arm-elf-gcc
OBJCOPY=arm-elf-objcopy
ARCH=arm-elf-ar
CRT0=boot.s
DEBUG=-g
OPTIM=-O0
LDSCRIPT=atmel-rom.ld

#
# CFLAGS common to both the THUMB and ARM mode builds
#

CFLAGS=
  -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 
  -D SAM7_GCC 
  -D THUMB_INTERWORK
  -mthumb-interwork
  -mcpu=arm7tdmi 
  -T$(LDSCRIPT)
  $(DEBUG) 
  $(OPTIM)
  -fomit-frame-pointer
  #-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  \

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

#
# Source files that can be built to THUMB mode.
#
FREERTOS_THUMB_SRC=
  …/…/Source/tasks.c
  …/…/Source/queue.c
  …/…/Source/list.c
  …/…/Source/portable/GCC/ARM7_AT91SAM7S/port.c

DEMO_APP_THMUB_SRC=
  …/…/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 
  fatfs/diskio.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 
  #wifi/tcpuip/uip.c
  #wifi/wlan/WhizFi/wlan

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

#
# Define all object files.
#
ARM_OBJ = $(ARM_SRC:.c=.o)
FREERTOS_THUMB_OBJ = $(FREERTOS_THUMB_SRC:.c=.o)
DEMO_APP_THMUB_OBJ = $(DEMO_APP_THMUB_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
    $(CC) $(CFLAGS) $(ARM_OBJ) $(DEMO_APP_THMUB_OBJ) $(LWIP_THUMB_OBJ) $(FREERTOS_THUMB_OBJ) -nostartfiles $(CRT0) $(LINKER_FLAGS)

$(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 …)
clean:
    -rm $(ARM_OBJ) $(FREERTOS_THUMB_OBJ) $(DEMO_APP_THMUB_OBJ) freertos.elf freertos.bin freertos.map freertos.hex

       
# **********************************************************************************************
#                            FLASH PROGRAMMING                                        
#
# 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)
OPENOCD = $(OPENOCD_DIR)openocd

# 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?

Thanks,
Monish