SystemWorkbench for STM32 Makefile Projects |
SystemWorkbench is supporting the "home made" makefiles. The user has just to create a makefile project thanks to the following steps :
For an easier getting started, example files are provided below : a main.c file, a LinkerScript.ld file and a makefile are example files to be added into the Makefile Project :
##################################
# Makefile Project Example
##################################
CC := arm-none-eabi-gcc
LD := arm-none-eabi-ld
CP := arm-none-eabi-objcopy
SZ := arm-none-eabi-size
PROJ := Makefile_Project
EXEC := $(PROJ).elf
LD_SCRIPT = LinkerScript.ld
CFLAGS = -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb
LFLAGS = -nostartfiles -T$(LD_SCRIPT)
all: $(EXEC)
main.o: main.c
$(CC) $(CFLAGS) -o main.o main.c
Makefile_Project.elf: main.o
$(LD) $(LFLAGS) -o $(EXEC) main.o
$(CP) -O binary "${PROJ}.elf" "${PROJ}.bin"
$(SZ) "${EXEC}"
clean:
rm -rf *.o *.elf *.bin
/*****************************************
* STM32 Link File Example
*****************************************/
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
SRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
}
/* Sections */
SECTIONS
{
/* Program code into FLASH */
.text :
{
*(.vector_table) /* Vector table */
*(.text) /* Program code */
} >FLASH
/* Variables into SRAM */
.data :
{
*(.data)
} >SRAM
}
/*******************************
* Makefile Project - main.c
*******************************/
/* Define Memory sizes */
#define SRAM_SIZE 20*1024
#define SRAM_BASE 0x20000000
#define SRAM_END (SRAM_BASE + SRAM_SIZE)
/* Global variables */
volatile unsigned int My_Var1;
/* User functions */
int main(void);
void My_Wait(unsigned long count);
/* Vector Table */
int main(void);
unsigned long *vector_table[] __attribute__((section(".vector_table"))) =
{
(unsigned long *)SRAM_END, // for the stack pointer
(unsigned long *)main // for the main
};
int main()
{
My_Var1 = 1;
while(1)
{
My_Var1 = My_Var1 | 0x01; // Toggle My_Var1
My_Wait(200000);
}
}
void My_Wait(unsigned long count)
{
while(count--);
}
For more information about C/C++ development tools in Eclipse, please see C/C++ Development User Guide.