Skip to content

Commit

Permalink
Merge branch 'update/extra-ldflags' into feature/malloc_count
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Jul 6, 2019
2 parents aded45d + 8f501d6 commit dedfeb9
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 39 deletions.
1 change: 0 additions & 1 deletion .appveyor/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ if "%SMING_ARCH%" == "Host" (
%MAKE_PARALLEL% Basic_Serial Basic_ProgMem STRICT=1 V=1 || goto :error

REM Run basic tests
set SMING_TARGET_OPTIONS="--flashfile=$(FLASH_BIN) --flashsize=$(SPI_SIZE)"
%MAKE_PARALLEL% tests || goto :error

) else (
Expand Down
6 changes: 6 additions & 0 deletions Sming/Arch/Esp8266/Components/esp8266/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ COMPONENT_INCDIRS := include $(SDK_INCDIR)
export SDK_INTERNAL
export SDK_LIBDIR
export SDK_INCDIR

# Required to ensure user-provided function gets linked instead of our 'weak' one
COMPONENT_LDFLAGS += -u custom_crash_callback

# Crash handler hooks this so debugger can be invoked
COMPONENT_LDFLAGS += -Wl,-wrap,system_restart_local
8 changes: 8 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_wifi/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ ifeq ($(ENABLE_WPS), 1)
GLOBAL_CFLAGS += -DENABLE_WPS=1
EXTRA_LIBS := wps
endif

EXTRA_LIBS := \
phy \
pp \
net80211 \
wpa \
crypto \
smartconfig
3 changes: 2 additions & 1 deletion Sming/Arch/Esp8266/Components/rboot/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ ifeq ($(RBOOT_GPIO_SKIP_ENABLED),1)
endif

$(RBOOT_BIN):
$(MAKE) -C $(ARCH_COMPONENTS)/rboot/rboot
$(Q) $(MAKE) -C $(ARCH_COMPONENTS)/rboot/rboot


# rBoot big flash support requires a slightly modified version of libmain (just one symbol gets weakened)
# Note that LIBMAIN/LIBMAIN_SRC changes depends on whether we're using a custom heap allocator
LIBMAIN_RBOOT := $(LIBMAIN)-rboot
LIBMAIN_RBOOT_DST := $(APP_LIBDIR)/lib$(LIBMAIN_RBOOT).a
CUSTOM_TARGETS += $(LIBMAIN_RBOOT_DST)
COMPONENT_LDFLAGS := -u Cache_Read_Enable_New

$(LIBMAIN_RBOOT_DST): $(LIBMAIN_SRC)
@echo "OC $@"
Expand Down
14 changes: 2 additions & 12 deletions Sming/Arch/Esp8266/app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,13 @@ LIBS += \
microgcc \
stdc++ \
hal \
phy \
pp \
net80211 \
wpa \
crypto \
smartconfig \
$(LIBMAIN)

# linker flags used to generate the main object file
LDFLAGS = -nostdlib \
LDFLAGS += \
-nostdlib \
-u call_user_start \
-u Cache_Read_Enable_New \
-u custom_crash_callback \
-Wl,-static \
-Wl,--gc-sections \
-Wl,-Map=$(basename $@).map \
-Wl,-wrap,system_restart_local


.PHONY: application
Expand Down
30 changes: 15 additions & 15 deletions Sming/Arch/Host/Components/spi_flash/include/esp_spi_flash.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#define SPI_FLASH_SEC_SIZE 4096

#ifdef __cplusplus
extern "C" {
#endif

#include <c_types.h>

uint32_t spi_flash_get_id(void);

#ifdef __cplusplus
}
#endif

#include_next <esp_spi_flash.h>
#define SPI_FLASH_SEC_SIZE 4096

#ifdef __cplusplus
extern "C" {
#endif

#include <c_types.h>

uint32_t spi_flash_get_id(void);

#ifdef __cplusplus
}
#endif

#include_next <esp_spi_flash.h>
22 changes: 12 additions & 10 deletions Sming/Arch/Host/app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
###

# linker flags used to generate the main object file
LDFLAGS = \
-m32 \
-Wl,--gc-sections \
-Wl,-Map=$(basename $@).map
LDFLAGS += \
-m32


# Executable
TARGET_OUT_0 := $(FW_BASE)/$(APP_NAME)$(TOOL_EXT)
Expand Down Expand Up @@ -36,12 +35,15 @@ endif
RUN_SCRIPT := $(FW_BASE)/run.sh

.PHONY: run
run: all ##Run the application image
$(Q) echo > $(RUN_SCRIPT); \
$(foreach id,$(ENABLE_HOST_UARTID),echo '$(call RunHostTerminal,$(id))' >> $(RUN_SCRIPT);) \
echo '$(TARGET_OUT_0) $(CLI_TARGET_OPTIONS)' >> $(RUN_SCRIPT); \
chmod +x $(RUN_SCRIPT); \
$(RUN_SCRIPT)
run: all $(RUN_SCRIPT) ##Run the application image
$(Q) $(RUN_SCRIPT)

$(RUN_SCRIPT)::
$(Q) echo '#!/bin/bash' > $@; \
$(foreach id,$(ENABLE_HOST_UARTID),echo '$(call RunHostTerminal,$(id))' >> $@;) \
echo '$(TARGET_OUT_0) $(CLI_TARGET_OPTIONS)' >> $@; \
chmod a+x $@


.PHONY: flashfs
flashfs: $(SPIFF_BIN_OUT) ##Write just the SPIFFS filesystem image
Expand Down
8 changes: 8 additions & 0 deletions Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ cs: ##Apply coding style to all core files
clang-format -i -style=file $$FILE; \
done

ALL_FILES = $(filter %.cpp %.h %.c %.mk %.sh %.cmd,$(shell $(GIT) ls-files))

.PHONY: dos2unix
dos2unix: ##Make sure all our files use Unix line endings
$(Q) dos2unix $(ALL_FILES)
@echo "$(words $(ALL_FILES)) files checked"


##@Help

.PHONY: help
Expand Down
1 change: 1 addition & 0 deletions Sming/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ Set `COMPONENT_LIBNAME :=` if the Component doesn't create a library. If you don

`EXTRA_LIBS` Set to names of any additional libraries to be linked.

`EXTRA_LDFLAGS` Set to any additional flags to be used when linking.

These values are global so must only be appended to (with `+=`) , never overwritten.

Expand Down
9 changes: 9 additions & 0 deletions Sming/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ LIBDIRS := $(APP_LIBDIR) $(USER_LIBDIR) $(ARCH_BASE)/Compiler/lib $(ARCH_BASE
# Standard libraries that will be linked with application (Component libraries are defined separately)
LIBS := $(EXTRA_LIBS)

# Common linker flags
LDFLAGS = \
-Wl,--gc-sections \
-Wl,-Map=$(basename $@).map


# Name of the application to use for link output targets
APP_NAME := app

Expand Down Expand Up @@ -150,6 +156,7 @@ COMPONENT_BUILD_DIR := $$(CMP_$1_BUILD_BASE)
COMPONENT_VARS :=
COMPONENT_TARGETS :=
EXTRA_LIBS :=
EXTRA_LDFLAGS :=
# Process any component.mk file (optional)
ifneq (,$(wildcard $2/component.mk))
COMPONENT_PATH := $2
Expand All @@ -163,6 +170,8 @@ CMP_$1_DEPENDS := $$(COMPONENT_DEPENDS)
CMP_$1_VARS := $$(sort $$(COMPONENT_VARS))
CMP_$1_APPCODE := $$(COMPONENT_APPCODE)
LIBS += $$(EXTRA_LIBS)
CMP_$1_LDFLAGS := $$(EXTRA_LDFLAGS)
LDFLAGS += $$(CMP_$1_LDFLAGS)
endif
CMP_$1_TARGETS := $$(COMPONENT_TARGETS)
CMP_$1_BUILD_DIR := $$(COMPONENT_BUILD_DIR)
Expand Down

0 comments on commit dedfeb9

Please sign in to comment.