mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-14 05:55:38 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
311
Living_SDK/build/Makefile
Normal file
311
Living_SDK/build/Makefile
Normal file
|
|
@ -0,0 +1,311 @@
|
|||
default: Help
|
||||
|
||||
export AOS_SDK_VERSION_MAJOR := 3
|
||||
export AOS_SDK_VERSION_MINOR := 2
|
||||
export AOS_SDK_VERSION_REVISION := 3
|
||||
|
||||
export SOURCE_ROOT ?= ./
|
||||
|
||||
export MAKEFILES_PATH := $(SOURCE_ROOT)/build
|
||||
export SCRIPTS_PATH := $(SOURCE_ROOT)/build/scripts
|
||||
|
||||
export BINSTYPE_UPPER
|
||||
export BINSTYPE_LOWER
|
||||
export UNDERLINE
|
||||
export RADIXPOINT
|
||||
|
||||
export MBINSTYPE_UPPER
|
||||
export MBINSTYPE_LOWER
|
||||
|
||||
MAKEFILE_TARGETS := clean # targets used by makefile
|
||||
|
||||
BINS ?=
|
||||
MBINS ?=
|
||||
|
||||
#define BUILD_STRING, AOS toolchain commands on different hosts
|
||||
include $(MAKEFILES_PATH)/aos_host_cmd.mk
|
||||
|
||||
define USAGE_TEXT
|
||||
Aborting due to invalid targets
|
||||
|
||||
Usage: make <target> [download] [run | debug] [JTAG=xxx] [total] [VERBOSE=1] [BINS=app/framework/kernel]
|
||||
make run
|
||||
|
||||
<target>
|
||||
One each of the following mandatory [and optional] components separated by '@'
|
||||
* Application (apps in example)
|
||||
* Board ($(filter-out common include README.txt,$(notdir $(wildcard board/*))))
|
||||
* [debug | release] Building for debug or release configurations
|
||||
|
||||
[download]
|
||||
Download firmware image to target platform
|
||||
|
||||
[run]
|
||||
Reset and run an application on the target hardware
|
||||
|
||||
[total]
|
||||
Build all targets related to this application and board
|
||||
|
||||
[JTAG=xxx]
|
||||
JTAG interface configuration file from the tools/OpenOCD dirctory
|
||||
Default option is jlink_swd
|
||||
|
||||
[VERBOSE=1]
|
||||
Shows the commands as they are being executed
|
||||
|
||||
[BINS=app/framework/kernel]
|
||||
Build bins: app or framework or kernel
|
||||
|
||||
Notes
|
||||
* Component names are case sensitive
|
||||
* 'rhino' and 'debug' are reserved component names
|
||||
* Component names MUST NOT include space or '@' characters
|
||||
* Building for debug is assumed unless '@release' is appended to the target
|
||||
|
||||
Example Usage
|
||||
Build for Debug
|
||||
$> make helloworld@mk3060
|
||||
|
||||
Build, Download and Run using the default USB-JTAG programming interface
|
||||
$> make helloworld@mk3060 download run
|
||||
|
||||
Build for Release
|
||||
$> make helloworld@mk3060@release
|
||||
|
||||
Reset and run an application on the target hardware
|
||||
$> make run
|
||||
|
||||
Clean output directory
|
||||
$> make clean
|
||||
endef
|
||||
|
||||
ifeq (,$(BINS))
|
||||
BINSTYPE_UPPER :=
|
||||
BINSTYPE_LOWER :=
|
||||
UNDERLINE :=
|
||||
RADIXPOINT :=
|
||||
else ifeq (app,$(BINS))
|
||||
BINSTYPE_UPPER :=APP
|
||||
BINSTYPE_LOWER :=app
|
||||
UNDERLINE :=_
|
||||
RADIXPOINT :=.
|
||||
CREATE_SYSCALLFILE :=$(MAKEFILES_PATH)/scripts/gen_syscalls.py
|
||||
PARSE_RESOURSE_TO_SYSCALL_FILE = $(PYTHON) $(CREATE_SYSCALLFILE) $(1) $(2)
|
||||
else ifeq (framework,$(BINS))
|
||||
BINSTYPE_UPPER :=FRAMEWORK
|
||||
BINSTYPE_LOWER :=framework
|
||||
UNDERLINE :=_
|
||||
RADIXPOINT :=.
|
||||
CREATE_SYSCALLFILE :=$(MAKEFILES_PATH)/scripts/gen_syscalls.py
|
||||
PARSE_RESOURSE_TO_SYSCALL_FILE = $(PYTHON) $(CREATE_SYSCALLFILE) $(1) $(2)
|
||||
else ifeq (kernel,$(BINS))
|
||||
BINSTYPE_UPPER :=KERNEL
|
||||
BINSTYPE_LOWER :=kernel
|
||||
UNDERLINE :=_
|
||||
RADIXPOINT :=.
|
||||
CREATE_SYSCALLFILE :=$(MAKEFILES_PATH)/scripts/gen_syscalls.py
|
||||
PARSE_RESOURSE_TO_SYSCALL_FILE = $(PYTHON) $(CREATE_SYSCALLFILE) $(1) $(2)
|
||||
else
|
||||
$(error ***** BINS Error, Valid BINS: [BINS=app BINS=kernel BINS=framework] ***** ***)
|
||||
endif
|
||||
|
||||
ifeq (,$(MBINS))
|
||||
MBINSTYPE_UPPER :=
|
||||
MBINSTYPE_LOWER :=
|
||||
UNDERLINE :=
|
||||
RADIXPOINT :=
|
||||
else ifeq (app,$(MBINS))
|
||||
MBINSTYPE_UPPER :=APP
|
||||
MBINSTYPE_LOWER :=app
|
||||
UNDERLINE :=_
|
||||
RADIXPOINT :=.
|
||||
else ifeq (kernel,$(MBINS))
|
||||
MBINSTYPE_UPPER :=KERNEL
|
||||
MBINSTYPE_LOWER :=kernel
|
||||
UNDERLINE :=_
|
||||
RADIXPOINT :=.
|
||||
else
|
||||
$(error ***** MBINS Error, Valid MBINS: [MBINS=app MBINS=kernel] ***** ***)
|
||||
endif
|
||||
|
||||
|
||||
############################
|
||||
# Extra options:
|
||||
# CHECK_HEADERS=1 : builds header files to test for their completeness
|
||||
############################
|
||||
|
||||
OPENOCD_LOG_FILE ?= $(BUILD_DIR)/openocd.log
|
||||
DOWNLOAD_LOG := >> $(OPENOCD_LOG_FILE)
|
||||
|
||||
BOOTLOADER_LOG_FILE ?= $(BUILD_DIR)/bootloader.log
|
||||
export HOST_OS
|
||||
export VERBOSE
|
||||
export SUB_BUILD
|
||||
export OPENOCD_LOG_FILE
|
||||
|
||||
COMPONENT_DEPENDENCY_SCRIPT := $(MAKEFILES_PATH)/scripts/component_dependencies.py
|
||||
COMPONENT_DEPENDENCY = $(PYTHON) $(COMPONENT_DEPENDENCY_SCRIPT)
|
||||
export COMPONENT_DEPENDENCY
|
||||
|
||||
.PHONY: $(BUILD_STRING) main_app bootloader clean Help download total run download_bootloader .gdbinit .gdbinit$(BINSTYPE_LOWER)
|
||||
|
||||
Help:
|
||||
$(TOOLCHAIN_HOOK_TARGETS)
|
||||
$(error $(USAGE_TEXT))
|
||||
|
||||
clean:
|
||||
$(QUIET)$(ECHO) Cleaning...
|
||||
$(QUIET)$(CLEAN_COMMAND)
|
||||
$(QUIET)$(RM) -rf .gdbinit .gdbinitkernel .gdbinitframework .gdbinitapp
|
||||
$(QUIET)rm -rf build/scripts/config_mk.py
|
||||
ifneq (,$(wildcard build/scripts/*.pyc))
|
||||
$(QUIET)rm -rf build/scripts/*.pyc
|
||||
endif
|
||||
$(QUIET)$(ECHO) Done
|
||||
|
||||
ifneq ($(BUILD_STRING),)
|
||||
-include $(OUTPUT_DIR)/config.mk
|
||||
|
||||
ifeq ($(IDE),iar)
|
||||
COMPILER := iar
|
||||
CLEANED_BUILD_STRING += COMPILER=iar
|
||||
else ifeq ($(IDE),keil)
|
||||
COMPILER := armcc
|
||||
CLEANED_BUILD_STRING += COMPILER=armcc
|
||||
endif
|
||||
|
||||
# Now we know the target architecture - include all toolchain makefiles and check one of them can handle the architecture
|
||||
ifeq ($(COMPILER),armcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_iar.mk
|
||||
else
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
endif
|
||||
|
||||
AUTO_COMPONENT = $(AUTO_COMPONENT_DIR)/auto_component.mk
|
||||
ifneq ($(test), )
|
||||
TEST_COMPONENT_COLLECTION = $(AUTO_COMPONENT_DIR)/test_collection.$(test)
|
||||
else
|
||||
TEST_COMPONENT_COLLECTION = $(AUTO_COMPONENT_DIR)/test_collection.default
|
||||
endif
|
||||
|
||||
$(AUTO_COMPONENT): $(TEST_COMPONENT_COLLECTION)
|
||||
$(QUIET)$(PYTHON) $(MAKEFILES_PATH)/scripts/auto_component.py $(AUTO_COMPONENT_DIR)
|
||||
|
||||
$(TEST_COMPONENT_COLLECTION):
|
||||
$(QUIET)$(PYTHON) $(MAKEFILES_PATH)/scripts/gen_test_collection.py $(AUTO_COMPONENT_DIR) $(TEST_COMPONENT_COLLECTION)
|
||||
|
||||
ifeq ($(COMPILER),armcc)
|
||||
TOOLCHAIN_MK = aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
TOOLCHAIN_MK = aos_toolchain_iar.mk
|
||||
else
|
||||
TOOLCHAIN_MK = aos_toolchain_gcc.mk
|
||||
endif
|
||||
|
||||
ifeq (,$(MBINS))
|
||||
$(OUTPUT_DIR)/config.mk: $(MAKEFILES_PATH)/aos_target_config.mk $(MAKEFILES_PATH)/aos_host_cmd.mk $(MAKEFILES_PATH)/$(TOOLCHAIN_MK) $(AOS_SDK_MAKEFILES) $(AUTO_COMPONENT)
|
||||
$(QUIET)$(if $(PARSE_RESOURSE_TO_SYSCALL_FILE), $(call MKDIR, $(OUTPUT_DIR)/precompile))
|
||||
$(QUIET)$(if $(PARSE_RESOURSE_TO_SYSCALL_FILE), $(call MKDIR, $(OUTPUT_DIR)/syscall/syscall_kapi))
|
||||
$(QUIET)$(if $(PARSE_RESOURSE_TO_SYSCALL_FILE), $(call MKDIR, $(OUTPUT_DIR)/syscall/syscall_fapi))
|
||||
$(QUIET)$(if $(PARSE_RESOURSE_TO_SYSCALL_FILE), $(call PARSE_RESOURSE_TO_SYSCALL_FILE, $(OUTPUT_DIR), pre-create))
|
||||
$(QUIET)$(ECHO) $(if $(AOS_SDK_MAKEFILES),Applying changes made to: $?,Making config file for first time)
|
||||
$(QUIET)$(MAKE) -r $(SILENT) -f $(MAKEFILES_PATH)/aos_target_config.mk $(CLEANED_BUILD_STRING)
|
||||
else
|
||||
$(OUTPUT_DIR)/config.mk: $(MAKEFILES_PATH)/aos_target_config_mbins.mk $(MAKEFILES_PATH)/aos_host_cmd.mk $(MAKEFILES_PATH)/$(TOOLCHAIN_MK) $(AOS_SDK_MAKEFILES) $(AUTO_COMPONENT)
|
||||
$(QUIET)$(ECHO) $(if $(AOS_SDK_MAKEFILES),Applying changes made to: $?,Making config file for first time)
|
||||
$(QUIET)$(MAKE) -r $(SILENT) -f $(MAKEFILES_PATH)/aos_target_config_mbins.mk $(CLEANED_BUILD_STRING)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
define BINS_EXIT
|
||||
$(error ***** This Platform Not Support Multi-Bins! [SUPPORT_BINS:=$(SUPPORT_BINS)] Not Use Option:[BINs=*] ***** ***)
|
||||
endef
|
||||
|
||||
define MBINS_EXIT
|
||||
$(error ***** This Platform Not Support Multi-Bins! [SUPPORT_BINS:=$(SUPPORT_BINS)] Not Use Option:[BINs=*] ***** ***)
|
||||
endef
|
||||
|
||||
ifneq ($(BINS),)
|
||||
ifneq ($(SUPPORT_BINS),yes)
|
||||
BINS_ERROR := error
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(MBINS),)
|
||||
ifneq ($(SUPPORT_MBINS),yes)
|
||||
MBINS_ERROR := error
|
||||
endif
|
||||
endif
|
||||
|
||||
JOBS ?=4
|
||||
ifeq (,$(SUB_BUILD))
|
||||
JOBSNO := -j$(JOBS)
|
||||
endif
|
||||
|
||||
PASSDOWN_TARGETS := $(strip $(filter-out $(MAKEFILE_TARGETS) $(BUILD_STRING),$(MAKECMDGOALS))) #download total
|
||||
$(PASSDOWN_TARGETS):
|
||||
@:
|
||||
|
||||
$(BUILD_STRING): main_app $(if $(SUB_BUILD),,.gdbinit .gdbinit$(BINSTYPE_LOWER))
|
||||
|
||||
ifeq (,$(MBINS))
|
||||
main_app: $(OUTPUT_DIR)/config.mk $(YOS_SDK_PRE_APP_BUILDS) $(MAKEFILES_PATH)/aos_target_build.mk
|
||||
$(if $(BINS_ERROR), $(call BINS_EXIT))
|
||||
$(if $(MBINS_ERROR), $(call MBINS_EXIT))
|
||||
$(QUIET)$(ECHO) Build AOS Now
|
||||
$(QUIET)$(ECHO) TOOLCHAIN_PATH=$(TOOLCHAIN_PATH)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/binary)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/modules)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/libraries)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/resources)
|
||||
$(QUIET)$(PYTHON) $(MAKEFILES_PATH)/scripts/gen_auto_code.py $(OUTPUT_DIR)/config.mk $(AUTO_COMPONENT_DIR)
|
||||
$(QUIET)$(MAKE) -r $(JOBSNO) $(SILENT) -f $(MAKEFILES_PATH)/aos_target_build.mk $(CLEANED_BUILD_STRING) $(PASSDOWN_TARGETS)
|
||||
$(QUIET)$(PYTHON) $(SCRIPTS_PATH)/gen_output.py $(OUTPUT_DIR)/binary $(OUTPUT_DIR)/config.mk
|
||||
$(QUIET)$(ECHO) Build complete
|
||||
else
|
||||
main_app: $(OUTPUT_DIR)/config.mk $(YOS_SDK_PRE_APP_BUILDS) $(MAKEFILES_PATH)/aos_target_build_mbins.mk
|
||||
$(if $(MBINS_ERROR), $(call MBINS_EXIT))
|
||||
$(QUIET)$(ECHO) Build AOS Now
|
||||
$(QUIET)$(ECHO) TOOLCHAIN_PATH=$(TOOLCHAIN_PATH)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/binary)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/modules)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/libraries)
|
||||
$(QUIET)$(call MKDIR, $(OUTPUT_DIR)/resources)
|
||||
$(QUIET)$(PYTHON) $(MAKEFILES_PATH)/scripts/gen_auto_code.py $(OUTPUT_DIR)/config.mk $(AUTO_COMPONENT_DIR)
|
||||
$(QUIET)$(MAKE) -r $(JOBSNO) $(SILENT) -f $(MAKEFILES_PATH)/aos_target_build_mbins.mk $(CLEANED_BUILD_STRING) $(PASSDOWN_TARGETS)
|
||||
$(QUIET)$(PYTHON) $(SCRIPTS_PATH)/gen_output.py $(OUTPUT_DIR)/binary $(OUTPUT_DIR)/config.mk
|
||||
$(QUIET)$(ECHO) Build complete
|
||||
endif
|
||||
|
||||
ifeq (littlevgl_simulate@linuxhost,$(CLEANED_BUILD_STRING))
|
||||
./out/littlevgl_simulate@linuxhost/binary/littlevgl_simulate@linuxhost.elf
|
||||
endif
|
||||
|
||||
ifeq ($(SUB_BUILD),)
|
||||
.gdbinit: $(OUTPUT_DIR)/config.mk $(MAKEFILES_PATH)/aos_host_cmd.mk main_app
|
||||
$(QUIET)$(ECHO) Making $@
|
||||
ifeq ($(HOST_OS), Win32)
|
||||
$(QUIET)$(ECHO) #GDB_PATH=$(GDB_COMMAND) > $@
|
||||
else
|
||||
$(QUIET)$(ECHO) '#GDB_PATH=$(GDB_COMMAND)' > $@
|
||||
endif
|
||||
$(QUIET)$(ECHO) set remotetimeout 20 >> $@
|
||||
$(QUIET)$(ECHO) $(GDB_KILL_OPENOCD) >> $@
|
||||
$(QUIET)$(ECHO) $(GDBINIT_STRING) >> $@
|
||||
|
||||
ifneq ($(BINS),)
|
||||
.gdbinit$(BINSTYPE_LOWER): $(OUTPUT_DIR)/config.mk $(MAKEFILES_PATH)/aos_host_cmd.mk main_app
|
||||
$(QUIET)$(ECHO) Making $@
|
||||
$(QUIET)$(ECHO) $(SUBGDBINIT_STRING) > $@
|
||||
endif
|
||||
|
||||
ifneq ($(MBINS),)
|
||||
.gdbinit$(MBINSTYPE_LOWER): $(OUTPUT_DIR)/config.mk $(MAKEFILES_PATH)/aos_host_cmd.mk main_app
|
||||
$(QUIET)$(ECHO) Making $@
|
||||
$(QUIET)$(ECHO) $(SUBGDBINIT_STRING) >> $@
|
||||
endif
|
||||
|
||||
endif
|
||||
699
Living_SDK/build/aos_firmware_update.py
Executable file
699
Living_SDK/build/aos_firmware_update.py
Executable file
|
|
@ -0,0 +1,699 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import division
|
||||
from functools import partial
|
||||
import sys
|
||||
import os
|
||||
import serial
|
||||
import time
|
||||
import platform
|
||||
import logging
|
||||
|
||||
# MODEM Protocol bytes
|
||||
NUL = b'\x00'
|
||||
SOH = b'\x01'
|
||||
STX = b'\x02'
|
||||
EOT = b'\x04'
|
||||
ACK = b'\x06'
|
||||
DLE = b'\x10'
|
||||
NAK = b'\x15'
|
||||
CAN = b'\x18'
|
||||
CRC = b'C'
|
||||
|
||||
LOG_LEVEL_ERROR=0
|
||||
LOG_LEVEL_WARN =1
|
||||
LOG_LEVEL_INFO =2
|
||||
LOG_LEVEL_DEBUG=3
|
||||
|
||||
class XMODEM(object):
|
||||
'''
|
||||
XMODEM Protocol handler, expects an object to read from and an object to
|
||||
write to.
|
||||
|
||||
>>> def getc(size, timeout=1):
|
||||
... return data or None
|
||||
...
|
||||
>>> def putc(data, timeout=1):
|
||||
... return size or None
|
||||
...
|
||||
>>> modem = XMODEM(getc, putc)
|
||||
|
||||
|
||||
:param getc: Function to retrieve bytes from a stream
|
||||
:type getc: callable
|
||||
:param putc: Function to transmit bytes to a stream
|
||||
:type putc: callable
|
||||
:param mode: XMODEM protocol mode
|
||||
:type mode: string
|
||||
:param pad: Padding character to make the packets match the packet size
|
||||
:type pad: char
|
||||
|
||||
'''
|
||||
|
||||
# crctab calculated by Mark G. Mendel, Network Systems Corporation
|
||||
crctable = [
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
||||
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
||||
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
||||
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
||||
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
||||
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
||||
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
||||
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
||||
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
||||
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
||||
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
||||
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
||||
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
|
||||
]
|
||||
|
||||
def __init__(self, getc, putc, mode='xmodem', pad=b'\x1a'):
|
||||
self.getc = getc
|
||||
self.putc = putc
|
||||
self.mode = mode
|
||||
self.pad = pad
|
||||
self.log_level = LOG_LEVEL_WARN
|
||||
|
||||
def log(self, log_level, logstr):
|
||||
if log_level <= self.log_level:
|
||||
print logstr
|
||||
|
||||
|
||||
def abort(self, count=2, timeout=60):
|
||||
'''
|
||||
Send an abort sequence using CAN bytes.
|
||||
'''
|
||||
for _ in range(count):
|
||||
self.putc(CAN, timeout)
|
||||
|
||||
|
||||
|
||||
def send(self, stream, retry=16, timeout=60, quiet=False, callback=None):
|
||||
'''
|
||||
Send a stream via the XMODEM protocol.
|
||||
|
||||
>>> stream = open('/etc/issue', 'rb')
|
||||
>>> print(modem.send(stream))
|
||||
True
|
||||
|
||||
Returns ``True`` upon successful transmission or ``False`` in case of
|
||||
failure.
|
||||
|
||||
:param stream: The stream object to send data from.
|
||||
:type stream: stream (file, etc.)
|
||||
:param retry: The maximum number of times to try to resend a failed
|
||||
packet before failing.
|
||||
:type retry: int
|
||||
:param timeout: The number of seconds to wait for a response before
|
||||
timing out.
|
||||
:type timeout: int
|
||||
:param quiet: If True, write transfer information to stderr.
|
||||
:type quiet: bool
|
||||
:param callback: Reference to a callback function that has the
|
||||
following signature. This is useful for
|
||||
getting status updates while a xmodem
|
||||
transfer is underway.
|
||||
Expected callback signature:
|
||||
def callback(total_packets, success_count, error_count)
|
||||
:type callback: callable
|
||||
'''
|
||||
|
||||
# initialize protocol
|
||||
try:
|
||||
packet_size = dict(
|
||||
xmodem = 128,
|
||||
xmodem1k = 1024,
|
||||
ymodem = 1024,
|
||||
)[self.mode]
|
||||
except KeyError:
|
||||
raise ValueError("Invalid mode specified: {self.mode!r}"
|
||||
.format(self=self))
|
||||
|
||||
self.log(LOG_LEVEL_DEBUG, 'Begin start sequence, packet_size={0:d}'.format(packet_size))
|
||||
error_count = 0
|
||||
crc_mode = 0
|
||||
cancel = 0
|
||||
while True:
|
||||
char = self.getc(1)
|
||||
if char:
|
||||
if char == NAK:
|
||||
self.log(LOG_LEVEL_DEBUG, 'standard checksum requested (NAK).')
|
||||
crc_mode = 0
|
||||
break
|
||||
elif char == CRC:
|
||||
self.log(LOG_LEVEL_DEBUG, '16-bit CRC requested (CRC).')
|
||||
crc_mode = 1
|
||||
break
|
||||
elif char == CAN:
|
||||
if not quiet:
|
||||
sys.stderr.write('received CAN\n')
|
||||
if cancel:
|
||||
self.log(LOG_LEVEL_INFO, 'Transmission canceled: received 2xCAN at start-sequence')
|
||||
return False
|
||||
else:
|
||||
self.log(LOG_LEVEL_DEBUG, 'cancellation at start sequence.')
|
||||
cancel = 1
|
||||
else:
|
||||
self.log(LOG_LEVEL_ERROR, 'send error: expected NAK, CRC, or CAN; got {0}'.format(char))
|
||||
|
||||
error_count += 1
|
||||
if error_count > retry:
|
||||
self.log(LOG_LEVEL_INFO, 'send error: error_count reached {0}, aborting.'.format(retry))
|
||||
self.abort(timeout=timeout)
|
||||
return False
|
||||
|
||||
# send data
|
||||
error_count = 0
|
||||
success_count = 0
|
||||
total_packets = 0
|
||||
image_size = 0 # the size of binary
|
||||
max_cnt = 0 # the count is to be added when the frame(sequence) over 255(max block: 255k bytes)
|
||||
if self.mode == 'ymodem':
|
||||
sequence = 0
|
||||
filenames = stream
|
||||
else:
|
||||
sequence = 1
|
||||
while True:
|
||||
# build packet
|
||||
if self.mode == 'ymodem' and success_count == 0:
|
||||
# send packet sequence 0 containing:
|
||||
# Filename Length [Modification-Date [Mode [Serial-Number]]]
|
||||
# 'stream' is actually the filename
|
||||
import os
|
||||
if len(filenames):
|
||||
filename = filenames.pop()
|
||||
stream = open(filename, 'rb')
|
||||
stat = os.stat(filename)
|
||||
data = os.path.basename(filename) + NUL + str(stat.st_size)
|
||||
image_size = stat.st_size
|
||||
self.log(LOG_LEVEL_DEBUG, 'ymodem sending : {0} len:{1}'.format(filename, stat.st_size))
|
||||
else:
|
||||
# empty file name packet terminates transmission
|
||||
filename = ''
|
||||
data = ''
|
||||
stream = None
|
||||
self.log(LOG_LEVEL_DEBUG, 'ymodem done, sending empty header.')
|
||||
if len(data) <= 128:
|
||||
header_size = 128
|
||||
else:
|
||||
header_size = 1024
|
||||
|
||||
header = self._make_send_header(header_size, sequence)
|
||||
data = data.ljust(header_size, NUL)
|
||||
checksum = self._make_send_checksum(crc_mode, data)
|
||||
else:
|
||||
# happens after sending ymodem empty filename
|
||||
if not stream:
|
||||
return True
|
||||
# normal data packet
|
||||
data = stream.read(packet_size)
|
||||
if not data:
|
||||
# end of stream
|
||||
self.log(LOG_LEVEL_DEBUG, 'send: at EOF')
|
||||
break
|
||||
total_packets += 1
|
||||
|
||||
header = self._make_send_header(packet_size, sequence)
|
||||
data = data.ljust(packet_size, self.pad)
|
||||
checksum = self._make_send_checksum(crc_mode, data)
|
||||
|
||||
# emit packet & get ACK
|
||||
while True:
|
||||
if (sequence == 255): max_cnt += 1
|
||||
if (image_size != 0):
|
||||
send_percent = (sequence + max_cnt*255)*100.0/(image_size/1000.0)
|
||||
if (round(send_percent)%5 == 0):
|
||||
print('[INFO]:send image process:%d%%\n' % send_percent)
|
||||
self.putc(header + data + checksum)
|
||||
time.sleep(0.1) # 100ms is needed to make more robust for differnt platform
|
||||
char = self.getc(1, timeout)
|
||||
if char == ACK:
|
||||
success_count += 1
|
||||
if callable(callback):
|
||||
callback(total_packets, success_count, error_count)
|
||||
error_count = 0
|
||||
if self.mode == 'ymodem' and success_count == 1 and len(filename):
|
||||
char = self.getc(1, timeout)
|
||||
if char == DLE: # dunno why
|
||||
char = self.getc(1, timeout)
|
||||
if char == CRC:
|
||||
break
|
||||
self.log(LOG_LEVEL_ERROR, 'send error: ymodem expected CRC; got {0} for block {1}'.format(char, sequence))
|
||||
else:
|
||||
break
|
||||
if char == CRC:
|
||||
curtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||
self.log(LOG_LEVEL_ERROR, 'Got {0} for block {1} ts:{2}'.format(char, sequence, curtime))
|
||||
continue
|
||||
|
||||
error_count += 1
|
||||
if callable(callback):
|
||||
callback(total_packets, success_count, error_count)
|
||||
if error_count > retry:
|
||||
# excessive amounts of retransmissions requested,
|
||||
# abort transfer
|
||||
self.log(LOG_LEVEL_ERROR, 'send error: NAK received {0} times, aborting.'.format(error_count))
|
||||
self.abort(timeout=timeout)
|
||||
return False
|
||||
|
||||
# keep track of sequence
|
||||
sequence = (sequence + 1) % 0x100
|
||||
|
||||
# emit EOT and get corresponding ACK
|
||||
while True:
|
||||
print('[INFO]:send image process:100%\n')
|
||||
self.log(LOG_LEVEL_DEBUG, 'sending EOT, awaiting ACK')
|
||||
# end of transmission
|
||||
self.putc(EOT)
|
||||
|
||||
# An ACK should be returned
|
||||
char = self.getc(1, timeout)
|
||||
if char == ACK:
|
||||
break
|
||||
else:
|
||||
self.log(LOG_LEVEL_ERROR, 'send error: expected ACK; got {0}'.format(char))
|
||||
error_count += 1
|
||||
if error_count > retry:
|
||||
self.log(LOG_LEVEL_WARN, 'EOT was not ACKd, aborting transfer')
|
||||
self.abort(timeout=timeout)
|
||||
return False
|
||||
|
||||
self.log(LOG_LEVEL_INFO, 'Transmission successful (ACK received).')
|
||||
if self.mode == 'ymodem':
|
||||
# YMODEM - recursively send next file
|
||||
# or empty filename header to end the xfer batch.
|
||||
stream.close()
|
||||
return self.send(filenames, retry, timeout, quiet, callback)
|
||||
return True
|
||||
|
||||
def _make_send_header(self, packet_size, sequence):
|
||||
assert packet_size in (128, 1024), packet_size
|
||||
_bytes = []
|
||||
if packet_size == 128:
|
||||
_bytes.append(ord(SOH))
|
||||
elif packet_size == 1024:
|
||||
_bytes.append(ord(STX))
|
||||
_bytes.extend([sequence, 0xff - sequence])
|
||||
return bytearray(_bytes)
|
||||
|
||||
def _make_send_checksum(self, crc_mode, data):
|
||||
_bytes = []
|
||||
if crc_mode:
|
||||
crc = self.calc_crc(data)
|
||||
_bytes.extend([crc >> 8, crc & 0xff])
|
||||
else:
|
||||
crc = self.calc_checksum(data)
|
||||
_bytes.append(crc)
|
||||
return bytearray(_bytes)
|
||||
|
||||
def recv(self, stream, crc_mode=1, retry=16, timeout=60, delay=1, quiet=0):
|
||||
'''
|
||||
Receive a stream via the XMODEM protocol.
|
||||
|
||||
>>> stream = open('/etc/issue', 'wb')
|
||||
>>> print(modem.recv(stream))
|
||||
2342
|
||||
|
||||
Returns the number of bytes received on success or ``None`` in case of
|
||||
failure.
|
||||
'''
|
||||
|
||||
# initiate protocol
|
||||
error_count = 0
|
||||
char = 0
|
||||
cancel = 0
|
||||
while True:
|
||||
# first try CRC mode, if this fails,
|
||||
# fall back to checksum mode
|
||||
if error_count >= retry:
|
||||
self.log(LOG_LEVEL_INFO, 'error_count reached {0}, aborting.'.format(retry))
|
||||
self.abort(timeout=timeout)
|
||||
return None
|
||||
elif crc_mode and error_count < (retry // 2):
|
||||
if not self.putc(CRC):
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv error: putc failed, sleeping for {0}'.format(delay))
|
||||
time.sleep(delay)
|
||||
error_count += 1
|
||||
else:
|
||||
crc_mode = 0
|
||||
if not self.putc(NAK):
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv error: putc failed, sleeping for {0}'.format(delay))
|
||||
time.sleep(delay)
|
||||
error_count += 1
|
||||
|
||||
char = self.getc(1, timeout)
|
||||
if char is None:
|
||||
self.log(LOG_LEVEL_WARN, 'recv error: getc timeout in start sequence')
|
||||
error_count += 1
|
||||
continue
|
||||
elif char == SOH:
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv: SOH')
|
||||
break
|
||||
elif char == STX:
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv: STX')
|
||||
break
|
||||
elif char == CAN:
|
||||
if cancel:
|
||||
self.log(LOG_LEVEL_INFO, 'Transmission canceled: received 2xCAN at start-sequence')
|
||||
return None
|
||||
else:
|
||||
self.log(LOG_LEVEL_DEBUG, 'cancellation at start sequence.')
|
||||
cancel = 1
|
||||
else:
|
||||
error_count += 1
|
||||
|
||||
# read data
|
||||
error_count = 0
|
||||
income_size = 0
|
||||
packet_size = 128
|
||||
sequence = 1
|
||||
cancel = 0
|
||||
while True:
|
||||
while True:
|
||||
if char == SOH:
|
||||
if packet_size != 128:
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv: SOH, using 128b packet_size')
|
||||
packet_size = 128
|
||||
break
|
||||
elif char == STX:
|
||||
if packet_size != 1024:
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv: SOH, using 1k packet_size')
|
||||
packet_size = 1024
|
||||
break
|
||||
elif char == EOT:
|
||||
# We received an EOT, so send an ACK and return the
|
||||
# received data length.
|
||||
self.putc(ACK)
|
||||
self.log(LOG_LEVEL_INFO, "Transmission complete, {0} bytes".format(income_size))
|
||||
return income_size
|
||||
elif char == CAN:
|
||||
# cancel at two consecutive cancels
|
||||
if cancel:
|
||||
self.log(LOG_LEVEL_INFO, 'Transmission canceled: received 2xCAN at block {0}'.format(sequence))
|
||||
return None
|
||||
else:
|
||||
self.log(LOG_LEVEL_DEBUG, 'cancellation at block {0}'.format(sequence))
|
||||
cancel = 1
|
||||
else:
|
||||
err_msg = ('recv error: expected SOH, EOT; got {0}'.format(char))
|
||||
if not quiet:
|
||||
sys.stderr.write(err_msg+"\n")
|
||||
self.log(LOG_LEVEL_WARN, err_msg)
|
||||
error_count += 1
|
||||
if error_count > retry:
|
||||
self.log(LOG_LEVEL_INFO, 'error_count reached {0}, aborting.'.format(retry))
|
||||
self.abort()
|
||||
return None
|
||||
|
||||
# read sequence
|
||||
error_count = 0
|
||||
cancel = 0
|
||||
self.log(LOG_LEVEL_DEBUG, 'recv: data block {0}'.format(sequence))
|
||||
seq1 = self.getc(1, timeout)
|
||||
if seq1 is None:
|
||||
self.log(LOG_LEVEL_WARN, 'getc failed to get first sequence byte')
|
||||
seq2 = None
|
||||
else:
|
||||
seq1 = ord(seq1)
|
||||
seq2 = self.getc(1, timeout)
|
||||
if seq2 is None:
|
||||
self.log(LOG_LEVEL_WARN, 'getc failed to get second sequence byte')
|
||||
else:
|
||||
# second byte is the same as first as 1's complement
|
||||
seq2 = 0xff - ord(seq2)
|
||||
|
||||
if not (seq1 == seq2 == sequence):
|
||||
# consume data anyway ... even though we will discard it,
|
||||
# it is not the sequence we expected!
|
||||
err_msg = 'expected sequence {0}, got (seq1={1}, seq2={2}), \
|
||||
receiving next block, will NAK.'.format(sequence, seq1, seq2)
|
||||
self.log(LOG_LEVEL_ERROR, err_msg)
|
||||
self.getc(packet_size + 1 + crc_mode)
|
||||
else:
|
||||
# sequence is ok, read packet
|
||||
# packet_size + checksum
|
||||
data = self.getc(packet_size + 1 + crc_mode, timeout)
|
||||
valid, data = self._verify_recv_checksum(crc_mode, data)
|
||||
|
||||
# valid data, append chunk
|
||||
if valid:
|
||||
income_size += len(data)
|
||||
stream.write(data)
|
||||
self.putc(ACK)
|
||||
sequence = (sequence + 1) % 0x100
|
||||
time.sleep(0.1) #100ms is needed to be robust for differnt platform
|
||||
# get next start-of-header byte
|
||||
char = self.getc(1, timeout)
|
||||
continue
|
||||
|
||||
# something went wrong, request retransmission
|
||||
self.log(LOG_LEVEL_WARN, 'recv error: purge, requesting retransmission (NAK)')
|
||||
while True:
|
||||
# When the receiver wishes to <nak>, it should call a "PURGE"
|
||||
# subroutine, to wait for the line to clear. Recall the sender
|
||||
# tosses any characters in its UART buffer immediately upon
|
||||
# completing sending a block, to ensure no glitches were mis-
|
||||
# interpreted. The most common technique is for "PURGE" to
|
||||
# call the character receive subroutine, specifying a 1-second
|
||||
# timeout, and looping back to PURGE until a timeout occurs.
|
||||
# The <nak> is then sent, ensuring the other end will see it.
|
||||
data = self.getc(1, timeout=1)
|
||||
if data is None:
|
||||
break
|
||||
assert False, data
|
||||
self.putc(NAK)
|
||||
# get next start-of-header byte
|
||||
time.sleep(0.1) #100ms is needed to be robust for differnt platform
|
||||
char = self.getc(1, timeout)
|
||||
continue
|
||||
|
||||
def _verify_recv_checksum(self, crc_mode, data):
|
||||
if crc_mode:
|
||||
_checksum = bytearray(data[-2:])
|
||||
their_sum = (_checksum[0] << 8) + _checksum[1]
|
||||
data = data[:-2]
|
||||
|
||||
our_sum = self.calc_crc(data)
|
||||
valid = bool(their_sum == our_sum)
|
||||
if not valid:
|
||||
self.log(LOG_LEVEL_WARN, 'recv error: checksum fail (theirs={0:04x}, ours={1:04x}), '.format(their_sum, our_sum))
|
||||
else:
|
||||
_checksum = bytearray([data[-1]])
|
||||
their_sum = _checksum[0]
|
||||
data = data[:-1]
|
||||
|
||||
our_sum = self.calc_checksum(data)
|
||||
valid = their_sum == our_sum
|
||||
if not valid:
|
||||
self.log(LOG_LEVEL_WARN, 'recv error: checksum fail (theirs={0:02x}, ours={1:02x})'.forma(their_sum, our_sum))
|
||||
return valid, data
|
||||
|
||||
def calc_checksum(self, data, checksum=0):
|
||||
'''
|
||||
Calculate the checksum for a given block of data, can also be used to
|
||||
update a checksum.
|
||||
|
||||
>>> csum = modem.calc_checksum('hello')
|
||||
>>> csum = modem.calc_checksum('world', csum)
|
||||
>>> hex(csum)
|
||||
'0x3c'
|
||||
|
||||
'''
|
||||
if platform.python_version_tuple() >= ('3', '0', '0'):
|
||||
return (sum(data) + checksum) % 256
|
||||
else:
|
||||
return (sum(map(ord, data)) + checksum) % 256
|
||||
|
||||
def calc_crc(self, data, crc=0):
|
||||
'''
|
||||
Calculate the Cyclic Redundancy Check for a given block of data, can
|
||||
also be used to update a CRC.
|
||||
|
||||
>>> crc = modem.calc_crc('hello')
|
||||
>>> crc = modem.calc_crc('world', crc)
|
||||
>>> hex(crc)
|
||||
'0xd5e3'
|
||||
|
||||
'''
|
||||
for char in bytearray(data):
|
||||
crctbl_idx = ((crc >> 8) ^ char) & 0xff
|
||||
crc = ((crc << 8) ^ self.crctable[crctbl_idx]) & 0xffff
|
||||
return crc & 0xffff
|
||||
|
||||
port = 0
|
||||
prcss_debug = False
|
||||
modem_debug = False
|
||||
|
||||
def getc(size, timeout=1):
|
||||
port.timeout = timeout
|
||||
ret = port.read(size)
|
||||
if modem_debug:
|
||||
print "read:",
|
||||
print ret,
|
||||
print ", {0} bytes".format(len(ret))
|
||||
return ret
|
||||
|
||||
def putc(data, timeout=1):
|
||||
port.timeout = timeout
|
||||
len = port.write(data)
|
||||
if modem_debug:
|
||||
print "{0} bytes writen".format(len)
|
||||
return len
|
||||
|
||||
def send_file(filename):
|
||||
modem = XMODEM(getc, putc, mode="ymodem")
|
||||
return modem.send([filename])
|
||||
|
||||
def assert_response(patterns, timeout):
|
||||
port.timeout = 0.01
|
||||
timeout_tick = time.time() + timeout
|
||||
while True:
|
||||
line = port.readline()
|
||||
if prcss_debug and len(line):
|
||||
print line
|
||||
for pattern in patterns:
|
||||
if pattern in line:
|
||||
return True
|
||||
if time.time() > timeout_tick:
|
||||
return False
|
||||
|
||||
def print_usage():
|
||||
print "Usage: {0} port [-a app.bin] [-b bootloader.bin] [-d driver.bin] [--bootloader-baudrate 921600] [--application-baudrate 115200] [--noboot]\n".format(sys.argv[0])
|
||||
print " examples: python {0} /dev/ttyUSB0 -a app.bin, to update app only".format(sys.argv[0])
|
||||
print " : python {0} /dev/ttyUSB1 -b bootloader.bin -a app.bin, to update bootloader and app".format(sys.argv[0])
|
||||
print " : python {0} /dev/ttyUSB0 -a app.bin -d driver.bin, to update app and driver".format(sys.argv[0])
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
device = sys.argv[1]
|
||||
|
||||
updates=[]
|
||||
bootloader_baudrate=921600
|
||||
application_baudrate=921600
|
||||
bootapp = True
|
||||
hardreboot = False
|
||||
|
||||
i = 2
|
||||
update = 0
|
||||
while i < len(sys.argv):
|
||||
if sys.argv[i].startswith("0x") and (i + 1) < len(sys.argv):
|
||||
if os.path.isfile(sys.argv[i+1]) == False:
|
||||
sys.stderr.write("error: file {0} does not exist\n".format(sys.argv[i+1]))
|
||||
sys.exit(1)
|
||||
updates.append([sys.argv[i], sys.argv[i+1]])
|
||||
update += 1
|
||||
i += 1
|
||||
elif sys.argv[i] == "--bootloader-baudrate" and (i + 1) < len(sys.argv):
|
||||
try:
|
||||
bootloader_baudrate = int(sys.argv[i+1])
|
||||
except:
|
||||
sys.stderr.write("error: invalid bootload baudrate value {0}\n".format(sys.argv[i+1]))
|
||||
sys.exit(1)
|
||||
i += 1
|
||||
elif sys.argv[i] == "--application-baudrate" and (i + 1) < len(sys.argv):
|
||||
try:
|
||||
application_baudrate = int(sys.argv[i+1])
|
||||
except:
|
||||
sys.stderr.write("error: invalid bootload baudrate value {0}\n".format(sys.argv[i+1]))
|
||||
sys.exit(1)
|
||||
i += 1
|
||||
elif sys.argv[i] == "--hardreset":
|
||||
hardreboot = True
|
||||
elif sys.argv[i] == "--noappboot":
|
||||
bootapp = False
|
||||
i += 1
|
||||
|
||||
if update <= 0:
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
port = serial.Serial(device, bootloader_baudrate, timeout = 0.05)
|
||||
port.setRTS(False)
|
||||
except:
|
||||
sys.stderr.write("error: unable to open {0}\n".format(device))
|
||||
sys.exit(1)
|
||||
|
||||
if hardreboot == False:
|
||||
port.write("a\r\n") #abort potential ongoing YMODEM transfer
|
||||
port.flushInput()
|
||||
port.write("help\r\n")
|
||||
if assert_response(["bootloader", "read [address] [size]"], 1) == False:
|
||||
if application_baudrate != bootloader_baudrate:
|
||||
port.baudrate = application_baudrate
|
||||
port.flushInput()
|
||||
port.write("dummycmd_for_flushing_purpose\r\n")
|
||||
time.sleep(0.1)
|
||||
port.write("reboot\r\n")
|
||||
if assert_response(["reboot"] , 1) == False:
|
||||
sys.stderr.write("error: failed to reboot the board, it did not respond to \"reboot\" command\n")
|
||||
sys.exit(1)
|
||||
if application_baudrate != bootloader_baudrate:
|
||||
port.baudrate = bootloader_baudrate
|
||||
time.sleep(0.11); port.write(" ") #0.11s
|
||||
time.sleep(0.03); port.write(" ") #0.14s
|
||||
time.sleep(0.03); port.write(" ") #0.17s
|
||||
time.sleep(0.03); port.write(" ") #0.20s
|
||||
time.sleep(0.03); port.write(" ") #0.23s
|
||||
time.sleep(0.03); port.write(" \r\n") #0.26s
|
||||
if assert_response(["ootloader", "BOOTLODER"], 1) == False:
|
||||
sys.stderr.write("error: failed to enter bootloader\n")
|
||||
sys.exit(1)
|
||||
else:
|
||||
port.setRTS(True)
|
||||
time.sleep(0.1)
|
||||
port.setRTS(False)
|
||||
time.sleep(0.11); port.write(" ") #0.11s
|
||||
time.sleep(0.03); port.write(" ") #0.14s
|
||||
time.sleep(0.03); port.write(" ") #0.17s
|
||||
time.sleep(0.03); port.write(" ") #0.20s
|
||||
time.sleep(0.03); port.write(" ") #0.23s
|
||||
time.sleep(0.03); port.write(" \r\n") #0.26s
|
||||
if assert_response(["bootloader"], 1) == False:
|
||||
sys.stderr.write("error: failed to enter bootloader\n")
|
||||
sys.exit(1)
|
||||
port.flushInput()
|
||||
|
||||
failed_num = 0
|
||||
for [addr, image] in updates:
|
||||
status_str = "[INFO]: updating {0} with {1} @ address {2} ...".format(device, image, addr)
|
||||
print status_str
|
||||
port.write("write {0}\r\n".format(addr))
|
||||
time.sleep(0.5) #500ms is needed to be robust for differnt platform
|
||||
if assert_response(["Waiting for the file to be sent"], 1) == False:
|
||||
sys.stderr.write("error: waiting for target to enter into YMODEM recived mode failed\n")
|
||||
sys.exit(1)
|
||||
result = send_file(image)
|
||||
if result == True:
|
||||
status_str = status_str + " succeed"
|
||||
else:
|
||||
status_str = status_str + " failed"
|
||||
failed_num += 1
|
||||
print status_str
|
||||
|
||||
if bootapp and failed_num == 0:
|
||||
port.write("boot\r\n")
|
||||
assert_response(["Booting......"], 1)
|
||||
port.close()
|
||||
sys.exit(failed_num)
|
||||
|
||||
22
Living_SDK/build/aos_flash_download_app.mk
Normal file
22
Living_SDK/build/aos_flash_download_app.mk
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
SFLASH_LOG_FILE ?= $(BUILD_DIR)/sflash_writer.log
|
||||
SFLASH_REDIRECT = > $(SFLASH_LOG_FILE)
|
||||
|
||||
SFLASH_APP_TARGET := sub_build.spi_flash_write@NoRTOS@$(PLATFORM)
|
||||
SFLASH_APP_PLATFROM_BUS := $(PLATFORM)
|
||||
SFLASH_PREBUILD_APP := board/$(PLATFORM)/flash_prog.elf
|
||||
|
||||
clean:
|
||||
$(QUIET)$(RM) -rf $(SFLASH_PREBUILD_APP)
|
||||
|
||||
# If Downloading is required, then the Serial Flash app need to be built
|
||||
$(SFLASH_PREBUILD_APP):
|
||||
$(QUIET)$(ECHO) Building Flash Loader App...
|
||||
$(QUIET)$(MAKE) -r -f $(SOURCE_ROOT)Makefile $(SFLASH_APP_TARGET) SFLASH= EXTERNAL_AOS_GLOBAL_DEFINES=$(EXTERNAL_AOS_GLOBAL_DEFINES) SUB_BUILD=sflash_app $(SFLASH_REDIRECT)
|
||||
$(QUIET)$(CP) -f $(BUILD_DIR)/$(SFLASH_APP_TARGET)/binary/$(SFLASH_APP_TARGET).elf $(SFLASH_PREBUILD_APP)
|
||||
$(QUIET)$(ECHO) Finished Building Flash Loader App
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
|
||||
sflash_write_app: $(SFLASH_PREBUILD_APP)
|
||||
|
||||
|
||||
|
||||
299
Living_SDK/build/aos_host_cmd.mk
Normal file
299
Living_SDK/build/aos_host_cmd.mk
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
TOOLS_ROOT ?= $(SOURCE_ROOT)build
|
||||
COMPILER_ROOT ?=$(TOOLS_ROOT)/compiler
|
||||
|
||||
|
||||
OPENOCD_PATH := $(TOOLS_ROOT)/OpenOCD/${HOST_OS}/
|
||||
OPENOCD_CFG_PATH := $(MAKEFILES_PATH)/OpenOCD/${HOST_OS}/
|
||||
PATH :=
|
||||
|
||||
JTAG ?= jlink_swd
|
||||
|
||||
BUILD_DIR ?= out
|
||||
|
||||
DATE := date
|
||||
|
||||
ifeq ($(HOST_OS),Win32)
|
||||
################
|
||||
# Windows settings
|
||||
################
|
||||
COMMON_TOOLS_PATH := $(TOOLS_ROOT)/cmd/win32/
|
||||
export SHELL = cmd.exe
|
||||
EXECUTABLE_SUFFIX := .exe
|
||||
OPENOCD_FULL_NAME := $(OPENOCD_PATH)bin/openocd.exe
|
||||
DATE := $(COMMON_TOOLS_PATH)$(DATE)
|
||||
|
||||
# Python
|
||||
ifneq ($(wildcard C:\Python34\python.exe),)
|
||||
PYTHON_FULL_NAME := C:\Python34\python.exe
|
||||
endif
|
||||
ifneq ($(wildcard C:\Python27\python.exe),)
|
||||
PYTHON_FULL_NAME := C:\Python27\python.exe
|
||||
endif
|
||||
|
||||
SLASH_QUOTE_START :=\"
|
||||
SLASH_QUOTE_END :=\"
|
||||
|
||||
ESC_QUOTE:="
|
||||
ESC_SPACE:=$(SPACE)
|
||||
CAT := type
|
||||
ECHO_BLANK_LINE := "$(COMMON_TOOLS_PATH)echo$(EXECUTABLE_SUFFIX)"
|
||||
ECHO_NO_NEWLINE := "$(COMMON_TOOLS_PATH)echo$(EXECUTABLE_SUFFIX)" -n
|
||||
ECHO := echo
|
||||
QUOTES_FOR_ECHO :=
|
||||
CMD_TRUNC := "$(COMMON_TOOLS_PATH)trunc$(EXECUTABLE_SUFFIX)"
|
||||
PERL := "$(COMMON_TOOLS_PATH)perl$(EXECUTABLE_SUFFIX)"
|
||||
PYTHON := "$(COMMON_TOOLS_PATH)Python27/python$(EXECUTABLE_SUFFIX)"
|
||||
LINT_EXE := "$(TOOLS_ROOT)/splint/splint/bin/splint$(EXECUTABLE_SUFFIX)"
|
||||
PERL_ESC_DOLLAR :=$$
|
||||
CLEAN_COMMAND := if exist "$(BUILD_DIR)" $(call CONV_SLASHES,$(COMMON_TOOLS_PATH))rmdir /s /q "$(BUILD_DIR)"
|
||||
#MKDIR = if not exist $(subst /,\,$1) mkdir $(subst /,\,$1)
|
||||
MKDIR = "$(COMMON_TOOLS_PATH)mkdir" -p $1
|
||||
RMDIR = if exist $(subst /,\,$1) rmdir /s /q $(subst /,\,$1)
|
||||
CPDIR = xcopy /s /q /i $(subst /,\,$1) $(subst /,\,$2)
|
||||
CONV_SLASHES = $(subst /,\,$1)
|
||||
DIR = $(dir $(subst /,\,$1))
|
||||
TOUCH = $(ECHO) >
|
||||
CYGWIN :=
|
||||
DEV_NULL := nul
|
||||
TRUE_CMD := call
|
||||
FALSE_CMD := fail > nul 2>&1
|
||||
|
||||
# $(1) is the content, $(2) is the file to print to.
|
||||
define PRINT
|
||||
@$(ECHO) $(1)>>$(2)
|
||||
|
||||
endef
|
||||
|
||||
WRITE_FILE_CREATE =$(file >$(1),$(2))
|
||||
WRITE_FILE_APPEND =$(file >>$(1),$(2))
|
||||
|
||||
else # Win32
|
||||
ifeq ($(HOST_OS),Linux32)
|
||||
################
|
||||
# Linux 32-bit settings
|
||||
################
|
||||
|
||||
COMMON_TOOLS_PATH := $(TOOLS_ROOT)/cmd/linux32/
|
||||
export SHELL = $(COMMON_TOOLS_PATH)dash
|
||||
EXECUTABLE_SUFFIX :=
|
||||
OPENOCD_FULL_NAME := "$(OPENOCD_PATH)bin/openocd"
|
||||
SLASH_QUOTE_START :=\"
|
||||
SLASH_QUOTE_END :=\"
|
||||
ESC_QUOTE :=\"
|
||||
ESC_SPACE :=\$(SPACE)
|
||||
CAT := "$(COMMON_TOOLS_PATH)cat"
|
||||
ECHO_BLANK_LINE := "$(COMMON_TOOLS_PATH)echo"
|
||||
ECHO_NO_NEWLINE := "$(COMMON_TOOLS_PATH)echo" -n
|
||||
# dash command shell has built in echo command
|
||||
ECHO := echo
|
||||
QUOTES_FOR_ECHO :="
|
||||
CMD_TRUNC := $(ECHO)
|
||||
PERL := $(shell which perl)
|
||||
PYTHON := $(shell which python)
|
||||
PERL_ESC_DOLLAR :=\$$
|
||||
CLEAN_COMMAND := "$(COMMON_TOOLS_PATH)rm" -rf $(BUILD_DIR)
|
||||
MKDIR = "$(COMMON_TOOLS_PATH)mkdir" -p $1
|
||||
RMDIR = "$(COMMON_TOOLS_PATH)rm" -rf $1
|
||||
CPDIR = "$(COMMON_TOOLS_PATH)cp" -rf $1 $2
|
||||
CONV_SLASHES = $1
|
||||
TOUCH = $(ECHO) >
|
||||
DEV_NULL := /dev/null
|
||||
TRUE_CMD := true
|
||||
FALSE_CMD := false
|
||||
|
||||
# $(1) is the content, $(2) is the file to print to.
|
||||
define PRINT
|
||||
@$(ECHO) '$(1)'>>$(2)
|
||||
|
||||
endef
|
||||
|
||||
WRITE_FILE_CREATE =$(ECHO) '$(subst ',\047,$(subst \,\\,$(2)))' > $(1);
|
||||
WRITE_FILE_APPEND =$(ECHO) '$(subst ',\047,$(subst \,\\,$(2)))' >> $(1);
|
||||
|
||||
else # Linux32
|
||||
ifeq ($(HOST_OS),Linux64)
|
||||
################
|
||||
# Linux 64-bit settings
|
||||
################
|
||||
|
||||
COMMON_TOOLS_PATH := $(TOOLS_ROOT)/cmd/linux64/
|
||||
export SHELL = $(COMMON_TOOLS_PATH)dash
|
||||
EXECUTABLE_SUFFIX :=
|
||||
OPENOCD_FULL_NAME := "$(OPENOCD_PATH)bin/openocd"
|
||||
SLASH_QUOTE_START :=\"
|
||||
SLASH_QUOTE_END :=\"
|
||||
ESC_QUOTE :=\"
|
||||
ESC_SPACE :=\$(SPACE)
|
||||
CAT := "$(COMMON_TOOLS_PATH)cat"
|
||||
ECHO_BLANK_LINE := "$(COMMON_TOOLS_PATH)echo"
|
||||
ECHO_NO_NEWLINE := "$(COMMON_TOOLS_PATH)echo" -n
|
||||
# dash command shell has built in echo command
|
||||
ECHO := echo
|
||||
QUOTES_FOR_ECHO :="
|
||||
CMD_TRUNC := $(ECHO)
|
||||
PERL := $(shell which perl)
|
||||
PYTHON := $(shell which python)
|
||||
PERL_ESC_DOLLAR :=\$$
|
||||
CLEAN_COMMAND := "$(COMMON_TOOLS_PATH)rm" -rf $(BUILD_DIR)
|
||||
MKDIR = "$(COMMON_TOOLS_PATH)mkdir" -p $1
|
||||
RMDIR = "$(COMMON_TOOLS_PATH)rm" -rf $1
|
||||
CPDIR = "$(COMMON_TOOLS_PATH)cp" -rf $1 $2
|
||||
CONV_SLASHES = $1
|
||||
TOUCH = $(ECHO) >
|
||||
DEV_NULL := /dev/null
|
||||
TRUE_CMD := true
|
||||
FALSE_CMD := false
|
||||
|
||||
# $(1) is the content, $(2) is the file to print to.
|
||||
define PRINT
|
||||
@$(ECHO) '$(1)'>>$(2)
|
||||
|
||||
endef
|
||||
|
||||
WRITE_FILE_CREATE =$(ECHO) '$(subst ',\047,$(subst \,\\,$(2)))' > $(1);
|
||||
WRITE_FILE_APPEND =$(ECHO) '$(subst ',\047,$(subst \,\\,$(2)))' >> $(1);
|
||||
# # Check the file writing is working correctly
|
||||
# # should result in: $'""\"\"\\"\\\"\\
|
||||
# TEST_DATA := $$'""\"\"\\"\\\"\\
|
||||
# $(info TEST_DATA=$(TEST_DATA))
|
||||
# $(info $(call WRITE_FILE_CREATE,test.txt,$(TEST_DATA)))
|
||||
# $(info done=$(shell $(call WRITE_FILE_CREATE,test.txt,$(TEST_DATA))))
|
||||
|
||||
else # Linux64
|
||||
ifeq ($(HOST_OS),OSX)
|
||||
################
|
||||
# OSX settings
|
||||
################
|
||||
|
||||
COMMON_TOOLS_PATH := $(TOOLS_ROOT)/cmd/osx/
|
||||
export SHELL = $(COMMON_TOOLS_PATH)dash
|
||||
EXECUTABLE_SUFFIX :=
|
||||
OPENOCD_FULL_NAME := "$(OPENOCD_PATH)bin/openocd"
|
||||
SLASH_QUOTE_START :=\"
|
||||
SLASH_QUOTE_END :=\"
|
||||
ESC_QUOTE :=\"
|
||||
ESC_SPACE :=\$(SPACE)
|
||||
CAT := "$(COMMON_TOOLS_PATH)cat"
|
||||
ECHO_BLANK_LINE := "$(COMMON_TOOLS_PATH)echo"
|
||||
ECHO_NO_NEWLINE := "$(COMMON_TOOLS_PATH)echo" -n
|
||||
ECHO := "$(COMMON_TOOLS_PATH)echo"
|
||||
QUOTES_FOR_ECHO :="
|
||||
CMD_TRUNC := $(ECHO)
|
||||
PERL := $(shell which perl)
|
||||
PYTHON := $(shell which python)
|
||||
PERL_ESC_DOLLAR :=\$$
|
||||
CLEAN_COMMAND := "$(COMMON_TOOLS_PATH)rm" -rf $(BUILD_DIR)
|
||||
MKDIR = "$(COMMON_TOOLS_PATH)mkdir" -p $1
|
||||
RMDIR = "$(COMMON_TOOLS_PATH)rm" -rf $1
|
||||
CPDIR = "$(COMMON_TOOLS_PATH)cp" -rf $1 $2
|
||||
CONV_SLASHES = $1
|
||||
TOUCH = $(ECHO) >
|
||||
DEV_NULL := /dev/null
|
||||
TRUE_CMD := true
|
||||
FALSE_CMD := false
|
||||
|
||||
# $(1) is the content, $(2) is the file to print to.
|
||||
define PRINT
|
||||
@$(ECHO) '$(1)'>>$(2)
|
||||
|
||||
endef
|
||||
|
||||
WRITE_FILE_CREATE =$(ECHO) '$(2)' > $(1);
|
||||
WRITE_FILE_APPEND =$(ECHO) '$(2)' >> $(1);
|
||||
|
||||
else # OSX
|
||||
|
||||
$(error incorrect 'make' used ($(MAKE)) - please use: (Windows) .\make.exe <target_string> (OS X, Linux) ./make <target_string>)
|
||||
|
||||
endif # OSX
|
||||
endif # Linux64
|
||||
endif # Linux32
|
||||
endif # Win32
|
||||
|
||||
|
||||
# Set shortcuts to the compiler and other tools
|
||||
RM := "$(COMMON_TOOLS_PATH)rm$(EXECUTABLE_SUFFIX)" -f
|
||||
CP := "$(COMMON_TOOLS_PATH)cp$(EXECUTABLE_SUFFIX)" -f
|
||||
MAKE := "$(COMMON_TOOLS_PATH)make$(EXECUTABLE_SUFFIX)"
|
||||
BIN2C := "$(COMMON_TOOLS_PATH)bin2c$(EXECUTABLE_SUFFIX)"
|
||||
CURRENT_TIME = $(shell $(DATE) +%Y%m%d.%H%M%S)
|
||||
|
||||
|
||||
SHOULD_I_WAIT_FOR_DOWNLOAD := $(filter download, $(MAKECMDGOALS))
|
||||
BUILD_STRING ?= $(strip $(filter-out $(MAKEFILE_TARGETS) download run total, $(MAKECMDGOALS)))
|
||||
BUILD_STRING_TO_DIR = $(subst .,/,$(1))
|
||||
DIR_TO_BUILD_STRING = $(subst /,.,$(1))
|
||||
CLEANED_BUILD_STRING := $(BUILD_STRING)
|
||||
|
||||
OUTPUT_DIR := $(BUILD_DIR)/$(CLEANED_BUILD_STRING)$(BINS)
|
||||
AUTO_COMPONENT_DIR := $(OUTPUT_DIR)/auto_component
|
||||
|
||||
# Newline Macro
|
||||
define newline
|
||||
|
||||
|
||||
endef
|
||||
|
||||
|
||||
# Use VERBOSE=1 to get full output
|
||||
ifneq ($(VERBOSE),1)
|
||||
QUIET:=@
|
||||
SILENT:=-s
|
||||
QUIET_SHELL =$(shell $(1))
|
||||
QUIET_SHELL_IN_MACRO =$$(shell $(1))
|
||||
else
|
||||
QUIET:=
|
||||
SILENT:=
|
||||
QUIET_SHELL =$(shell $(1)$(info $(1)))
|
||||
QUIET_SHELL_IN_MACRO =$$(shell $(1)$$(info $(1)))
|
||||
endif
|
||||
|
||||
|
||||
|
||||
COMMA :=,
|
||||
|
||||
SPACE :=
|
||||
SPACE +=
|
||||
|
||||
# $(1) is a string to be escaped
|
||||
ESCAPE_BACKSLASHES =$(subst \,\\,$(1))
|
||||
|
||||
#########
|
||||
# Expand wildcard platform names.
|
||||
# Consider all platforms in platforms/* and platform/*/*
|
||||
define EXPAND_WILDCARD_PLATFORMS
|
||||
$(eval POSSIBLE_PLATFORMS :=) \
|
||||
$(eval EXPANDED_PLATFORMS :=) \
|
||||
$(foreach ENTRY, $(1), \
|
||||
$(eval WILDCARD_PLATFORM := $(call BUILD_STRING_TO_DIR, $(ENTRY))) \
|
||||
$(eval POSSIBLE_PLATFORMS += $(subst board/,,$(wildcard board/$(WILDCARD_PLATFORM)))) \
|
||||
$(eval POSSIBLE_PLATFORMS += $(subst board/,,$(wildcard board/$(WILDCARD_PLATFORM)/*)))) \
|
||||
$(eval $(foreach PLATFORM, $(POSSIBLE_PLATFORMS), \
|
||||
$(eval $(if $(wildcard board/$(PLATFORM)/$(notdir $(PLATFORM)).mk), EXPANDED_PLATFORMS += $(call DIR_TO_BUILD_STRING, $(PLATFORM))))))\
|
||||
${EXPANDED_PLATFORMS}
|
||||
endef
|
||||
|
||||
##########
|
||||
# Recurse directories to find valid AOS components.
|
||||
# $(1) = starting directory
|
||||
# $(2) = name of variable to which to add components that are found
|
||||
define RECURSE_DIR_COMPONENT_SEARCH
|
||||
$(foreach file, $(wildcard $(1)/*), $(if $(wildcard $(file)/*), $(if $(wildcard $(file)/$(notdir $(file)).mk), $(eval $(2) += $(file)),) $(call RECURSE_DIR_COMPONENT_SEARCH,$(file),$(2)),))
|
||||
endef
|
||||
|
||||
|
||||
##########
|
||||
# Find all valid components.
|
||||
# $(1) = name of variable to which to add components that are found
|
||||
# $(2) = list of component directories
|
||||
define FIND_VALID_COMPONENTS
|
||||
$(call RECURSE_DIR_COMPONENT_SEARCH, $(patsubst %/,%,$(SOURCE_ROOT)),$(1)) \
|
||||
$(eval $(1) := $(subst ./,,$($(strip $(1))))) \
|
||||
$(foreach compdir, $(2),$(eval $(1) := $(patsubst $(compdir)/%,%,$($(strip $(1)))))) \
|
||||
$(eval $(1) := $(subst /,.,$($(strip $(1)))))
|
||||
endef
|
||||
|
||||
##########
|
||||
# Strip duplicate items in list without sorting
|
||||
# $(1) = List of items to de-duplicate
|
||||
unique = $(eval seen :=)$(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_)))${seen}
|
||||
63
Living_SDK/build/aos_images_download.mk
Normal file
63
Living_SDK/build/aos_images_download.mk
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
include $(MAKEFILES_PATH)/aos_partition.mk
|
||||
include $(MAKEFILES_PATH)/aos_flash_download_app.mk
|
||||
|
||||
SFLASH_LOG_FILE ?= $(BUILD_DIR)/sflash_writer.log
|
||||
SFLASH_REDIRECT = > $(SFLASH_LOG_FILE)
|
||||
|
||||
IMAGE_SIZE_SCRIPT := $(MAKEFILES_PATH)/scripts/image_size.py
|
||||
|
||||
IMAGES_SECTORS_DEFAULT_COUNT := 1
|
||||
|
||||
APPS_HEADER_DEFINES :=
|
||||
CURRENT_DEPENDENCY :=
|
||||
|
||||
OPENOCD_LOG_FILE ?= $(BUILD_DIR)/openocd_log.txt
|
||||
DOWNLOAD_LOG := >> $(OPENOCD_LOG_FILE)
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_IMAGES_RULES
|
||||
|
||||
define BUILD_IMAGES_RULES
|
||||
$(if $($(1)),$(eval $(1)_ENTRY_COUNT := 1),$(eval $(1)_ENTRY_COUNT := 0))
|
||||
$(if $($(1)),$(eval $(1)_SIZE := $(shell $(PYTHON) $(IMAGE_SIZE_SCRIPT) $($(1)))),$(eval $(1)_SIZE := 0))
|
||||
endef
|
||||
### end of BUILD_APPS_RULES
|
||||
|
||||
###############################################################################
|
||||
|
||||
# MACRO: BUILD_IMAGE_DOWNLOAD_DEPENDENCY
|
||||
define BUILD_IMAGE_DOWNLOAD_DEPENDENCY
|
||||
$(if $($(1)),$(eval $(1)_DOWNLOAD_DEPENDENCY := $($(1)) $(CURRENT_DEPENDENCY) sflash_write_app display_map_summary $(EXT_IMAGES_DOWNLOAD_DEP) IMAGES_DOWNLOAD_RULES $(LINK_APPS_FILE)),)
|
||||
$(if $($(1)),$(eval CURRENT_DEPENDENCY += $(1)_DOWNLOAD),)
|
||||
endef
|
||||
#### end of BUILD_IMAGE_DOWNLOAD_DEPENDENCY
|
||||
|
||||
IMAGES_DOWNLOADS_DEPENDENCY :=
|
||||
IMAGES := WIFI_FIRMWARE BT_PATCH_FIRMWARE BOOTLOAD_FIRMWARE APPLICATION_FIRMWARE ATE_FIRMWARE PARAMETER_1_IMAGE PARAMETER_2_IMAGEFILESYSTEM_IMAGE
|
||||
$(foreach IMAGE,$(IMAGES),$(eval $(if $($(IMAGE)), IMAGES_DOWNLOADS_DEPENDENCY += $(IMAGE)_DOWNLOAD)))
|
||||
$(foreach IMAGE,$(IMAGES),$(eval $(call BUILD_IMAGE_DOWNLOAD_DEPENDENCY,$(IMAGE))))
|
||||
|
||||
.PHONY: FILESYSTEM_IMAGE_DOWNLOAD BT_PATCH_DOWNLOAD WIFI_FIRMWARE_DOWNLOAD EXT_IMAGE_DOWNLOAD
|
||||
|
||||
IMAGES_DOWNLOAD_RULES: $(APPS_HEADER_DEPENDENCY)
|
||||
$(foreach IMAGE,$(IMAGES),$(eval $(call BUILD_IMAGES_RULES,$(IMAGE), $($(IMAGE)_SECTOR_START))))
|
||||
|
||||
ifneq ($(WIFI_FIRMWARE),)
|
||||
WIFI_FIRMWARE_DOWNLOAD: $(WIFI_FIRMWARE_DOWNLOAD_DEPENDENCY)
|
||||
$(QUIET)$(ECHO) Downloading WIFI_FIRMWARE to partition: $(WIFI_FIRMWARE_PARTITION_TCL) size: $(WIFI_FIRMWARE_SIZE) bytes...
|
||||
$(call CONV_SLASHES,$(OPENOCD_FULL_NAME)) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f demos/sub_build/spi_flash_write/sflash_write.tcl -c "sflash_write_file $(WIFI_FIRMWARE) $(WIFI_FIRMWARE_PARTITION_TCL) 0x0 $(SFLASH_APP_PLATFROM_BUS) 0" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) Download failed. See $(OPENOCD_LOG_FILE) for detail.
|
||||
endif
|
||||
|
||||
ifneq ($(BT_PATCH_FIRMWARE),)
|
||||
BT_PATCH_FIRMWARE_DOWNLOAD: $(BT_PATCH_FIRMWARE_DOWNLOAD_DEPENDENCY)
|
||||
$(QUIET)$(ECHO) Downloading BT_PATCH to partition: $(BT_PATCH_FIRMWARE_PARTITION_TCL) size: $(BT_PATCH_FIRMWARE_SIZE) bytes ...
|
||||
$(call CONV_SLASHES,$(OPENOCD_FULL_NAME)) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f demos/sub_build/spi_flash_write/sflash_write.tcl -c "sflash_write_file $(BT_PATCH_FIRMWARE) $(BT_PATCH_FIRMWARE_PARTITION_TCL) 0x0 $(SFLASH_APP_PLATFROM_BUS) 0" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) Download failed. See $(OPENOCD_LOG_FILE) for detail.
|
||||
endif
|
||||
|
||||
ifneq ($(FILESYSTEM_IMAGE),)
|
||||
FILESYSTEM_IMAGE_DOWNLOAD: $(FILESYSTEM_IMAGE_DOWNLOAD_DEPENDENCY)
|
||||
$(QUIET)$(ECHO) Downloading resources filesystem ... $(FILESYSTEM_IMAGE) at sector $(FILESYSTEM_IMAGE_SECTOR_START) size $(FILESYSTEM_IMAGE_SECTOR_COUNT)...
|
||||
$(call CONV_SLASHES,$(OPENOCD_FULL_NAME)) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f apps/waf/sflash_write/sflash_write.tcl -c "sflash_write_file $(FILESYSTEM_IMAGE) $(FILESYSTEM_IMAGE_SECTOR_ADDRESS) $(SFLASH_APP_PLATFROM_BUS) 0" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) Download failed. See $(OPENOCD_LOG_FILE) for detail.
|
||||
endif
|
||||
|
||||
EXT_IMAGE_DOWNLOAD: sflash_write_app $(IMAGES_DOWNLOADS_DEPENDENCY)
|
||||
154
Living_SDK/build/aos_library_build.mk
Normal file
154
Living_SDK/build/aos_library_build.mk
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
all: stripped_lib
|
||||
|
||||
$(info $(filter wipe_source_for_test,$(MAKECMDGOALS)))
|
||||
ifeq ($(filter wipe_source_for_test,$(MAKECMDGOALS)),)
|
||||
|
||||
LIBRARY_NAME :=$(NAME)
|
||||
ifndef LIBRARY_NAME
|
||||
$(error LIBRARY_NAME not defined)
|
||||
endif
|
||||
|
||||
ifdef RTOS
|
||||
LIBRARY_NAME :=$(LIBRARY_NAME).$(RTOS)
|
||||
endif
|
||||
ifdef NETWORK
|
||||
LIBRARY_NAME:=$(LIBRARY_NAME).$(NETWORK)
|
||||
endif
|
||||
|
||||
ifndef TARGET_ARCH
|
||||
$(error HOST_ARCH not defined - needed to include correct toolchain)
|
||||
endif
|
||||
|
||||
LIBRARY_NAME:=$(LIBRARY_NAME).$(TARGET_ARCH)
|
||||
|
||||
ifneq (,$(TARGET_BOARD))
|
||||
LIBRARY_NAME := $(LIBRARY_NAME).$(TARGET_BOARD)
|
||||
endif
|
||||
|
||||
CC :=
|
||||
|
||||
include $(SOURCE_ROOT)build/aos_host_cmd.mk
|
||||
|
||||
ifeq ($(COMPILER),armcc)
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_iar.mk
|
||||
else
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_gcc.mk
|
||||
endif
|
||||
|
||||
ifndef CC
|
||||
$(error No matching toolchain found for architecture $(HOST_ARCH))
|
||||
endif
|
||||
|
||||
LIBRARY_NAME:=$(LIBRARY_NAME).$(TOOLCHAIN_NAME)
|
||||
|
||||
# Add a option for pre-built library to turn of library poison.
|
||||
# This is useful for adding a new library which uses poisoned functions extensively.
|
||||
# Over time, these function calls in the library can be gradually phased out.
|
||||
ifdef BYPASS_LIBRARY_POISON_CHECK
|
||||
LIBRARY_POISON_H_INCLUSION :=
|
||||
else
|
||||
LIBRARY_POISON_H_INCLUSION := -include library_poison.h
|
||||
endif
|
||||
|
||||
MAKEFILES_DIR := $(TOOLS_ROOT)$(SOURCE_ROOT)/tools/makefiles
|
||||
|
||||
# NOTE: The system builds each object twice - once with built-in functions disabled and bad functions poisoned to catch uses of these functions,
|
||||
# Then again with built-in functions re-enabled to allow optimisations
|
||||
$(SOURCE_ROOT)/out/$(NAME)/%.o: %.c $(SOURCE_ROOT)build/aos_library_makefile.mk
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
$(QUIET)$(ECHO) Compiling $<
|
||||
$(QUIET)$(CC) -I $(SOURCE_ROOT)/tools/makefiles -fno-builtin $(LIBRARY_POISON_H_INCLUSION) $(CFLAGS) -o $@ $<
|
||||
$(QUIET)$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(SOURCE_ROOT)out/$(NAME)/%.o: %.cpp $(SOURCE_ROOT)build/aos_library_makefile.mk
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
$(QUIET)$(ECHO) Compiling $<
|
||||
$(QUIET)$(CC) $(CFLAGS) -o $@ $<
|
||||
$(QUIET)$(CXX) -I $(SOURCE_ROOT)/tools/makefiles $(LIBRARY_POISON_H_INCLUSION) -fno-builtin $(CFLAGS) -o $@ $<
|
||||
$(QUIET)$(CXX) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(SOURCE_ROOT)out/$(NAME)/%.o: %.S $(SOURCE_ROOT)build/aos_library_makefile.mk
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
$(QUIET)$(ECHO) Assembling $<
|
||||
$(QUIET)$(AS) $(ASMFLAGS) -o $@ $<
|
||||
|
||||
# AOS pre-built library defines
|
||||
CFLAGS += -DAOS_PREBUILT_LIBS
|
||||
|
||||
ifeq ($(DEBUG), yes)
|
||||
CFLAGS += -DDEBUG
|
||||
ifndef ALWAYS_OPTIMISE
|
||||
CFLAGS += -O0
|
||||
else
|
||||
CFLAGS += -Os
|
||||
endif
|
||||
LIBRARY_NAME :=$(LIBRARY_NAME).debug
|
||||
else
|
||||
CFLAGS += -Os -DNDEBUG
|
||||
LIBRARY_NAME :=$(LIBRARY_NAME).release
|
||||
endif
|
||||
|
||||
ASMFLAGS += $(CPU_ASMFLAGS)
|
||||
|
||||
|
||||
#platform_assert
|
||||
CFLAGS += -I$(SOURCE_ROOT)platform \
|
||||
-I$(SOURCE_ROOT)platform/$(HOST_ARCH)
|
||||
|
||||
|
||||
CFLAGS += -DAOS_PREBUILT_LIBS
|
||||
|
||||
OBJS := $(addprefix $(SOURCE_ROOT)out/$(NAME)/,$(filter %.o,$(SOURCES:.cpp=.o) $(SOURCES:.c=.o) $(SOURCES:.S=.o)))
|
||||
|
||||
$(SOURCE_ROOT)out/$(NAME)/$(LIBRARY_NAME).a: $(OBJS)
|
||||
$(QUIET)$(RM) $@
|
||||
$(QUIET)$(ECHO) Making Library
|
||||
$(if $(wordlist 1,50, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 1,50, $(OBJS)))
|
||||
$(if $(wordlist 51,100, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 51,100, $(OBJS)))
|
||||
$(if $(wordlist 101,150, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 101,150, $(OBJS)))
|
||||
$(if $(wordlist 151,200, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 151,200, $(OBJS)))
|
||||
$(if $(wordlist 201,250, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 201,250, $(OBJS)))
|
||||
$(if $(wordlist 251,300, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 251,300, $(OBJS)))
|
||||
$(if $(wordlist 301,350, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 301,350, $(OBJS)))
|
||||
$(if $(wordlist 351,400, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 351,400, $(OBJS)))
|
||||
$(if $(wordlist 401,450, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 401,450, $(OBJS)))
|
||||
$(if $(wordlist 451,500, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 451,500, $(OBJS)))
|
||||
$(if $(wordlist 501,550, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 501,550, $(OBJS)))
|
||||
$(if $(wordlist 551,600, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 551,600, $(OBJS)))
|
||||
$(if $(wordlist 601,650, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 601,650, $(OBJS)))
|
||||
$(if $(wordlist 651,700, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 651,700, $(OBJS)))
|
||||
$(if $(wordlist 701,750, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 701,750, $(OBJS)))
|
||||
$(if $(wordlist 751,1000, $(OBJS)),$(QUIET)$(AR) -rcs $@ $(wordlist 751,1000, $(OBJS)))
|
||||
|
||||
|
||||
stripped_lib: $(SOURCE_ROOT)out/$(NAME)/$(LIBRARY_NAME).a $(SOURCE_ROOT)build/aos_library_makefile.mk
|
||||
ifdef NO_STRIP_LIBS
|
||||
$(QUIET)$(CP) $(SOURCE_ROOT)/out/$(NAME)/$(LIBRARY_NAME).a $(LIBRARY_NAME).a
|
||||
else
|
||||
$(QUIET)$(STRIP) -g -o $(LIBRARY_NAME).a $(SOURCE_ROOT)/out/$(NAME)/$(LIBRARY_NAME).a
|
||||
endif
|
||||
$(QUIET)$(RM) -rf $(SOURCE_ROOT)/out/$(NAME)
|
||||
$(QUIET)$(ECHO) $(LIBRARY_NAME).a DONE
|
||||
|
||||
clean:
|
||||
$(QUIET)$(RM) -rf $(NAME)*.a
|
||||
|
||||
else
|
||||
|
||||
ifeq ($(HOST_OS),Win32)
|
||||
LIB_TOOLS_DIR := $(subst /,\,/pf8_3/MinGW/msys/1.0/mingw/bin/)
|
||||
EXECUTABLE_SUFFIX := .exe
|
||||
endif
|
||||
|
||||
LIB_RM := $(LIB_TOOLS_DIR)rm$(EXECUTABLE_SUFFIX)
|
||||
LIB_RMDIR := $(LIB_TOOLS_DIR)rmdir$(EXECUTABLE_SUFFIX)
|
||||
LIB_XARGS := $(LIB_TOOLS_DIR)xargs$(EXECUTABLE_SUFFIX)
|
||||
LIB_FIND := $(LIB_TOOLS_DIR)find$(EXECUTABLE_SUFFIX)
|
||||
|
||||
wipe_source_for_test:
|
||||
cd $(KEEP_LIST_DIR) && $(LIB_FIND) . -type f -a -not \( $(foreach SPEC,$(KEEP_LIST), -path "./$(SPEC)" -o ) -false \) -print0 | $(LIB_XARGS) -0 $(LIB_RM)
|
||||
cd $(KEEP_LIST_DIR) && $(LIB_FIND) . -type d -empty -print0 | $(LIB_XARGS) -0 --no-run-if-empty $(LIB_RMDIR)
|
||||
|
||||
endif
|
||||
86
Living_SDK/build/aos_library_config.mk
Normal file
86
Living_SDK/build/aos_library_config.mk
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
export AOS_SDK_VERSION_MAJOR := 3
|
||||
export AOS_SDK_VERSION_MINOR := 2
|
||||
export AOS_SDK_VERSION_REVISION := 3
|
||||
|
||||
export MAKEFILES_PATH := $(SOURCE_ROOT)/build
|
||||
export SCRIPTS_PATH := $(SOURCE_ROOT)/build/scripts
|
||||
|
||||
include $(SOURCE_ROOT)/build/aos_host_cmd.mk
|
||||
|
||||
ifeq ($(COMPILER),armcc)
|
||||
include $(SOURCE_ROOT)/build/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_iar.mk
|
||||
else
|
||||
include $(SOURCE_ROOT)/build/aos_toolchain_gcc.mk
|
||||
endif
|
||||
|
||||
OLD_MAKECMDGOALS := $(MAKECMDGOALS)
|
||||
OLD_CURDIR := $(CURDIR)
|
||||
|
||||
ifeq ($(TARGET_ARCH), $(filter $(TARGET_ARCH), Cortex-M4 Cortex-M3 Cortex-M4F))
|
||||
ifeq ($(TARGET_BOARD), b_l475e)
|
||||
HOST_ARCH := $(TARGET_ARCH)
|
||||
endif
|
||||
else
|
||||
HOST_ARCH := $(BOARD_ARCH)
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(TARGET_ARCH), $(HOST_ARCH))
|
||||
LIB_NAME := $(word $(words $(subst /, , $(LIB_DIR))), $(subst /, , $(LIB_DIR)))
|
||||
|
||||
ifneq ($(notdir $(LIB_DIR)), )
|
||||
LIB_OUT_DIR := $(LIB_DIR)/
|
||||
else
|
||||
LIB_OUT_DIR := $(LIB_DIR)
|
||||
endif
|
||||
|
||||
ALWAYS_OPTIMISE := 1
|
||||
|
||||
BYPASS_LIBRARY_POISON_CHECK=1
|
||||
|
||||
ONLY_BUILD_LIBRARY := yes
|
||||
|
||||
POSSIBLE_APP_NAME := $(LIB_NAME)app
|
||||
APP := $(strip $(filter $(POSSIBLE_APP_NAME), $(foreach app, $(SOURCE_ROOT)/example, $(notdir $(wildcard $(app)/*)))))
|
||||
|
||||
ifeq ($(APP),)
|
||||
ifeq ($(TARGET_BOARD), b_l475e)
|
||||
APP := mqttapp
|
||||
else
|
||||
APP := alinkapp
|
||||
endif
|
||||
endif
|
||||
|
||||
MAKECMDGOALS += $(APP)@$(TARGET_BOARD)
|
||||
|
||||
include $(LIB_OUT_DIR)$(LIB_NAME).mk
|
||||
TARGET_CFLAGS := $(addprefix -I$(LIB_OUT_DIR),$(GLOBAL_INCLUDES)) $(addprefix -D,$(GLOBAL_DEFINES)) $(addprefix -I$(LIB_OUT_DIR),$($(NAME)_INCLUDES)) $(addprefix -D,$($(NAME)_DEFINES)) $($(NAME)_CFLAGS)
|
||||
|
||||
SOURCES := $(addprefix $(LIB_OUT_DIR),$($(NAME)_SOURCES))
|
||||
|
||||
CFLAGS :=
|
||||
AOS_SDK_CFLAGS :=
|
||||
AOS_SDK_INCLUDES :=
|
||||
AOS_SDK_DEFINES :=
|
||||
|
||||
include $(SOURCE_ROOT)/build/aos_target_config.mk
|
||||
|
||||
CFLAGS += -c -MD -ggdb -Os $(strip $(AOS_SDK_CFLAGS)) $($(LIB_NAME)_CFLAGS_ALL)
|
||||
CFLAGS += -Wall -fsigned-char -ffunction-sections -fdata-sections -fno-common -std=gnu11
|
||||
CFLAGS += $(strip $(AOS_SDK_INCLUDES)) $(strip $(addprefix -D,$(AOS_SDK_DEFINES)))
|
||||
|
||||
MAKECMDGOALS := $(OLD_MAKECMDGOALS)
|
||||
CURDIR := $(OLD_CURDIR)
|
||||
CFLAGS += $(TARGET_CFLAGS)
|
||||
NAME := $(LIB_NAME)
|
||||
|
||||
include $(SOURCE_ROOT)/build/aos_library_build.mk
|
||||
|
||||
else
|
||||
|
||||
.PHONY : all
|
||||
all :
|
||||
|
||||
endif
|
||||
19
Living_SDK/build/aos_library_makefile.mk
Normal file
19
Living_SDK/build/aos_library_makefile.mk
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export SOURCE_ROOT ?= ./
|
||||
|
||||
include $(SOURCE_ROOT)/build/aos_host_cmd.mk
|
||||
|
||||
define TRY_TO_BUILD_LIBRARY
|
||||
.PHONY : $(1)
|
||||
all : $(1)
|
||||
$(1):
|
||||
$(QUIET)$(eval board := $(1))
|
||||
$(QUIET)$(eval include $(SOURCE_ROOT)/board/$(board)/$(board).mk)
|
||||
$(QUIET)$(MAKE) -r $(SILENT) -f $(SOURCE_ROOT)/build/aos_library_config.mk TARGET_BOARD=$(board) BOARD_ARCH=$(HOST_ARCH)
|
||||
endef
|
||||
|
||||
POSSIBLE_BOARD_LIST := $(notdir $(wildcard $(SOURCE_ROOT)/board/*))
|
||||
|
||||
$(foreach b, $(POSSIBLE_BOARD_LIST), \
|
||||
$(if $(wildcard $(SOURCE_ROOT)/board/$(b)/$(b).mk), \
|
||||
$(eval $(call TRY_TO_BUILD_LIBRARY, $(b)))))
|
||||
|
||||
18
Living_SDK/build/aos_partition.mk
Normal file
18
Living_SDK/build/aos_partition.mk
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Add AOS image download script define
|
||||
BOOTLOADER_FIRMWARE_PARTITION_TCL := 1
|
||||
APPLICATION_FIRMWARE_PARTITION_TCL := 2
|
||||
ATE_FIRMWARE_PARTITION_TCL := 3
|
||||
WIFI_FIRMWARE_PARTITION_TCL := 4
|
||||
PARAMETER_1_IMAGE_PARTITION_TCL := 5
|
||||
PARAMETER_2_IMAGE_PARTITION_TCL := 6
|
||||
BT_PATCH_FIRMWARE_PARTITION_TCL := 7
|
||||
FILESYSTEM_IMAGE_PARTITION_TCL := 8
|
||||
|
||||
GLOBAL_DEFINES += BOOTLOADER_FIRMWARE_PARTITION_TCL=$(BOOTLOADER_FIRMWARE_PARTITION_TCL) \
|
||||
APPLICATION_FIRMWARE_PARTITION_TCL=$(APPLICATION_FIRMWARE_PARTITION_TCL) \
|
||||
ATE_FIRMWARE_PARTITION_TCL=$(ATE_FIRMWARE_PARTITION_TCL) \
|
||||
WIFI_FIRMWARE_PARTITION_TCL=$(WIFI_FIRMWARE_PARTITION_TCL) \
|
||||
PARAMETER_1_IMAGE_PARTITION_TCL=$(PARAMETER_1_IMAGE_PARTITION_TCL) \
|
||||
PARAMETER_2_IMAGE_PARTITION_TCL=$(PARAMETER_2_IMAGE_PARTITION_TCL) \
|
||||
BT_PATCH_FIRMWARE_PARTITION_TCL=$(BT_PATCH_FIRMWARE_PARTITION_TCL) \
|
||||
FILESYSTEM_IMAGE_PARTITION_TCL=$(FILESYSTEM_IMAGE_PARTITION_TCL)
|
||||
135
Living_SDK/build/aos_resources.mk
Normal file
135
Living_SDK/build/aos_resources.mk
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
# filters for resources
|
||||
TEXT_FILTERS := %.html %.htm %.txt %.eml %.js %.css %.dat %.cer %.pem %.json %.xml %.py %.key
|
||||
BINARY_FILTERS := %.jpg %.jpeg %.png %.ico %.gif %.bin %.flac
|
||||
|
||||
STAGING_DIR ?= $(OUTPUT_DIR)/resources/Staging/
|
||||
FS_IMAGE ?= $(OUTPUT_DIR)/resources/filesystem.bin
|
||||
|
||||
|
||||
###############################################################################
|
||||
# MACRO: RESOURCE_FILENAME
|
||||
# Makes an output path C file for a resource file, converting dots to underscores
|
||||
# $(1) is resource filename in the resource directory
|
||||
RESOURCE_FILENAME =$(addprefix $(OUTPUT_DIR)/resources/,$(addsuffix .c,$(subst .,_,$(notdir $(1)))))
|
||||
|
||||
###############################################################################
|
||||
# MACRO: RESOURCE_VARIABLE_NAME
|
||||
# Creates a variable name that will be used for a resource from it's filename
|
||||
# slashes are converted to _DIR_ and dots to underscores
|
||||
# $(1) is resource filename in the resource directory
|
||||
RESOURCE_VARIABLE_NAME =$(if $(findstring firmware,$(1)),wifi_firmware_image,$(addprefix resources_,$(subst /,_DIR_,$(subst .,_,$(subst $(SOURCE_ROOT)resources/,,$(1))))))
|
||||
|
||||
BIN_TO_RES_SCRIPT := $(TOOLS_ROOT)/text_to_c/bin_to_resource_c.pl
|
||||
TEXT_TO_RES_SCRIPT := $(TOOLS_ROOT)/text_to_c/text_to_resource_c.pl
|
||||
###############################################################################
|
||||
# MACRO: BUILD_RESOURCE_RULES
|
||||
# Creates targets to build a resource file
|
||||
# the first target converts the text resource file to a C file
|
||||
# the second target compiles the C resource file into an object file
|
||||
# $(1) is the name of a resource
|
||||
# $(2) should be MEM or FILESYSTEM - indication location of resource
|
||||
define BUILD_RESOURCE_RULES
|
||||
$(call RESOURCE_FILENAME, $(1)): $(1) $(STAGING_DIR).d | $(EXTRA_PRE_BUILD_TARGETS) $(TEXT_TO_RES_SCRIPT) $(BIN_TO_RES_SCRIPT)
|
||||
$$(if $(RESOURCES_START_PRINT),,$(eval RESOURCES_START_PRINT:=1) $(QUIET)$(ECHO) Processing resources)
|
||||
$$(if $(filter $(TEXT_FILTERS),$(1)),$(QUIET)$(PERL) $(TEXT_TO_RES_SCRIPT) $(2) $(call RESOURCE_VARIABLE_NAME, $(1)) $(1) > $$@)
|
||||
$$(if $(filter $(BINARY_FILTERS),$(1)),$(QUIET)$(PERL) $(BIN_TO_RES_SCRIPT) $(2) $(call RESOURCE_VARIABLE_NAME,$(1)) $(1) > $$@)
|
||||
$(QUIET)$(CP) $(1) $(STAGING_DIR)$(notdir $(1))
|
||||
|
||||
|
||||
$(patsubst %.c,%.o,$(call RESOURCE_FILENAME, $(1))): $(call RESOURCE_FILENAME, $(1))
|
||||
ifeq (IAR,$(TOOLCHAIN_NAME))
|
||||
$(QUIET)$(CC) $(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_SPECIFIC_DEPS_FLAG) $(RESOURCE_CFLAGS) $(call ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS, ) $($(1)_CFLAGS) -I$(SOURCE_ROOT)include/ -I$(SOURCE_ROOT)AOS/WWD/include -o $$@ $$< >> $$(IAR_BUILD_RESULTS_FILE)
|
||||
else
|
||||
$(QUIET)$(CC) $(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_SPECIFIC_DEPS_FLAG) $(RESOURCE_CFLAGS) $(call ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS, ) $($(1)_CFLAGS) -I$(SOURCE_ROOT)include/ -I$(SOURCE_ROOT)AOS/WWD/include -o $$@ $$<
|
||||
endif
|
||||
|
||||
$(eval RESOURCE_OBJS += $(patsubst %.c,%.o,$(call RESOURCE_FILENAME, $(1))))
|
||||
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: CREATE_ALL_RESOURCE_TARGETS
|
||||
# Create build targets which convert resources from binary to C files and build
|
||||
# the C files
|
||||
# Also creates a target for the overall resources variables header file
|
||||
# $(1) is a list of resources
|
||||
define CREATE_ALL_RESOURCE_TARGETS
|
||||
|
||||
$(foreach RESOURCE,$(1),$(eval $(call BUILD_RESOURCE_RULES,$(RESOURCE),$(if $(filter $(1),$(INTERNAL_MEMORY_RESOURCES)),MEM,FILESYSTEM))))
|
||||
|
||||
$(STAGING_DIR).d:
|
||||
$(QUIET)$$(call MKDIR, $$(dir $$@))
|
||||
$(QUIET)$(TOUCH) $$(@)
|
||||
|
||||
# Target for build-from-source
|
||||
# The repeated lines avoid line-too-long errors in windows
|
||||
$(OUTPUT_DIR)/libraries/resources.a: $$(RESOURCE_OBJS)
|
||||
$(QUIET)$(RM) $$@
|
||||
$$(if $$(wordlist 1,50, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_CREATE) $$@ $$(wordlist 1,50, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 51,100, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 51,100, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 101,150, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 101,150, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 151,200, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 151,200, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 201,250, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 201,250, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 251,300, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 251,300, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 301,350, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 301,350, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 351,400, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 351,400, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 401,450, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 401,450, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 451,500, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 451,500, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 501,550, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 501,550, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 551,600, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 551,600, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 601,650, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 601,650, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 651,700, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 651,700, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 701,750, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 701,750, $$(RESOURCE_OBJS)))
|
||||
$$(if $$(wordlist 751,1000, $$(RESOURCE_OBJS)),$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_ADD) $$@ $$(wordlist 751,1000, $$(RESOURCE_OBJS)))
|
||||
|
||||
|
||||
RESOURCE_HEADER_TARGET_CREATED := 1
|
||||
|
||||
$(eval RESOURCE_C_FILES += $(call RESOURCE_FILENAME, $(1)))
|
||||
|
||||
$(OUTPUT_DIR)/resources/resources.h: $$(RESOURCE_C_FILES)
|
||||
|
||||
endef
|
||||
|
||||
|
||||
# resources header target - creates a header file of all the resource variables.
|
||||
$(OUTPUT_DIR)/resources/resources.h: $(CONFIG_FILE)
|
||||
$(QUIET)$(ECHO) $(QUOTES_FOR_ECHO)/* Automatically generated file - this comment ensures resources.h file creation */$(QUOTES_FOR_ECHO) > $@
|
||||
$(if $(RESOURCE_C_FILES), $(QUIET)$(PERL) $(TOOLS_ROOT)/text_to_c/resources_header.pl $(RESOURCE_C_FILES) >> $@)
|
||||
|
||||
|
||||
RESOURCES_DEPENDENCY = $(OUTPUT_DIR)/resources/resources.h $(if $(RESOURCE_HEADER_TARGET_CREATED), $(OUTPUT_DIR)/libraries/resources.a, )
|
||||
RESOURCES_LIBRARY = $(if $(RESOURCE_HEADER_TARGET_CREATED),$(OUTPUT_DIR)/libraries/resources.a)
|
||||
|
||||
# Expand the list of resources to point to the full location (either component local or the common resources directory)
|
||||
# $(1) is the resource name, $(2) is the current directory
|
||||
RESOURCE_EXPAND_DIRECTORY = $(foreach res,$($(1)_RESOURCES),$(word 1,$(wildcard $(addsuffix $(res),$(2) $(SOURCE_ROOT)resources/))))
|
||||
RESOURCE_EXPAND_DIRECTORY = $$($(1)_RESOURCES)
|
||||
|
||||
|
||||
ifneq ($(filter SFLASH_FILESYSTEM,$(RESOURCES_LOCATION)),)
|
||||
|
||||
RESOURCE_DOWNLOADER_TARGET := $(if $(findstring sflash_write,$(APP)),,external_resource_downloader)
|
||||
RESOURCE_DOWNLOAD = download_all_resources
|
||||
|
||||
download_all_resources: $(RESOURCES_DEPENDENCY) $(RESOURCE_DOWNLOADER_TARGET)
|
||||
$(OPENOCD_FULL_NAME) -f $(OPENOCD_PATH)$(JTAG).cfg -f $(OPENOCD_PATH)$(HOST_OPENOCD).cfg -f $($(SOURCE_ROOT)apps/waf/sflash_write/sflash_write.tcl -c "sflash_write_file $(FS_IMAGE) 0x0 $(PLATFORM)-$(BUS) 1 0" -c shutdown
|
||||
|
||||
$(FS_IMAGE): $(RESOURCES_DEPENDENCY)
|
||||
$(COMMON_TOOLS_PATH)mk_aosfs32 $(FS_IMAGE) $(STAGING_DIR)
|
||||
|
||||
|
||||
|
||||
SFLASH_WRITE_TARGET := waf.sflash_write-NoOS-$(PLATFORM)-$(BUS)
|
||||
SFLASH_WRITE_LOG_FILE ?= out/sflash_write.log
|
||||
SFLASH_WRITE_OUTFILE := $(BUILD_DIR)/$(SFLASH_WRITE_TARGET)/binary/$(SFLASH_WRITE_TARGET)
|
||||
ifneq ($(VERBOSE),1)
|
||||
SFLASH_WRITE_REDIRECT = > $(SFLASH_WRITE_LOG_FILE)
|
||||
endif
|
||||
|
||||
external_resource_downloader:
|
||||
$(QUIET)$(ECHO) Building serial flash downloader
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
$(QUIET)$(MAKE) -r $(SILENT) -f $(SOURCE_ROOT)Makefile $(SFLASH_WRITE_TARGET) NO_BUILD_BOOTLOADER=1 -I$(OUTPUT_DIR) SFLASH= $(SFLASH_WRITE_REDIRECT)
|
||||
|
||||
endif
|
||||
142
Living_SDK/build/aos_standard_targets.mk
Normal file
142
Living_SDK/build/aos_standard_targets.mk
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
.PHONY: bootloader download_bootloader total download_dct download kill_openocd
|
||||
|
||||
EXTRA_PRE_BUILD_TARGETS += bootloader
|
||||
EXTRA_POST_BUILD_TARGETS += copy_output_for_eclipse
|
||||
|
||||
ifeq (download,$(findstring download,$(MAKECMDGOALS)))
|
||||
EXTRA_POST_BUILD_TARGETS += sflash_write_app
|
||||
OPENOCD_LOG_FILE ?= $(BUILD_DIR)/openocd_log.txt
|
||||
DOWNLOAD_LOG := >> $(OPENOCD_LOG_FILE)
|
||||
endif
|
||||
|
||||
#SFLASH_WRITER_APP Required by download_apps
|
||||
SFLASH_APP_PLATFROM_BUS := $(PLATFORM)
|
||||
|
||||
BOOTLOADER_TARGET := bootloader@$(PLATFORM)@release
|
||||
BOOTLOADER_OUTFILE := $(BUILD_DIR)/$(BOOTLOADER_TARGET)/binary/$(BOOTLOADER_TARGET)
|
||||
BOOTLOADER_OUTFILE_BIN := $(BUILD_DIR)/$(BOOTLOADER_TARGET)/binary/$(BOOTLOADER_TARGET).bin
|
||||
BOOTLOADER_LOG_FILE ?= $(BUILD_DIR)/bootloader.log
|
||||
|
||||
ifeq (,$(and $(OPENOCD_PATH),$(OPENOCD_FULL_NAME)))
|
||||
$(error Path to OpenOCD has not been set using OPENOCD_PATH and OPENOCD_FULL_NAME)
|
||||
endif
|
||||
|
||||
ifneq ($(VERBOSE),1)
|
||||
BOOTLOADER_REDIRECT = > $(BOOTLOADER_LOG_FILE)
|
||||
endif
|
||||
|
||||
# Build bootloader itself
|
||||
ifneq (,$(findstring bootloader, $(BUILD_STRING)))
|
||||
BOOTLOADER_APP:=1
|
||||
BUILD_BOOTLOADER:=0
|
||||
else
|
||||
# Target "total" not exist, no need to build bootloader
|
||||
ifneq (total,$(findstring total,$(MAKECMDGOALS)))
|
||||
BOOTLOADER_APP:=0
|
||||
BOOTLOADER_SUB_BUILD:=0
|
||||
else
|
||||
BOOTLOADER_APP:=0
|
||||
BOOTLOADER_SUB_BUILD:=1
|
||||
endif #$(total,$(findstring total,$(MAKECMDGOALS)))
|
||||
endif #$(findstring bootloader, $(BUILD_STRING))
|
||||
|
||||
ifeq ($(BOOTLOADER_SUB_BUILD),1)
|
||||
bootloader:
|
||||
$(QUIET)$(ECHO) Building Bootloader...
|
||||
$(QUIET)$(MAKE) -r -f $(SOURCE_ROOT)build/Makefile $(BOOTLOADER_TARGET) -I$(OUTPUT_DIR) SFLASH= EXTERNAL_AOS_GLOBAL_DEFINES=$(EXTERNAL_AOS_GLOBAL_DEFINES) SUB_BUILD=bootloader $(BOOTLOADER_REDIRECT)
|
||||
$(QUIET)$(ECHO) Finished Building Bootloader
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
|
||||
download_bootloader: bootloader display_map_summary sflash_write_app
|
||||
$(eval BOOTLOADER_IMAGE_SIZE := $(shell $(PYTHON) $(IMAGE_SIZE_SCRIPT) $(BOOTLOADER_OUTFILE_BIN)))
|
||||
$(QUIET)$(ECHO) Downloading bootloader to partition: $(BOOTLOADER_FIRMWARE_PARTITION_TCL) size: $(BOOTLOADER_IMAGE_SIZE) bytes...
|
||||
$(call CONV_SLASHES, $(OPENOCD_FULL_NAME)) -s $(SOURCE_ROOT) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -c init -c soft_reset_halt -c flash_init -c "flash_erase 0x00000 0x10000" -c "load_image $(BUILD_DIR)/eclipse_debug/last_bootloader.elf 0" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) Download failed
|
||||
|
||||
#$(QUIET)$(call CONV_SLASHES,$(OPENOCD_FULL_NAME)) -f $(OPENOCD_PATH)$(JTAG).cfg -f $(OPENOCD_PATH)$(HOST_OPENOCD).cfg -f $(OPENOCD_PATH)$(HOST_OPENOCD)-flash-app.cfg -c "verify_image_checksum $(BOOTLOADER_OUTFILE).stripped.elf" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) No changes detected && $(ECHO_BLANK_LINE) || $(call CONV_SLASHES,$(OPENOCD_FULL_NAME)) -f $(OPENOCD_PATH)$(JTAG).cfg -f $(OPENOCD_PATH)$(HOST_OPENOCD).cfg -f $(OPENOCD_PATH)$(HOST_OPENOCD)-flash-app.cfg -c "flash write_image erase $(BOOTLOADER_OUTFILE).hex" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) "**** OpenOCD failed - ensure you have installed the driver from the drivers directory, and that the debugger is not running **** In Linux this may be due to USB access permissions. In a virtual machine it may be due to USB passthrough settings. Check in the task list that another OpenOCD process is not running. Check that you have the correct target and JTAG device plugged in. ****"
|
||||
|
||||
copy_bootloader_output_for_eclipse: build_done
|
||||
$(QUIET)$(call MKDIR, $(BUILD_DIR)/eclipse_debug/)
|
||||
$(QUIET)$(CP) $(BOOTLOADER_OUTFILE).elf $(BUILD_DIR)/eclipse_debug/last_bootloader.elf
|
||||
|
||||
|
||||
else
|
||||
ifeq (0,$(BOOTLOADER_APP))
|
||||
bootloader:
|
||||
$(QUIET)$(ECHO) Skipping building bootloader due to \"total\" is not set
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
|
||||
download_bootloader: display_map_summary sflash_write_app
|
||||
$(QUIET)$(ECHO) Downloading Bootloader ...
|
||||
$(QUIET)$(ECHO) Skipping download bootloader due to \"total\" is not set
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
|
||||
else
|
||||
bootloader:
|
||||
@:
|
||||
|
||||
download_bootloader:
|
||||
@:
|
||||
endif
|
||||
|
||||
#copy_bootloader_output_for_eclipse: build_done
|
||||
# $(QUIET)$(call MKDIR, $(BUILD_DIR)/eclipse_debug/)
|
||||
# $(QUIET)$(CP) $(LINK_OUTPUT_FILE).elf $(BUILD_DIR)/eclipse_debug/last_bootloader.elf
|
||||
|
||||
copy_bootloader_output_for_eclipse:
|
||||
@:
|
||||
endif
|
||||
|
||||
total:
|
||||
@:
|
||||
|
||||
ifeq ($(BOOTLOADER_APP),1)
|
||||
download_app: $(STRIPPED_LINK_OUTPUT_FILE) display_map_summary sflash_write_app kill_openocd
|
||||
$(eval IMAGE_SIZE := $(shell $(PYTHON) $(IMAGE_SIZE_SCRIPT) $(BIN_OUTPUT_FILE)))
|
||||
$(call CONV_SLASHES, $(OPENOCD_FULL_NAME)) -s $(SOURCE_ROOT) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -c init -c soft_reset_halt -c flash_init -c "flash_erase 0x00000 0x10000" -c "load_image $(BUILD_DIR)/eclipse_debug/last_bootloader.elf 0" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) Download failed. See $(OPENOCD_LOG_FILE) for detail.
|
||||
else
|
||||
|
||||
ifeq ($(PLATFORM),mk108)
|
||||
APP_SIZE := 0xDE000
|
||||
else
|
||||
APP_SIZE := 0x8E000
|
||||
endif
|
||||
|
||||
download_app: $(STRIPPED_LINK_OUTPUT_FILE) display_map_summary download_bootloader sflash_write_app kill_openocd
|
||||
$(eval IMAGE_SIZE := $(shell $(PYTHON) $(IMAGE_SIZE_SCRIPT) $(BIN_OUTPUT_FILE)))
|
||||
$(QUIET)$(ECHO) Downloading application to partition: $(APPLICATION_FIRMWARE_PARTITION_TCL) size: $(IMAGE_SIZE) bytes...
|
||||
$(call CONV_SLASHES, $(OPENOCD_FULL_NAME)) -s $(SOURCE_ROOT) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -c init -c flash_boot_check -c "flash_program $(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.ota$(BIN_OUTPUT_SUFFIX)) $(BINS_DOWNLOAD_ADDR)" -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Download complete && $(ECHO_BLANK_LINE) || $(ECHO) Download failed. See $(OPENOCD_LOG_FILE) for detail.
|
||||
|
||||
endif
|
||||
|
||||
ifeq (download,$(filter download,$(MAKECMDGOALS)))
|
||||
EXT_IMAGES_DOWNLOAD_DEP := download_app
|
||||
endif
|
||||
|
||||
download: download_app $(if $(findstring total,$(MAKECMDGOALS)), EXT_IMAGE_DOWNLOAD,)
|
||||
|
||||
kill_openocd:
|
||||
$(info kill_openocd)
|
||||
|
||||
run: $(SHOULD_I_WAIT_FOR_DOWNLOAD)
|
||||
$(QUIET)$(ECHO) Resetting target
|
||||
$(QUIET)$(call CONV_SLASHES,$(OPENOCD_FULL_NAME)) -c "log_output $(OPENOCD_LOG_FILE)" -s $(SOURCE_ROOT) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -c init -c soft_reset_halt -c resume -c shutdown $(DOWNLOAD_LOG) 2>&1 && $(ECHO) Target running
|
||||
|
||||
ifeq ($(BOOTLOADER_APP),1)
|
||||
copy_output_for_eclipse: build_done
|
||||
$(QUIET)$(call MKDIR, $(BUILD_DIR)/eclipse_debug/)
|
||||
#$(QUIET)$(CP) $(LINK_OUTPUT_FILE) $(BUILD_DIR)/eclipse_debug/last_bootloader.elf
|
||||
else
|
||||
copy_output_for_eclipse: build_done copy_bootloader_output_for_eclipse
|
||||
$(QUIET)$(call MKDIR, $(BUILD_DIR)/eclipse_debug/)
|
||||
ifeq (,$(BINS))
|
||||
$(QUIET)$(CP) $(LINK_OUTPUT_FILE) $(BUILD_DIR)/eclipse_debug/last_built.elf
|
||||
else
|
||||
$(QUIET)$(CP) $(LINK_OUTPUT_FILE) $(BUILD_DIR)/eclipse_debug/$(BINSTYPE_LOWER)_built.elf
|
||||
endif
|
||||
endif
|
||||
|
||||
debug: $(BUILD_STRING) $(SHOULD_I_WAIT_FOR_DOWNLOAD)
|
||||
$(QUIET)$(GDB_COMMAND) $(LINK_OUTPUT_FILE) -x .gdbinit_attach
|
||||
|
||||
|
||||
|
||||
420
Living_SDK/build/aos_target_build.mk
Normal file
420
Living_SDK/build/aos_target_build.mk
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
include $(MAKEFILES_PATH)/aos_host_cmd.mk
|
||||
|
||||
CONFIG_FILE := $(OUTPUT_DIR)/config.mk
|
||||
|
||||
include $(CONFIG_FILE)
|
||||
|
||||
# Include all toolchain makefiles - one of them will handle the architecture
|
||||
# default gcc
|
||||
ifeq ($(COMPILER),)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
else ifeq ($(COMPILER),gcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
else ifeq ($(COMPILER),armcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_iar.mk
|
||||
endif
|
||||
|
||||
.PHONY: display_map_summary build_done
|
||||
|
||||
##################################
|
||||
# Filenames
|
||||
##################################
|
||||
|
||||
LINK_OUTPUT_FILE :=$(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING)$(RADIXPOINT)$(BINSTYPE_LOWER)$(LINK_OUTPUT_SUFFIX)
|
||||
# out/helloworld@xx/binary/helloworld@xx.elf
|
||||
STRIPPED_LINK_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.stripped$(LINK_OUTPUT_SUFFIX))
|
||||
# out/helloworld@xx/binary/helloworld@xx.stripped.elf
|
||||
BIN_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=$(BIN_OUTPUT_SUFFIX))
|
||||
# out/helloworld@xx/binary/helloworld@xx.bin
|
||||
HEX_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=$(HEX_OUTPUT_SUFFIX))
|
||||
# out/helloworld@xx/binary/helloworld@xx.bin
|
||||
MAP_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.map)
|
||||
# out/helloworld@xx/binary/helloworld@xx.map
|
||||
MAP_CSV_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=_map.csv)
|
||||
# out/helloworld@xx/binary/helloworld@xx_map.csv
|
||||
BIN_OUTPUT_FILE_TMP :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.tmp.bin)
|
||||
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
LINK_OUTPUT_FILE_XIP2 :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.xip2$(LINK_OUTPUT_SUFFIX))
|
||||
STRIPPED_LINK_OUTPUT_FILE_XIP2 :=$(LINK_OUTPUT_FILE_XIP2:$(LINK_OUTPUT_SUFFIX)=.stripped$(LINK_OUTPUT_SUFFIX))
|
||||
$(info $(LINK_OUTPUT_FILE_XIP2))
|
||||
$(info $(STRIPPED_LINK_OUTPUT_FILE_XIP2))
|
||||
BIN_OUTPUT_FILE_XIP2 :=$(LINK_OUTPUT_FILE_XIP2:$(LINK_OUTPUT_SUFFIX)=$(BIN_OUTPUT_SUFFIX))
|
||||
HEX_OUTPUT_FILE_XIP2 :=$(LINK_OUTPUT_FILE_XIP2:$(LINK_OUTPUT_SUFFIX)=$(HEX_OUTPUT_SUFFIX))
|
||||
MAP_OUTPUT_FILE_XIP2 :=$(LINK_OUTPUT_FILE_XIP2:$(LINK_OUTPUT_SUFFIX)=.map)
|
||||
MAP_CSV_OUTPUT_FILE_XIP2 :=$(LINK_OUTPUT_FILE_XIP2:$(LINK_OUTPUT_SUFFIX)=_map.csv)
|
||||
endif
|
||||
|
||||
OPENOCD_LOG_FILE ?= $(OUTPUT_DIR)/openocd_log.txt
|
||||
|
||||
LIBS_DIR := $(OUTPUT_DIR)/libraries
|
||||
LINK_OPTS_FILE := $(OUTPUT_DIR)/binary/link$(UNDERLINE)$(BINSTYPE_LOWER).opts
|
||||
|
||||
LINT_OPTS_FILE := $(OUTPUT_DIR)/binary/lint$(UNDERLINE)$(BINSTYPE_LOWER).opts
|
||||
|
||||
LDS_FILE_DIR := $(OUTPUT_DIR)/ld
|
||||
|
||||
ifeq (,$(SUB_BUILD))
|
||||
ifneq (,$(EXTRA_TARGET_MAKEFILES))
|
||||
$(foreach makefile_name,$(EXTRA_TARGET_MAKEFILES),$(eval include $(makefile_name)))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(BINS))
|
||||
CREATE_SYSCALLFILE :=$(MAKEFILES_PATH)/scripts/gen_syscalls.py
|
||||
PARSE_RESOURSE_TO_SYSCALL_FILE = $(PYTHON) $(CREATE_SYSCALLFILE) $(1) $(2)
|
||||
PROCESS_PRECOMPILED_FILES := $(OUTPUT_DIR)/precompile/mark.i
|
||||
endif
|
||||
|
||||
include $(MAKEFILES_PATH)/aos_resources.mk
|
||||
include $(MAKEFILES_PATH)/aos_images_download.mk
|
||||
|
||||
##################################
|
||||
# Macros
|
||||
##################################
|
||||
|
||||
###############################################################################
|
||||
# MACRO: GET_BARE_LOCATION
|
||||
# Returns a the location of the given component relative to source-tree-root
|
||||
# rather than from the cwd
|
||||
# $(1) is component
|
||||
GET_BARE_LOCATION =$(patsubst $(call ESCAPE_BACKSLASHES,$(SOURCE_ROOT))%,%,$(strip $(subst :,/,$($(1)_LOCATION))))
|
||||
|
||||
define SELF_BUILD_RULE
|
||||
$(LIBS_DIR)/$(notdir $($(1)_SELF_BUIlD_COMP_targets)): $(OUTPUT_DIR)/config.mk
|
||||
echo CONFIG_ENV_CFLAGS += $(RESOURCE_CFLAGS) > $($(1)_LOCATION)iotx-sdk-c_clone/aos_board_conf.mk
|
||||
echo CROSS_PREFIX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)>> $($(1)_LOCATION)iotx-sdk-c_clone/aos_board_conf.mk
|
||||
sh $($(1)_LOCATION)$($(1)_SELF_BUIlD_COMP_scripts) $(LIBS_DIR) $(SOURCE_ROOT)example/$(APP_FULL) $(HOST_OS)
|
||||
endef
|
||||
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_C_RULE
|
||||
# Creates a target for building C language files (*.c)
|
||||
# $(1) is component, $(2) is the source file
|
||||
define BUILD_C_RULE
|
||||
ifeq ($(COMPILER),)
|
||||
-include $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2:.c=.d)
|
||||
endif
|
||||
$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2:.c=.o): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2)).d $(RESOURCES_DEPENDENCY) $(LIBS_DIR)/$(1).c_opts $(PROCESS_PRECOMPILED_FILES) | $(EXTRA_PRE_BUILD_TARGETS)
|
||||
$$(if $($(1)_START_PRINT),,$(eval $(1)_START_PRINT:=1) $(QUIET)$(ECHO) Compiling $(1) )
|
||||
$(QUIET)$(CC) $($(1)_C_OPTS) -D__FILENAME__='"$$(notdir $$<)"' $(call COMPILER_SPECIFIC_DEPS_FILE,$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2:.c=.d)) -o $$@ $$< $(COMPILER_SPECIFIC_STDOUT_REDIRECT)
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: CHECK_HEADER_RULE
|
||||
# Compiles a C language header file to ensure it is stand alone complete
|
||||
# $(1) is component, $(2) is the source header file
|
||||
define CHECK_HEADER_RULE
|
||||
$(eval $(1)_CHECK_HEADER_LIST+=$(OUTPUT_DIR)/modules/$(strip $($(1)_LOCATION))$(2:.h=.chk) )
|
||||
.PHONY: $(OUTPUT_DIR)/modules/$(strip $($(1)_LOCATION))$(2:.h=.chk)
|
||||
$(OUTPUT_DIR)/modules/$(strip $($(1)_LOCATION))$(2:.h=.chk): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2)).d
|
||||
$(QUIET)$(ECHO) Checking header $(2)
|
||||
$(QUIET)$(CC) -c $(AOS_SDK_CFLAGS) $(filter-out -pedantic -Werror, $($(1)_CFLAGS) $(C_BUILD_OPTIONS) ) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES) -o $$@ $$<
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_CPP_RULE
|
||||
# Creates a target for building C++ language files (*.cpp)
|
||||
# $(1) is component name, $(2) is the source file
|
||||
define BUILD_CPP_RULE
|
||||
-include $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(patsubst %.cc,%.d,$(2:.cpp=.d))
|
||||
$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(patsubst %.cc,%.o,$(2:.cpp=.o)): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2)).d $(RESOURCES_DEPENDENCY) $(LIBS_DIR)/$(1).cpp_opts | $(EXTRA_PRE_BUILD_TARGETS)
|
||||
$$(if $($(1)_START_PRINT),,$(eval $(1)_START_PRINT:=1) $(ECHO) Compiling $(1))
|
||||
$(QUIET)$(CXX) $($(1)_CPP_OPTS) -o $$@ $$< $(COMPILER_SPECIFIC_STDOUT_REDIRECT)
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_S_RULE
|
||||
# Creates a target for building Assembly language files (*.s & *.S)
|
||||
# $(1) is component name, $(2) is the source file
|
||||
define BUILD_S_RULE
|
||||
$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S,%.o, $(2:.s=.o) )): $(strip $($(1)_LOCATION))$(2) $($(1)_PRE_BUILD_TARGETS) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S, %.o, $(2)))).d $(RESOURCES_DEPENDENCY) $(LIBS_DIR)/$(1).as_opts $(PROCESS_PRECOMPILED_FILES) | $(EXTRA_PRE_BUILD_TARGETS)
|
||||
$$(if $($(1)_START_PRINT),,$(eval $(1)_START_PRINT:=1) $(ECHO) Compiling $(1))
|
||||
$(QUIET)$(AS) $($(1)_S_OPTS) -o $$@ $$< $(COMPILER_SPECIFIC_STDOUT_REDIRECT)
|
||||
endef
|
||||
|
||||
IDE_IAR_FLAG :=
|
||||
IDE_KEIL_FLAG :=
|
||||
|
||||
ifeq ($(IDE),iar)
|
||||
IDE_IAR_FLAG := 1
|
||||
else ifeq ($(IDE),keil)
|
||||
IDE_KEIL_FLAG := 1
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_COMPONENT_RULES
|
||||
# Creates targets for building an entire component
|
||||
# Target for the component static library is created in this macro
|
||||
# Targets for source files are created by calling the macros defined above
|
||||
# $(1) is component name
|
||||
define BUILD_COMPONENT_RULES
|
||||
|
||||
$(eval LINK_LIBS +=$(if $($(1)_SOURCES),$(LIBS_DIR)/$(1).a))
|
||||
$(eval LINK_LIBS +=$(if $($(1)_SELF_BUIlD_COMP_targets),$(LIBS_DIR)/$(notdir $($(1)_SELF_BUIlD_COMP_targets) )))
|
||||
|
||||
ifneq ($($(1)_PRE_BUILD_TARGETS),)
|
||||
include $($(1)_MAKEFILE)
|
||||
endif
|
||||
|
||||
# Make a list of the object files that will be used to build the static library
|
||||
$(eval $(1)_LIB_OBJS := $(addprefix $(strip $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))), $(filter %.o, $($(1)_SOURCES:.cc=.o) $($(1)_SOURCES:.cpp=.o) $($(1)_SOURCES:.c=.o) $($(1)_SOURCES:.s=.o) $($(1)_SOURCES:.S=.o))) $(patsubst %.c,%.o,$(call RESOURCE_FILENAME, $($(1)_RESOURCES))))
|
||||
|
||||
|
||||
$(LIBS_DIR)/$(1).c_opts: $($(1)_PRE_BUILD_TARGETS) $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(eval $(1)_C_OPTS:=$(subst $(COMMA),$$(COMMA), $(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_SPECIFIC_DEPS_FLAG) $(COMPILER_UNI_CFLAGS) $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES)))
|
||||
$(eval C_OPTS_IAR := $(subst =\",="\",$($(1)_C_OPTS)) )
|
||||
$(eval C_OPTS_IAR := $(subst \" ,\"" ,$(C_OPTS_IAR) ) )
|
||||
$(eval C_OPTS_IAR := $(filter-out -I% --cpu=% --endian% --dlib_config%,$(C_OPTS_IAR)) )
|
||||
$(eval C_OPTS_KEIL := $(subst -I.,-I../../../../.,$($(1)_C_OPTS)) )
|
||||
$(eval C_OPTS_FILE := $($(1)_C_OPTS) )
|
||||
$(if $(IDE_IAR_FLAG),$(eval C_OPTS_FILE:=$(C_OPTS_IAR)),)
|
||||
$(if $(IDE_KEIL_FLAG),$(eval C_OPTS_FILE:=$(C_OPTS_KEIL)),)
|
||||
$$(file >$$@, $(C_OPTS_FILE) )
|
||||
|
||||
$(LIBS_DIR)/$(1).cpp_opts: $($(1)_PRE_BUILD_TARGETS) $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(eval $(1)_CPP_OPTS:=$(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_SPECIFIC_DEPS_FLAG) $($(1)_CXXFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES))
|
||||
$$(file >$$@, $($(1)_CPP_OPTS) )
|
||||
|
||||
$(LIBS_DIR)/$(1).as_opts: $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(eval $(1)_S_OPTS:=$(CPU_ASMFLAGS) $(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_UNI_SFLAGS) $($(1)_ASMFLAGS) $($(1)_INCLUDES) $(AOS_SDK_INCLUDES))
|
||||
$(eval S_OPTS_IAR := $(filter-out --cpu Cortex-M4, $($(1)_S_OPTS) ) )
|
||||
$(eval S_OPTS_FILE := $($(1)_S_OPTS) )
|
||||
$(if $(IDE_IAR_FLAG),$(eval S_OPTS_FILE:=$(S_OPTS_IAR)),)
|
||||
$$(file >$$@, $(S_OPTS_FILE) )
|
||||
|
||||
$(LIBS_DIR)/$(1).ar_opts: $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(QUIET)$$(call WRITE_FILE_CREATE, $$@ ,$($(1)_LIB_OBJS))
|
||||
|
||||
# Allow checking of completeness of headers
|
||||
$(foreach src, $(if $(findstring 1,$(CHECK_HEADERS)), $(filter %.h, $($(1)_CHECK_HEADERS)), ),$(eval $(call CHECK_HEADER_RULE,$(1),$(src))))
|
||||
|
||||
# Target for build-from-source
|
||||
#$(OUTPUT_DIR)/libraries/$(1).a: $$($(1)_LIB_OBJS) $($(1)_CHECK_HEADER_LIST) $(OUTPUT_DIR)/libraries/$(1).ar_opts $$(if $(AOS_BUILT_WITH_ROM_SYMBOLS),$(ROMOBJCOPY_OPTS_FILE))
|
||||
$(LIBS_DIR)/$(1).a: $$($(1)_LIB_OBJS) $($(1)_CHECK_HEADER_LIST) $(OUTPUT_DIR)/libraries/$(1).ar_opts
|
||||
$(ECHO) Making $$@
|
||||
$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_CREATE) $$@ $(OPTIONS_IN_FILE_OPTION_PREFIX)$(OPTIONS_IN_FILE_OPTION)$(OUTPUT_DIR)/libraries/$(1).ar_opts$(OPTIONS_IN_FILE_OPTION_SUFFIX)
|
||||
# Create targets to built the component's source files into object files
|
||||
$(if $($(1)_SELF_BUIlD_COMP_scripts), $(eval $(call SELF_BUILD_RULE,$(1))) )
|
||||
$(foreach src, $(filter %.c, $($(1)_SOURCES)),$(eval $(call BUILD_C_RULE,$(1),$(src))))
|
||||
$(foreach src, $(filter %.cpp, $($(1)_SOURCES)) $(filter %.cc, $($(1)_SOURCES)),$(eval $(call BUILD_CPP_RULE,$(1),$(src))))
|
||||
$(foreach src, $(filter %.s %.S, $($(1)_SOURCES)),$(eval $(call BUILD_S_RULE,$(1),$(src))))
|
||||
|
||||
|
||||
$(eval $(1)_LINT_FLAGS += $(filter -D% -I%, $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES) ) )
|
||||
$(eval LINT_FLAGS += $($(1)_LINT_FLAGS) )
|
||||
$(eval LINT_FILES += $(addprefix $(strip $($(1)_LOCATION)), $(filter %.c, $($(1)_SOURCES))) )
|
||||
endef
|
||||
|
||||
define PROCESS_C_FILE
|
||||
$(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(2:.c=.i): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(2)).i
|
||||
$(QUIET)$(CPP) -P $(subst $(COMMA),$$(COMMA), $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES)) -DAOS_EXPORTX -o $$@ $$<
|
||||
$(eval PRECOMPILED_FILES += $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(2:.c=.i))
|
||||
endef
|
||||
|
||||
define PROCESS_S_FILE
|
||||
$(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S,%.i, $(2:.s=.i))): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S, %.i, $(2:.s=.i)))).i
|
||||
$(QUIET)$(CPP) -P $(subst $(COMMA),$$(COMMA), $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES)) -DAOS_EXPORTX -o $$@ $$<
|
||||
$(eval PRECOMPILED_FILES += $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S,%.i, $(2:.s=.i))))
|
||||
endef
|
||||
|
||||
define PRECOMPILED_RESOURCE_FILE
|
||||
$(foreach src, $(filter %.c, $($(1)_SOURCES)),$(eval $(call PROCESS_C_FILE,$(1),$(src),$(2))))
|
||||
$(foreach src, $(filter %.s %.S, $($(1)_SOURCES)),$(eval $(call PROCESS_S_FILE,$(1),$(src),$(2))))
|
||||
endef
|
||||
|
||||
define PROCESS_LDS_FILE
|
||||
$(LDS_FILE_DIR)/$(notdir $(1:.ld.S=.ld)): $(LDS_FILE_DIR)
|
||||
$(ECHO) Making $$@
|
||||
$(QUIET)$(CPP) -P $(AOS_SDK_CFLAGS) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES) $(1) -o $$@
|
||||
|
||||
$(eval LDS_FILES += $(LDS_FILE_DIR)/$(notdir $(1:.ld.S=.ld)))
|
||||
endef
|
||||
|
||||
##################################
|
||||
# Processing
|
||||
##################################
|
||||
|
||||
# Create targets for resource files
|
||||
# $(info Resources: $(ALL_RESOURCES))
|
||||
$(eval $(if $(ALL_RESOURCES),$(call CREATE_ALL_RESOURCE_TARGETS,$(ALL_RESOURCES))))
|
||||
LINK_LIBS += $(RESOURCES_LIBRARY)
|
||||
|
||||
$(info Components: $(COMPONENTS))
|
||||
# Create targets for components
|
||||
ifeq (app, $(BINS))
|
||||
# precompile kernel/framework file
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel, $($(comp)_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),kernel))))
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter framework, $($(comp)_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),framework))))
|
||||
# Create targets for components
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $($(comp)_TYPE), $(if $(filter app app&framework app&kernel share, $($(comp)_TYPE)), $(call BUILD_COMPONENT_RULES,$(comp))), $(call BUILD_COMPONENT_RULES,$(comp)))))
|
||||
else ifeq (framework, $(BINS))
|
||||
# precompile kernel/framework file
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel, $($(comp)_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),kernel))))
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter framework, $($(comp)_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),framework))))
|
||||
# Create targets for components
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter framework app&framework framework&kernel share, $($(comp)_TYPE)), $(call BUILD_COMPONENT_RULES,$(comp)))))
|
||||
else ifeq (kernel, $(BINS))
|
||||
# precompile kernel file
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel, $($(comp)_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),kernel))))
|
||||
# Create targets for components
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel app&kernel framework&kernel share, $($(comp)_TYPE)), $(call BUILD_COMPONENT_RULES,$(comp)))))
|
||||
else ifeq (,$(BINS))
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(call BUILD_COMPONENT_RULES,$(comp))))
|
||||
endif
|
||||
|
||||
# handle lds file, lds -> ld
|
||||
$(foreach ldsfile,$(AOS_SDK_LDS_FILES),$(eval $(call PROCESS_LDS_FILE,$(ldsfile))))
|
||||
$(foreach ldsfile,$(AOS_SDK_LDS_INCLUDES),$(eval $(call PROCESS_LDS_FILE,$(ldsfile))))
|
||||
$(foreach ldsfile,$(AOS_SDK_LDS_FILES),$(eval AOS_SDK_LDFLAGS += -T $(notdir $(ldsfile:.ld.S=.ld))))
|
||||
$(if $(AOS_SDK_LDS_FILES),$(eval AOS_SDK_LDFLAGS += -L $(LDS_FILE_DIR)))
|
||||
|
||||
ifneq (,$(BINS))
|
||||
$(PROCESS_PRECOMPILED_FILES): $(PRECOMPILED_FILES)
|
||||
$(QUIET)$(TOUCH) $@
|
||||
$(QUIET)$(if $(PARSE_RESOURSE_TO_SYSCALL_FILE), $(call PARSE_RESOURSE_TO_SYSCALL_FILE, $(OUTPUT_DIR), create))
|
||||
endif
|
||||
|
||||
# Add pre-built libraries
|
||||
LINK_LIBS += $(AOS_SDK_PREBUILT_LIBRARIES)
|
||||
|
||||
##################################
|
||||
# Build rules
|
||||
##################################
|
||||
|
||||
$(LIBS_DIR):
|
||||
$(QUIET)$(call MKDIR, $@)
|
||||
|
||||
$(LDS_FILE_DIR):
|
||||
$(QUIET)$(call MKDIR, $@)
|
||||
|
||||
# Directory dependency - causes mkdir to be called once for each directory.
|
||||
%/.d:
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
$(QUIET)$(TOUCH) $(@)
|
||||
|
||||
%/.i:
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
|
||||
LINK_OPTS := $(AOS_SDK_LINK_SCRIPT_CMD) $(call COMPILER_SPECIFIC_LINK_MAP,$(MAP_OUTPUT_FILE)) $(call COMPILER_SPECIFIC_LINK_FILES, $(AOS_SDK_LINK_FILES) $(filter %.a,$^) $(LINK_LIBS)) $(AOS_SDK_LDFLAGS)
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
LINK_OPTS_XIP2 := $(AOS_SDK_LINK_SCRIPT_CMD) $(call COMPILER_SPECIFIC_LINK_MAP,$(MAP_OUTPUT_FILE_XIP2)) $(call COMPILER_SPECIFIC_LINK_FILES, $(AOS_SDK_LINK_FILES) $(filter %.a,$^) $(LINK_LIBS)) $(AOS_SDK_LDFLAGS)
|
||||
endif
|
||||
|
||||
# FIXME GCC Whole archive not ready in all platform
|
||||
$(LINK_OPTS_FILE): $(OUTPUT_DIR)/config.mk $(LDS_FILES)
|
||||
ifeq ($(COMPILER),armcc)
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $@ ,$(LINK_OPTS))
|
||||
else
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $@ ,$(LINK_OPTS) )
|
||||
endif
|
||||
|
||||
$(LINT_OPTS_FILE): $(LINK_LIBS)
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $@ , )
|
||||
$(QUIET)$(foreach opt,$(sort $(subst \",",$(LINT_FLAGS))) $(sort $(LINT_FILES)),$(call WRITE_FILE_APPEND, $@ ,$(opt)))
|
||||
|
||||
define LINK_OUTPUT_FILE_OPTIONS_MACRO
|
||||
LINK_OUTPUT_FILE_OPTIONS = $(OPTIONS_IN_FILE_OPTION_PREFIX)$(OPTIONS_IN_FILE_OPTION)$1$(OPTIONS_IN_FILE_OPTION_SUFFIX)
|
||||
endef
|
||||
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
$(LINK_OUTPUT_FILE): $(LINK_LIBS) $(AOS_SDK_LINK_SCRIPT) $(LINK_OPTS_FILE) $(LINT_DEPENDENCY) | $(EXTRA_PRE_LINK_TARGETS)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(LINKER) $(LINK_OPTS) $(COMPILER_SPECIFIC_STDOUT_REDIRECT) -T $(AOS_SDK_IMG1_XIP1_LD_FILE) -o $@
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
$(QUIET)$(call COMPILER_SPECIFIC_MAPFILE_TO_CSV,$(MAP_OUTPUT_FILE),$(MAP_CSV_OUTPUT_FILE))
|
||||
|
||||
$(LINK_OUTPUT_FILE_XIP2): $(LINK_LIBS) $(AOS_SDK_LINK_SCRIPT) $(LINK_OPTS_FILE) $(LINT_DEPENDENCY) | $(EXTRA_PRE_LINK_TARGETS)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(LINKER) $(LINK_OPTS_XIP2) $(COMPILER_SPECIFIC_STDOUT_REDIRECT) -T $(AOS_SDK_IMG2_XIP2_LD_FILE) -o $@
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
$(QUIET)$(call COMPILER_SPECIFIC_MAPFILE_TO_CSV,$(MAP_OUTPUT_FILE_XIP2),$(MAP_CSV_OUTPUT_FILE_XIP2))
|
||||
else
|
||||
$(LINK_OUTPUT_FILE): $(LINK_LIBS) $(AOS_SDK_LINK_SCRIPT) $(LINK_OPTS_FILE) $(LINT_DEPENDENCY) | $(EXTRA_PRE_LINK_TARGETS)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(LINKER) $(LINK_OPTS) $(COMPILER_SPECIFIC_STDOUT_REDIRECT) -o $@
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
$(QUIET)$(call COMPILER_SPECIFIC_MAPFILE_TO_CSV,$(MAP_OUTPUT_FILE),$(MAP_CSV_OUTPUT_FILE))
|
||||
endif
|
||||
|
||||
# Stripped elf file target - Strips the full elf file and outputs to a new .stripped.elf file
|
||||
$(STRIPPED_LINK_OUTPUT_FILE): $(LINK_OUTPUT_FILE)
|
||||
ifeq ($(COMPILER),iar)
|
||||
$(QUIET)$(STRIP) $(STRIPFLAGS) $< $(STRIP_OUTPUT_PREFIX)$@
|
||||
else
|
||||
$(QUIET)$(STRIP) $(STRIP_OUTPUT_PREFIX)$@ $(STRIPFLAGS) $<
|
||||
endif
|
||||
|
||||
PROJ_GEN_DIR := projects/autogen/$(CLEANED_BUILD_STRING)
|
||||
|
||||
# Bin file target - uses objcopy to convert the stripped elf into a binary file
|
||||
$(BIN_OUTPUT_FILE_TMP): $(STRIPPED_LINK_OUTPUT_FILE)
|
||||
$(ECHO) Making $(notdir $(BIN_OUTPUT_FILE))
|
||||
$(QUIET)$(RM) $(BIN_OUTPUT_FILE)
|
||||
$(QUIET)$(OBJCOPY) $(OBJCOPY_BIN_FLAGS) $< $(OBJCOPY_OUTPUT_PREFIX)$(BIN_OUTPUT_FILE)
|
||||
ifeq ($(IDE),iar)
|
||||
echo copy iar opt files..
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/iar_project/opts)
|
||||
$(QUIET)cp -rf $(OUTPUT_DIR)/libraries/*_opts $(PROJ_GEN_DIR)/iar_project/opts
|
||||
else ifeq ($(IDE),keil)
|
||||
echo copy keil opt files..
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/keil_project/opts)
|
||||
$(QUIET)cp -rf $(OUTPUT_DIR)/libraries/*_opts $(PROJ_GEN_DIR)/keil_project/opts
|
||||
endif
|
||||
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
$(STRIPPED_LINK_OUTPUT_FILE_XIP2): $(LINK_OUTPUT_FILE_XIP2)
|
||||
$(QUIET)$(STRIP) $(STRIP_OUTPUT_PREFIX)$@ $(STRIPFLAGS) $<
|
||||
|
||||
$(BIN_OUTPUT_FILE_XIP2): $(STRIPPED_LINK_OUTPUT_FILE_XIP2)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(OBJCOPY) $(OBJCOPY_BIN_FLAGS) $< $(OBJCOPY_OUTPUT_PREFIX)$@
|
||||
endif
|
||||
|
||||
$(HEX_OUTPUT_FILE): $(STRIPPED_LINK_OUTPUT_FILE)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(OBJCOPY) $(OBJCOPY_HEX_FLAGS) $< $(OBJCOPY_OUTPUT_PREFIX)$@
|
||||
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
$(HEX_OUTPUT_FILE_XIP2): $(STRIPPED_LINK_OUTPUT_FILE_XIP2)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(OBJCOPY) $(OBJCOPY_HEX_FLAGS) $< $(OBJCOPY_OUTPUT_PREFIX)$@
|
||||
endif
|
||||
|
||||
# Linker output target - This links all component & resource libraries and objects into an output executable
|
||||
# CXX is used for compatibility with C++
|
||||
#$(AOS_SDK_CONVERTER_OUTPUT_FILE): $(LINK_OUTPUT_FILE)
|
||||
# $(QUIET)$(ECHO) Making $(notdir $@)
|
||||
# $(QUIET)$(CONVERTER) "--ihex" "--verbose" $(LINK_OUTPUT_FILE) $@
|
||||
|
||||
#$(AOS_SDK_FINAL_OUTPUT_FILE): $(AOS_SDK_CONVERTER_OUTPUT_FILE)
|
||||
# $(QUIET)$(ECHO) Making $(PYTHON_FULL_NAME) $(AOS_SDK_CHIP_SPECIFIC_SCRIPT) -i $(AOS_SDK_CONVERTER_OUTPUT_FILE) -o $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
# $(QUIET)$(PYTHON_FULL_NAME) $(AOS_SDK_CHIP_SPECIFIC_SCRIPT) -i $(AOS_SDK_CONVERTER_OUTPUT_FILE) -o $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
|
||||
display_map_summary: $(LINK_OUTPUT_FILE) $(AOS_SDK_CONVERTER_OUTPUT_FILE) $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
$(QUIET) $(call COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY,$(MAP_OUTPUT_FILE))
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
$(LINK_OUTPUT_FILE_XIP2): $(LINK_OUTPUT_FILE)
|
||||
display_map_summary_XIP2: $(LINK_OUTPUT_FILE_XIP2) $(AOS_SDK_CONVERTER_OUTPUT_FILE) $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
$(QUIET) $(call COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY,$(MAP_OUTPUT_FILE_XIP2))
|
||||
endif
|
||||
|
||||
# Main Target - Ensures the required parts get built
|
||||
# $(info Prebuild targets:$(EXTRA_PRE_BUILD_TARGETS))
|
||||
# $(info $(BIN_OUTPUT_FILE))
|
||||
ifeq ($(PING_PONG_OTA),1)
|
||||
$(BIN_OUTPUT_FILE_XIP2): $(BIN_OUTPUT_FILE_TMP)
|
||||
build_done: $(EXTRA_PRE_BUILD_TARGETS) $(BIN_OUTPUT_FILE_TMP) $(HEX_OUTPUT_FILE) display_map_summary
|
||||
build_done: $(EXTRA_PRE_BUILD_TARGETS) $(BIN_OUTPUT_FILE_XIP2) $(HEX_OUTPUT_FILE_XIP2) display_map_summary_XIP2
|
||||
else
|
||||
build_done: $(EXTRA_PRE_BUILD_TARGETS) $(BIN_OUTPUT_FILE_TMP) $(HEX_OUTPUT_FILE) display_map_summary
|
||||
endif
|
||||
|
||||
$(EXTRA_POST_BUILD_TARGETS): build_done
|
||||
|
||||
#$(BUILD_STRING): $(if $(EXTRA_POST_BUILD_TARGETS),$(EXTRA_POST_BUILD_TARGETS),build_done)
|
||||
$(BUILD_STRING) $(BIN_OUTPUT_FILE): $(if $(EXTRA_POST_BUILD_TARGETS),$(EXTRA_POST_BUILD_TARGETS),build_done)
|
||||
$(PYTHON) $(SCRIPTS_PATH)/ota_gen_md5_bin.py $(BIN_OUTPUT_FILE)
|
||||
349
Living_SDK/build/aos_target_build_mbins.mk
Normal file
349
Living_SDK/build/aos_target_build_mbins.mk
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
include $(MAKEFILES_PATH)/aos_host_cmd.mk
|
||||
|
||||
CONFIG_FILE := $(OUTPUT_DIR)/config.mk
|
||||
|
||||
include $(CONFIG_FILE)
|
||||
|
||||
# Include all toolchain makefiles - one of them will handle the architecture
|
||||
# default gcc
|
||||
ifeq ($(COMPILER),)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
else ifeq ($(COMPILER),gcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
else ifeq ($(COMPILER),armcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_iar.mk
|
||||
endif
|
||||
|
||||
.PHONY: display_map_summary build_done
|
||||
|
||||
##################################
|
||||
# Filenames
|
||||
##################################
|
||||
|
||||
LINK_OUTPUT_FILE :=$(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING)$(RADIXPOINT)$(MBINSTYPE_LOWER)$(LINK_OUTPUT_SUFFIX)
|
||||
# out/helloworld@xx/binary/helloworld@xx.elf
|
||||
STRIPPED_LINK_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.stripped$(LINK_OUTPUT_SUFFIX))
|
||||
# out/helloworld@xx/binary/helloworld@xx.stripped.elf
|
||||
BIN_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=$(BIN_OUTPUT_SUFFIX))
|
||||
# out/helloworld@xx/binary/helloworld@xx.bin
|
||||
HEX_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=$(HEX_OUTPUT_SUFFIX))
|
||||
# out/helloworld@xx/binary/helloworld@xx.bin
|
||||
MAP_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=.map)
|
||||
# out/helloworld@xx/binary/helloworld@xx.map
|
||||
MAP_CSV_OUTPUT_FILE :=$(LINK_OUTPUT_FILE:$(LINK_OUTPUT_SUFFIX)=_map.csv)
|
||||
# out/helloworld@xx/binary/helloworld@xx_map.csv
|
||||
|
||||
OPENOCD_LOG_FILE ?= $(OUTPUT_DIR)/openocd_log.txt
|
||||
|
||||
LIBS_DIR := $(OUTPUT_DIR)/libraries
|
||||
LINK_OPTS_FILE := $(OUTPUT_DIR)/binary/link$(UNDERLINE)$(MBINSTYPE_LOWER).opts
|
||||
|
||||
LINT_OPTS_FILE := $(OUTPUT_DIR)/binary/lint$(UNDERLINE)$(MBINSTYPE_LOWER).opts
|
||||
|
||||
LDS_FILE_DIR := $(OUTPUT_DIR)/ld
|
||||
|
||||
ifeq (,$(SUB_BUILD))
|
||||
ifneq (,$(EXTRA_TARGET_MAKEFILES))
|
||||
$(foreach makefile_name,$(EXTRA_TARGET_MAKEFILES),$(eval include $(makefile_name)))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(BINS))
|
||||
CREATE_SYSCALLFILE :=$(MAKEFILES_PATH)/scripts/gen_syscalls.py
|
||||
PARSE_RESOURSE_TO_SYSCALL_FILE = $(PYTHON) $(CREATE_SYSCALLFILE) $(1) $(2)
|
||||
PROCESS_PRECOMPILED_FILES := $(OUTPUT_DIR)/precompile/mark.i
|
||||
endif
|
||||
|
||||
include $(MAKEFILES_PATH)/aos_resources.mk
|
||||
include $(MAKEFILES_PATH)/aos_images_download.mk
|
||||
|
||||
##################################
|
||||
# Macros
|
||||
##################################
|
||||
|
||||
###############################################################################
|
||||
# MACRO: GET_BARE_LOCATION
|
||||
# Returns a the location of the given component relative to source-tree-root
|
||||
# rather than from the cwd
|
||||
# $(1) is component
|
||||
GET_BARE_LOCATION =$(patsubst $(call ESCAPE_BACKSLASHES,$(SOURCE_ROOT))%,%,$(strip $(subst :,/,$($(1)_LOCATION))))
|
||||
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_C_RULE
|
||||
# Creates a target for building C language files (*.c)
|
||||
# $(1) is component, $(2) is the source file
|
||||
define BUILD_C_RULE
|
||||
ifeq ($(COMPILER),)
|
||||
-include $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2:.c=.d)
|
||||
endif
|
||||
$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2:.c=.o): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2)).d $(RESOURCES_DEPENDENCY) $(LIBS_DIR)/$(1).c_opts $(PROCESS_PRECOMPILED_FILES) | $(EXTRA_PRE_BUILD_TARGETS)
|
||||
$$(if $($(1)_START_PRINT),,$(eval $(1)_START_PRINT:=1) $(QUIET)$(ECHO) Compiling $(1) )
|
||||
$(QUIET)$(CC) $($(1)_C_OPTS) -D__FILENAME__='"$$(notdir $$<)"' $(call COMPILER_SPECIFIC_DEPS_FILE,$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2:.c=.d)) -o $$@ $$< $(COMPILER_SPECIFIC_STDOUT_REDIRECT)
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: CHECK_HEADER_RULE
|
||||
# Compiles a C language header file to ensure it is stand alone complete
|
||||
# $(1) is component, $(2) is the source header file
|
||||
define CHECK_HEADER_RULE
|
||||
$(eval $(1)_CHECK_HEADER_LIST+=$(OUTPUT_DIR)/modules/$(strip $($(1)_LOCATION))$(2:.h=.chk) )
|
||||
.PHONY: $(OUTPUT_DIR)/modules/$(strip $($(1)_LOCATION))$(2:.h=.chk)
|
||||
$(OUTPUT_DIR)/modules/$(strip $($(1)_LOCATION))$(2:.h=.chk): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2)).d
|
||||
$(QUIET)$(ECHO) Checking header $(2)
|
||||
$(QUIET)$(CC) -c $(AOS_SDK_CFLAGS) $(filter-out -pedantic -Werror, $($(1)_CFLAGS) $(C_BUILD_OPTIONS) ) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES) -o $$@ $$<
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_CPP_RULE
|
||||
# Creates a target for building C++ language files (*.cpp)
|
||||
# $(1) is component name, $(2) is the source file
|
||||
define BUILD_CPP_RULE
|
||||
-include $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(patsubst %.cc,%.d,$(2:.cpp=.d))
|
||||
$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(patsubst %.cc,%.o,$(2:.cpp=.o)): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(2)).d $(RESOURCES_DEPENDENCY) $(LIBS_DIR)/$(1).cpp_opts | $(EXTRA_PRE_BUILD_TARGETS)
|
||||
$$(if $($(1)_START_PRINT),,$(eval $(1)_START_PRINT:=1) $(ECHO) Compiling $(1))
|
||||
$(QUIET)$(CXX) $($(1)_CPP_OPTS) -o $$@ $$< $(COMPILER_SPECIFIC_STDOUT_REDIRECT)
|
||||
endef
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_S_RULE
|
||||
# Creates a target for building Assembly language files (*.s & *.S)
|
||||
# $(1) is component name, $(2) is the source file
|
||||
define BUILD_S_RULE
|
||||
$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S,%.o, $(2:.s=.o) )): $(strip $($(1)_LOCATION))$(2) $($(1)_PRE_BUILD_TARGETS) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S, %.o, $(2)))).d $(RESOURCES_DEPENDENCY) $(LIBS_DIR)/$(1).as_opts $(PROCESS_PRECOMPILED_FILES) | $(EXTRA_PRE_BUILD_TARGETS)
|
||||
$$(if $($(1)_START_PRINT),,$(eval $(1)_START_PRINT:=1) $(ECHO) Compiling $(1))
|
||||
$(QUIET)$(AS) $($(1)_S_OPTS) -o $$@ $$< $(COMPILER_SPECIFIC_STDOUT_REDIRECT)
|
||||
endef
|
||||
|
||||
IDE_IAR_FLAG :=
|
||||
IDE_KEIL_FLAG :=
|
||||
|
||||
ifeq ($(IDE),iar)
|
||||
IDE_IAR_FLAG := 1
|
||||
else ifeq ($(IDE),keil)
|
||||
IDE_KEIL_FLAG := 1
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
# MACRO: BUILD_COMPONENT_RULES
|
||||
# Creates targets for building an entire component
|
||||
# Target for the component static library is created in this macro
|
||||
# Targets for source files are created by calling the macros defined above
|
||||
# $(1) is component name
|
||||
define BUILD_COMPONENT_RULES
|
||||
|
||||
$(eval LINK_LIBS +=$(if $($(1)_SOURCES),$(LIBS_DIR)/$(1).a))
|
||||
|
||||
|
||||
ifneq ($($(1)_PRE_BUILD_TARGETS),)
|
||||
include $($(1)_MAKEFILE)
|
||||
endif
|
||||
|
||||
# Make a list of the object files that will be used to build the static library
|
||||
$(eval $(1)_LIB_OBJS := $(addprefix $(strip $(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(1))), $(filter %.o, $($(1)_SOURCES:.cc=.o) $($(1)_SOURCES:.cpp=.o) $($(1)_SOURCES:.c=.o) $($(1)_SOURCES:.s=.o) $($(1)_SOURCES:.S=.o))) $(patsubst %.c,%.o,$(call RESOURCE_FILENAME, $($(1)_RESOURCES))))
|
||||
|
||||
|
||||
$(LIBS_DIR)/$(1).c_opts: $($(1)_PRE_BUILD_TARGETS) $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(eval $(1)_C_OPTS:=$(subst $(COMMA),$$(COMMA), $(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_SPECIFIC_DEPS_FLAG) $(COMPILER_UNI_CFLAGS) $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES)))
|
||||
$(eval C_OPTS_IAR := $(subst =\",="\",$($(1)_C_OPTS)) )
|
||||
$(eval C_OPTS_IAR := $(subst \" ,\"" ,$(C_OPTS_IAR) ) )
|
||||
$(eval C_OPTS_IAR := $(filter-out -I% --cpu=% --endian% --dlib_config%,$(C_OPTS_IAR)) )
|
||||
$(eval C_OPTS_KEIL := $(subst -I.,-I../../../../.,$($(1)_C_OPTS)) )
|
||||
$(eval C_OPTS_FILE := $($(1)_C_OPTS) )
|
||||
$(if $(IDE_IAR_FLAG),$(eval C_OPTS_FILE:=$(C_OPTS_IAR)),)
|
||||
$(if $(IDE_KEIL_FLAG),$(eval C_OPTS_FILE:=$(C_OPTS_KEIL)),)
|
||||
$$(file >$$@, $(C_OPTS_FILE) )
|
||||
|
||||
$(LIBS_DIR)/$(1).cpp_opts: $($(1)_PRE_BUILD_TARGETS) $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(eval $(1)_CPP_OPTS:=$(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_SPECIFIC_DEPS_FLAG) $($(1)_CXXFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES))
|
||||
$$(file >$$@, $($(1)_CPP_OPTS) )
|
||||
|
||||
$(LIBS_DIR)/$(1).as_opts: $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(eval $(1)_S_OPTS:=$(CPU_ASMFLAGS) $(COMPILER_SPECIFIC_COMP_ONLY_FLAG) $(COMPILER_UNI_SFLAGS) $($(1)_ASMFLAGS) $($(1)_INCLUDES) $(AOS_SDK_INCLUDES))
|
||||
$(eval S_OPTS_IAR := $(filter-out --cpu Cortex-M4, $($(1)_S_OPTS) ) )
|
||||
$(eval S_OPTS_FILE := $($(1)_S_OPTS) )
|
||||
$(if $(IDE_IAR_FLAG),$(eval S_OPTS_FILE:=$(S_OPTS_IAR)),)
|
||||
$$(file >$$@, $(S_OPTS_FILE) )
|
||||
|
||||
$(LIBS_DIR)/$(1).ar_opts: $(CONFIG_FILE) | $(LIBS_DIR)
|
||||
$(QUIET)$$(call WRITE_FILE_CREATE, $$@ ,$($(1)_LIB_OBJS))
|
||||
|
||||
|
||||
# Allow checking of completeness of headers
|
||||
$(foreach src, $(if $(findstring 1,$(CHECK_HEADERS)), $(filter %.h, $($(1)_CHECK_HEADERS)), ),$(eval $(call CHECK_HEADER_RULE,$(1),$(src))))
|
||||
|
||||
# Target for build-from-source
|
||||
#$(OUTPUT_DIR)/libraries/$(1).a: $$($(1)_LIB_OBJS) $($(1)_CHECK_HEADER_LIST) $(OUTPUT_DIR)/libraries/$(1).ar_opts $$(if $(AOS_BUILT_WITH_ROM_SYMBOLS),$(ROMOBJCOPY_OPTS_FILE))
|
||||
$(LIBS_DIR)/$(1).a: $$($(1)_LIB_OBJS) $($(1)_CHECK_HEADER_LIST) $(OUTPUT_DIR)/libraries/$(1).ar_opts
|
||||
$(ECHO) Making $$@
|
||||
$(QUIET)$(AR) $(AOS_SDK_ARFLAGS) $(COMPILER_SPECIFIC_ARFLAGS_CREATE) $$@ $(OPTIONS_IN_FILE_OPTION_PREFIX)$(OPTIONS_IN_FILE_OPTION)$(OUTPUT_DIR)/libraries/$(1).ar_opts$(OPTIONS_IN_FILE_OPTION_SUFFIX)
|
||||
# Create targets to built the component's source files into object files
|
||||
$(foreach src, $(filter %.c, $($(1)_SOURCES)),$(eval $(call BUILD_C_RULE,$(1),$(src))))
|
||||
$(foreach src, $(filter %.cpp, $($(1)_SOURCES)) $(filter %.cc, $($(1)_SOURCES)),$(eval $(call BUILD_CPP_RULE,$(1),$(src))))
|
||||
$(foreach src, $(filter %.s %.S, $($(1)_SOURCES)),$(eval $(call BUILD_S_RULE,$(1),$(src))))
|
||||
|
||||
|
||||
$(eval $(1)_LINT_FLAGS += $(filter -D% -I%, $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES) ) )
|
||||
$(eval LINT_FLAGS += $($(1)_LINT_FLAGS) )
|
||||
$(eval LINT_FILES += $(addprefix $(strip $($(1)_LOCATION)), $(filter %.c, $($(1)_SOURCES))) )
|
||||
endef
|
||||
|
||||
define PROCESS_C_FILE
|
||||
$(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(2:.c=.i): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(2)).i
|
||||
$(QUIET)$(CPP) -P $(subst $(COMMA),$$(COMMA), $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES)) -DAOS_EXPORTX -o $$@ $$<
|
||||
$(eval PRECOMPILED_FILES += $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(2:.c=.i))
|
||||
endef
|
||||
|
||||
define PROCESS_S_FILE
|
||||
$(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S,%.i, $(2:.s=.i))): $(strip $($(1)_LOCATION))$(2) $(CONFIG_FILE) $$(dir $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S, %.i, $(2:.s=.i)))).i
|
||||
$(QUIET)$(CPP) -P $(subst $(COMMA),$$(COMMA), $($(1)_CFLAGS) $($(1)_INCLUDES) $($(1)_DEFINES) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES)) -DAOS_EXPORTX -o $$@ $$<
|
||||
$(eval PRECOMPILED_FILES += $(OUTPUT_DIR)/precompile/$(3)/$(call GET_BARE_LOCATION,$(1))$(strip $(patsubst %.S,%.i, $(2:.s=.i))))
|
||||
endef
|
||||
|
||||
define PRECOMPILED_RESOURCE_FILE
|
||||
$(foreach src, $(filter %.c, $($(1)_SOURCES)),$(eval $(call PROCESS_C_FILE,$(1),$(src),$(2))))
|
||||
$(foreach src, $(filter %.s %.S, $($(1)_SOURCES)),$(eval $(call PROCESS_S_FILE,$(1),$(src),$(2))))
|
||||
endef
|
||||
|
||||
define PROCESS_LDS_FILE
|
||||
$(LDS_FILE_DIR)/$(notdir $(1:.ld.S=.ld)): $(LDS_FILE_DIR)
|
||||
$(ECHO) Making $$@
|
||||
$(QUIET)$(CPP) -P $(AOS_SDK_CFLAGS) $(AOS_SDK_INCLUDES) $(AOS_SDK_DEFINES) $(1) -o $$@
|
||||
|
||||
$(eval LDS_FILES += $(LDS_FILE_DIR)/$(notdir $(1:.ld.S=.ld)))
|
||||
endef
|
||||
|
||||
##################################
|
||||
# Processing
|
||||
##################################
|
||||
|
||||
# Create targets for resource files
|
||||
# $(info Resources: $(ALL_RESOURCES))
|
||||
$(eval $(if $(ALL_RESOURCES),$(call CREATE_ALL_RESOURCE_TARGETS,$(ALL_RESOURCES))))
|
||||
LINK_LIBS += $(RESOURCES_LIBRARY)
|
||||
|
||||
# $(info Components: $(COMPONENTS))
|
||||
# Create targets for components
|
||||
ifeq (app, $(MBINS))
|
||||
# precompile kernel/framework file
|
||||
#$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel, $($(comp)_MBINS_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),kernel))))
|
||||
#$(foreach comp,$(COMPONENTS),$(eval $(if $(filter framework, $($(comp)_MBINS_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),framework))))
|
||||
# Create targets for components
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $($(comp)_MBINS_TYPE), $(if $(filter app share, $($(comp)_MBINS_TYPE)), $(call BUILD_COMPONENT_RULES,$(comp))), $(call BUILD_COMPONENT_RULES,$(comp)))))
|
||||
else ifeq (kernel, $(MBINS))
|
||||
# precompile kernel file
|
||||
#$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel, $($(comp)_MBINS_TYPE)), $(call PRECOMPILED_RESOURCE_FILE,$(comp),kernel))))
|
||||
# Create targets for components
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(if $(filter kernel share, $($(comp)_MBINS_TYPE)), $(call BUILD_COMPONENT_RULES,$(comp)))))
|
||||
else ifeq (,$(MBINS))
|
||||
$(foreach comp,$(COMPONENTS),$(eval $(call BUILD_COMPONENT_RULES,$(comp))))
|
||||
endif
|
||||
|
||||
# handle lds file, lds -> ld
|
||||
$(foreach ldsfile,$(AOS_SDK_LDS_FILES),$(eval $(call PROCESS_LDS_FILE,$(ldsfile))))
|
||||
$(foreach ldsfile,$(AOS_SDK_LDS_INCLUDES),$(eval $(call PROCESS_LDS_FILE,$(ldsfile))))
|
||||
$(foreach ldsfile,$(AOS_SDK_LDS_FILES),$(eval AOS_SDK_LDFLAGS += -T $(notdir $(ldsfile:.ld.S=.ld))))
|
||||
$(if $(AOS_SDK_LDS_FILES),$(eval AOS_SDK_LDFLAGS += -L $(LDS_FILE_DIR)))
|
||||
|
||||
ifneq (,$(BINS))
|
||||
$(PROCESS_PRECOMPILED_FILES): $(PRECOMPILED_FILES)
|
||||
$(QUIET)$(TOUCH) $@
|
||||
$(QUIET)$(if $(PARSE_RESOURSE_TO_SYSCALL_FILE), $(call PARSE_RESOURSE_TO_SYSCALL_FILE, $(OUTPUT_DIR), create))
|
||||
endif
|
||||
|
||||
# Add pre-built libraries
|
||||
LINK_LIBS += $(AOS_SDK_PREBUILT_LIBRARIES)
|
||||
|
||||
##################################
|
||||
# Build rules
|
||||
##################################
|
||||
|
||||
$(LIBS_DIR):
|
||||
$(QUIET)$(call MKDIR, $@)
|
||||
|
||||
$(LDS_FILE_DIR):
|
||||
$(QUIET)$(call MKDIR, $@)
|
||||
|
||||
# Directory dependency - causes mkdir to be called once for each directory.
|
||||
%/.d:
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
$(QUIET)$(TOUCH) $(@)
|
||||
|
||||
%/.i:
|
||||
$(QUIET)$(call MKDIR, $(dir $@))
|
||||
|
||||
LINK_OPTS := $(AOS_SDK_LINK_SCRIPT_CMD) $(call COMPILER_SPECIFIC_LINK_MAP,$(MAP_OUTPUT_FILE)) $(call COMPILER_SPECIFIC_LINK_FILES, $(AOS_SDK_LINK_FILES) $(filter %.a,$^) $(LINK_LIBS)) $(AOS_SDK_LDFLAGS)
|
||||
|
||||
# FIXME GCC Whole archive not ready in all platform
|
||||
$(LINK_OPTS_FILE): $(OUTPUT_DIR)/config.mk $(LDS_FILES)
|
||||
ifeq ($(COMPILER),armcc)
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $@ ,$(LINK_OPTS))
|
||||
else
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $@ ,$(LINK_OPTS) )
|
||||
endif
|
||||
|
||||
$(LINT_OPTS_FILE): $(LINK_LIBS)
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $@ , )
|
||||
$(QUIET)$(foreach opt,$(sort $(subst \",",$(LINT_FLAGS))) $(sort $(LINT_FILES)),$(call WRITE_FILE_APPEND, $@ ,$(opt)))
|
||||
|
||||
define LINK_OUTPUT_FILE_OPTIONS_MACRO
|
||||
LINK_OUTPUT_FILE_OPTIONS = $(OPTIONS_IN_FILE_OPTION_PREFIX)$(OPTIONS_IN_FILE_OPTION)$1$(OPTIONS_IN_FILE_OPTION_SUFFIX)
|
||||
endef
|
||||
|
||||
$(LINK_OUTPUT_FILE): $(LINK_LIBS) $(AOS_SDK_LINK_SCRIPT) $(LINK_OPTS_FILE) $(LINT_DEPENDENCY) | $(EXTRA_PRE_LINK_TARGETS)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(LINKER) $(LINK_OPTS) $(COMPILER_SPECIFIC_STDOUT_REDIRECT) -o $@
|
||||
$(QUIET)$(ECHO_BLANK_LINE)
|
||||
$(QUIET)$(call COMPILER_SPECIFIC_MAPFILE_TO_CSV,$(MAP_OUTPUT_FILE),$(MAP_CSV_OUTPUT_FILE))
|
||||
|
||||
# Stripped elf file target - Strips the full elf file and outputs to a new .stripped.elf file
|
||||
$(STRIPPED_LINK_OUTPUT_FILE): $(LINK_OUTPUT_FILE)
|
||||
ifeq ($(COMPILER),iar)
|
||||
$(QUIET)$(STRIP) $(STRIPFLAGS) $< $(STRIP_OUTPUT_PREFIX)$@
|
||||
else
|
||||
$(QUIET)$(STRIP) $(STRIP_OUTPUT_PREFIX)$@ $(STRIPFLAGS) $<
|
||||
endif
|
||||
|
||||
PROJ_GEN_DIR := projects/autogen/$(CLEANED_BUILD_STRING)
|
||||
|
||||
# Bin file target - uses objcopy to convert the stripped elf into a binary file
|
||||
$(BIN_OUTPUT_FILE): $(STRIPPED_LINK_OUTPUT_FILE)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(OBJCOPY) $(OBJCOPY_BIN_FLAGS) $< $(OBJCOPY_OUTPUT_PREFIX)$@
|
||||
ifeq ($(IDE),iar)
|
||||
echo copy iar opt files..
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/iar_project/opts)
|
||||
$(QUIET)cp -rf $(OUTPUT_DIR)/libraries/*_opts $(PROJ_GEN_DIR)/iar_project/opts
|
||||
else ifeq ($(IDE),keil)
|
||||
echo copy keil opt files..
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/keil_project/opts)
|
||||
$(QUIET)cp -rf $(OUTPUT_DIR)/libraries/*_opts $(PROJ_GEN_DIR)/keil_project/opts
|
||||
endif
|
||||
|
||||
$(HEX_OUTPUT_FILE): $(STRIPPED_LINK_OUTPUT_FILE)
|
||||
$(QUIET)$(ECHO) Making $(notdir $@)
|
||||
$(QUIET)$(OBJCOPY) $(OBJCOPY_HEX_FLAGS) $< $(OBJCOPY_OUTPUT_PREFIX)$@
|
||||
|
||||
# Linker output target - This links all component & resource libraries and objects into an output executable
|
||||
# CXX is used for compatibility with C++
|
||||
#$(AOS_SDK_CONVERTER_OUTPUT_FILE): $(LINK_OUTPUT_FILE)
|
||||
# $(QUIET)$(ECHO) Making $(notdir $@)
|
||||
# $(QUIET)$(CONVERTER) "--ihex" "--verbose" $(LINK_OUTPUT_FILE) $@
|
||||
|
||||
#$(AOS_SDK_FINAL_OUTPUT_FILE): $(AOS_SDK_CONVERTER_OUTPUT_FILE)
|
||||
# $(QUIET)$(ECHO) Making $(PYTHON_FULL_NAME) $(AOS_SDK_CHIP_SPECIFIC_SCRIPT) -i $(AOS_SDK_CONVERTER_OUTPUT_FILE) -o $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
# $(QUIET)$(PYTHON_FULL_NAME) $(AOS_SDK_CHIP_SPECIFIC_SCRIPT) -i $(AOS_SDK_CONVERTER_OUTPUT_FILE) -o $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
|
||||
display_map_summary: $(LINK_OUTPUT_FILE) $(AOS_SDK_CONVERTER_OUTPUT_FILE) $(AOS_SDK_FINAL_OUTPUT_FILE)
|
||||
$(QUIET) $(call COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY,$(MAP_OUTPUT_FILE))
|
||||
|
||||
# Main Target - Ensures the required parts get built
|
||||
# $(info Prebuild targets:$(EXTRA_PRE_BUILD_TARGETS))
|
||||
# $(info $(BIN_OUTPUT_FILE))
|
||||
build_done: $(EXTRA_PRE_BUILD_TARGETS) $(BIN_OUTPUT_FILE) $(HEX_OUTPUT_FILE) display_map_summary
|
||||
|
||||
$(EXTRA_POST_BUILD_TARGETS): build_done
|
||||
|
||||
$(BUILD_STRING): $(if $(EXTRA_POST_BUILD_TARGETS),$(EXTRA_POST_BUILD_TARGETS),build_done)
|
||||
524
Living_SDK/build/aos_target_config.mk
Normal file
524
Living_SDK/build/aos_target_config.mk
Normal file
|
|
@ -0,0 +1,524 @@
|
|||
include $(MAKEFILES_PATH)/aos_host_cmd.mk
|
||||
|
||||
APPDIR ?=
|
||||
CONFIG_FILE_DIR := $(OUTPUT_DIR)
|
||||
CONFIG_FILE := $(CONFIG_FILE_DIR)/config.mk
|
||||
|
||||
|
||||
COMPONENT_DIRECTORIES := . \
|
||||
example \
|
||||
board \
|
||||
kernel \
|
||||
platform \
|
||||
utility \
|
||||
framework \
|
||||
tools \
|
||||
test \
|
||||
device \
|
||||
security
|
||||
|
||||
TEST_COMPONENT_DIRECTORIES := test
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
COMPONENT_DIRECTORIES += $(OUTPUT_DIR)/syscall
|
||||
COMPONENT_DIRECTORIES += $(OUTPUT_DIR)
|
||||
endif
|
||||
|
||||
COMPONENT_DIRECTORIES += $(APPDIR)
|
||||
|
||||
AOS_SDK_VERSION ?= $(AOS_SDK_VERSION_MAJOR).$(AOS_SDK_VERSION_MINOR).$(AOS_SDK_VERSION_REVISION)
|
||||
|
||||
##################################
|
||||
# Macros
|
||||
##################################
|
||||
|
||||
# $(1) is component
|
||||
GET_BARE_LOCATION =$(patsubst $(call ESCAPE_BACKSLASHES,$(SOURCE_ROOT))%,%,$(strip $($(1)_LOCATION)))
|
||||
|
||||
define PREPROCESS_TEST_COMPONENT
|
||||
$(if $(filter yts,$(COMPONENTS)), \
|
||||
$(if $(test), $(eval TEST_COMPONENTS := $(strip $(subst $(COMMA), $(SPACE), $(test)))),) \
|
||||
$(if $(TEST_COMPONENTS), $(call RECURSE_DIR_COMPONENT_SEARCH, $(patsubst %/,%,$(TEST_COMPONENT_DIRECTORIES)), TEST_COMPONENT_LIST) \
|
||||
$(eval TEST_COMPONENTS := $(addprefix %., $(addsuffix _test, $(TEST_COMPONENTS)))) \
|
||||
$(eval COMPONENTS += $(filter $(TEST_COMPONENTS), $(subst /,.,$(strip $(TEST_COMPONENT_LIST)))))))
|
||||
endef
|
||||
|
||||
#####################################################################################
|
||||
# Macro FIND_COMPONENT use breadth traversal to search component
|
||||
# $(1) is the list of components left to process. $(COMP) is set as the first element in the list
|
||||
define FIND_COMPONENT
|
||||
|
||||
$(eval COMP := $(word 1,$(1)))
|
||||
$(eval COMP_LOCATION := $(subst .,/,$(COMP)))
|
||||
$(eval COMP_MAKEFILE_NAME := $(notdir $(COMP_LOCATION)))
|
||||
# Find the component makefile in directory list
|
||||
$(eval TEMP_MAKEFILE := $(strip $(wildcard $(foreach dir, $(if $(filter-out out, $(BUILD_DIR)),$(OUTPUT_DIR) $(OUTPUT_DIR)/syscall,) $(if $(APPDIR),$(APPDIR),) $(if $(CUBE_AOS_DIR),$(CUBE_AOS_DIR) $(CUBE_AOS_DIR)/remote,) $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(COMP_LOCATION)/$(COMP_MAKEFILE_NAME).mk))))
|
||||
# Check if component makefile was found - if not try downloading it and re-doing the makefile search
|
||||
$(if $(TEMP_MAKEFILE),,\
|
||||
$(info Unknown component: $(COMP) - directory or makefile for component not found. Ensure the $(COMP_LOCATION) directory contains $(COMP_MAKEFILE_NAME).mk) \
|
||||
$(info Below is a list of valid local components (Some are internal): ) \
|
||||
$(call FIND_VALID_COMPONENTS, VALID_COMPONENT_LIST,$(COMPONENT_DIRECTORIES)) \
|
||||
$(foreach comp,$(VALID_COMPONENT_LIST),$(info $(comp))) \
|
||||
$(info Below is a list of valid components from the internet: ) \
|
||||
$(info $(call DOWNLOAD_COMPONENT_LIST)) \
|
||||
$(error Unknown component: $(COMP) - directory or makefile for component not found. Ensure the $(COMP_LOCATION) directory contains $(COMP_MAKEFILE_NAME).mk))
|
||||
$(if $(filter 1,$(words $(TEMP_MAKEFILE))),,$(error More than one component with the name "$(COMP)". See $(TEMP_MAKEFILE)))
|
||||
|
||||
$(eval TEMP_MAKEFILE := $(subst ././,./,$(TEMP_MAKEFILE)))
|
||||
|
||||
$(eval include $(TEMP_MAKEFILE))
|
||||
$(eval deps :=)
|
||||
$(eval deps_src := $($(NAME)_COMPONENTS))
|
||||
$(eval components_cube := $(subst .,/,$(COMPONENTS)))
|
||||
$(eval deps_cube := $(subst .,/,$($(NAME)_COMPONENTS)))
|
||||
|
||||
$(foreach dep, $(deps_cube),\
|
||||
$(eval comp_dep := $(firstword $(deps_src))) \
|
||||
$(eval find := 0) \
|
||||
$(foreach component, $(components_cube) $(CUBE_REMOVE_COMPONENTS), \
|
||||
$(if $(filter $(notdir $(dep)),$(notdir $(component))), \
|
||||
$(if $(findstring $(dep), $(component)),$(eval find := 1))))\
|
||||
$(if $(filter 0, $(find)), $(eval deps += $(comp_dep))) \
|
||||
$(eval deps_src := $(filter-out $(comp_dep),$(deps_src))))
|
||||
|
||||
$(if $(findstring $(TEMP_MAKEFILE),$(ALL_MAKEFILES)),,\
|
||||
$(eval ALL_MAKEFILES += $(TEMP_MAKEFILE)) \
|
||||
$(eval COMPONENTS += $(deps)) \
|
||||
$(eval REAL_COMPONENTS_LOCS += $(COMP)) \
|
||||
$(eval iotx_check_RET:=0)\
|
||||
$(eval COMP_sub:=$(subst linkkit/sdk, linkkit_sdk ,$(COMP))) \
|
||||
$(eval COMP_sub:=$(subst linkkit.sdk, linkkit_sdk ,$(COMP_sub))) \
|
||||
$(if $(filter linkkit_sdk, $(COMP_sub)), \
|
||||
$(eval iotx_check_RET=$(shell sh build/checkout_iotx_sdk.sh)),) \
|
||||
$(if $(filter fail!, $(iotx_check_RET)), \
|
||||
$(error iotx-sdk-c checkout fail!),) \
|
||||
$(call PREPROCESS_TEST_COMPONENT, $(COMPONENTS), $(TEST_COMPONENTS)) \
|
||||
DEPENDENCY += '$(NAME)': '$($(NAME)_COMPONENTS)',)
|
||||
|
||||
$(eval PROCESSED_COMPONENTS_LOCS += $(COMP))
|
||||
$(if $(strip $(filter-out $(PROCESSED_COMPONENTS_LOCS),$(COMPONENTS))),\
|
||||
$(call FIND_COMPONENT,$(filter-out $(PROCESSED_COMPONENTS_LOCS),$(COMPONENTS))),\
|
||||
)
|
||||
endef
|
||||
|
||||
#####################################################################################
|
||||
# Macro PROCESS_ONE_COMPONENT
|
||||
# $(1) is one component
|
||||
define PROCESS_ONE_COMPONENT
|
||||
$(eval COMP := $(1))
|
||||
$(eval COMP_LOCATION := $(subst .,/,$(COMP)))
|
||||
$(eval COMP_MAKEFILE_NAME := $(notdir $(COMP_LOCATION)))
|
||||
# Find the component makefile in directory list
|
||||
$(eval TEMP_MAKEFILE := $(strip $(wildcard $(foreach dir, $(if $(filter-out out, $(BUILD_DIR)),$(OUTPUT_DIR) $(OUTPUT_DIR)/syscall,) $(if $(APPDIR),$(APPDIR)/$(comp),) $(if $(CUBE_AOS_DIR),$(CUBE_AOS_DIR) $(CUBE_AOS_DIR)/remote) $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(COMP_LOCATION)/$(COMP_MAKEFILE_NAME).mk))))
|
||||
|
||||
# Clear all the temporary variables
|
||||
$(eval GLOBAL_INCLUDES:=)
|
||||
$(eval GLOBAL_LINK_SCRIPT:=)
|
||||
$(eval DEFAULT_LINK_SCRIPT:=)
|
||||
$(eval DCT_LINK_SCRIPT:=)
|
||||
$(eval GLOBAL_DEFINES:=)
|
||||
$(eval GLOBAL_CFLAGS:=)
|
||||
$(eval GLOBAL_CXXFLAGS:=)
|
||||
$(eval GLOBAL_ASMFLAGS:=)
|
||||
$(eval GLOBAL_LDFLAGS:=)
|
||||
$(eval GLOBAL_LDS_FILES:=)
|
||||
$(eval GLOBAL_LDS_INCLUDES:=)
|
||||
$(eval GLOBAL_CERTIFICATES:=)
|
||||
$(eval WIFI_CONFIG_DCT_H:=)
|
||||
$(eval BT_CONFIG_DCT_H:=)
|
||||
$(eval APPLICATION_DCT:=)
|
||||
$(eval CERTIFICATE:=)
|
||||
$(eval PRIVATE_KEY:=)
|
||||
$(eval CHIP_SPECIFIC_SCRIPT:=)
|
||||
$(eval CONVERTER_OUTPUT_FILE:=)
|
||||
$(eval BIN_OUTPUT_FILE:=)
|
||||
$(eval OLD_CURDIR := $(CURDIR))
|
||||
$(eval CURDIR := $(CURDIR)$(dir $(TEMP_MAKEFILE)))
|
||||
$(eval TEST_COMPONENTS :=)
|
||||
|
||||
$(eval AOS_IMG1_XIP1_LD_FILE :=)
|
||||
$(eval AOS_IMG2_XIP2_LD_FILE :=)
|
||||
# Cache the last valid RTOS/NS combination for iterative filtering.
|
||||
$(eval TEMP_VALID_OSNS_COMBOS := $(VALID_OSNS_COMBOS))
|
||||
|
||||
# Include the component makefile - This defines the NAME variable
|
||||
$(eval include $(TEMP_MAKEFILE))
|
||||
|
||||
# Filter the valid RTOS/NS combination to the least-common set.
|
||||
$(eval VALID_OSNS_COMBOS :=\
|
||||
$(if $(VALID_OSNS_COMBOS),\
|
||||
$(filter $(VALID_OSNS_COMBOS),$(TEMP_VALID_OSNS_COMBOS)),\
|
||||
$(TEMP_VALID_OSNS_COMBOS)\
|
||||
)\
|
||||
)
|
||||
|
||||
$(eval $(NAME)_MAKEFILE :=$(TEMP_MAKEFILE))
|
||||
|
||||
# Expand the list of resources to point to the full location (either component local or the common resources directory)
|
||||
$(eval $(NAME)_RESOURCES_EXPANDED := $(foreach res,$($(NAME)_RESOURCES),$(word 1,$(wildcard $(addsuffix $(res),$(CURDIR) $(SOURCE_ROOT)resources/)))))
|
||||
|
||||
$(eval CURDIR := $(OLD_CURDIR))
|
||||
|
||||
$(eval $(NAME)_LOCATION := $(dir $(TEMP_MAKEFILE)))
|
||||
$(eval $(NAME)_MAKEFILE := $(TEMP_MAKEFILE))
|
||||
AOS_SDK_MAKEFILES += $($(NAME)_MAKEFILE)
|
||||
|
||||
# Set debug/release specific options
|
||||
$(eval $(NAME)_BUILD_TYPE := $(BUILD_TYPE))
|
||||
$(eval $(NAME)_BUILD_TYPE := $(if $($(NAME)_NEVER_OPTIMISE), debug, $($(NAME)_BUILD_TYPE)))
|
||||
$(eval $(NAME)_BUILD_TYPE := $(if $($(NAME)_ALWAYS_OPTIMISE), release, $($(NAME)_BUILD_TYPE)))
|
||||
|
||||
$(NAME)_ASMFLAGS += $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_ASFLAGS), $(COMPILER_SPECIFIC_RELEASE_ASFLAGS))
|
||||
$(NAME)_LDFLAGS += $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_LDFLAGS), $(COMPILER_SPECIFIC_RELEASE_LDFLAGS))
|
||||
|
||||
$(NAME)_OPTIM_CFLAGS ?= $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_CFLAGS), $(if $(findstring release_log,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS), $(COMPILER_SPECIFIC_RELEASE_CFLAGS)))
|
||||
|
||||
$(NAME)_OPTIM_CXXFLAGS ?= $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_CXXFLAGS), $(if $(findstring release_log,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS), $(COMPILER_SPECIFIC_RELEASE_CXXFLAGS)))
|
||||
|
||||
AOS_SDK_INCLUDES +=$(addprefix -I$($(NAME)_LOCATION),$(GLOBAL_INCLUDES))
|
||||
AOS_SDK_LINK_SCRIPT +=$(if $(GLOBAL_LINK_SCRIPT),$(GLOBAL_LINK_SCRIPT),)
|
||||
AOS_SDK_DEFAULT_LINK_SCRIPT+=$(if $(DEFAULT_LINK_SCRIPT),$(addprefix $($(NAME)_LOCATION),$(DEFAULT_LINK_SCRIPT)),)
|
||||
$(eval AOS_SDK_DEFINES +=$(GLOBAL_DEFINES))
|
||||
AOS_SDK_CFLAGS +=$(GLOBAL_CFLAGS)
|
||||
AOS_SDK_CXXFLAGS +=$(GLOBAL_CXXFLAGS)
|
||||
AOS_SDK_ASMFLAGS +=$(GLOBAL_ASMFLAGS)
|
||||
AOS_SDK_LDFLAGS +=$(GLOBAL_LDFLAGS)
|
||||
AOS_SDK_LDS_FILES +=$(GLOBAL_LDS_FILES)
|
||||
AOS_SDK_LDS_INCLUDES +=$(GLOBAL_LDS_INCLUDES)
|
||||
AOS_SDK_CHIP_SPECIFIC_SCRIPT += $(CHIP_SPECIFIC_SCRIPT)
|
||||
AOS_SDK_CONVERTER_OUTPUT_FILE += $(CONVERTER_OUTPUT_FILE)
|
||||
AOS_SDK_FINAL_OUTPUT_FILE += $(BIN_OUTPUT_FILE)
|
||||
|
||||
AOS_SDK_IMG1_XIP1_LD_FILE +=$(AOS_IMG1_XIP1_LD_FILE)
|
||||
AOS_SDK_IMG2_XIP2_LD_FILE +=$(AOS_IMG2_XIP2_LD_FILE)
|
||||
$(eval PROCESSED_COMPONENTS += $(NAME))
|
||||
$(eval $(NAME)_SOURCES := $(sort $($(NAME)_SOURCES)) )
|
||||
|
||||
endef
|
||||
|
||||
|
||||
#####################################################################################
|
||||
# Macro PROCESS_COMPONENT
|
||||
# $(1) is the list of components left to process. $(COMP) is set as the first element in the list
|
||||
define PROCESS_COMPONENT
|
||||
AOS_SDK_DEFINES += MCU_FAMILY=\"$(PLATFORM_MCU_BOARD)\"
|
||||
$(foreach TMP_COMP, $(REAL_COMPONENTS_LOCS),$(call PROCESS_ONE_COMPONENT, $(TMP_COMP)))
|
||||
endef
|
||||
|
||||
##################################
|
||||
# Start of processing
|
||||
##################################
|
||||
|
||||
# Separate the build string into components
|
||||
COMPONENTS := $(subst @, ,$(MAKECMDGOALS))
|
||||
|
||||
|
||||
ifneq (,$(filter mk3060,$(COMPONENTS)))
|
||||
ifneq (,$(filter bootloader,$(COMPONENTS)))
|
||||
$(error mk3060 doesn't support bootlaoder option)
|
||||
endif
|
||||
endif
|
||||
|
||||
#Dependency python dict start
|
||||
DEPENDENCY := "{
|
||||
|
||||
BUILD_TYPE_LIST := debug \
|
||||
release_log \
|
||||
release
|
||||
|
||||
# Extract out: the debug/release option, OTA option, and the lint option
|
||||
BUILD_TYPE := $(if $(filter $(BUILD_TYPE_LIST),$(COMPONENTS)),$(firstword $(filter $(BUILD_TYPE_LIST),$(COMPONENTS))),release_log)
|
||||
COMPONENTS := $(filter-out $(BUILD_TYPE_LIST), $(COMPONENTS))
|
||||
|
||||
# Set debug/release specific options
|
||||
ifeq ($(BUILD_TYPE),release)
|
||||
AOS_SDK_LDFLAGS += $(COMPILER_SPECIFIC_RELEASE_LDFLAGS)
|
||||
else
|
||||
AOS_SDK_LDFLAGS += $(COMPILER_SPECIFIC_DEBUG_LDFLAGS)
|
||||
endif
|
||||
|
||||
|
||||
# Check if there are any unknown components; output error if so.
|
||||
$(foreach comp, $(COMPONENTS), $(if $(wildcard $(APPDIR)/$(comp) $(CUBE_AOS_DIR)/$(comp) $(foreach dir, $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(subst .,/,$(comp)) ) ),,$(error Unknown component: $(comp))))
|
||||
|
||||
# Find the matching platform and application from the build string components
|
||||
PLATFORM_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(SOURCE_ROOT)board/$(comp)),$(comp),)))
|
||||
APP_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(APPDIR)/$(comp) $(SOURCE_ROOT)example/$(comp) $(SOURCE_ROOT)$(comp)),$(comp),)))
|
||||
|
||||
PLATFORM :=$(notdir $(PLATFORM_FULL))
|
||||
APP :=$(notdir $(APP_FULL))
|
||||
|
||||
PLATFORM_DIRECTORY := $(PLATFORM_FULL)
|
||||
|
||||
EXTRA_CFLAGS := -DAOS_SDK_VERSION_MAJOR=$(AOS_SDK_VERSION_MAJOR) \
|
||||
-DAOS_SDK_VERSION_MINOR=$(AOS_SDK_VERSION_MINOR) \
|
||||
-DAOS_SDK_VERSION_REVISION=$(AOS_SDK_VERSION_REVISION) \
|
||||
-I$(OUTPUT_DIR)/resources/ \
|
||||
-DPLATFORM=$(SLASH_QUOTE_START)$$(PLATFORM)$(SLASH_QUOTE_END)
|
||||
|
||||
# Load platform makefile to make variables like WLAN_CHIP, HOST_OPENOCD & HOST_ARCH available to all makefiles
|
||||
$(eval CURDIR := $(SOURCE_ROOT)board/$(PLATFORM_DIRECTORY)/)
|
||||
|
||||
include $(SOURCE_ROOT)board/$(PLATFORM_DIRECTORY)/$(notdir $(PLATFORM_DIRECTORY)).mk
|
||||
|
||||
PLATFORM_MCU_BOARD :=$(subst .,/,$(HOST_MCU_FAMILY))
|
||||
PLATFORM_MCU_BD :=$(subst ., ,$(HOST_MCU_FAMILY))
|
||||
PLATFORM_MCU_MK :=$(if ($(words $(PLATFORM_MCU_BD)):1= $(PLATFORM_MCU_BD)),$(word $(words $(PLATFORM_MCU_BD)),$(PLATFORM_MCU_BD)))
|
||||
|
||||
$(eval CURDIR := $(SOURCE_ROOT)/platform/mcu/$(PLATFORM_MCU_BOARD)/)
|
||||
include $(SOURCE_ROOT)platform/mcu/$(PLATFORM_MCU_BOARD)/$(PLATFORM_MCU_MK).mk
|
||||
MAIN_COMPONENT_PROCESSING :=1
|
||||
|
||||
# Now we know the target architecture - include all toolchain makefiles and check one of them can handle the architecture
|
||||
CC :=
|
||||
|
||||
ifeq ($(COMPILER),armcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_iar.mk
|
||||
else
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
endif
|
||||
|
||||
ifndef CC
|
||||
$(error No matching toolchain found for architecture $(HOST_ARCH))
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# Process all the components + AOS
|
||||
|
||||
COMPONENTS += platform/mcu/$(PLATFORM_MCU_BOARD) vcall init
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
COMPONENTS += auto_component
|
||||
endif
|
||||
|
||||
ifeq ($(BINS),app)
|
||||
COMPONENTS += syscall_kapi syscall_fapi ksyscall fsyscall
|
||||
AOS_SDK_INCLUDES += -I$(OUTPUT_DIR)/syscall/syscall_kapi -I$(OUTPUT_DIR)/syscall/syscall_fapi
|
||||
AOS_SDK_DEFINES += BUILD_APP
|
||||
AOS_SDK_LDFLAGS += -Wl,-wrap,vprintf -Wl,-wrap,fflush
|
||||
else ifeq ($(BINS),framework)
|
||||
COMPONENTS += fsyscall syscall_kapi ksyscall
|
||||
AOS_SDK_DEFINES += BUILD_FRAMEWORK
|
||||
AOS_SDK_INCLUDES += -I$(OUTPUT_DIR)/syscall/syscall_kapi -I$(OUTPUT_DIR)/syscall/syscall_fapi
|
||||
AOS_SDK_LDFLAGS += -Wl,-wrap,vprintf -Wl,-wrap,fflush
|
||||
else ifeq ($(BINS),kernel)
|
||||
COMPONENTS += ksyscall
|
||||
AOS_SDK_DEFINES += BUILD_KERNEL
|
||||
AOS_SDK_INCLUDES += -I$(OUTPUT_DIR)/syscall/syscall_kapi
|
||||
else ifeq (,$(BINS))
|
||||
AOS_SDK_DEFINES += BUILD_BIN
|
||||
endif
|
||||
|
||||
ALL_MAKEFILES :=
|
||||
ifneq ($(CUBE_MAKEFILE), )
|
||||
include $(CUBE_MAKEFILE)
|
||||
COMPONENTS += $(CUBE_ADD_COMPONENTS)
|
||||
COMPONENT_DIRECTORIES += $(CUBE_AOS_DIR)
|
||||
endif
|
||||
|
||||
CURDIR :=
|
||||
$(info processing components: $(COMPONENTS))
|
||||
$(eval $(call FIND_COMPONENT, $(COMPONENTS)))
|
||||
#$(error stop Intentionally !)
|
||||
# remove repeat component
|
||||
$(eval COMPONENTS := $(sort $(COMPONENTS)) )
|
||||
$(eval $(call PROCESS_COMPONENT, $(PROCESSED_COMPONENTS_LOCS)))
|
||||
|
||||
PLATFORM :=$(notdir $(PLATFORM_FULL))
|
||||
|
||||
# Add some default values
|
||||
AOS_SDK_INCLUDES += -I$(SOURCE_ROOT)include -I$(SOURCE_ROOT)example/$(APP_FULL)
|
||||
AOS_SDK_DEFINES += $(EXTERNAL_AOS_GLOBAL_DEFINES)
|
||||
|
||||
ALL_RESOURCES := $(sort $(foreach comp,$(PROCESSED_COMPONENTS),$($(comp)_RESOURCES_EXPANDED)))
|
||||
|
||||
# Make sure the user has specified a component from each category
|
||||
$(if $(PLATFORM),,$(error No platform specified. Options are: $(notdir $(wildcard board/*))))
|
||||
$(if $(APP),,$(error No application specified. Options are: $(notdir $(wildcard example/*))))
|
||||
|
||||
# Make sure a WLAN_CHIP, WLAN_CHIP_REVISION, WLAN_CHIP_FAMILY and HOST_OPENOCD have been defined
|
||||
#$(if $(WLAN_CHIP),,$(error No WLAN_CHIP has been defined))
|
||||
#$(if $(WLAN_CHIP_REVISION),,$(error No WLAN_CHIP_REVISION has been defined))
|
||||
#$(if $(WLAN_CHIP_FAMILY),,$(error No WLAN_CHIP_FAMILY has been defined))
|
||||
$(if $(HOST_OPENOCD),,$(error No HOST_OPENOCD has been defined))
|
||||
|
||||
VALID_PLATFORMS :=
|
||||
INVALID_PLATFORMS :=
|
||||
|
||||
$(eval VALID_PLATFORMS := $(call EXPAND_WILDCARD_PLATFORMS,$(VALID_PLATFORMS)))
|
||||
$(eval INVALID_PLATFORMS := $(call EXPAND_WILDCARD_PLATFORMS,$(INVALID_PLATFORMS)))
|
||||
|
||||
# Check for valid platform, OSNS combination, build type, image type and bus
|
||||
$(eval $(if $(VALID_PLATFORMS), $(if $(filter $(VALID_PLATFORMS),$(PLATFORM)),,$(error $(APP) application does not support $(PLATFORM) platform)),))
|
||||
$(eval $(if $(INVALID_PLATFORMS), $(if $(filter $(INVALID_PLATFORMS),$(PLATFORM)),$(error $(APP) application does not support $(PLATFORM) platform)),))
|
||||
$(eval $(if $(VALID_BUILD_TYPES), $(if $(filter $(VALID_BUILD_TYPES),$(BUILD_TYPE)),,$(error $(APP) application does not support $(BUILD_TYPE) build)),))
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
#Dependency python dict end
|
||||
DEPENDENCY += }"
|
||||
#Call python script
|
||||
$(eval DEPENDENCY = $(shell $(COMPONENT_DEPENDENCY) $(OUTPUT_DIR) $(DEPENDENCY)))
|
||||
|
||||
REMOVE_FIRST = $(wordlist 2,$(words $(1)),$(1))
|
||||
|
||||
EXTRA_TARGET_MAKEFILES :=$(call unique,$(EXTRA_TARGET_MAKEFILES))
|
||||
$(foreach makefile_name,$(EXTRA_TARGET_MAKEFILES),$(eval include $(makefile_name)))
|
||||
|
||||
$(CONFIG_FILE_DIR):
|
||||
$(QUIET)$(call MKDIR, $@)
|
||||
|
||||
endif
|
||||
# Summarize all the information into the config file
|
||||
|
||||
|
||||
# Fill out full CFLAGS - done here to allow late expansion of macros
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CFLAGS_ALL := $(call ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS,$($(comp)_OPTIM_CFLAGS))) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CFLAGS_ALL += $(EXTRA_CFLAGS)) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CFLAGS_ALL += $($(comp)_CFLAGS)) )
|
||||
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CXXFLAGS_ALL := $(call ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS,$($(comp)_OPTIM_CXXFLAGS))) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CXXFLAGS_ALL += $(EXTRA_CFLAGS)) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CXXFLAGS_ALL += $($(comp)_CXXFLAGS)) )
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
# select the prebuilt libraries
|
||||
ifeq (app, $(BINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(if $($(comp)_TYPE), $(if $(filter app app&framework app&kernel share, $($(comp)_TYPE)),$(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
else ifeq (framework, $(BINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(if $(filter framework app&framework framework&kernel share, $($(comp)_TYPE)), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
else ifeq (kernel, $(BINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(if $(filter kernel app&kernel framework&kernel share, $($(comp)_TYPE)), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
else ifeq (, $(BINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY)))
|
||||
endif
|
||||
|
||||
AOS_SDK_LINK_FILES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(comp)),$($(comp)_LINK_FILES)))
|
||||
AOS_SDK_UNIT_TEST_SOURCES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $($(comp)_LOCATION),$($(comp)_UNIT_TEST_SOURCES)))
|
||||
|
||||
ifeq ($(ADD_UNIT_TESTS_TO_LINK_FILES),1)
|
||||
AOS_SDK_LINK_FILES += $(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(patsubst %.c,%.o, $(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(comp)),$($(comp)_UNIT_TEST_SOURCES))) )))
|
||||
endif
|
||||
|
||||
|
||||
# Build target, generate config file
|
||||
.PHONY: $(MAKECMDGOALS)
|
||||
$(MAKECMDGOALS): $(CONFIG_FILE) $(TOOLCHAIN_HOOK_TARGETS)
|
||||
|
||||
$(CONFIG_FILE): $(AOS_SDK_MAKEFILES) | $(CONFIG_FILE_DIR)
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $(CONFIG_FILE) ,AOS_SDK_MAKEFILES += $(AOS_SDK_MAKEFILES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,TOOLCHAIN_NAME := $(TOOLCHAIN_NAME))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LDFLAGS += $(strip $(AOS_SDK_LDFLAGS)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LDS_FILES += $(strip $(AOS_SDK_LDS_FILES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LDS_INCLUDES += $(strip $(AOS_SDK_LDS_INCLUDES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_IMG1_XIP1_LD_FILE += $(strip $(AOS_SDK_IMG1_XIP1_LD_FILE)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_IMG2_XIP2_LD_FILE += $(strip $(AOS_SDK_IMG2_XIP2_LD_FILE)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,RESOURCE_CFLAGS += $(strip $(AOS_SDK_CFLAGS)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LINK_SCRIPT += $(strip $(if $(strip $(AOS_SDK_LINK_SCRIPT)),$(AOS_SDK_LINK_SCRIPT),$(AOS_SDK_DEFAULT_LINK_SCRIPT))))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LINK_SCRIPT_CMD += $(call COMPILER_SPECIFIC_LINK_SCRIPT,$(strip $(if $(strip $(AOS_SDK_LINK_SCRIPT)),$(AOS_SDK_LINK_SCRIPT),$(AOS_SDK_DEFAULT_LINK_SCRIPT)))))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_PREBUILT_LIBRARIES += $(strip $(AOS_SDK_PREBUILT_LIBRARIES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_CERTIFICATES += $(strip $(AOS_SDK_CERTIFICATES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_PRE_APP_BUILDS += $(strip $(PRE_APP_BUILDS)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LINK_FILES += $(AOS_SDK_LINK_FILES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_INCLUDES += $(call unique,$(AOS_SDK_INCLUDES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_DEFINES += $(call unique,$(strip $(addprefix -D,$(AOS_SDK_DEFINES)))))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,COMPONENTS := $(PROCESSED_COMPONENTS))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PLATFORM_DIRECTORY := $(PLATFORM_DIRECTORY))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APP_FULL := $(APP_FULL))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PLATFORM := $(PLATFORM))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,HOST_MCU_FAMILY := $(HOST_MCU_FAMILY))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,SUPPORT_BINS := $(SUPPORT_BINS))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APP := $(APP))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,HOST_OPENOCD := $(HOST_OPENOCD))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,JTAG := $(JTAG))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,HOST_ARCH := $(HOST_ARCH))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,NO_BUILD_BOOTLOADER := $(NO_BUILD_BOOTLOADER))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,NO_BOOTLOADER_REQUIRED := $(NO_BOOTLOADER_REQUIRED))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_LOCATION := $($(comp)_LOCATION)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_SOURCES += $($(comp)_SOURCES)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_CHECK_HEADERS += $($(comp)_CHECK_HEADERS)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_INCLUDES := $(addprefix -I$($(comp)_LOCATION),$($(comp)_INCLUDES))))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_DEFINES := $(addprefix -D,$($(comp)_DEFINES))))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_CFLAGS := $(AOS_SDK_CFLAGS) $($(comp)_CFLAGS_ALL)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_CXXFLAGS := $(AOS_SDK_CXXFLAGS) $($(comp)_CXXFLAGS_ALL)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_ASMFLAGS := $(AOS_SDK_ASMFLAGS) $($(comp)_ASMFLAGS)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_RESOURCES := $($(comp)_RESOURCES_EXPANDED)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_MAKEFILE := $($(comp)_MAKEFILE)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_PRE_BUILD_TARGETS:= $($(comp)_PRE_BUILD_TARGETS)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_PREBUILT_LIBRARY := $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_TYPE := $($(comp)_TYPE)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_SELF_BUIlD_COMP_targets := $($(comp)_SELF_BUIlD_COMP_targets)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_SELF_BUIlD_COMP_scripts := $($(comp)_SELF_BUIlD_COMP_scripts)))
|
||||
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_UNIT_TEST_SOURCES := $(AOS_SDK_UNIT_TEST_SOURCES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,ALL_RESOURCES := $(call unique,$(ALL_RESOURCES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,INTERNAL_MEMORY_RESOURCES := $(call unique,$(INTERNAL_MEMORY_RESOURCES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,EXTRA_TARGET_MAKEFILES := $(EXTRA_TARGET_MAKEFILES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APPS_START_SECTOR := $(APPS_START_SECTOR) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,BOOTLOADER_FIRMWARE := $(BOOTLOADER_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,ATE_FIRMWARE := $(ATE_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APPLICATION_FIRMWARE := $(APPLICATION_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PARAMETER_1_IMAGE := $(PARAMETER_1_IMAGE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PARAMETER_2_IMAGE := $(PARAMETER_2_IMAGE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,FILESYSTEM_IMAGE := $(FILESYSTEM_IMAGE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,WIFI_FIRMWARE := $(WIFI_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,BT_PATCH_FIRMWARE := $(BT_PATCH_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_ROM_SYMBOL_LIST_FILE := $(AOS_ROM_SYMBOL_LIST_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_CHIP_SPECIFIC_SCRIPT := $(AOS_SDK_CHIP_SPECIFIC_SCRIPT))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_CONVERTER_OUTPUT_FILE := $(AOS_SDK_CONVERTER_OUTPUT_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_FINAL_OUTPUT_FILE := $(AOS_SDK_FINAL_OUTPUT_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_RAM_STUB_LIST_FILE := $(AOS_RAM_STUB_LIST_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PING_PONG_OTA := $(PING_PONG_OTA))
|
||||
endif
|
||||
|
||||
CONFIG_PY_FILE := build/scripts/config_mk.py
|
||||
|
||||
# write a component name in python format
|
||||
define WRITE_COMPOENT_PY
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,{'name':'$(comp)'$(COMMA) )
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'src':[ )
|
||||
$(eval SOURCES_FULLPATH := $(addprefix $($(comp)_LOCATION), $($(comp)_SOURCES)))
|
||||
$(foreach src,$(SOURCES_FULLPATH), $(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'$(src)'$(COMMA)))
|
||||
$(eval LIB_FULLPATH := $(addprefix $($(comp)_LOCATION), $($(comp)_PREBUILT_LIBRARY)))
|
||||
$(foreach complib,$(LIB_FULLPATH), $(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'$(complib)'$(COMMA)))
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,]$(COMMA))
|
||||
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'include':[ )
|
||||
$(eval INCLUDE_FULLPATH := $(addprefix $($(comp)_LOCATION),$($(comp)_INCLUDES)) )
|
||||
$(eval INCLUDE_FULLPATH += $(subst -I.,.,$(call unique,$(AOS_SDK_INCLUDES))) )
|
||||
$(foreach inc,$(INCLUDE_FULLPATH), $(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'$(inc)'$(COMMA)))
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,]$(COMMA))
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,}$(COMMA))
|
||||
endef
|
||||
|
||||
PROJ_GEN_DIR := projects/autogen/$(CLEANED_BUILD_STRING)
|
||||
|
||||
ifeq ($(IDE),iar)
|
||||
PROJECT_GEN := $(PROJ_GEN_DIR)/iar_project/$(CLEANED_BUILD_STRING).ewp
|
||||
$(MAKECMDGOALS): $(PROJECT_GEN)
|
||||
$(PROJECT_GEN): build/scripts/iar.py build/aos_target_config.mk $(CONFIG_FILE)
|
||||
$(QUIET)echo Making $(IDE) Project
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $(CONFIG_PY_FILE) ,Projects = [)
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_COMPOENT_PY ))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,])
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/iar_project)
|
||||
$(QUIET)cp -f build/scripts/template.ewd $(PROJ_GEN_DIR)/iar_project/$(CLEANED_BUILD_STRING).ewd
|
||||
python build/scripts/iar.py $(CLEANED_BUILD_STRING)
|
||||
$(QUIET)echo ----------- iar project has generated in $(PROJ_GEN_DIR)/iar_project -----------
|
||||
endif
|
||||
|
||||
ifeq ($(IDE),keil)
|
||||
PROJECT_GEN := $(PROJ_GEN_DIR)/keil_project/$(CLEANED_BUILD_STRING).uvprojx
|
||||
$(MAKECMDGOALS): $(PROJECT_GEN)
|
||||
$(PROJECT_GEN): build/scripts/keil.py build/aos_target_config.mk $(CONFIG_FILE)
|
||||
$(QUIET)echo Making $(IDE) Project
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $(CONFIG_PY_FILE) ,Projects = [)
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_COMPOENT_PY ))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,])
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/keil_project)
|
||||
python build/scripts/keil.py $(CLEANED_BUILD_STRING)
|
||||
$(QUIET)echo ----------- keil project has generated in $(PROJ_GEN_DIR)/keil_project -----------
|
||||
endif
|
||||
|
||||
491
Living_SDK/build/aos_target_config_mbins.mk
Normal file
491
Living_SDK/build/aos_target_config_mbins.mk
Normal file
|
|
@ -0,0 +1,491 @@
|
|||
include $(MAKEFILES_PATH)/aos_host_cmd.mk
|
||||
|
||||
APPDIR ?=
|
||||
CONFIG_FILE_DIR := $(OUTPUT_DIR)
|
||||
CONFIG_FILE := $(CONFIG_FILE_DIR)/config.mk
|
||||
|
||||
|
||||
COMPONENT_DIRECTORIES := . \
|
||||
example \
|
||||
board \
|
||||
kernel \
|
||||
platform \
|
||||
utility \
|
||||
framework \
|
||||
tools \
|
||||
test \
|
||||
device \
|
||||
security \
|
||||
app
|
||||
|
||||
TEST_COMPONENT_DIRECTORIES := test
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
COMPONENT_DIRECTORIES += $(OUTPUT_DIR)/syscall
|
||||
COMPONENT_DIRECTORIES += $(OUTPUT_DIR)
|
||||
endif
|
||||
|
||||
COMPONENT_DIRECTORIES += $(APPDIR)
|
||||
|
||||
AOS_SDK_VERSION ?= $(AOS_SDK_VERSION_MAJOR).$(AOS_SDK_VERSION_MINOR).$(AOS_SDK_VERSION_REVISION)
|
||||
|
||||
##################################
|
||||
# Macros
|
||||
##################################
|
||||
|
||||
# $(1) is component
|
||||
GET_BARE_LOCATION =$(patsubst $(call ESCAPE_BACKSLASHES,$(SOURCE_ROOT))%,%,$(strip $($(1)_LOCATION)))
|
||||
|
||||
define PREPROCESS_TEST_COMPONENT
|
||||
$(if $(filter yts,$(COMPONENTS)), \
|
||||
$(if $(test), $(eval TEST_COMPONENTS := $(strip $(subst $(COMMA), $(SPACE), $(test)))),) \
|
||||
$(if $(TEST_COMPONENTS), $(call RECURSE_DIR_COMPONENT_SEARCH, $(patsubst %/,%,$(TEST_COMPONENT_DIRECTORIES)), TEST_COMPONENT_LIST) \
|
||||
$(eval TEST_COMPONENTS := $(addprefix %., $(addsuffix _test, $(TEST_COMPONENTS)))) \
|
||||
$(eval COMPONENTS += $(filter $(TEST_COMPONENTS), $(subst /,.,$(strip $(TEST_COMPONENT_LIST)))))))
|
||||
endef
|
||||
|
||||
#####################################################################################
|
||||
# Macro FIND_COMPONENT use breadth traversal to search component
|
||||
# $(1) is the list of components left to process. $(COMP) is set as the first element in the list
|
||||
define FIND_COMPONENT
|
||||
|
||||
$(eval COMP := $(word 1,$(1)))
|
||||
$(eval COMP_LOCATION := $(subst .,/,$(COMP)))
|
||||
$(eval COMP_MAKEFILE_NAME := $(notdir $(COMP_LOCATION)))
|
||||
# Find the component makefile in directory list
|
||||
$(eval TEMP_MAKEFILE := $(strip $(wildcard $(foreach dir, $(if $(filter-out out, $(BUILD_DIR)),$(OUTPUT_DIR) $(OUTPUT_DIR)/syscall,) $(if $(APPDIR),$(APPDIR),) $(if $(CUBE_AOS_DIR),$(CUBE_AOS_DIR) $(CUBE_AOS_DIR)/remote,) $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(COMP_LOCATION)/$(COMP_MAKEFILE_NAME).mk))))
|
||||
# Check if component makefile was found - if not try downloading it and re-doing the makefile search
|
||||
$(if $(TEMP_MAKEFILE),,\
|
||||
$(info Unknown component: $(COMP) - directory or makefile for component not found. Ensure the $(COMP_LOCATION) directory contains $(COMP_MAKEFILE_NAME).mk) \
|
||||
$(info Below is a list of valid local components (Some are internal): ) \
|
||||
$(call FIND_VALID_COMPONENTS, VALID_COMPONENT_LIST,$(COMPONENT_DIRECTORIES)) \
|
||||
$(foreach comp,$(VALID_COMPONENT_LIST),$(info $(comp))) \
|
||||
$(info Below is a list of valid components from the internet: ) \
|
||||
$(info $(call DOWNLOAD_COMPONENT_LIST)) \
|
||||
$(error Unknown component: $(COMP) - directory or makefile for component not found. Ensure the $(COMP_LOCATION) directory contains $(COMP_MAKEFILE_NAME).mk))
|
||||
$(if $(filter 1,$(words $(TEMP_MAKEFILE))),,$(error More than one component with the name "$(COMP)". See $(TEMP_MAKEFILE)))
|
||||
|
||||
$(eval TEMP_MAKEFILE := $(subst ././,./,$(TEMP_MAKEFILE)))
|
||||
$(eval include $(TEMP_MAKEFILE))
|
||||
$(eval deps :=)
|
||||
$(eval deps_src := $($(NAME)_COMPONENTS))
|
||||
$(eval components_cube := $(subst .,/,$(COMPONENTS)))
|
||||
$(eval deps_cube := $(subst .,/,$($(NAME)_COMPONENTS)))
|
||||
|
||||
$(foreach dep, $(deps_cube),\
|
||||
$(eval comp_dep := $(firstword $(deps_src))) \
|
||||
$(eval find := 0) \
|
||||
$(foreach component, $(components_cube) $(CUBE_REMOVE_COMPONENTS), \
|
||||
$(if $(filter $(notdir $(dep)),$(notdir $(component))), \
|
||||
$(if $(findstring $(dep), $(component)),$(eval find := 1))))\
|
||||
$(if $(filter 0, $(find)), $(eval deps += $(comp_dep))) \
|
||||
$(eval deps_src := $(filter-out $(comp_dep),$(deps_src))))
|
||||
|
||||
$(if $(findstring $(TEMP_MAKEFILE),$(ALL_MAKEFILES)),,\
|
||||
$(eval ALL_MAKEFILES += $(TEMP_MAKEFILE)) \
|
||||
$(eval COMPONENTS += $(deps)) \
|
||||
$(call PREPROCESS_TEST_COMPONENT, $(COMPONENTS), $(TEST_COMPONENTS)) \
|
||||
DEPENDENCY += '$(NAME)': '$($(NAME)_COMPONENTS)',)
|
||||
|
||||
$(eval PROCESSED_COMPONENTS_LOCS += $(COMP))
|
||||
$(if $(strip $(filter-out $(PROCESSED_COMPONENTS_LOCS),$(COMPONENTS))),\
|
||||
$(call FIND_COMPONENT,$(filter-out $(PROCESSED_COMPONENTS_LOCS),$(COMPONENTS))),\
|
||||
)
|
||||
endef
|
||||
|
||||
#####################################################################################
|
||||
# Macro PROCESS_ONE_COMPONENT
|
||||
# $(1) is one component
|
||||
define PROCESS_ONE_COMPONENT
|
||||
$(eval COMP := $(1))
|
||||
$(eval COMP_LOCATION := $(subst .,/,$(COMP)))
|
||||
$(eval COMP_MAKEFILE_NAME := $(notdir $(COMP_LOCATION)))
|
||||
# Find the component makefile in directory list
|
||||
$(eval TEMP_MAKEFILE := $(strip $(wildcard $(foreach dir, $(if $(filter-out out, $(BUILD_DIR)),$(OUTPUT_DIR) $(OUTPUT_DIR)/syscall,) $(if $(APPDIR),$(APPDIR)/$(comp),) $(if $(CUBE_AOS_DIR),$(CUBE_AOS_DIR) $(CUBE_AOS_DIR)/remote) $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(COMP_LOCATION)/$(COMP_MAKEFILE_NAME).mk))))
|
||||
|
||||
# Clear all the temporary variables
|
||||
$(eval GLOBAL_INCLUDES:=)
|
||||
$(eval GLOBAL_LINK_SCRIPT:=)
|
||||
$(eval DEFAULT_LINK_SCRIPT:=)
|
||||
$(eval DCT_LINK_SCRIPT:=)
|
||||
$(eval GLOBAL_DEFINES:=)
|
||||
$(eval GLOBAL_CFLAGS:=)
|
||||
$(eval GLOBAL_CXXFLAGS:=)
|
||||
$(eval GLOBAL_ASMFLAGS:=)
|
||||
$(eval GLOBAL_LDFLAGS:=)
|
||||
$(eval GLOBAL_LDS_FILES:=)
|
||||
$(eval GLOBAL_LDS_INCLUDES:=)
|
||||
$(eval GLOBAL_CERTIFICATES:=)
|
||||
$(eval WIFI_CONFIG_DCT_H:=)
|
||||
$(eval BT_CONFIG_DCT_H:=)
|
||||
$(eval APPLICATION_DCT:=)
|
||||
$(eval CERTIFICATE:=)
|
||||
$(eval PRIVATE_KEY:=)
|
||||
$(eval CHIP_SPECIFIC_SCRIPT:=)
|
||||
$(eval CONVERTER_OUTPUT_FILE:=)
|
||||
$(eval BIN_OUTPUT_FILE:=)
|
||||
$(eval OLD_CURDIR := $(CURDIR))
|
||||
$(eval CURDIR := $(CURDIR)$(dir $(TEMP_MAKEFILE)))
|
||||
$(eval TEST_COMPONENTS :=)
|
||||
|
||||
# Cache the last valid RTOS/NS combination for iterative filtering.
|
||||
$(eval TEMP_VALID_OSNS_COMBOS := $(VALID_OSNS_COMBOS))
|
||||
|
||||
# Include the component makefile - This defines the NAME variable
|
||||
$(eval include $(TEMP_MAKEFILE))
|
||||
|
||||
# Filter the valid RTOS/NS combination to the least-common set.
|
||||
$(eval VALID_OSNS_COMBOS :=\
|
||||
$(if $(VALID_OSNS_COMBOS),\
|
||||
$(filter $(VALID_OSNS_COMBOS),$(TEMP_VALID_OSNS_COMBOS)),\
|
||||
$(TEMP_VALID_OSNS_COMBOS)\
|
||||
)\
|
||||
)
|
||||
|
||||
$(eval $(NAME)_MAKEFILE :=$(TEMP_MAKEFILE))
|
||||
|
||||
# Expand the list of resources to point to the full location (either component local or the common resources directory)
|
||||
$(eval $(NAME)_RESOURCES_EXPANDED := $(foreach res,$($(NAME)_RESOURCES),$(word 1,$(wildcard $(addsuffix $(res),$(CURDIR) $(SOURCE_ROOT)resources/)))))
|
||||
|
||||
$(eval CURDIR := $(OLD_CURDIR))
|
||||
|
||||
$(eval $(NAME)_LOCATION := $(dir $(TEMP_MAKEFILE)))
|
||||
$(eval $(NAME)_MAKEFILE := $(TEMP_MAKEFILE))
|
||||
AOS_SDK_MAKEFILES += $($(NAME)_MAKEFILE)
|
||||
|
||||
# Set debug/release specific options
|
||||
$(eval $(NAME)_BUILD_TYPE := $(BUILD_TYPE))
|
||||
$(eval $(NAME)_BUILD_TYPE := $(if $($(NAME)_NEVER_OPTIMISE), debug, $($(NAME)_BUILD_TYPE)))
|
||||
$(eval $(NAME)_BUILD_TYPE := $(if $($(NAME)_ALWAYS_OPTIMISE), release, $($(NAME)_BUILD_TYPE)))
|
||||
|
||||
$(NAME)_ASMFLAGS += $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_ASFLAGS), $(COMPILER_SPECIFIC_RELEASE_ASFLAGS))
|
||||
$(NAME)_LDFLAGS += $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_LDFLAGS), $(COMPILER_SPECIFIC_RELEASE_LDFLAGS))
|
||||
|
||||
$(NAME)_OPTIM_CFLAGS ?= $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_CFLAGS), $(if $(findstring release_log,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS), $(COMPILER_SPECIFIC_RELEASE_CFLAGS)))
|
||||
|
||||
$(NAME)_OPTIM_CXXFLAGS ?= $(if $(findstring debug,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_DEBUG_CXXFLAGS), $(if $(findstring release_log,$($(NAME)_BUILD_TYPE)), $(COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS), $(COMPILER_SPECIFIC_RELEASE_CXXFLAGS)))
|
||||
|
||||
AOS_SDK_INCLUDES +=$(addprefix -I$($(NAME)_LOCATION),$(GLOBAL_INCLUDES))
|
||||
AOS_SDK_LINK_SCRIPT +=$(if $(GLOBAL_LINK_SCRIPT),$(GLOBAL_LINK_SCRIPT),)
|
||||
AOS_SDK_DEFAULT_LINK_SCRIPT+=$(if $(DEFAULT_LINK_SCRIPT),$(addprefix $($(NAME)_LOCATION),$(DEFAULT_LINK_SCRIPT)),)
|
||||
AOS_SDK_DEFINES +=$(GLOBAL_DEFINES)
|
||||
AOS_SDK_CFLAGS +=$(GLOBAL_CFLAGS)
|
||||
AOS_SDK_CXXFLAGS +=$(GLOBAL_CXXFLAGS)
|
||||
AOS_SDK_ASMFLAGS +=$(GLOBAL_ASMFLAGS)
|
||||
AOS_SDK_LDFLAGS +=$(GLOBAL_LDFLAGS)
|
||||
AOS_SDK_LDS_FILES +=$(GLOBAL_LDS_FILES)
|
||||
AOS_SDK_LDS_INCLUDES +=$(GLOBAL_LDS_INCLUDES)
|
||||
AOS_SDK_CHIP_SPECIFIC_SCRIPT += $(CHIP_SPECIFIC_SCRIPT)
|
||||
AOS_SDK_CONVERTER_OUTPUT_FILE += $(CONVERTER_OUTPUT_FILE)
|
||||
AOS_SDK_FINAL_OUTPUT_FILE += $(BIN_OUTPUT_FILE)
|
||||
|
||||
$(eval PROCESSED_COMPONENTS += $(NAME))
|
||||
|
||||
$(eval $(NAME)_SOURCES := $(sort $($(NAME)_SOURCES)) )
|
||||
|
||||
endef
|
||||
|
||||
|
||||
#####################################################################################
|
||||
# Macro PROCESS_COMPONENT
|
||||
# $(1) is the list of components left to process. $(COMP) is set as the first element in the list
|
||||
define PROCESS_COMPONENT
|
||||
$(foreach TMP_COMP, $(COMPONENTS),$(call PROCESS_ONE_COMPONENT, $(TMP_COMP)))
|
||||
endef
|
||||
|
||||
##################################
|
||||
# Start of processing
|
||||
##################################
|
||||
|
||||
# Separate the build string into components
|
||||
COMPONENTS := $(subst @, ,$(MAKECMDGOALS))
|
||||
|
||||
|
||||
ifneq (,$(filter mk3060,$(COMPONENTS)))
|
||||
ifneq (,$(filter bootloader,$(COMPONENTS)))
|
||||
$(error mk3060 doesn't support bootlaoder option)
|
||||
endif
|
||||
endif
|
||||
|
||||
#Dependency python dict start
|
||||
DEPENDENCY := "{
|
||||
|
||||
BUILD_TYPE_LIST := debug \
|
||||
release_log \
|
||||
release
|
||||
|
||||
# Extract out: the debug/release option, OTA option, and the lint option
|
||||
BUILD_TYPE := $(if $(filter $(BUILD_TYPE_LIST),$(COMPONENTS)),$(firstword $(filter $(BUILD_TYPE_LIST),$(COMPONENTS))),release_log)
|
||||
COMPONENTS := $(filter-out $(BUILD_TYPE_LIST), $(COMPONENTS))
|
||||
|
||||
# Set debug/release specific options
|
||||
ifeq ($(BUILD_TYPE),release)
|
||||
AOS_SDK_LDFLAGS += $(COMPILER_SPECIFIC_RELEASE_LDFLAGS)
|
||||
else
|
||||
AOS_SDK_LDFLAGS += $(COMPILER_SPECIFIC_DEBUG_LDFLAGS)
|
||||
endif
|
||||
|
||||
|
||||
# Check if there are any unknown components; output error if so.
|
||||
$(foreach comp, $(COMPONENTS), $(if $(wildcard $(APPDIR)/$(comp) $(CUBE_AOS_DIR)/$(comp) $(foreach dir, $(addprefix $(SOURCE_ROOT),$(COMPONENT_DIRECTORIES)), $(dir)/$(subst .,/,$(comp)) ) ),,$(error Unknown component: $(comp))))
|
||||
|
||||
# Find the matching platform and application from the build string components
|
||||
PLATFORM_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(SOURCE_ROOT)board/$(comp)),$(comp),)))
|
||||
APP_FULL :=$(strip $(foreach comp,$(subst .,/,$(COMPONENTS)),$(if $(wildcard $(APPDIR)/$(comp) $(SOURCE_ROOT)example/$(comp) $(SOURCE_ROOT)$(comp)),$(comp),)))
|
||||
|
||||
PLATFORM :=$(notdir $(PLATFORM_FULL))
|
||||
APP :=$(notdir $(APP_FULL))
|
||||
|
||||
PLATFORM_DIRECTORY := $(PLATFORM_FULL)
|
||||
|
||||
EXTRA_CFLAGS := -DAOS_SDK_VERSION_MAJOR=$(AOS_SDK_VERSION_MAJOR) \
|
||||
-DAOS_SDK_VERSION_MINOR=$(AOS_SDK_VERSION_MINOR) \
|
||||
-DAOS_SDK_VERSION_REVISION=$(AOS_SDK_VERSION_REVISION) \
|
||||
-I$(OUTPUT_DIR)/resources/ \
|
||||
-DPLATFORM=$(SLASH_QUOTE_START)$$(PLATFORM)$(SLASH_QUOTE_END)
|
||||
|
||||
# Load platform makefile to make variables like WLAN_CHIP, HOST_OPENOCD & HOST_ARCH available to all makefiles
|
||||
$(eval CURDIR := $(SOURCE_ROOT)board/$(PLATFORM_DIRECTORY)/)
|
||||
|
||||
include $(SOURCE_ROOT)board/$(PLATFORM_DIRECTORY)/$(notdir $(PLATFORM_DIRECTORY)).mk
|
||||
|
||||
PLATFORM_MCU_BOARD :=$(subst .,/,$(HOST_MCU_FAMILY))
|
||||
PLATFORM_MCU_BD :=$(subst ., ,$(HOST_MCU_FAMILY))
|
||||
PLATFORM_MCU_MK :=$(if ($(words $(PLATFORM_MCU_BD)):1= $(PLATFORM_MCU_BD)),$(word $(words $(PLATFORM_MCU_BD)),$(PLATFORM_MCU_BD)))
|
||||
|
||||
$(eval CURDIR := $(SOURCE_ROOT)/platform/mcu/$(PLATFORM_MCU_BOARD)/)
|
||||
include $(SOURCE_ROOT)platform/mcu/$(PLATFORM_MCU_BOARD)/$(PLATFORM_MCU_MK).mk
|
||||
MAIN_COMPONENT_PROCESSING :=1
|
||||
|
||||
# Now we know the target architecture - include all toolchain makefiles and check one of them can handle the architecture
|
||||
CC :=
|
||||
|
||||
ifeq ($(COMPILER),armcc)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_armcc.mk
|
||||
else ifeq ($(COMPILER),iar)
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_iar.mk
|
||||
else
|
||||
include $(MAKEFILES_PATH)/aos_toolchain_gcc.mk
|
||||
endif
|
||||
|
||||
ifndef CC
|
||||
$(error No matching toolchain found for architecture $(HOST_ARCH))
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# Process all the components + AOS
|
||||
|
||||
COMPONENTS += platform/mcu/$(PLATFORM_MCU_BOARD) vcall
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
#COMPONENTS += auto_component
|
||||
endif
|
||||
|
||||
ifeq ($(MBINS),app)
|
||||
COMPONENTS += usyscall.umbins platform.mcu.pca10056.aos.app_runtime
|
||||
AOS_SDK_DEFINES += BUILD_APP
|
||||
AOS_SDK_LDFLAGS += -Wl,-wrap,vprintf -Wl,-wrap,fflush -nostartfiles
|
||||
else ifeq ($(MBINS),kernel)
|
||||
COMPONENTS += ksyscall.kmbins
|
||||
AOS_SDK_DEFINES += BUILD_KERNEL
|
||||
else ifeq (,$(MBINS))
|
||||
AOS_SDK_DEFINES += BUILD_BIN
|
||||
endif
|
||||
|
||||
ALL_MAKEFILES :=
|
||||
ifneq ($(CUBE_MAKEFILE), )
|
||||
include $(CUBE_MAKEFILE)
|
||||
COMPONENTS += $(CUBE_ADD_COMPONENTS)
|
||||
COMPONENT_DIRECTORIES += $(CUBE_AOS_DIR)
|
||||
endif
|
||||
|
||||
CURDIR :=
|
||||
$(info processing components: $(COMPONENTS))
|
||||
$(eval $(call FIND_COMPONENT, $(COMPONENTS)))
|
||||
# remove repeat component
|
||||
$(eval COMPONENTS := $(sort $(COMPONENTS)) )
|
||||
$(eval $(call PROCESS_COMPONENT, $(COMPONENTS)))
|
||||
|
||||
PLATFORM :=$(notdir $(PLATFORM_FULL))
|
||||
|
||||
# Add some default values
|
||||
AOS_SDK_INCLUDES += -I$(SOURCE_ROOT)include -I$(SOURCE_ROOT)example/$(APP_FULL)
|
||||
AOS_SDK_DEFINES += $(EXTERNAL_AOS_GLOBAL_DEFINES)
|
||||
|
||||
ALL_RESOURCES := $(sort $(foreach comp,$(PROCESSED_COMPONENTS),$($(comp)_RESOURCES_EXPANDED)))
|
||||
|
||||
# Make sure the user has specified a component from each category
|
||||
$(if $(PLATFORM),,$(error No platform specified. Options are: $(notdir $(wildcard board/*))))
|
||||
$(if $(APP),,$(error No application specified. Options are: $(notdir $(wildcard example/*))))
|
||||
|
||||
# Make sure a WLAN_CHIP, WLAN_CHIP_REVISION, WLAN_CHIP_FAMILY and HOST_OPENOCD have been defined
|
||||
#$(if $(WLAN_CHIP),,$(error No WLAN_CHIP has been defined))
|
||||
#$(if $(WLAN_CHIP_REVISION),,$(error No WLAN_CHIP_REVISION has been defined))
|
||||
#$(if $(WLAN_CHIP_FAMILY),,$(error No WLAN_CHIP_FAMILY has been defined))
|
||||
$(if $(HOST_OPENOCD),,$(error No HOST_OPENOCD has been defined))
|
||||
|
||||
$(eval VALID_PLATFORMS := $(call EXPAND_WILDCARD_PLATFORMS,$(VALID_PLATFORMS)))
|
||||
$(eval INVALID_PLATFORMS := $(call EXPAND_WILDCARD_PLATFORMS,$(INVALID_PLATFORMS)))
|
||||
|
||||
# Check for valid platform, OSNS combination, build type, image type and bus
|
||||
$(eval $(if $(VALID_PLATFORMS), $(if $(filter $(VALID_PLATFORMS),$(PLATFORM)),,$(error $(APP) application does not support $(PLATFORM) platform)),))
|
||||
$(eval $(if $(INVALID_PLATFORMS), $(if $(filter $(INVALID_PLATFORMS),$(PLATFORM)),$(error $(APP) application does not support $(PLATFORM) platform)),))
|
||||
$(eval $(if $(VALID_BUILD_TYPES), $(if $(filter $(VALID_BUILD_TYPES),$(BUILD_TYPE)),,$(error $(APP) application does not support $(BUILD_TYPE) build)),))
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
#Dependency python dict end
|
||||
DEPENDENCY += }"
|
||||
#Call python script
|
||||
$(eval DEPENDENCY = $(shell $(COMPONENT_DEPENDENCY) $(OUTPUT_DIR) $(DEPENDENCY)))
|
||||
|
||||
REMOVE_FIRST = $(wordlist 2,$(words $(1)),$(1))
|
||||
|
||||
EXTRA_TARGET_MAKEFILES :=$(call unique,$(EXTRA_TARGET_MAKEFILES))
|
||||
$(foreach makefile_name,$(EXTRA_TARGET_MAKEFILES),$(eval include $(makefile_name)))
|
||||
|
||||
$(CONFIG_FILE_DIR):
|
||||
$(QUIET)$(call MKDIR, $@)
|
||||
|
||||
endif
|
||||
# Summarize all the information into the config file
|
||||
|
||||
|
||||
# Fill out full CFLAGS - done here to allow late expansion of macros
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CFLAGS_ALL := $(call ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS,$($(comp)_OPTIM_CFLAGS))) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CFLAGS_ALL += $(EXTRA_CFLAGS)) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CFLAGS_ALL += $($(comp)_CFLAGS)) )
|
||||
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CXXFLAGS_ALL := $(call ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS,$($(comp)_OPTIM_CXXFLAGS))) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CXXFLAGS_ALL += $(EXTRA_CFLAGS)) )
|
||||
$(foreach comp,$(PROCESSED_COMPONENTS), $(eval $(comp)_CXXFLAGS_ALL += $($(comp)_CXXFLAGS)) )
|
||||
|
||||
ifneq ($(ONLY_BUILD_LIBRARY), yes)
|
||||
# select the prebuilt libraries
|
||||
ifeq (app, $(MBINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(if $($(comp)_MBINS_TYPE), $(if $(filter app share, $($(comp)_MBINS_TYPE)),$(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
else ifeq (kernel, $(MBINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(if $(filter kernel share, $($(comp)_MBINS_TYPE)), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
else ifeq (, $(MBINS))
|
||||
AOS_SDK_PREBUILT_LIBRARIES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY)))
|
||||
endif
|
||||
|
||||
AOS_SDK_LINK_FILES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(comp)),$($(comp)_LINK_FILES)))
|
||||
AOS_SDK_UNIT_TEST_SOURCES +=$(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $($(comp)_LOCATION),$($(comp)_UNIT_TEST_SOURCES)))
|
||||
|
||||
ifeq ($(ADD_UNIT_TESTS_TO_LINK_FILES),1)
|
||||
AOS_SDK_LINK_FILES += $(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(patsubst %.c,%.o, $(foreach comp,$(PROCESSED_COMPONENTS), $(addprefix $$(OUTPUT_DIR)/modules/$(call GET_BARE_LOCATION,$(comp)),$($(comp)_UNIT_TEST_SOURCES))) )))
|
||||
endif
|
||||
|
||||
|
||||
# Build target, generate config file
|
||||
.PHONY: $(MAKECMDGOALS)
|
||||
$(MAKECMDGOALS): $(CONFIG_FILE) $(TOOLCHAIN_HOOK_TARGETS)
|
||||
|
||||
$(CONFIG_FILE): $(AOS_SDK_MAKEFILES) | $(CONFIG_FILE_DIR)
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $(CONFIG_FILE) ,AOS_SDK_MAKEFILES += $(AOS_SDK_MAKEFILES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,TOOLCHAIN_NAME := $(TOOLCHAIN_NAME))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LDFLAGS += $(strip $(AOS_SDK_LDFLAGS)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LDS_FILES += $(strip $(AOS_SDK_LDS_FILES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LDS_INCLUDES += $(strip $(AOS_SDK_LDS_INCLUDES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,RESOURCE_CFLAGS += $(strip $(AOS_SDK_CFLAGS)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LINK_SCRIPT += $(strip $(if $(strip $(AOS_SDK_LINK_SCRIPT)),$(AOS_SDK_LINK_SCRIPT),$(AOS_SDK_DEFAULT_LINK_SCRIPT))))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LINK_SCRIPT_CMD += $(call COMPILER_SPECIFIC_LINK_SCRIPT,$(strip $(if $(strip $(AOS_SDK_LINK_SCRIPT)),$(AOS_SDK_LINK_SCRIPT),$(AOS_SDK_DEFAULT_LINK_SCRIPT)))))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_PREBUILT_LIBRARIES += $(strip $(AOS_SDK_PREBUILT_LIBRARIES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_CERTIFICATES += $(strip $(AOS_SDK_CERTIFICATES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_PRE_APP_BUILDS += $(strip $(PRE_APP_BUILDS)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_LINK_FILES += $(AOS_SDK_LINK_FILES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_INCLUDES += $(call unique,$(AOS_SDK_INCLUDES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_DEFINES += $(call unique,$(strip $(addprefix -D,$(AOS_SDK_DEFINES)))))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,COMPONENTS := $(PROCESSED_COMPONENTS))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PLATFORM_DIRECTORY := $(PLATFORM_DIRECTORY))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APP_FULL := $(APP_FULL))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PLATFORM := $(PLATFORM))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,HOST_MCU_FAMILY := $(HOST_MCU_FAMILY))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,SUPPORT_MBINS := $(SUPPORT_MBINS))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APP := $(APP))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,HOST_OPENOCD := $(HOST_OPENOCD))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,JTAG := $(JTAG))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,HOST_ARCH := $(HOST_ARCH))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,NO_BUILD_BOOTLOADER := $(NO_BUILD_BOOTLOADER))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,NO_BOOTLOADER_REQUIRED := $(NO_BOOTLOADER_REQUIRED))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_LOCATION := $($(comp)_LOCATION)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_SOURCES += $($(comp)_SOURCES)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_CHECK_HEADERS += $($(comp)_CHECK_HEADERS)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_INCLUDES := $(addprefix -I$($(comp)_LOCATION),$($(comp)_INCLUDES))))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_DEFINES := $(addprefix -D,$($(comp)_DEFINES))))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_CFLAGS := $(AOS_SDK_CFLAGS) $($(comp)_CFLAGS_ALL)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_CXXFLAGS := $(AOS_SDK_CXXFLAGS) $($(comp)_CXXFLAGS_ALL)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_ASMFLAGS := $(AOS_SDK_ASMFLAGS) $($(comp)_ASMFLAGS)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_RESOURCES := $($(comp)_RESOURCES_EXPANDED)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_MAKEFILE := $($(comp)_MAKEFILE)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_PRE_BUILD_TARGETS:= $($(comp)_PRE_BUILD_TARGETS)))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_PREBUILT_LIBRARY := $(addprefix $($(comp)_LOCATION),$($(comp)_PREBUILT_LIBRARY))))
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,$(comp)_MBINS_TYPE := $($(comp)_MBINS_TYPE)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_UNIT_TEST_SOURCES := $(AOS_SDK_UNIT_TEST_SOURCES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,ALL_RESOURCES := $(call unique,$(ALL_RESOURCES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,INTERNAL_MEMORY_RESOURCES := $(call unique,$(INTERNAL_MEMORY_RESOURCES)))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,EXTRA_TARGET_MAKEFILES := $(EXTRA_TARGET_MAKEFILES))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APPS_START_SECTOR := $(APPS_START_SECTOR) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,BOOTLOADER_FIRMWARE := $(BOOTLOADER_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,ATE_FIRMWARE := $(ATE_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,APPLICATION_FIRMWARE := $(APPLICATION_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PARAMETER_1_IMAGE := $(PARAMETER_1_IMAGE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,PARAMETER_2_IMAGE := $(PARAMETER_2_IMAGE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,FILESYSTEM_IMAGE := $(FILESYSTEM_IMAGE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,WIFI_FIRMWARE := $(WIFI_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,BT_PATCH_FIRMWARE := $(BT_PATCH_FIRMWARE) )
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_ROM_SYMBOL_LIST_FILE := $(AOS_ROM_SYMBOL_LIST_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_CHIP_SPECIFIC_SCRIPT := $(AOS_SDK_CHIP_SPECIFIC_SCRIPT))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_CONVERTER_OUTPUT_FILE := $(AOS_SDK_CONVERTER_OUTPUT_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_SDK_FINAL_OUTPUT_FILE := $(AOS_SDK_FINAL_OUTPUT_FILE))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_FILE) ,AOS_RAM_STUB_LIST_FILE := $(AOS_RAM_STUB_LIST_FILE))
|
||||
endif
|
||||
|
||||
CONFIG_PY_FILE := build/scripts/config_mk.py
|
||||
|
||||
# write a component name in python format
|
||||
define WRITE_COMPOENT_PY
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,{'name':'$(comp)'$(COMMA) )
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'src':[ )
|
||||
$(eval SOURCES_FULLPATH := $(addprefix $($(comp)_LOCATION), $($(comp)_SOURCES)))
|
||||
$(foreach src,$(SOURCES_FULLPATH), $(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'$(src)'$(COMMA)))
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,]$(COMMA))
|
||||
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'include':[ )
|
||||
$(eval INCLUDE_FULLPATH := $(addprefix $($(comp)_LOCATION),$($(comp)_INCLUDES)) )
|
||||
$(eval INCLUDE_FULLPATH += $(subst -I.,.,$(call unique,$(AOS_SDK_INCLUDES))) )
|
||||
$(foreach inc,$(INCLUDE_FULLPATH), $(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,'$(inc)'$(COMMA)))
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,]$(COMMA))
|
||||
$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,}$(COMMA))
|
||||
endef
|
||||
|
||||
PROJ_GEN_DIR := projects/autogen/$(CLEANED_BUILD_STRING)
|
||||
|
||||
ifeq ($(IDE),iar)
|
||||
PROJECT_GEN := $(PROJ_GEN_DIR)/iar_project/$(CLEANED_BUILD_STRING).ewp
|
||||
$(MAKECMDGOALS): $(PROJECT_GEN)
|
||||
$(PROJECT_GEN): build/scripts/iar.py build/aos_target_config.mk $(CONFIG_FILE)
|
||||
$(QUIET)echo Making $(IDE) Project
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $(CONFIG_PY_FILE) ,Projects = [)
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_COMPOENT_PY ))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,])
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/iar_project)
|
||||
$(QUIET)cp -f build/scripts/template.ewd $(PROJ_GEN_DIR)/iar_project/$(CLEANED_BUILD_STRING).ewd
|
||||
python build/scripts/iar.py $(CLEANED_BUILD_STRING)
|
||||
$(QUIET)echo ----------- iar project has generated in $(PROJ_GEN_DIR)/iar_project -----------
|
||||
endif
|
||||
|
||||
ifeq ($(IDE),keil)
|
||||
PROJECT_GEN := $(PROJ_GEN_DIR)/keil_project/$(CLEANED_BUILD_STRING).uvprojx
|
||||
$(MAKECMDGOALS): $(PROJECT_GEN)
|
||||
$(PROJECT_GEN): build/scripts/keil.py build/aos_target_config.mk $(CONFIG_FILE)
|
||||
$(QUIET)echo Making $(IDE) Project
|
||||
$(QUIET)$(call WRITE_FILE_CREATE, $(CONFIG_PY_FILE) ,Projects = [)
|
||||
$(QUIET)$(foreach comp,$(PROCESSED_COMPONENTS), $(call WRITE_COMPOENT_PY ))
|
||||
$(QUIET)$(call WRITE_FILE_APPEND, $(CONFIG_PY_FILE) ,])
|
||||
$(QUIET)$(call MKDIR, $(PROJ_GEN_DIR)/keil_project)
|
||||
python build/scripts/keil.py $(CLEANED_BUILD_STRING)
|
||||
$(QUIET)echo ----------- keil project has generated in $(PROJ_GEN_DIR)/keil_project -----------
|
||||
endif
|
||||
|
||||
301
Living_SDK/build/aos_toolchain_arm-none-eabi.mk
Normal file
301
Living_SDK/build/aos_toolchain_arm-none-eabi.mk
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
ARM_GNU_ARCH_LIST := ARM968E-S
|
||||
|
||||
THUMB_GNU_ARCH_LIST := Cortex-M0 \
|
||||
Cortex-M3 \
|
||||
Cortex-M4 \
|
||||
Cortex-M4F\
|
||||
Cortex-M7\
|
||||
Cortex-R3
|
||||
|
||||
|
||||
ifneq ($(filter $(HOST_ARCH), $(THUMB_GNU_ARCH_LIST) $(ARM_GNU_ARCH_LIST)),)
|
||||
|
||||
ifneq ($(filter $(HOST_ARCH), $(ARM_GNU_ARCH_LIST)),)
|
||||
HOST_INSTRUCTION_SET := ARM
|
||||
else
|
||||
HOST_INSTRUCTION_SET := THUMB
|
||||
endif
|
||||
|
||||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX := arm-none-eabi-
|
||||
TOOLCHAIN_DEFAULT_FOLDER := gcc-arm-none-eabi
|
||||
|
||||
ifneq (,$(wildcard $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS)/bin))
|
||||
TOOLCHAIN_PATH := $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS)/bin/
|
||||
endif
|
||||
|
||||
BINS ?=
|
||||
|
||||
ifeq ($(HOST_OS),Win32)
|
||||
################
|
||||
# Windows settings
|
||||
################
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
SYSTEM_GCC_PATH = $(shell where $(TOOLCHAIN_PREFIX)gcc.exe)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc.exe,$(SYSTEM_GCC_PATH)))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
DOWNLOAD_URL = "https://launchpad.net/gcc-arm-embedded/+download"
|
||||
TOOLCHIAN_FILE = "gcc-arm-none-eabi-5_4-2016q3-20160926-win32.zip"
|
||||
$(error can not find compiler toolchain, please download $(TOOLCHIAN_FILE) from $(DOWNLOAD_URL) and unzip to $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS) folder)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(findstring stm32, $(HOST_MCU_FAMILY)), stm32)
|
||||
GDB_KILL_OPENOCD = shell $(TOOLS_ROOT)/cmd/win32/taskkill /F /IM st-util.exe
|
||||
GDBINIT_STRING = shell start /B $(TOOLS_ROOT)/cmd/win32/st-util.exe
|
||||
GDB_COMMAND = $(call CONV_SLASHES, $(TOOLCHAIN_PATH))$(TOOLCHAIN_PREFIX)gdb$(EXECUTABLE_SUFFIX)
|
||||
else
|
||||
GDB_KILL_OPENOCD = shell $(TOOLS_ROOT)/cmd/win32/taskkill /F /IM openocd.exe
|
||||
GDBINIT_STRING = shell start /B $(OPENOCD_FULL_NAME) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD)_gdb_jtag.cfg -l $(OPENOCD_LOG_FILE)
|
||||
GDB_COMMAND = cmd /C $(call CONV_SLASHES, $(TOOLCHAIN_PATH))$(TOOLCHAIN_PREFIX)gdb$(EXECUTABLE_SUFFIX)
|
||||
endif
|
||||
|
||||
else # Win32
|
||||
ifneq (,$(filter $(HOST_OS),Linux32 Linux64))
|
||||
################
|
||||
# Linux 32/64-bit settings
|
||||
################
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
DOWNLOAD_URL = "https://launchpad.net/gcc-arm-embedded/+download"
|
||||
TOOLCHIAN_FILE = "gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2"
|
||||
$(error can not find compiler toolchain, please download $(TOOLCHIAN_FILE) from $(DOWNLOAD_URL) and unzip to $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS) folder)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(findstring stm32, $(HOST_MCU_FAMILY)), stm32)
|
||||
GDB_KILL_OPENOCD = 'shell killall st-util'
|
||||
GDBINIT_STRING = 'shell $(COMMON_TOOLS_PATH)st-util &'
|
||||
GDB_COMMAND = "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gdb"
|
||||
else
|
||||
GDB_KILL_OPENOCD = 'shell killall openocd'
|
||||
GDBINIT_STRING = 'shell $(COMMON_TOOLS_PATH)dash -c "trap \\"\\" 2;$(OPENOCD_FULL_NAME) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD)_gdb_jtag.cfg -l $(OPENOCD_LOG_FILE) &"'
|
||||
GDB_COMMAND = "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gdb"
|
||||
endif
|
||||
|
||||
else # Linux32/64
|
||||
ifeq ($(HOST_OS),OSX)
|
||||
################
|
||||
# OSX settings
|
||||
################
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
DOWNLOAD_URL = "https://launchpad.net/gcc-arm-embedded/+download"
|
||||
TOOLCHIAN_FILE = "gcc-arm-none-eabi-5_4-2016q3-20160926-mac.tar.bz2"
|
||||
$(error can not find compiler toolchain, please download $(TOOLCHIAN_FILE) from $(DOWNLOAD_URL) and unzip to $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS) folder)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(findstring stm32, $(HOST_MCU_FAMILY)), stm32)
|
||||
GDB_KILL_OPENOCD = 'shell killall st-util'
|
||||
GDBINIT_STRING = 'shell $(COMMON_TOOLS_PATH)st-util &'
|
||||
GDB_COMMAND = "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gdb"
|
||||
else
|
||||
GDB_KILL_OPENOCD = 'shell killall openocd_run'
|
||||
GDBINIT_STRING = 'shell $(COMMON_TOOLS_PATH)dash -c "trap \\"\\" 2;$(OPENOCD_FULL_NAME) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD)_gdb_jtag.cfg -l $(OPENOCD_LOG_FILE) &"'
|
||||
GDB_COMMAND = "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gdb"
|
||||
endif
|
||||
|
||||
else # OSX
|
||||
$(error unsupport OS $(HOST_OS))
|
||||
endif # OSX
|
||||
endif # Linux32 Linux64 OSX
|
||||
endif # Win32
|
||||
|
||||
# Notes on C++ options:
|
||||
# The next two CXXFLAGS reduce the size of C++ code by removing unneeded
|
||||
# features. For example, these flags reduced the size of a console app build
|
||||
# (with C++ iperf) from 604716kB of flash to 577580kB of flash and 46756kB of
|
||||
# RAM to 46680kB of RAM.
|
||||
#
|
||||
# -fno-rtti
|
||||
# Disable generation of information about every class with virtual functions for
|
||||
# use by the C++ runtime type identification features (dynamic_cast and typeid).
|
||||
# Disabling RTTI eliminates several KB of support code from the C++ runtime
|
||||
# library (assuming that you don't link with code that uses RTTI).
|
||||
#
|
||||
# -fno-exceptions
|
||||
# Stop generating extra code needed to propagate exceptions, which can produce
|
||||
# significant data size overhead. Disabling exception handling eliminates
|
||||
# several KB of support code from the C++ runtime library (assuming that you
|
||||
# don't link external code that uses exception handling).
|
||||
|
||||
CC := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc$(EXECUTABLE_SUFFIX)"
|
||||
CXX := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++$(EXECUTABLE_SUFFIX)"
|
||||
AS := $(CC)
|
||||
AR := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar$(EXECUTABLE_SUFFIX)"
|
||||
LD := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld$(EXECUTABLE_SUFFIX)"
|
||||
CPP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cpp$(EXECUTABLE_SUFFIX)"
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
READELF := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)readelf$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) -Wall -Wfatal-errors -fsigned-char -ffunction-sections -fdata-sections -fno-common -std=gnu11 $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) -Wall -Wfatal-errors -fsigned-char -ffunction-sections -fdata-sections -fno-common -fno-rtti -fno-exceptions $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS) -Werror -Wstrict-prototypes -W -Wshadow -Wwrite-strings -pedantic -std=c99 -U__STRICT_ANSI__ -Wconversion -Wextra -Wdeclaration-after-statement -Wconversion -Waddress -Wlogical-op -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-field-initializers -Wdouble-promotion -Wswitch-enum -Wswitch-default -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow # -Wcast-qual -Wtraditional -Wtraditional-conversion
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1 -ggdb
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS := -ggdb
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS := -ggdb
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--whole-archive -Wl,--start-group $(1) -Wl,--end-group -Wl,-no-whole-archive
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION = -Wl$(COMMA)-T
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT = $(addprefix -Wl$(COMMA)-T ,$(1))
|
||||
LINKER := $(CC) --static -Wl,-static -Wl,--warn-common
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
|
||||
CLIB_LDFLAGS_NANO := --specs=nano.specs
|
||||
ifeq ($(BINS),)
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
else ifeq ($(BINS),kernel)
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
else ifeq ($(BINS),framework)
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs
|
||||
else ifeq ($(BINS),app)
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs
|
||||
endif
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
ifeq ($(HOST_ARCH),Cortex-M4F)
|
||||
CPU_CFLAGS := -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CPU_CXXFLAGS := -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CPU_ASMFLAGS := $(CPU_CFLAGS)
|
||||
CPU_LDFLAGS := -mthumb -mcpu=cortex-m4 -Wl,-A,thumb
|
||||
CLIB_LDFLAGS_NANO += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CLIB_LDFLAGS_NANO_FLOAT += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_ARCH),Cortex-M4)
|
||||
CPU_CFLAGS := -mthumb -mcpu=cortex-m4
|
||||
CPU_CXXFLAGS := -mthumb -mcpu=cortex-m4
|
||||
CPU_ASMFLAGS := $(CPU_CFLAGS)
|
||||
CPU_LDFLAGS := -mthumb -mcpu=cortex-m4 -Wl,-A,thumb
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_ARCH),Cortex-M3)
|
||||
CPU_CFLAGS := -mthumb -mcpu=cortex-m3
|
||||
CPU_CXXFLAGS := -mthumb -mcpu=cortex-m3
|
||||
CPU_ASMFLAGS := $(CPU_CFLAGS)
|
||||
CPU_LDFLAGS := -mthumb -mcpu=cortex-m3 -Wl,-A,thumb
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_ARCH),Cortex-M0)
|
||||
CPU_CFLAGS := -mthumb -mcpu=cortex-m0
|
||||
CPU_CXXFLAGS := -mthumb -mcpu=cortex-m0
|
||||
CPU_ASMFLAGS := $(CPU_CFLAGS)
|
||||
CPU_LDFLAGS := -mthumb -mcpu=cortex-m0 -Wl,-A,thumb
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_ARCH),Cortex-R4)
|
||||
CPU_BASE_FLAGS := -mcpu=cortex-r4 -mthumb-interwork
|
||||
CPU_COMPILER_FLAGS := $(CPU_BASE_FLAGS) -mthumb -fno-builtin-memcpy
|
||||
CPU_CFLAGS := $(CPU_COMPILER_FLAGS)
|
||||
CPU_CXXFLAGS := $(CPU_COMPILER_FLAGS)
|
||||
CPU_ASMFLAGS := $(CPU_BASE_FLAGS)
|
||||
CPU_LDFLAGS := -mthumb $(CPU_BASE_FLAGS) -Wl,-A,thumb -Wl,-z,max-page-size=0x10 -Wl,-z,common-page-size=0x10
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_ARCH),ARM968E-S)
|
||||
CPU_BASE_FLAGS := -mcpu=arm968e-s -march=armv5te -marm -mlittle-endian -mthumb-interwork
|
||||
CPU_CFLAGS := $(CPU_BASE_FLAGS)
|
||||
CPU_CXXFLAGS := $(CPU_BASE_FLAGS)
|
||||
CPU_ASMFLAGS := $(CPU_BASE_FLAGS)
|
||||
CPU_LDFLAGS := $(CPU_BASE_FLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_ARCH),Cortex-M7)
|
||||
CPU_CFLAGS := -mthumb -mcpu=cortex-m7
|
||||
CPU_CXXFLAGS := -mthumb -mcpu=cortex-m7
|
||||
CPU_ASMFLAGS := $(CPU_CFLAGS)
|
||||
CPU_LDFLAGS := -mthumb -mcpu=cortex-m7 -Wl,-A,thumb
|
||||
endif
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
|
||||
|
||||
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
ifneq ($(BINS),)
|
||||
ifeq ($(HOST_OS),Win32)
|
||||
DOWNLOAD_BRACKETS := )
|
||||
DOWNLOAD_COMMA := ;
|
||||
BINS_DOWNLOAD_ADDR = $(subst $(DOWNLOAD_COMMA),, $(subst $(DOWNLOAD_BRACKETS),, $(filter 0x%, $(subst X,x,$(strip $(shell findstr /d:$(OUTPUT_DIR)/ld "$(BINSTYPE_LOWER)_download_addr" *.ld))))))
|
||||
READELF_STR = $(call CONV_SLASHES, $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).$(BINSTYPE_LOWER)$(LINK_OUTPUT_SUFFIX))
|
||||
LOAD_SYMBOL_ADDRSTR = $(shell $(READELF) -S $(READELF_STR) | findstr ".text")
|
||||
LOAD_SYMBOL_ADDR = 0x$(wordlist 5, 5, $(LOAD_SYMBOL_ADDRSTR))
|
||||
endif # Win32
|
||||
ifeq ($(HOST_OS),Linux32)
|
||||
BINS_DOWNLOAD_ADDR = `$(TOOLS_ROOT)/cmd/linux32/grep -nr "$(BINSTYPE_LOWER)_download_addr" $(OUTPUT_DIR)/ld | $(TOOLS_ROOT)/cmd/linux32/awk -F '=' '{print $$2}' | $(TOOLS_ROOT)/cmd/linux32/awk -F ')' '{print $$1}'`
|
||||
LOAD_SYMBOL_ADDR = 0x`$(READELF) -S $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).$(BINSTYPE_LOWER)$(LINK_OUTPUT_SUFFIX) | $(TOOLS_ROOT)/cmd/linux32/grep ".text" | $(TOOLS_ROOT)/cmd/linux32/awk '{print $$5}'`
|
||||
endif # Linux32
|
||||
ifeq ($(HOST_OS),Linux64)
|
||||
BINS_DOWNLOAD_ADDR = `$(TOOLS_ROOT)/cmd/linux64/grep -nr "$(BINSTYPE_LOWER)_download_addr" $(OUTPUT_DIR)/ld | $(TOOLS_ROOT)/cmd/linux64/awk -F '=' '{print $$2}' | $(TOOLS_ROOT)/cmd/linux64/awk -F ')' '{print $$1}'`
|
||||
LOAD_SYMBOL_ADDR = 0x`$(READELF) -S $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).$(BINSTYPE_LOWER)$(LINK_OUTPUT_SUFFIX) | $(TOOLS_ROOT)/cmd/linux64/grep ".text" | $(TOOLS_ROOT)/cmd/linux64/awk '{print $$5}'`
|
||||
endif # Linux64
|
||||
ifeq ($(HOST_OS),OSX)
|
||||
BINS_DOWNLOAD_ADDR = `$(TOOLS_ROOT)/cmd/osx/grep -nr "$(BINSTYPE_LOWER)_download_addr" $(OUTPUT_DIR)/ld | $(TOOLS_ROOT)/cmd/osx/awk -F '=' '{print $$2}' | $(TOOLS_ROOT)/cmd/osx/awk -F ')' '{print $$1}'`
|
||||
LOAD_SYMBOL_ADDR = 0x`$(READELF) -S $(OUTPUT_DIR)/binary/$(CLEANED_BUILD_STRING).$(BINSTYPE_LOWER)$(LINK_OUTPUT_SUFFIX) | $(TOOLS_ROOT)/cmd/osx/grep ".text" | $(TOOLS_ROOT)/cmd/osx/awk '{print $$5}'`
|
||||
endif # OSX
|
||||
SUBGDBINIT_STRING = add-symbol-file $(BUILD_DIR)/eclipse_debug/$(BINSTYPE_LOWER)_built.elf $(LOAD_SYMBOL_ADDR)
|
||||
else
|
||||
BINS_DOWNLOAD_ADDR = 0x13200
|
||||
endif # BINS
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
endif #ifneq ($(filter $(HOST_ARCH), Cortex-M3 Cortex-M4),)
|
||||
94
Living_SDK/build/aos_toolchain_armcc.mk
Normal file
94
Living_SDK/build/aos_toolchain_armcc.mk
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX := arm
|
||||
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cc
|
||||
CXX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cc
|
||||
AS := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)asm
|
||||
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
|
||||
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)link
|
||||
CPP := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cc
|
||||
|
||||
OPTIONS_IN_FILE_OPTION_PREFIX = $$
|
||||
OPTIONS_IN_FILE_OPTION = (file <
|
||||
OPTIONS_IN_FILE_OPTION_SUFFIX = )
|
||||
OBJCOPYFLAGS := --bin --output=
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS =
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS =
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -Dgdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -Dgdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS :=
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -Dgdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -Dgdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS :=
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS :=
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := --md
|
||||
COMPILER_SPECIFIC_DEPS_FILE = --depend="$(1)"
|
||||
COMPILER_UNI_CFLAGS := --c90 --gnu --library_type=microlib -W
|
||||
COMPILER_UNI_SFLAGS := --library_type=microlib
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -L --map -L --list=$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = $(1)
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
|
||||
LINKER := $(CC)
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := armcc
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := --littleend
|
||||
ENDIAN_CXXFLAGS_LITTLE := --littleend
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := --littleend
|
||||
CLIB_LDFLAGS_NANO :=
|
||||
CLIB_LDFLAGS_NANO_FLOAT:=
|
||||
|
||||
# Chip specific flags for compiler
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
#COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
#TODO
|
||||
#MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_armcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
#COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
#TODO treat mapfile
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)fromelf$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)fromelf$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
#no need to strip in arm fromelf
|
||||
STRIP := "$(TOOLCHAIN_PATH)fromelf$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
STRIP_OUTPUT_PREFIX := --output=
|
||||
STRIPFLAGS := --strip=debug,symbols --elf
|
||||
OBJCOPY_BIN_FLAGS := --bin
|
||||
OBJCOPY_OUTPUT_PREFIX := --output=
|
||||
OBJCOPY_HEX_FLAGS := --i32
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.axf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
110
Living_SDK/build/aos_toolchain_armhflinux.mk
Normal file
110
Living_SDK/build/aos_toolchain_armhflinux.mk
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
ifneq ($(filter $(HOST_ARCH), armhflinux),)
|
||||
|
||||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX := arm-linux-gnueabihf-
|
||||
|
||||
SYSTEM_TOOLCHAIN_PATH :=
|
||||
ifneq (,$(filter $(HOST_OS),Linux32 Linux64 OSX))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc,,$(SYSTEM_GCC_PATH))
|
||||
endif
|
||||
else #Linux32 Linux64 OSX
|
||||
$(error unsupport OS $(HOST_OS))
|
||||
endif #Linux32 Linux64 OSX
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
ifneq (,$(SYSTEM_TOOLCHAIN_PATH))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
$(error can not find compiler toolchain, please install gcc-arm-linux-gnueabihf toolchain first)
|
||||
endif #SYSTEM_TOOLCHAIN_PATH
|
||||
endif #TOOLCHAIN_PATH
|
||||
|
||||
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc
|
||||
CXX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++
|
||||
AS := $(CC)
|
||||
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
|
||||
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--start-group $(1) -Wl,--end-group
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
LINKER := $(CC)
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
|
||||
CLIB_LDFLAGS_NANO := --specs=nano.specs
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
CLIB_LDFLAGS_NANO +=
|
||||
CLIB_LDFLAGS_NANO_FLOAT +=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
|
||||
|
||||
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
endif
|
||||
122
Living_SDK/build/aos_toolchain_csky.mk
Normal file
122
Living_SDK/build/aos_toolchain_csky.mk
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
ifneq ($(filter $(HOST_ARCH), ck802),)
|
||||
|
||||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX := csky-abiv2-elf-
|
||||
TOOLCHAIN_DEFAULT_FOLDER := gcc-csky-abiv2
|
||||
|
||||
ifneq (,$(wildcard $(COMPILER_ROOT)/${TOOLCHAIN_DEFAULT_FOLDER}/${HOST_OS}/bin))
|
||||
TOOLCHAIN_PATH := $(COMPILER_ROOT)/${TOOLCHAIN_DEFAULT_FOLDER}/${HOST_OS}/bin/
|
||||
endif
|
||||
|
||||
SYSTEM_TOOLCHAIN_PATH :=
|
||||
ifeq ($(HOST_OS),Win32)
|
||||
SYSTEM_GCC_PATH = $(shell where $(TOOLCHAIN_PREFIX)gcc.exe)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc.exe,$(SYSTEM_GCC_PATH)))
|
||||
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc.exe,,$(SYSTEM_GCC_PATH))
|
||||
endif
|
||||
else #WIN32
|
||||
ifneq (,$(filter $(HOST_OS),Linux32 Linux64 OSX))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc,,$(SYSTEM_GCC_PATH))
|
||||
endif
|
||||
else #Linux32 Linux64 OSX
|
||||
$(error unsupport OS $(HOST_OS))
|
||||
endif #Linux32 Linux64 OSX
|
||||
endif #WIN32
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
ifneq (,$(SYSTEM_TOOLCHAIN_PATH))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
$(error can not find compiler toolchain, please install gcc-csky-abiv2-elf toolchain to $(COMPILER_ROOT)/${TOOLCHAIN_DEFAULT_FOLDER/${HOST_OS} folder)
|
||||
endif #SYSTEM_TOOLCHAIN_PATH
|
||||
endif #TOOLCHAIN_PATH
|
||||
|
||||
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc
|
||||
AS := $(CC)
|
||||
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
|
||||
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld
|
||||
DUMP := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump
|
||||
OBJCOPY := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Wl)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Wl)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--start-group $(1) -Wl,--end-group
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
LINKER := $(CC)
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
|
||||
CLIB_LDFLAGS_NANO := --specs=nano.specs
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
CLIB_LDFLAGS_NANO +=
|
||||
CLIB_LDFLAGS_NANO_FLOAT +=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
|
||||
|
||||
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
endif
|
||||
7
Living_SDK/build/aos_toolchain_gcc.mk
Normal file
7
Living_SDK/build/aos_toolchain_gcc.mk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
include $(SOURCE_ROOT)build/aos_toolchain_arm-none-eabi.mk
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_rockchiplinux.mk
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_linux.mk
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_armhflinux.mk
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_xtensa.mk
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_csky.mk
|
||||
include $(SOURCE_ROOT)build/aos_toolchain_nds32le-elf-newlib-v3.mk
|
||||
92
Living_SDK/build/aos_toolchain_iar.mk
Normal file
92
Living_SDK/build/aos_toolchain_iar.mk
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX :=
|
||||
CC := $(TOOLCHAIN_PATH)iccarm
|
||||
CXX := $(TOOLCHAIN_PATH)iccarm
|
||||
AS := $(TOOLCHAIN_PATH)iasmarm
|
||||
AR := $(TOOLCHAIN_PATH)iarchive
|
||||
LD := $(TOOLCHAIN_PATH)ilinkarm
|
||||
CPP := $(TOOLCHAIN_PATH)iccarm
|
||||
|
||||
OPTIONS_IN_FILE_OPTION_PREFIX_DIRECT = $
|
||||
OPTIONS_IN_FILE_OPTION_PREFIX = $$
|
||||
OPTIONS_IN_FILE_OPTION = (file <
|
||||
OPTIONS_IN_FILE_OPTION_SUFFIX = )
|
||||
OBJCOPYFLAGS := --bin --output=
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS =
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS =
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := --create
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := --create
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -V
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -Dgdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -Dgdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS :=
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -Dgdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -Dgdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS :=
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS :=
|
||||
|
||||
# -MD -> --dependencies xx.d
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -e --dlib_config=full -D_TIMESPEC_DEFINED --silent --only_stdout --no_warnings --diag_warning=Pe167,Pe144,Pe513
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG :=
|
||||
COMPILER_SPECIFIC_LINK_MAP = --map $(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = $(addprefix --whole_archive , $(filter-out %alicrypto.a,$(1))) $(filter %alicrypto.a,$(1))
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
|
||||
LINKER := $(LD)
|
||||
LINK_SCRIPT_SUFFIX := .icf
|
||||
TOOLCHAIN_NAME := iar
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := --littleend
|
||||
ENDIAN_CXXFLAGS_LITTLE := --littleend
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := --littleend
|
||||
CLIB_LDFLAGS_NANO :=
|
||||
CLIB_LDFLAGS_NANO_FLOAT:=
|
||||
|
||||
# Chip specific flags for compiler
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
#COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
#TODO
|
||||
#MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_armcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
# iar map file format is different
|
||||
#COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ielfdumparm$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ielftool$(EXECUTABLE_SUFFIX)"
|
||||
# -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes -> iobjmanip --remvoe_secton
|
||||
OBJCOPY_BIN_FLAGS := --bin --silent
|
||||
OBJCOPY_HEX_FLAGS := --ihex --silent
|
||||
|
||||
#no need to strip in arm fromelf
|
||||
STRIP := "$(TOOLCHAIN_PATH)ielftool"
|
||||
STRIPFLAGS := --strip --silent
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.iarElf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
93
Living_SDK/build/aos_toolchain_linux.mk
Normal file
93
Living_SDK/build/aos_toolchain_linux.mk
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
ifneq ($(filter $(HOST_ARCH), linux),)
|
||||
|
||||
TOOLCHAIN_PATH :=
|
||||
|
||||
PATH := $(PATH):/bin:/usr/bin:/usr/local/bin
|
||||
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc
|
||||
CXX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++
|
||||
AS := $(CC)
|
||||
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
|
||||
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
export PATH
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--start-group $(1) -Wl,--end-group
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
LINKER := $(CC)
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
|
||||
CLIB_LDFLAGS_NANO := --specs=nano.specs
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
CLIB_LDFLAGS_NANO +=
|
||||
CLIB_LDFLAGS_NANO_FLOAT +=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
|
||||
|
||||
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
endif
|
||||
132
Living_SDK/build/aos_toolchain_nds32le-elf-newlib-v3.mk
Normal file
132
Living_SDK/build/aos_toolchain_nds32le-elf-newlib-v3.mk
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
ifneq ($(filter $(HOST_ARCH), ANDES_N10),)
|
||||
|
||||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX := nds32le-elf-
|
||||
TOOLCHAIN_DEFAULT_FOLDER := nds32le-elf-newlib-v3
|
||||
ifneq (,$(wildcard $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/bin))
|
||||
TOOLCHAIN_PATH := $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/bin/
|
||||
endif
|
||||
|
||||
BINS ?=
|
||||
|
||||
|
||||
ifneq (,$(filter $(HOST_OS),Linux32 Linux64))
|
||||
################
|
||||
# Linux 32/64-bit settings
|
||||
################
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
$(error can not find compiler toolchain, please download toolchain and unzip to $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER) folder)
|
||||
endif
|
||||
endif
|
||||
|
||||
GDB_KILL_OPENOCD =
|
||||
GDBINIT_STRING = 'shell $(COMMON_TOOLS_PATH)dash -c "trap \\"\\" 2;$(OPENOCD_FULL_NAME) -f $(OPENOCD_CFG_PATH)interface/$(JTAG).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD).cfg -f $(OPENOCD_CFG_PATH)$(HOST_OPENOCD)/$(HOST_OPENOCD)_gdb_jtag.cfg -l $(OPENOCD_LOG_FILE) &"'
|
||||
GDB_COMMAND = "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gdb"
|
||||
|
||||
else # Linux32/64
|
||||
$(error incorrect 'make' used ($(MAKE)) - please use: (Windows) .\make.exe <target_string> (OS X, Linux) ./make <target_string>)
|
||||
endif
|
||||
|
||||
|
||||
# Notes on C++ options:
|
||||
# The next two CXXFLAGS reduce the size of C++ code by removing unneeded
|
||||
# features. For example, these flags reduced the size of a console app build
|
||||
# (with C++ iperf) from 604716kB of flash to 577580kB of flash and 46756kB of
|
||||
# RAM to 46680kB of RAM.
|
||||
#
|
||||
# -fno-rtti
|
||||
# Disable generation of information about every class with virtual functions for
|
||||
# use by the C++ runtime type identification features (dynamic_cast and typeid).
|
||||
# Disabling RTTI eliminates several KB of support code from the C++ runtime
|
||||
# library (assuming that you don't link with code that uses RTTI).
|
||||
#
|
||||
# -fno-exceptions
|
||||
# Stop generating extra code needed to propagate exceptions, which can produce
|
||||
# significant data size overhead. Disabling exception handling eliminates
|
||||
# several KB of support code from the C++ runtime library (assuming that you
|
||||
# don't link external code that uses exception handling).
|
||||
|
||||
CC := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc$(EXECUTABLE_SUFFIX)"
|
||||
CXX := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++$(EXECUTABLE_SUFFIX)"
|
||||
AS := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc$(EXECUTABLE_SUFFIX)"
|
||||
AR := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar$(EXECUTABLE_SUFFIX)"
|
||||
LD := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld$(EXECUTABLE_SUFFIX)"
|
||||
CPP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cpp$(EXECUTABLE_SUFFIX)"
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
READELF := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)readelf$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) -fno-common $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) -fno-common -fno-rtti -fno-exceptions $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -O2
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O1
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := --defsym DEBUG=1 -ggdb
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS := -ggdb
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS := -ggdb
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--whole-archive -Wl,--start-group $(1) -Wl,--end-group -Wl,-no-whole-archive
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION = -Wl$(COMMA)-T
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT = $(addprefix -Wl$(COMMA)-T ,$(1))
|
||||
LINKER := $(CC) --static -Wl,-static -Wl,--warn-common
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
#CPU_ASMFLAGS := $(CPU_CFLAGS)
|
||||
|
||||
COMPILER_UNI_SFLAGS := $(CFLAGS) -DMH4
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(SCRIPTS_PATH)/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
#KILL_OPENOCD_SCRIPT := $(SCRIPTS_PATH)/kill_openocd.py
|
||||
|
||||
#KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
STRIPFLAGS :=
|
||||
|
||||
OBJCOPY_BIN_FLAGS := -O binary
|
||||
|
||||
endif
|
||||
116
Living_SDK/build/aos_toolchain_rockchiplinux.mk
Normal file
116
Living_SDK/build/aos_toolchain_rockchiplinux.mk
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
ifneq ($(filter $(HOST_ARCH), rockchiplinux),)
|
||||
|
||||
TOOLCHAIN_PATH ?=
|
||||
TOOLCHAIN_PREFIX := arm-rockchip-linux-gnueabihf-
|
||||
|
||||
TOOLCHAIN_DEFAULT_FOLDER := usr
|
||||
|
||||
ifneq (,$(wildcard $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/bin))
|
||||
TOOLCHAIN_PATH := $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/bin/
|
||||
endif
|
||||
|
||||
SYSTEM_TOOLCHAIN_PATH :=
|
||||
ifneq (,$(filter $(HOST_OS),Linux32 Linux64 OSX))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc,,$(SYSTEM_GCC_PATH))
|
||||
endif
|
||||
else #Linux32 Linux64 OSX
|
||||
$(error unsupport OS $(HOST_OS))
|
||||
endif #Linux32 Linux64 OSX
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
ifneq (,$(SYSTEM_TOOLCHAIN_PATH))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
$(error can not find compiler toolchain, please install gcc-arm-linux-gnueabihf toolchain first)
|
||||
endif #SYSTEM_TOOLCHAIN_PATH
|
||||
endif #TOOLCHAIN_PATH
|
||||
|
||||
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc
|
||||
CXX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++
|
||||
AS := $(CC)
|
||||
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
|
||||
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--start-group $(1) -Wl,--end-group
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
LINKER := $(CC)
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
|
||||
CLIB_LDFLAGS_NANO := --specs=nano.specs
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
CLIB_LDFLAGS_NANO +=
|
||||
CLIB_LDFLAGS_NANO_FLOAT +=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
|
||||
|
||||
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
endif
|
||||
130
Living_SDK/build/aos_toolchain_xtensa.mk
Normal file
130
Living_SDK/build/aos_toolchain_xtensa.mk
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
ifneq ($(filter $(HOST_ARCH), xtensa),)
|
||||
|
||||
TOOLCHAIN_PATH ?=
|
||||
ifneq ($(filter $(HOST_MCU_FAMILY), esp8266), )
|
||||
TOOLCHAIN_PREFIX := xtensa-lx106-elf-
|
||||
TOOLCHAIN_DEFAULT_FOLDER := gcc-xtensa-lx106
|
||||
endif
|
||||
ifneq ($(filter $(HOST_MCU_FAMILY), esp32), )
|
||||
TOOLCHAIN_PREFIX := xtensa-esp32-elf-
|
||||
TOOLCHAIN_DEFAULT_FOLDER := gcc-xtensa-esp32
|
||||
endif
|
||||
|
||||
ifneq (,$(wildcard $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS)/bin))
|
||||
TOOLCHAIN_PATH := $(COMPILER_ROOT)/$(TOOLCHAIN_DEFAULT_FOLDER)/$(HOST_OS)/bin/
|
||||
endif
|
||||
|
||||
SYSTEM_TOOLCHAIN_PATH :=
|
||||
ifeq ($(HOST_OS),Win32)
|
||||
SYSTEM_GCC_PATH = $(shell where $(TOOLCHAIN_PREFIX)gcc.exe)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc.exe,$(SYSTEM_GCC_PATH)))
|
||||
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc.exe,,$(SYSTEM_GCC_PATH))
|
||||
endif
|
||||
else #WIN32
|
||||
ifneq (,$(filter $(HOST_OS),Linux32 Linux64 OSX))
|
||||
SYSTEM_GCC_PATH = $(shell which $(TOOLCHAIN_PREFIX)gcc)
|
||||
ifneq (,$(findstring $(TOOLCHAIN_PREFIX)gcc,$(SYSTEM_GCC_PATH)))
|
||||
SYSTEM_TOOLCHAIN_PATH := $(subst $(TOOLCHAIN_PREFIX)gcc,,$(SYSTEM_GCC_PATH))
|
||||
endif
|
||||
else #Linux32 Linux64 OSX
|
||||
$(error unsupport OS $(HOST_OS))
|
||||
endif #Linux32 Linux64 OSX
|
||||
endif #WIN32
|
||||
|
||||
ifeq (,$(TOOLCHAIN_PATH))
|
||||
ifneq (,$(SYSTEM_TOOLCHAIN_PATH))
|
||||
TOOLCHAIN_PATH :=
|
||||
else
|
||||
DOWNLOAD_URL = "https://esp-idf.readthedocs.io/en/latest/get-started/index.html\#setup-toolchain"
|
||||
$(error can not find compiler toolchain, please setup toolchain as $(DOWNLOAD_URL) instructed)
|
||||
endif #SYSTEM_TOOLCHAIN_PATH
|
||||
endif #TOOLCHAIN_PATH
|
||||
|
||||
CC := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)gcc
|
||||
CXX := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)g++
|
||||
AS := $(CC)
|
||||
AR := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ar
|
||||
LD := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)ld
|
||||
CPP := $(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)cpp
|
||||
OPTIONS_IN_FILE_OPTION := @
|
||||
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_CXXFLAGS = $(1) $(if $(filter yes,$(MXCHIP_INTERNAL) $(TESTER)),-Werror)
|
||||
ADD_COMPILER_SPECIFIC_STANDARD_ADMFLAGS = $(1)
|
||||
COMPILER_SPECIFIC_OPTIMIZED_CFLAGS := -Os
|
||||
COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS := -O0
|
||||
COMPILER_SPECIFIC_PEDANTIC_CFLAGS := $(COMPILER_SPECIFIC_STANDARD_CFLAGS)
|
||||
COMPILER_SPECIFIC_ARFLAGS_CREATE := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_ADD := -rcs
|
||||
COMPILER_SPECIFIC_ARFLAGS_VERBOSE := -v
|
||||
|
||||
#debug: no optimize and log enable
|
||||
COMPILER_SPECIFIC_DEBUG_CFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_CXXFLAGS := -DDEBUG -ggdb $(COMPILER_SPECIFIC_UNOPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_DEBUG_ASFLAGS := -DDEBUG=1
|
||||
COMPILER_SPECIFIC_DEBUG_LDFLAGS := -Wl,--gc-sections -Wl,--cref
|
||||
|
||||
#release_log: optimize but log enable
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_CXXFLAGS := -ggdb $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LOG_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref -nostdlib
|
||||
|
||||
#release: optimize and log disable
|
||||
COMPILER_SPECIFIC_RELEASE_CFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_CXXFLAGS := -DNDEBUG $(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS)
|
||||
COMPILER_SPECIFIC_RELEASE_ASFLAGS :=
|
||||
COMPILER_SPECIFIC_RELEASE_LDFLAGS := -Wl,--gc-sections -Wl,$(COMPILER_SPECIFIC_OPTIMIZED_CFLAGS) -Wl,--cref -nostdlib
|
||||
|
||||
COMPILER_SPECIFIC_DEPS_FLAG := -MD
|
||||
COMPILER_SPECIFIC_COMP_ONLY_FLAG := -c
|
||||
COMPILER_SPECIFIC_LINK_MAP = -Wl,-Map,$(1)
|
||||
COMPILER_SPECIFIC_LINK_FILES = -Wl,--start-group $(1) -Wl,--end-group
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT_DEFINE_OPTION =
|
||||
COMPILER_SPECIFIC_LINK_SCRIPT =
|
||||
LINKER := $(CC)
|
||||
LINK_SCRIPT_SUFFIX := .ld
|
||||
TOOLCHAIN_NAME := GCC
|
||||
|
||||
ENDIAN_CFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_CXXFLAGS_LITTLE := -mlittle-endian
|
||||
ENDIAN_ASMFLAGS_LITTLE :=
|
||||
ENDIAN_LDFLAGS_LITTLE := -mlittle-endian
|
||||
CLIB_LDFLAGS_NANO := --specs=nano.specs
|
||||
CLIB_LDFLAGS_NANO_FLOAT:= --specs=nano.specs -u _printf_float
|
||||
|
||||
# Chip specific flags for GCC
|
||||
|
||||
CPU_CFLAGS :=
|
||||
CPU_CXXFLAGS :=
|
||||
CPU_ASMFLAGS :=
|
||||
CPU_LDFLAGS :=
|
||||
CLIB_LDFLAGS_NANO +=
|
||||
CLIB_LDFLAGS_NANO_FLOAT +=
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_TO_CSV = $(PYTHON) $(MAPFILE_PARSER) $(1) > $(2)
|
||||
|
||||
MAPFILE_PARSER :=$(MAKEFILES_PATH)/scripts/map_parse_gcc.py
|
||||
|
||||
# $(1) is map file, $(2) is CSV output file
|
||||
COMPILER_SPECIFIC_MAPFILE_DISPLAY_SUMMARY = $(PYTHON) $(MAPFILE_PARSER) $(1)
|
||||
|
||||
KILL_OPENOCD_SCRIPT := $(MAKEFILES_PATH)/scripts/kill_openocd.py
|
||||
|
||||
KILL_OPENOCD = $(PYTHON) $(KILL_OPENOCD_SCRIPT)
|
||||
|
||||
OBJDUMP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objdump$(EXECUTABLE_SUFFIX)"
|
||||
OBJCOPY := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)objcopy$(EXECUTABLE_SUFFIX)"
|
||||
STRIP := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)strip$(EXECUTABLE_SUFFIX)"
|
||||
NM := "$(TOOLCHAIN_PATH)$(TOOLCHAIN_PREFIX)nm$(EXECUTABLE_SUFFIX)"
|
||||
|
||||
STRIP_OUTPUT_PREFIX := -o
|
||||
OBJCOPY_BIN_FLAGS := -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
OBJCOPY_HEX_FLAGS := -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes
|
||||
|
||||
LINK_OUTPUT_SUFFIX :=.elf
|
||||
BIN_OUTPUT_SUFFIX :=.bin
|
||||
HEX_OUTPUT_SUFFIX :=.hex
|
||||
|
||||
endif
|
||||
124
Living_SDK/build/autobuild.sh
Executable file
124
Living_SDK/build/autobuild.sh
Executable file
|
|
@ -0,0 +1,124 @@
|
|||
if [ "$(uname)" = "Linux" ]; then
|
||||
CUR_OS="Linux"
|
||||
elif [ "$(uname)" = "Darwin" ]; then
|
||||
CUR_OS="OSX"
|
||||
elif [ "$(uname | grep NT)" != "" ]; then
|
||||
CUR_OS="Windows"
|
||||
else
|
||||
echo "error: unkonw OS"
|
||||
exit 1
|
||||
fi
|
||||
echo "OS: ${CUR_OS}"
|
||||
|
||||
|
||||
git status > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error: not in any git repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JNUM=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||
|
||||
if [ -f ~/.bashrc ]; then
|
||||
. ~/.bashrc
|
||||
fi
|
||||
|
||||
branch=`git status | grep "On branch" | sed -r 's/.*On branch //g'`
|
||||
cd $(git rev-parse --show-toplevel)
|
||||
|
||||
|
||||
function do_build()
|
||||
{
|
||||
build_app=$1
|
||||
build_board=$2
|
||||
build_option=$3
|
||||
|
||||
build_cmd_log=$app_$build_board@${branch}.log
|
||||
build_cmd="aos make $build_app@$build_board"
|
||||
if [ "${build_option}" != "" ]; then
|
||||
build_cmd="${build_cmd} ${build_option}"
|
||||
fi
|
||||
|
||||
#remove @release @debug
|
||||
board_without_at=$(echo $build_board | cut -d"@" -f1 )
|
||||
if [ -f build/scons_enabled.py ]; then
|
||||
scons_support=$(grep $board_without_at build/scons_enabled.py)
|
||||
else
|
||||
scons_support=""
|
||||
fi
|
||||
if [ -z "$scons_support" ]; then
|
||||
#echo rm -rf out/$build_app@$build_board
|
||||
rm -rf out/$build_app@$build_board > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
start_time=$(date +%s.%N)
|
||||
|
||||
#echo $build_cmd
|
||||
$build_cmd > $build_cmd_log 2>&1
|
||||
|
||||
ret=$?; end_time=$(date +%s.%N)
|
||||
elapsed_time=$(python -c "print '{0:0.1f}'.format(${end_time}-${start_time})")
|
||||
if [ ${ret} -eq 0 ]; then
|
||||
echo -e "$build_cmd at ${branch} branch succeed in ${elapsed_time}S"
|
||||
rm -f $build_cmd_log
|
||||
else
|
||||
echo -e "$build_cmd at ${branch} branch failed, log:\n"
|
||||
cat $build_cmd_log
|
||||
echo -e "\n$build_cmd at ${branch} branch failed in ${elapsed_time}S"
|
||||
aos make clean > /dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function resolveTargets()
|
||||
{
|
||||
targets=$1
|
||||
build_type=$(grep "build_type" board/$board/ucube.py | cut -d\" -f2 )
|
||||
platform_options=$(grep "platform_options" board/$board/ucube.py | cut -d\" -f2 )
|
||||
|
||||
for target in ${targets[@]};do
|
||||
if [ -z "$(echo \"$target\" | grep \|)" ]; then
|
||||
app=$target
|
||||
option=$platform_options
|
||||
else
|
||||
app=$(echo $target | cut -d"|" -f1)
|
||||
option="$platform_options "$(echo $target | cut -d"|" -f2- | sed -r 's/\|/ /g')
|
||||
fi
|
||||
|
||||
do_build "$app" "$board" "$option"
|
||||
|
||||
for platform_type in ${build_type[@]};do
|
||||
do_build "$app" "$board@$platform_type" "$option"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#--- main_proces ---
|
||||
if [ xx$1 = xx ]; then
|
||||
boards_list=$(ls board)
|
||||
elif [ ! -f $1 ]; then
|
||||
echo "boards list file $1 is not existed!"
|
||||
exit 1
|
||||
else
|
||||
boards_list=$(cat $1)
|
||||
fi
|
||||
|
||||
for board in $boards_list
|
||||
do
|
||||
#echo $board
|
||||
if [ -f board/$board/ucube.py ];then
|
||||
targets=$(grep "supported_targets" board/$board/ucube.py | cut -d\" -f2)
|
||||
resolveTargets "$targets"
|
||||
|
||||
if [ $CUR_OS = "Windows" ]; then
|
||||
targets=$(grep "windows_only_targets" board/$board/ucube.py | cut -d\" -f2 )
|
||||
resolveTargets "$targets"
|
||||
fi
|
||||
|
||||
if [ $CUR_OS = "Linux" ]; then
|
||||
targets=$(grep "linux_only_targets" board/$board/ucube.py | cut -d\" -f2 )
|
||||
resolveTargets "$targets"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
17
Living_SDK/build/checkout_iotx_sdk.sh
Executable file
17
Living_SDK/build/checkout_iotx_sdk.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
origin_path="$(pwd)"
|
||||
cd framework/protocol/linkkit/sdk
|
||||
|
||||
if [ ! -d "iotx-sdk-c_clone" ]; then
|
||||
git clone https://github.com/aliyun/iotkit-embedded.git iotx-sdk-c_clone
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "clone iotx-sdk-c fail!"
|
||||
exit 1
|
||||
fi
|
||||
cd iotx-sdk-c_clone
|
||||
git checkout -b rel_ada --track origin/rel_ada
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "checkout linkplatform_refactor branch fail!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
BIN
Living_SDK/build/cmd/etc/._readme.txt
Normal file
BIN
Living_SDK/build/cmd/etc/._readme.txt
Normal file
Binary file not shown.
3
Living_SDK/build/cmd/etc/readme.txt
Normal file
3
Living_SDK/build/cmd/etc/readme.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
This directory is needed due to the MinGW version of uname.exe.
|
||||
The program seems to reference the ../etc directory even though it is empty.
|
||||
Without this directory uname.exe prints nothing.
|
||||
BIN
Living_SDK/build/cmd/linux32/._aes_cbc_128
Normal file
BIN
Living_SDK/build/cmd/linux32/._aes_cbc_128
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._bin2c
Executable file
BIN
Living_SDK/build/cmd/linux32/._bin2c
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._bin2c.c
Normal file
BIN
Living_SDK/build/cmd/linux32/._bin2c.c
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._cat
Executable file
BIN
Living_SDK/build/cmd/linux32/._cat
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._cp
Executable file
BIN
Living_SDK/build/cmd/linux32/._cp
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._dash
Executable file
BIN
Living_SDK/build/cmd/linux32/._dash
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._echo
Executable file
BIN
Living_SDK/build/cmd/linux32/._echo
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._hmac_sha256
Normal file
BIN
Living_SDK/build/cmd/linux32/._hmac_sha256
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._make
Executable file
BIN
Living_SDK/build/cmd/linux32/._make
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._mkdir
Executable file
BIN
Living_SDK/build/cmd/linux32/._mkdir
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._rm
Executable file
BIN
Living_SDK/build/cmd/linux32/._rm
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/._uname
Executable file
BIN
Living_SDK/build/cmd/linux32/._uname
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/aes_cbc_128
Normal file
BIN
Living_SDK/build/cmd/linux32/aes_cbc_128
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/bin2c
Executable file
BIN
Living_SDK/build/cmd/linux32/bin2c
Executable file
Binary file not shown.
281
Living_SDK/build/cmd/linux32/bin2c.c
Normal file
281
Living_SDK/build/cmd/linux32/bin2c.c
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
|
||||
|
||||
#pragma warning(disable:4996) // Disable MSVC++ warnings about unsafe functions
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
int getopt(int argc, char *argv[], const char *optstring);
|
||||
char *optarg;
|
||||
int optind = 0;
|
||||
extern int getopt(int ac, char *av[], const char *optstring);
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
#elif defined __GNUC__
|
||||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#error Need definition for getopt
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
int opt_bigendian = 0;
|
||||
int opt_word = 0;
|
||||
int opt_indent = 8;
|
||||
int opt_maxcol = 79;
|
||||
|
||||
char *opt_utype = NULL;
|
||||
|
||||
#define SWAP32(x) ((((x) >> 24) & 0x000000ff) | \
|
||||
(((x) >> 8) & 0x0000ff00) | \
|
||||
(((x) << 8) & 0x00ff0000) | \
|
||||
(((x) << 24) & 0xff000000))
|
||||
|
||||
int
|
||||
convert(char *ifn, char *ofn, char *array_name)
|
||||
{
|
||||
FILE *ifp, *ofp;
|
||||
int c, lc;
|
||||
struct stat istat;
|
||||
char *array_type;
|
||||
int array_len;
|
||||
|
||||
if (stat(ifn, &istat) < 0) {
|
||||
fprintf(stderr, "error: could not stat input file %s: %s\n",
|
||||
ifn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
array_type = (opt_word ? "const unsigned int" : "const unsigned char");
|
||||
array_len = (opt_word ? ((int)istat.st_size + 3) / 4 : (int)istat.st_size);
|
||||
|
||||
if ((ifp = fopen(ifn, "rb")) == NULL) {
|
||||
fprintf(stderr, "error: could not open input file %s: %s\n",
|
||||
ifn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ofp = fopen(ofn, "w")) == NULL) {
|
||||
fclose(ifp);
|
||||
fprintf(stderr, "error: could not open output file %s: %s\n",
|
||||
ofn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(ofp, "/* FILE-CSTYLED */\n");
|
||||
if (opt_utype != NULL) {
|
||||
fprintf(ofp,
|
||||
"#define %s %s_align._%s\n"
|
||||
"union %s_u {\n"
|
||||
"%*s%s _%s[%d];\n"
|
||||
"%*s%s align;\n"
|
||||
"} %s_align = {{\n",
|
||||
array_name, array_name, array_name,
|
||||
array_name,
|
||||
opt_indent, "", array_type, array_name, array_len,
|
||||
opt_indent, "", opt_utype,
|
||||
array_name);
|
||||
} else {
|
||||
fprintf(ofp,
|
||||
"%s %s[%d] = {\n",
|
||||
array_type, array_name, array_len);
|
||||
}
|
||||
|
||||
lc = 0;
|
||||
|
||||
if (opt_word) {
|
||||
while ((c = fgetc(ifp)) != EOF) {
|
||||
int i;
|
||||
unsigned int val = (unsigned int)c;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if ((c = getc(ifp)) == EOF)
|
||||
c = 0;
|
||||
val = (val << 8) | (unsigned int)c;
|
||||
}
|
||||
if (!opt_bigendian)
|
||||
val = SWAP32(val);
|
||||
if (lc > 0 && lc >= opt_maxcol - 12) {
|
||||
fprintf(ofp, ",\n");
|
||||
lc = 0;
|
||||
}
|
||||
if (lc == 0)
|
||||
lc += fprintf(ofp, "%*s0x%08x", opt_indent, "", val);
|
||||
else
|
||||
lc += fprintf(ofp, ", 0x%08x", val);
|
||||
}
|
||||
} else {
|
||||
while ((c = getc(ifp)) != EOF) {
|
||||
if (lc > 0 && lc >= opt_maxcol - 5) {
|
||||
fprintf(ofp, ",\n");
|
||||
lc = 0;
|
||||
}
|
||||
if (lc == 0)
|
||||
lc += fprintf(ofp, "%*s%d", opt_indent, "", c);
|
||||
else
|
||||
lc += fprintf(ofp, ", %d", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (lc > 0)
|
||||
fprintf(ofp, "\n");
|
||||
|
||||
if (opt_utype != NULL)
|
||||
fprintf(ofp, "}");
|
||||
fprintf(ofp, "};\n");
|
||||
|
||||
(void)fclose(ifp);
|
||||
|
||||
if (fclose(ofp) < 0) {
|
||||
fprintf(stderr, "error: could not close output file %s: %s\n",
|
||||
ofn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: bin2c [-w] [-eb] [-u type] [-i indent] [-m maxcol]\n"
|
||||
" <input> <output> <arrayname>\n"
|
||||
" -w Output 32-bit ints instead of bytes\n"
|
||||
" -eb Output for big-endian CPU (when used with -w)\n"
|
||||
" -u type Output a union with specified alignment type\n"
|
||||
" -i indent Indentation amount\n"
|
||||
" -m maxcol Maximum output columns to use\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "we:u:i:m:")) > 0)
|
||||
switch (c) {
|
||||
case 'w':
|
||||
opt_word = 1;
|
||||
break;
|
||||
case 'e':
|
||||
opt_bigendian = (optarg[0] == 'b');
|
||||
break;
|
||||
case 'u':
|
||||
opt_utype = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
opt_indent = atoi(optarg);
|
||||
break;
|
||||
case 'm':
|
||||
opt_maxcol = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
if (optind + 3 != argc)
|
||||
usage();
|
||||
|
||||
if (convert(argv[optind], argv[optind + 1], argv[optind + 2]) < 0)
|
||||
exit(1);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
|
||||
// From XGetopt.cpp Version 1.2
|
||||
//
|
||||
// Author: Hans Dietrich
|
||||
// hdietrich2@hotmail.com
|
||||
//
|
||||
// Description:
|
||||
// XGetopt.cpp implements getopt(), a function to parse command lines.
|
||||
//
|
||||
// History
|
||||
// Version 1.2 - 2003 May 17
|
||||
// - Added Unicode support
|
||||
//
|
||||
// Version 1.1 - 2002 March 10
|
||||
// - Added example to XGetopt.cpp module header
|
||||
//
|
||||
// This software is released into the public domain.
|
||||
// You are free to use it in any way you like.
|
||||
//
|
||||
// This software is provided "as is" with no expressed
|
||||
// or implied warranty. I accept no liability for any
|
||||
// damage or loss of business that this software may cause.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getopt(int argc, char *argv[], const char *optstring)
|
||||
{
|
||||
char c;
|
||||
char *cp;
|
||||
static char *next = NULL;
|
||||
if (optind == 0)
|
||||
next = NULL;
|
||||
|
||||
optarg = NULL;
|
||||
|
||||
if (next == NULL || *next == '\0')
|
||||
{
|
||||
if (optind == 0)
|
||||
optind++;
|
||||
|
||||
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
{
|
||||
optarg = NULL;
|
||||
if (optind < argc)
|
||||
optarg = argv[optind];
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (strcmp(argv[optind], "--") == 0)
|
||||
{
|
||||
optind++;
|
||||
optarg = NULL;
|
||||
if (optind < argc)
|
||||
optarg = argv[optind];
|
||||
return EOF;
|
||||
}
|
||||
|
||||
next = argv[optind];
|
||||
next++; // skip past -
|
||||
optind++;
|
||||
}
|
||||
|
||||
c = *next++;
|
||||
cp = strchr(optstring, c);
|
||||
|
||||
if (( cp == NULL ) || ( c == ':') )
|
||||
return '?';
|
||||
|
||||
cp++;
|
||||
if ( *cp == ':')
|
||||
{
|
||||
if (*next != '\0')
|
||||
{
|
||||
optarg = next;
|
||||
next = NULL;
|
||||
}
|
||||
else if (optind < argc)
|
||||
{
|
||||
optarg = argv[optind];
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif /* if defined( _MSC_VER ) */
|
||||
BIN
Living_SDK/build/cmd/linux32/cat
Executable file
BIN
Living_SDK/build/cmd/linux32/cat
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/cp
Executable file
BIN
Living_SDK/build/cmd/linux32/cp
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/dash
Executable file
BIN
Living_SDK/build/cmd/linux32/dash
Executable file
Binary file not shown.
8
Living_SDK/build/cmd/linux32/echo
Executable file
8
Living_SDK/build/cmd/linux32/echo
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2002, Earnie Boyd
|
||||
# mailto:earnie@users.sf.net
|
||||
# This file is part of MSYS
|
||||
# http://www.mingw.org/msys.shtml
|
||||
# File: echo
|
||||
|
||||
echo "$@"
|
||||
BIN
Living_SDK/build/cmd/linux32/hmac_sha256
Normal file
BIN
Living_SDK/build/cmd/linux32/hmac_sha256
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/make
Executable file
BIN
Living_SDK/build/cmd/linux32/make
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/mkdir
Executable file
BIN
Living_SDK/build/cmd/linux32/mkdir
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/rm
Executable file
BIN
Living_SDK/build/cmd/linux32/rm
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux32/uname
Executable file
BIN
Living_SDK/build/cmd/linux32/uname
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._aes_cbc_128
Executable file
BIN
Living_SDK/build/cmd/linux64/._aes_cbc_128
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._bin2c
Executable file
BIN
Living_SDK/build/cmd/linux64/._bin2c
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._bin2c.c
Normal file
BIN
Living_SDK/build/cmd/linux64/._bin2c.c
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._cat
Executable file
BIN
Living_SDK/build/cmd/linux64/._cat
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._cp
Executable file
BIN
Living_SDK/build/cmd/linux64/._cp
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._dash
Executable file
BIN
Living_SDK/build/cmd/linux64/._dash
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._echo
Executable file
BIN
Living_SDK/build/cmd/linux64/._echo
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._hmac_sha256
Executable file
BIN
Living_SDK/build/cmd/linux64/._hmac_sha256
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._make
Executable file
BIN
Living_SDK/build/cmd/linux64/._make
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._mkdir
Executable file
BIN
Living_SDK/build/cmd/linux64/._mkdir
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._rm
Executable file
BIN
Living_SDK/build/cmd/linux64/._rm
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/._uname
Executable file
BIN
Living_SDK/build/cmd/linux64/._uname
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/aes_cbc_128
Executable file
BIN
Living_SDK/build/cmd/linux64/aes_cbc_128
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/awk
Executable file
BIN
Living_SDK/build/cmd/linux64/awk
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/bin2c
Executable file
BIN
Living_SDK/build/cmd/linux64/bin2c
Executable file
Binary file not shown.
280
Living_SDK/build/cmd/linux64/bin2c.c
Normal file
280
Living_SDK/build/cmd/linux64/bin2c.c
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
|
||||
#pragma warning(disable:4996) // Disable MSVC++ warnings about unsafe functions
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
int getopt(int argc, char *argv[], const char *optstring);
|
||||
char *optarg;
|
||||
int optind = 0;
|
||||
extern int getopt(int ac, char *av[], const char *optstring);
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
#elif defined __GNUC__
|
||||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#error Need definition for getopt
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
int opt_bigendian = 0;
|
||||
int opt_word = 0;
|
||||
int opt_indent = 8;
|
||||
int opt_maxcol = 79;
|
||||
|
||||
char *opt_utype = NULL;
|
||||
|
||||
#define SWAP32(x) ((((x) >> 24) & 0x000000ff) | \
|
||||
(((x) >> 8) & 0x0000ff00) | \
|
||||
(((x) << 8) & 0x00ff0000) | \
|
||||
(((x) << 24) & 0xff000000))
|
||||
|
||||
int
|
||||
convert(char *ifn, char *ofn, char *array_name)
|
||||
{
|
||||
FILE *ifp, *ofp;
|
||||
int c, lc;
|
||||
struct stat istat;
|
||||
char *array_type;
|
||||
int array_len;
|
||||
|
||||
if (stat(ifn, &istat) < 0) {
|
||||
fprintf(stderr, "error: could not stat input file %s: %s\n",
|
||||
ifn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
array_type = (opt_word ? "const unsigned int" : "const unsigned char");
|
||||
array_len = (opt_word ? ((int)istat.st_size + 3) / 4 : (int)istat.st_size);
|
||||
|
||||
if ((ifp = fopen(ifn, "rb")) == NULL) {
|
||||
fprintf(stderr, "error: could not open input file %s: %s\n",
|
||||
ifn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ofp = fopen(ofn, "w")) == NULL) {
|
||||
fclose(ifp);
|
||||
fprintf(stderr, "error: could not open output file %s: %s\n",
|
||||
ofn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(ofp, "/* FILE-CSTYLED */\n");
|
||||
if (opt_utype != NULL) {
|
||||
fprintf(ofp,
|
||||
"#define %s %s_align._%s\n"
|
||||
"union %s_u {\n"
|
||||
"%*s%s _%s[%d];\n"
|
||||
"%*s%s align;\n"
|
||||
"} %s_align = {{\n",
|
||||
array_name, array_name, array_name,
|
||||
array_name,
|
||||
opt_indent, "", array_type, array_name, array_len,
|
||||
opt_indent, "", opt_utype,
|
||||
array_name);
|
||||
} else {
|
||||
fprintf(ofp,
|
||||
"%s %s[%d] = {\n",
|
||||
array_type, array_name, array_len);
|
||||
}
|
||||
|
||||
lc = 0;
|
||||
|
||||
if (opt_word) {
|
||||
while ((c = fgetc(ifp)) != EOF) {
|
||||
int i;
|
||||
unsigned int val = (unsigned int)c;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if ((c = getc(ifp)) == EOF)
|
||||
c = 0;
|
||||
val = (val << 8) | (unsigned int)c;
|
||||
}
|
||||
if (!opt_bigendian)
|
||||
val = SWAP32(val);
|
||||
if (lc > 0 && lc >= opt_maxcol - 12) {
|
||||
fprintf(ofp, ",\n");
|
||||
lc = 0;
|
||||
}
|
||||
if (lc == 0)
|
||||
lc += fprintf(ofp, "%*s0x%08x", opt_indent, "", val);
|
||||
else
|
||||
lc += fprintf(ofp, ", 0x%08x", val);
|
||||
}
|
||||
} else {
|
||||
while ((c = getc(ifp)) != EOF) {
|
||||
if (lc > 0 && lc >= opt_maxcol - 5) {
|
||||
fprintf(ofp, ",\n");
|
||||
lc = 0;
|
||||
}
|
||||
if (lc == 0)
|
||||
lc += fprintf(ofp, "%*s%d", opt_indent, "", c);
|
||||
else
|
||||
lc += fprintf(ofp, ", %d", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (lc > 0)
|
||||
fprintf(ofp, "\n");
|
||||
|
||||
if (opt_utype != NULL)
|
||||
fprintf(ofp, "}");
|
||||
fprintf(ofp, "};\n");
|
||||
|
||||
(void)fclose(ifp);
|
||||
|
||||
if (fclose(ofp) < 0) {
|
||||
fprintf(stderr, "error: could not close output file %s: %s\n",
|
||||
ofn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: bin2c [-w] [-eb] [-u type] [-i indent] [-m maxcol]\n"
|
||||
" <input> <output> <arrayname>\n"
|
||||
" -w Output 32-bit ints instead of bytes\n"
|
||||
" -eb Output for big-endian CPU (when used with -w)\n"
|
||||
" -u type Output a union with specified alignment type\n"
|
||||
" -i indent Indentation amount\n"
|
||||
" -m maxcol Maximum output columns to use\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "we:u:i:m:")) > 0)
|
||||
switch (c) {
|
||||
case 'w':
|
||||
opt_word = 1;
|
||||
break;
|
||||
case 'e':
|
||||
opt_bigendian = (optarg[0] == 'b');
|
||||
break;
|
||||
case 'u':
|
||||
opt_utype = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
opt_indent = atoi(optarg);
|
||||
break;
|
||||
case 'm':
|
||||
opt_maxcol = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
if (optind + 3 != argc)
|
||||
usage();
|
||||
|
||||
if (convert(argv[optind], argv[optind + 1], argv[optind + 2]) < 0)
|
||||
exit(1);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
|
||||
// From XGetopt.cpp Version 1.2
|
||||
//
|
||||
// Author: Hans Dietrich
|
||||
// hdietrich2@hotmail.com
|
||||
//
|
||||
// Description:
|
||||
// XGetopt.cpp implements getopt(), a function to parse command lines.
|
||||
//
|
||||
// History
|
||||
// Version 1.2 - 2003 May 17
|
||||
// - Added Unicode support
|
||||
//
|
||||
// Version 1.1 - 2002 March 10
|
||||
// - Added example to XGetopt.cpp module header
|
||||
//
|
||||
// This software is released into the public domain.
|
||||
// You are free to use it in any way you like.
|
||||
//
|
||||
// This software is provided "as is" with no expressed
|
||||
// or implied warranty. I accept no liability for any
|
||||
// damage or loss of business that this software may cause.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getopt(int argc, char *argv[], const char *optstring)
|
||||
{
|
||||
char c;
|
||||
char *cp;
|
||||
static char *next = NULL;
|
||||
if (optind == 0)
|
||||
next = NULL;
|
||||
|
||||
optarg = NULL;
|
||||
|
||||
if (next == NULL || *next == '\0')
|
||||
{
|
||||
if (optind == 0)
|
||||
optind++;
|
||||
|
||||
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
{
|
||||
optarg = NULL;
|
||||
if (optind < argc)
|
||||
optarg = argv[optind];
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (strcmp(argv[optind], "--") == 0)
|
||||
{
|
||||
optind++;
|
||||
optarg = NULL;
|
||||
if (optind < argc)
|
||||
optarg = argv[optind];
|
||||
return EOF;
|
||||
}
|
||||
|
||||
next = argv[optind];
|
||||
next++; // skip past -
|
||||
optind++;
|
||||
}
|
||||
|
||||
c = *next++;
|
||||
cp = strchr(optstring, c);
|
||||
|
||||
if (( cp == NULL ) || ( c == ':') )
|
||||
return '?';
|
||||
|
||||
cp++;
|
||||
if ( *cp == ':')
|
||||
{
|
||||
if (*next != '\0')
|
||||
{
|
||||
optarg = next;
|
||||
next = NULL;
|
||||
}
|
||||
else if (optind < argc)
|
||||
{
|
||||
optarg = argv[optind];
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif /* if defined( _MSC_VER ) */
|
||||
BIN
Living_SDK/build/cmd/linux64/cat
Executable file
BIN
Living_SDK/build/cmd/linux64/cat
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/cp
Executable file
BIN
Living_SDK/build/cmd/linux64/cp
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/dash
Executable file
BIN
Living_SDK/build/cmd/linux64/dash
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/echo
Executable file
BIN
Living_SDK/build/cmd/linux64/echo
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/grep
Executable file
BIN
Living_SDK/build/cmd/linux64/grep
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/hmac_sha256
Executable file
BIN
Living_SDK/build/cmd/linux64/hmac_sha256
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/make
Executable file
BIN
Living_SDK/build/cmd/linux64/make
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/mkdir
Executable file
BIN
Living_SDK/build/cmd/linux64/mkdir
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/rm
Executable file
BIN
Living_SDK/build/cmd/linux64/rm
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/st-flash
Executable file
BIN
Living_SDK/build/cmd/linux64/st-flash
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/st-info
Executable file
BIN
Living_SDK/build/cmd/linux64/st-info
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/st-util
Executable file
BIN
Living_SDK/build/cmd/linux64/st-util
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/uname
Executable file
BIN
Living_SDK/build/cmd/linux64/uname
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/linux64/xz
Executable file
BIN
Living_SDK/build/cmd/linux64/xz
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._aes_cbc_128.exe
Normal file
BIN
Living_SDK/build/cmd/win32/._aes_cbc_128.exe
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._bin2c.c
Normal file
BIN
Living_SDK/build/cmd/win32/._bin2c.c
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._bin2c.exe
Normal file
BIN
Living_SDK/build/cmd/win32/._bin2c.exe
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._bzip2.exe
Normal file
BIN
Living_SDK/build/cmd/win32/._bzip2.exe
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._cp.exe
Executable file
BIN
Living_SDK/build/cmd/win32/._cp.exe
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._echo.exe
Executable file
BIN
Living_SDK/build/cmd/win32/._echo.exe
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._hmac_sha256.exe
Normal file
BIN
Living_SDK/build/cmd/win32/._hmac_sha256.exe
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._libgcc_s_sjlj-1.dll
Normal file
BIN
Living_SDK/build/cmd/win32/._libgcc_s_sjlj-1.dll
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._libiconv2.dll
Normal file
BIN
Living_SDK/build/cmd/win32/._libiconv2.dll
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._libintl3.dll
Normal file
BIN
Living_SDK/build/cmd/win32/._libintl3.dll
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._libstdc++-6.dll
Normal file
BIN
Living_SDK/build/cmd/win32/._libstdc++-6.dll
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._make.exe
Executable file
BIN
Living_SDK/build/cmd/win32/._make.exe
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._make_redirect_mingw.sh
Normal file
BIN
Living_SDK/build/cmd/win32/._make_redirect_mingw.sh
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._md5sum.exe
Normal file
BIN
Living_SDK/build/cmd/win32/._md5sum.exe
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._mkdir.exe
Executable file
BIN
Living_SDK/build/cmd/win32/._mkdir.exe
Executable file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._msys-1.0.dll
Normal file
BIN
Living_SDK/build/cmd/win32/._msys-1.0.dll
Normal file
Binary file not shown.
BIN
Living_SDK/build/cmd/win32/._msys-bz2-1.dll
Normal file
BIN
Living_SDK/build/cmd/win32/._msys-bz2-1.dll
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue