我正在尝试交叉编译,主机是wondows目标是stm32(arm)。我正在尝试从arm-none-eabi-ld生成Map文件。我的问题有两个
1.我无法生成Map文件。这是我的主要问题。
1.当我运行构建清理我的.hex文件和.bin文件没有被删除。
请在下面找到我的工具链cmake文件(arm-none-eabi.cmake)。
MESSAGE("Running : arm-none-eabi.cmake")
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_TRY_COMPILE_TARGTE_TYPE STATIC_LIBRARY)
SET(TARGET STM32F030x4)
SET(ARCH armv6-m)
SET(CPU cortex-m0)
SET(ARM_ISA mthumb)
SET(CMAKE_C_COMPILER arm-none-eabi-gcc)
SET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
SET(CMAKE_ASM_COMPILER arm-none-eabi-g++)
SET(CMAKE_SIZE arm-none-eabi-size)
SET(CMAKE_OBJDUMP arm-none-eabi-objdump)
SET(CMAKE_OBJCOPY arm-none-eabi-objcopy)
SET(OPTIMISATION Og)
SET(DEBUG "ggdb")
SET(CMAKE_COMMON_FLAGS "-march=${ARCH} -mcpu=${CPU} -${ARM_ISA} -D${TARGET} -${OPTIMISATION} -${DEBUG} -Wall -Wextra -ffunction-sections -fdata-sections -nostdlib -ffreestanding -fno-builtin --specs=nosys.specs -lc --entry main")
SET(CMAKE_ASM_FLAGS "${CMAKE_COMMON_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_COMMON_FLAGS} ") #-std=gnull
SET(CMAKE_CXX_FLAGS "${CMAKE_COMMON_FLAGS} -fno-rtti -fno-exceptions -Wno-volatile -std=c++1z")
SET(CMAKE_LINKER_FLAGS "${CMAKE_COMMON_FLAGS} -nostartfiles -Wl,-Map,\"${TARGET}.map\" --specs-nosys.specs")
-Wl,-Map,"${TARGET}.map”命令未生成Map文件。
我的CmakeLists.txt文件
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
INCLUDE("CMake/arm-none-eabi.cmake")
SET(CMAKE_C_STANDARD 11)
SET(CMAKE_CXX_STANDARD 17)
PROJECT(BLINKY VERSION 1.0.1 DESCRIPTION "Blinky Example")
MESSAGE("Building "${PROJECT_NAME})
FILE(GLOB_RECURSE
LDSCRIPTS
"ldscripts/*.ld"
)
FOREACH(file ${LDSCRIPTS})
SET(CMAKE_LINKER_FLAGS "${CAMKE_LINKER_FLAGS} -T \"${file}\" ")
ENDFOREACH()
#Setup project headers
INCLUDE_DIRECTORIES(
"Core/"
"Drivers/"
)
#Setup porject sources
FILE(GLOB_RECURSE
APPLICATION_SOURCE
"Application/*.c"
"Application/*.cpp"
"Application/*.s"
"Core/*.c"
"Core/*cpp"
"Core/*.s"
"Drivers/*.c"
"Drivers/*.cpp"
"Drivers/*.s"
)
ADD_EXECUTABLE(${TARGET}.elf ${APPLICATION_SOURCE})
ADD_CUSTOM_TARGET(${TARGET}.bin ALL DEPENDS ${TARGET}.elf COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET}.elf ${TARGET}.bin)
ADD_CUSTOM_TARGET(${TARGET}.hex ALL DEPENDS ${TARGET}.elf COMMAND ${CMAKE_OBJCOPY} -O ihex ${TARGET}.elf ${TARGET}.hex)
ADD_CUSTOM_TARGET(SIZE ALL ${CMAKE_SIZE} ${TARGET}.elf DEPENDS ${TARGET}.elf)
1条答案
按热度按时间shyt4zoc1#
(我认为一般指导是每个发布的问题对应一个问题)
回答:
当我运行构建清理我的. hex文件和. bin文件没有被删除。
根据add_custom_target()的文档:
目标没有输出文件
没有输出文件意味着CMake不知道它生成了什么,您可能需要使用add_custom_command(),然后使自定义目标依赖于自定义命令:
我不确定
${TARGET}.bin
是否会发生冲突,但我对它进行了修改,以减少未来维护人员的歧义。