forked from wolfSSL/wolfssl
Add code to detect if Cortex M series and disable architecture specific code in armtarget.c
. Improved Makefile.common
to include toolchain prefix.
This commit is contained in:
@@ -3,7 +3,9 @@ CMD_ECHO =
|
|||||||
|
|
||||||
# Important directories
|
# Important directories
|
||||||
BUILD_DIR = ./Build
|
BUILD_DIR = ./Build
|
||||||
TOOLCHAIN_DIR = /opt/gcc-arm-none-eabi/bin
|
|
||||||
|
# Toolchain location and prefix
|
||||||
|
TOOLCHAIN = /opt/gcc-arm-none-eabi/bin/arm-none-eabi-
|
||||||
|
|
||||||
INC = -I./Header \
|
INC = -I./Header \
|
||||||
-I./Source \
|
-I./Source \
|
||||||
@@ -26,9 +28,16 @@ CFLAGS = $(ARCHFLAGS) -std=gnu99 -Wall -Wno-cpp \
|
|||||||
-ffunction-sections -fdata-sections \
|
-ffunction-sections -fdata-sections \
|
||||||
-Os -flto $(DBGFLAGS)
|
-Os -flto $(DBGFLAGS)
|
||||||
|
|
||||||
# LD: Remove unused sections, link with newlib-nano implementation, generate map
|
# LD: Remove unused sections
|
||||||
LDFLAGS = $(ARCHFLAGS) -Wl,--gc-sections --specs=nano.specs --specs=nosys.specs
|
LDFLAGS = $(ARCHFLAGS) -Wl,--gc-sections
|
||||||
|
|
||||||
|
# LD: Link with newlib-nano implementation
|
||||||
|
LDFLAGS += --specs=nano.specs --specs=nosys.specs
|
||||||
|
|
||||||
|
# LD: generate map
|
||||||
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(BIN).map $(DBGFLAGS)
|
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(BIN).map $(DBGFLAGS)
|
||||||
|
|
||||||
|
# LD: Entry point
|
||||||
LDFLAGS += -Wl,-ereset_handler
|
LDFLAGS += -Wl,-ereset_handler
|
||||||
|
|
||||||
# Math lib (for DH)
|
# Math lib (for DH)
|
||||||
@@ -42,14 +51,14 @@ OBJS_C = $(addprefix $(BUILD_DIR)/, $(FILENAMES_C:.c=.o))
|
|||||||
vpath %.c $(dir $(SRC_C))
|
vpath %.c $(dir $(SRC_C))
|
||||||
|
|
||||||
# Tools selection
|
# Tools selection
|
||||||
CC = $(TOOLCHAIN_DIR)/arm-none-eabi-gcc
|
CC = $(TOOLCHAIN)gcc
|
||||||
AS = $(TOOLCHAIN_DIR)/arm-none-eabi-gcc
|
AS = $(TOOLCHAIN)gcc
|
||||||
LD = $(TOOLCHAIN_DIR)/arm-none-eabi-gcc
|
LD = $(TOOLCHAIN)gcc
|
||||||
AR = $(TOOLCHAIN_DIR)/arm-none-eabi-ar
|
AR = $(TOOLCHAIN)ar
|
||||||
NM = $(TOOLCHAIN_DIR)/arm-none-eabi-nm
|
NM = $(TOOLCHAIN)nm
|
||||||
OBJCOPY = $(TOOLCHAIN_DIR)/arm-none-eabi-objcopy
|
OBJCOPY = $(TOOLCHAIN)objcopy
|
||||||
OBJDUMP = $(TOOLCHAIN_DIR)/arm-none-eabi-objdump
|
OBJDUMP = $(TOOLCHAIN)objdump
|
||||||
SIZE = $(TOOLCHAIN_DIR)/arm-none-eabi-size
|
SIZE = $(TOOLCHAIN)size
|
||||||
|
|
||||||
build_hex: $(BUILD_DIR) $(BUILD_DIR)/$(BIN).hex
|
build_hex: $(BUILD_DIR) $(BUILD_DIR)/$(BIN).hex
|
||||||
@echo ""
|
@echo ""
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
# Example Project for GCC ARM
|
# Example Project for GCC ARM
|
||||||
|
|
||||||
|
This example is for Cortex M series, but can be adopted for other architectures.
|
||||||
|
|
||||||
## Design
|
## Design
|
||||||
|
|
||||||
* All library options are defined in `Header/user_settings.h`.
|
* All library options are defined in `Header/user_settings.h`.
|
||||||
@@ -10,7 +12,9 @@
|
|||||||
## Building
|
## Building
|
||||||
|
|
||||||
1. Make sure you have `gcc-arm-none-eabi` installed.
|
1. Make sure you have `gcc-arm-none-eabi` installed.
|
||||||
2. Modify the `Makefile.common` to use correct toolchain directory `TOOLCHAIN_DIR` and architecture 'ARCHFLAGS' (default is cortex-m0 / thumb). See [GCC ARM Options](https://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/ARM-Options.html) `-mcpu=name`.
|
2. Modify the `Makefile.common`:
|
||||||
|
* Use correct toolchain path `TOOLCHAIN`.
|
||||||
|
* Use correct architecture 'ARCHFLAGS' (default is cortex-m0 / thumb). See [GCC ARM Options](https://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/ARM-Options.html) `-mcpu=name`.
|
||||||
3. Use `make` and it will build the static library and wolfCrypt test/benchmark and wolfSSL TLS client targets as `.elf` and `.hex` in `/Build`.
|
3. Use `make` and it will build the static library and wolfCrypt test/benchmark and wolfSSL TLS client targets as `.elf` and `.hex` in `/Build`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@@ -28,6 +28,13 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Test to determine if ARM Cortex M */
|
||||||
|
#if defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH == 6 || __ARM_ARCH == 7)
|
||||||
|
#define CORTEX_M_SERIES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CORTEX_M_SERIES
|
||||||
/* Memory initialization */
|
/* Memory initialization */
|
||||||
extern uint32_t __data_load_start__[];
|
extern uint32_t __data_load_start__[];
|
||||||
extern uint32_t __data_start__[];
|
extern uint32_t __data_start__[];
|
||||||
@@ -55,10 +62,12 @@ void meminit32(uint32_t* start, uint32_t* end)
|
|||||||
*start++ = 0;
|
*start++ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CORTEX_M_SERIES */
|
||||||
|
|
||||||
/* Entry Point */
|
/* Entry Point */
|
||||||
void reset_handler(void)
|
void reset_handler(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CORTEX_M_SERIES
|
||||||
/* Init sections */
|
/* Init sections */
|
||||||
memcpy32(__data_load_start__, __data_start__, __data_end__);
|
memcpy32(__data_load_start__, __data_start__, __data_end__);
|
||||||
meminit32(__bss_start__, __bss_end__);
|
meminit32(__bss_start__, __bss_end__);
|
||||||
@@ -66,6 +75,7 @@ void reset_handler(void)
|
|||||||
/* Init heap */
|
/* Init heap */
|
||||||
__heap_start__[0] = 0;
|
__heap_start__[0] = 0;
|
||||||
__heap_start__[1] = ((uint32_t)__heap_end__ - (uint32_t)__heap_start__);
|
__heap_start__[1] = ((uint32_t)__heap_end__ - (uint32_t)__heap_start__);
|
||||||
|
#endif /* CORTEX_M_SERIES */
|
||||||
|
|
||||||
/* Start main */
|
/* Start main */
|
||||||
extern int main(void);
|
extern int main(void);
|
||||||
@@ -75,6 +85,7 @@ void reset_handler(void)
|
|||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CORTEX_M_SERIES
|
||||||
// Vector Exception/Interrupt Handlers
|
// Vector Exception/Interrupt Handlers
|
||||||
static void Default_Handler(void)
|
static void Default_Handler(void)
|
||||||
{
|
{
|
||||||
@@ -199,6 +210,7 @@ const vector_entry vectors[] __attribute__ ((section(".vectors"),used)) =
|
|||||||
|
|
||||||
/* remainder go below */
|
/* remainder go below */
|
||||||
};
|
};
|
||||||
|
#endif /* CORTEX_M_SERIES */
|
||||||
|
|
||||||
|
|
||||||
/* TIME CODE */
|
/* TIME CODE */
|
||||||
|
Reference in New Issue
Block a user