diff --git a/arduino/CMakeLists.txt b/arduino/CMakeLists.txt index eec92c6..a2bb900 100644 --- a/arduino/CMakeLists.txt +++ b/arduino/CMakeLists.txt @@ -43,17 +43,18 @@ file(GLOB_RECURSE ARDUINO_SRC ${ARDUINO_ESP8266_DIR}/cores/esp8266/*.cpp ) -file(GLOB ARDUINO_ASM_SRC +file(GLOB ARDUINO_SRC_ASM ${ARDUINO_ESP8266_DIR}/cores/esp8266/*.S ) -set_source_files_properties(${ARDUINO_ASM_SRC} PROPERTIES +set_source_files_properties(${ARDUINO_SRC_ASM} PROPERTIES LANGUAGE ASM + COMPILE_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}" ) add_library(arduino STATIC ${ARDUINO_SRC} - ${ARDUINO_ASM_SRC} + ${ARDUINO_SRC_ASM} ) target_include_directories(arduino PUBLIC diff --git a/arduino/libraries/GDBStub/CMakeLists.txt b/arduino/libraries/GDBStub/CMakeLists.txt index 61d937f..3749fc7 100644 --- a/arduino/libraries/GDBStub/CMakeLists.txt +++ b/arduino/libraries/GDBStub/CMakeLists.txt @@ -3,8 +3,18 @@ file(GLOB GDBSTUB_LIB_SRC ${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/internal/*.S ) +file(GLOB GDBSTUB_LIB_SRC_ASM + ${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/internal/*.S +) + +set_source_files_properties(${GDBSTUB_LIB_SRC_ASM} PROPERTIES + LANGUAGE ASM + COMPILE_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}" +) + add_library(esp8266gdbstub STATIC ${GDBSTUB_LIB_SRC} + ${GDBSTUB_LIB_SRC_ASM} ) target_include_directories(esp8266gdbstub PUBLIC @@ -14,3 +24,11 @@ target_include_directories(esp8266gdbstub PUBLIC ${ARDUINO_ESP8266_DIR}/libraries/GDBStub/src/xtensa/config ) +target_compile_definitions(esp8266gdbstub PUBLIC + -DGDBSTUB_REDIRECT_CONSOLE_OUTPUT + -DGDBSTUB_CTRLC_BREAK + -DGDBSTUB_BREAK_ON_INIT +) + +target_link_libraries(esp8266gdbstub + arduino diff --git a/cmake/toolchain.ESP8266.cmake b/cmake/toolchain.ESP8266.cmake index d4e7ea9..abca7fe 100644 --- a/cmake/toolchain.ESP8266.cmake +++ b/cmake/toolchain.ESP8266.cmake @@ -5,7 +5,8 @@ set(CMAKE_SYSTEM_VERSION 1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules") -set (ESP8266_FLASH_SIZE "512K" CACHE STRING "Size of flash") +set (ESP8266_FLASH_SIZE "512k0" CACHE STRING "Size of flash") +set (ESP8266_LINKER_SCRIPT "eagle.flash.512k0.ld" CACHE STRING "Name of linker script") if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") set(USER_HOME $ENV{HOME}) @@ -45,7 +46,7 @@ CMAKE_FORCE_CXX_COMPILER(${ESP8266_XTENSA_CXX_COMPILER} GNU_CXX) set(CMAKE_C_FLAGS "-Os -g -std=gnu99 -Wpointer-arith -Wno-implicit-function-declaration -Wundef -pipe -D__ets__ -DICACHE_FLASH -fno-inline-functions -ffunction-sections -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -fdata-sections" CACHE STRING "C compiler flags") set(CMAKE_CXX_FLAGS "-Os -g -D__ets__ -DICACHE_FLASH -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections" CACHE STRING "CXX compiler flags") -set(CMAKE_EXE_LINKER_FLAGS "-nostdlib -Wl,--no-check-sections -Wl,-static -Wl,--gc-sections -Wl,--no-relax -L${ARDUINO_ESP8266_DIR}/tools/sdk/ld -Teagle.flash.512k0.ld -u call_user_start -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy" CACHE STRING "linker flags") +set(CMAKE_EXE_LINKER_FLAGS "-nostdlib -Wl,--no-check-sections -Wl,-static -Wl,--gc-sections -Wl,--no-relax -L${ARDUINO_ESP8266_DIR}/tools/sdk/ld -Teagle.flash.${ESP8266_FLASH_SIZE}.ld -u call_user_start -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy" CACHE STRING "linker flags") set(CMAKE_C_LINK_EXECUTABLE " -o -Wl,--start-group -Wl,--end-group" CACHE STRING "C linker invocation") set(CMAKE_CXX_LINK_EXECUTABLE " -o -Wl,--start-group -Wl,--end-group" CACHE STRING "CXX linker invocation")