build: W600-SDK importiert, Firmware-Build und Hello am EVK
Docker-Build mit gcc-arm-none-eabi 4.9-2014q4 (statt Homebrew-Cask) verwendet, Dockerfile/tools/docker.sh dafür aus Task 13 vorgezogen. cmake/sdk.cmake schont gcc 4.9 (kennt -fcommon/-Wno-error=... nicht). Zwei zusätzliche SDK-Stubs (EarlyInit, pre_gpio_config) in src/sys/sdk_stubs.c ergänzt, siehe sdk/PATCHES.md.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
# Official ARM GNU toolchain (ships newlib). In Docker the compiler is found via PATH.
|
||||
file(GLOB _nl_arm_bins "/Applications/ArmGNUToolchain/*/arm-none-eabi/bin")
|
||||
list(SORT _nl_arm_bins ORDER DESCENDING)
|
||||
set(_nl_arm_default "")
|
||||
if(_nl_arm_bins)
|
||||
list(GET _nl_arm_bins 0 _nl_arm_default)
|
||||
endif()
|
||||
set(NL_ARM_TOOLCHAIN_BIN "${_nl_arm_default}" CACHE PATH "bin directory of the ARM GNU toolchain (empty = PATH)")
|
||||
|
||||
if(NL_ARM_TOOLCHAIN_BIN)
|
||||
set(_nl_prefix "${NL_ARM_TOOLCHAIN_BIN}/arm-none-eabi-")
|
||||
else()
|
||||
set(_nl_prefix "arm-none-eabi-")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER "${_nl_prefix}gcc")
|
||||
set(CMAKE_ASM_COMPILER "${_nl_prefix}gcc")
|
||||
set(CMAKE_OBJCOPY "${_nl_prefix}objcopy" CACHE INTERNAL "")
|
||||
set(CMAKE_SIZE "${_nl_prefix}size" CACHE INTERNAL "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
|
||||
@@ -0,0 +1,20 @@
|
||||
# Host tool wm_tool packs the firmware into .img / _gz.img / .fls.
|
||||
set(NL_WM_TOOL ${CMAKE_BINARY_DIR}/wm_tool)
|
||||
add_custom_command(OUTPUT ${NL_WM_TOOL}
|
||||
COMMAND cc -O2 -w -o ${NL_WM_TOOL} ${SDK_DIR}/tools/wm_tool.c -lpthread
|
||||
DEPENDS ${SDK_DIR}/tools/wm_tool.c
|
||||
COMMENT "Building host tool wm_tool")
|
||||
add_custom_target(nl_wm_tool DEPENDS ${NL_WM_TOOL})
|
||||
|
||||
# 2M layout: update area 0x100000, run area 0x10100 (same as the old Klyqa images).
|
||||
function(nl_add_images target)
|
||||
add_dependencies(${target} nl_wm_tool)
|
||||
set(out ${CMAKE_BINARY_DIR}/${target})
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} --output-target=binary -S -g -x -X -R .sbss -R .bss -R .reginfo -R .stack
|
||||
$<TARGET_FILE:${target}> ${out}.bin
|
||||
COMMAND ${NL_WM_TOOL} -b ${out}.bin -sb ${SDK_DIR}/Bin/secboot.img -fc compress -it 2M
|
||||
-ua 100000 -ra 10100 -df -o ${out}
|
||||
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${target}>
|
||||
COMMENT "Packing ${target}.fls and ${target}_gz.img")
|
||||
endfunction()
|
||||
@@ -0,0 +1,49 @@
|
||||
# W600 SDK: compiler flags, include paths and the SDK object libraries.
|
||||
set(SDK_DIR ${CMAKE_SOURCE_DIR}/sdk)
|
||||
|
||||
set(NL_ARCH_FLAGS "-mthumb -mcpu=cortex-m3 -march=armv7-m -mabi=aapcs")
|
||||
set(CMAKE_C_FLAGS "${NL_ARCH_FLAGS} --function-sections --data-sections -std=gnu99 -fno-builtin -DGCC_COMPILE=1 -D_IN_ADDR_T_DECLARED -D__MACHINE_ENDIAN_H__ -D_TIMEVAL_DEFINED -D__INSIDE_CYGWIN_NET__")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Os")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Og -g3")
|
||||
set(CMAKE_ASM_FLAGS "${NL_ARCH_FLAGS} -mthumb-interwork")
|
||||
|
||||
# The SDK predates the GCC 10/14 defaults (-fno-common, implicit declarations are errors).
|
||||
# gcc 4.9 (the Docker build toolchain, see docker/Dockerfile) does not know these options and
|
||||
# already defaults to common symbols / warnings-only, so only add them for newer host compilers.
|
||||
# Directory-level options are inherited by the SDK subdirectories below.
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
|
||||
add_compile_options(
|
||||
-fcommon
|
||||
-Wno-error=implicit-function-declaration
|
||||
-Wno-error=incompatible-pointer-types
|
||||
-Wno-error=int-conversion
|
||||
-Wno-error=implicit-int
|
||||
-Wno-error=return-mismatch)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${SDK_DIR}/Include ${SDK_DIR}/Include/App ${SDK_DIR}/Include/Net ${SDK_DIR}/Include/WiFi
|
||||
${SDK_DIR}/Include/OS ${SDK_DIR}/Include/Driver ${SDK_DIR}/Include/Platform
|
||||
${SDK_DIR}/Src/OS/RTOS/include
|
||||
${SDK_DIR}/Platform/Boot/gcc ${SDK_DIR}/Platform/Common/Params ${SDK_DIR}/Platform/Common/task
|
||||
${SDK_DIR}/Platform/Common/mem ${SDK_DIR}/Platform/Common/fwup ${SDK_DIR}/Platform/Common/utils
|
||||
${SDK_DIR}/Platform/Common/crypto ${SDK_DIR}/Platform/Inc ${SDK_DIR}/Platform/Sys
|
||||
${SDK_DIR}/Src/App/OTA ${SDK_DIR}/Src/App/dhcpserver ${SDK_DIR}/Src/App/dnsserver ${SDK_DIR}/Src/App/httpclient
|
||||
${SDK_DIR}/Src/Network/lwip2.0.3/include ${SDK_DIR}/Src/Network/api2.0.3
|
||||
${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
foreach(dir Platform/Common Platform/Drivers Platform/Sys Src/Network Src/OS/RTOS
|
||||
Src/App/dhcpserver Src/App/dnsserver Src/App/httpclient Src/App/OTA)
|
||||
string(REPLACE "/" "_" bindir ${dir})
|
||||
add_subdirectory(${SDK_DIR}/${dir} sdk_${bindir})
|
||||
endforeach()
|
||||
|
||||
set(NL_SDK_OBJECTS
|
||||
$<TARGET_OBJECTS:wmcommon.a> $<TARGET_OBJECTS:wmdriver.a> $<TARGET_OBJECTS:wmmain.a>
|
||||
$<TARGET_OBJECTS:wmlwip.a> $<TARGET_OBJECTS:wmrtos.a> $<TARGET_OBJECTS:wmdhcpserver.a>
|
||||
$<TARGET_OBJECTS:wmdnsserver.a> $<TARGET_OBJECTS:wmhttpclient.a> $<TARGET_OBJECTS:wmota.a>)
|
||||
|
||||
set(NL_SDK_BOOT_SOURCES
|
||||
${SDK_DIR}/Platform/Boot/gcc/startup.S
|
||||
${SDK_DIR}/Platform/Boot/gcc/retarget.c
|
||||
${SDK_DIR}/Platform/Boot/gcc/misc.c)
|
||||
@@ -0,0 +1,12 @@
|
||||
execute_process(
|
||||
COMMAND git describe --tags --always --dirty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE NINLIGHT_FW_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
if(NOT NINLIGHT_FW_VERSION)
|
||||
set(NINLIGHT_FW_VERSION "0.0.0-dev")
|
||||
endif()
|
||||
string(REGEX REPLACE "^v" "" NINLIGHT_FW_VERSION "${NINLIGHT_FW_VERSION}")
|
||||
# The OTA trailer reserves 16 bytes incl. terminator for the version.
|
||||
string(SUBSTRING "${NINLIGHT_FW_VERSION}" 0 15 NINLIGHT_FW_VERSION)
|
||||
string(TIMESTAMP NINLIGHT_BUILD_DATE "%Y-%m-%d")
|
||||
Reference in New Issue
Block a user