From cb4a49e0db540e7728ed841a4c095bac877d21b7 Mon Sep 17 00:00:00 2001 From: HuangRui Date: Mon, 5 Jan 2015 13:15:59 +0800 Subject: [PATCH] Changed Makefile to support Windows xcc. --- Makefile | 66 +++++++++++++++++++++++++++++++++++---- app/Makefile | 32 ------------------- app/include/user_config.h | 1 + app/lua/lrodefs.h | 2 +- app/platform/flash_api.c | 2 +- ld/eagle.app.v6.ld | 1 + 6 files changed, 64 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 0c94576c..6984e4ea 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,66 @@ ifndef PDIR endif -AR = xt-ar -CC = xt-xcc -NM = xt-nm -CPP = xt-cpp -OBJCOPY = xt-objcopy -#MAKE = xt-make +############################################################# +# Select compile +# +ifeq ($(OS),Windows_NT) +# WIN32 +# We are under windows. + ifeq ($(XTENSA_CORE),lx106) + # It is xcc + AR = xt-ar + CC = xt-xcc + NM = xt-nm + CPP = xt-cpp + OBJCOPY = xt-objcopy + #MAKE = xt-make + CCFLAGS += -Os --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal + else + # It is gcc, may be cygwin + # Can we use -fdata-sections? + CCFLAGS += -Os -ffunction-sections -fno-jump-tables + AR = xtensa-lx106-elf-ar + CC = xtensa-lx106-elf-gcc + NM = xtensa-lx106-elf-nm + CPP = xtensa-lx106-elf-cpp + OBJCOPY = xtensa-lx106-elf-objcopy + endif + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) +# ->AMD64 + endif + ifeq ($(PROCESSOR_ARCHITECTURE),x86) +# ->IA32 + endif +else +# We are under other system, may be Linux. Assume using gcc. + # Can we use -fdata-sections? + CCFLAGS += -Os -ffunction-sections -fno-jump-tables + AR = xtensa-lx106-elf-ar + CC = xtensa-lx106-elf-gcc + NM = xtensa-lx106-elf-nm + CPP = xtensa-lx106-elf-cpp + OBJCOPY = xtensa-lx106-elf-objcopy + + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) +# LINUX + endif + ifeq ($(UNAME_S),Darwin) +# OSX + endif + UNAME_P := $(shell uname -p) + ifeq ($(UNAME_P),x86_64) +# ->AMD64 + endif + ifneq ($(filter %86,$(UNAME_P)),) +# ->IA32 + endif + ifneq ($(filter arm%,$(UNAME_P)),) +# ->ARM + endif +endif +############################################################# CSRCS ?= $(wildcard *.c) ASRCs ?= $(wildcard *.s) diff --git a/app/Makefile b/app/Makefile index b5d9c4b8..84a5f424 100644 --- a/app/Makefile +++ b/app/Makefile @@ -41,38 +41,6 @@ endif # } PDIR APPDIR = . LDDIR = ../ld -ifeq ($(OS),Windows_NT) -# WIN32 -# We are under windows. Assume using xcc. - CCFLAGS += -Os --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal - ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) -# ->AMD64 - endif - ifeq ($(PROCESSOR_ARCHITECTURE),x86) -# ->IA32 - endif -else -# We are under other system, may be Linux. Assume using gcc. -# Can we use -fdata-sections? - CCFLAGS += -Os -ffunction-sections -fno-jump-tables - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Linux) -# LINUX - endif - ifeq ($(UNAME_S),Darwin) -# OSX - endif - UNAME_P := $(shell uname -p) - ifeq ($(UNAME_P),x86_64) -# ->AMD64 - endif - ifneq ($(filter %86,$(UNAME_P)),) -# ->IA32 - endif - ifneq ($(filter arm%,$(UNAME_P)),) -# ->ARM - endif -endif TARGET_LDFLAGS = \ -nostdlib \ diff --git a/app/include/user_config.h b/app/include/user_config.h index cf7b9687..63ed16b0 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -38,6 +38,7 @@ #define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed)) #define ICACHE_STORE_ATTR __attribute__((aligned(4))) #define ICACHE_RAM_ATTR __attribute__((section(".iram0.text"))) +#define ICACHE_RODATA_ATTR __attribute__((section(".rodata.text"))) #define CLIENT_SSL_ENABLE #define GPIO_INTERRUPT_ENABLE diff --git a/app/lua/lrodefs.h b/app/lua/lrodefs.h index 7094586d..fb6fabfb 100644 --- a/app/lua/lrodefs.h +++ b/app/lua/lrodefs.h @@ -16,7 +16,7 @@ #undef LREGISTER #if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL) -#define LUA_REG_TYPE luaR_entry ICACHE_FLASH_ATTR +#define LUA_REG_TYPE luaR_entry ICACHE_RODATA_ATTR #define LSTRKEY LRO_STRKEY #define LNUMKEY LRO_NUMKEY #define LNILKEY LRO_NILKEY diff --git a/app/platform/flash_api.c b/app/platform/flash_api.c index 164cfdb7..c5f26d40 100644 --- a/app/platform/flash_api.c +++ b/app/platform/flash_api.c @@ -7,7 +7,7 @@ #include "flash_api.h" #include "spi_flash.h" -static volatile const uint8_t flash_init_data[128] ICACHE_STORE_ATTR ICACHE_FLASH_ATTR = +static volatile const uint8_t flash_init_data[128] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = { 0x05, 0x00, 0x04, 0x02, 0x05, 0x05, 0x05, 0x02, 0x05, 0x00, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05, 0x04, 0xFE, 0xFD, 0xFF, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE1, 0x0A, 0xFF, 0xFF, 0xF8, 0x00, diff --git a/ld/eagle.app.v6.ld b/ld/eagle.app.v6.ld index b8f45bea..09b1465b 100644 --- a/ld/eagle.app.v6.ld +++ b/ld/eagle.app.v6.ld @@ -71,6 +71,7 @@ SECTIONS _irom0_text_start = ABSOLUTE(.); *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text) *(.literal.* .text.*) + *(.rodata.text) _irom0_text_end = ABSOLUTE(.); _flash_used_end = ABSOLUTE(.); } >irom0_0_seg :irom0_0_phdr