21ic问答首页 - HC32L130 GCC编译的hex文件下载无反应
HC32L130 GCC编译的hex文件下载无反应
188976717192024-02-23
由于版权问题,不能用keil。官方的例程中没有GCC的启动文件和ld文件,从论坛中下载了一份。成功生成hex文件并下载成功,但没反应。
不晓得是不是生成hex文件的问题。
附上cmake
set(CMAKE_SYSTEM_NAME Generic)
cmake_minimum_required(VERSION 3.21)
project(HC32L130 C ASM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_C_FLAGS_DEBUG "-O0 -g2 -ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 99)
include_directories(
CMSIS/Inc
Components/BSP/Inc
Driver/Inc
${CMAKE_CURRENT_BINARY_DIR}
)
file(GLOB_RECURSE hc32l130lib CONFIGURE_DEPENDS
CMSIS/Src/*.c
Driver/Src/*.c
)
file(GLOB_RECURSE bsp CONFIGURE_DEPENDS
Components/BSP/Src
)
aux_source_directory(${CMAKE_SOURCE_DIR}/main main)
set(startup ${CMAKE_SOURCE_DIR}/startup_hc32L13x.S)
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/HC32L130.ld)
set(MAP_FILE ${PROJECT_NAME}.map)
set(CMAKE_C_FLAGS "-mlong-calls -fno-common -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections")
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=cortex-m0plus -mthumb -ffunction-sections -T ${LINKER_SCRIPT} -Xlinker --gc-sections -Wl,-Map,${MAP_FILE} --specs=nano.specs --specs=nosys.specs" )
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mcpu=cortex-m0plus -mthumb -nostartfiles -ffunction-sections -Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs --print-memory-usage")
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
add_executable(${PROJECT_NAME}.elf ${main} ${hc32l130lib} ${bsp} ${startup} ${LINKER_SCRIPT})
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMENT "Building ${HEX_FILE}")
不晓得是不是生成hex文件的问题。
附上cmake
set(CMAKE_SYSTEM_NAME Generic)
cmake_minimum_required(VERSION 3.21)
project(HC32L130 C ASM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_C_FLAGS_DEBUG "-O0 -g2 -ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 99)
include_directories(
CMSIS/Inc
Components/BSP/Inc
Driver/Inc
${CMAKE_CURRENT_BINARY_DIR}
)
file(GLOB_RECURSE hc32l130lib CONFIGURE_DEPENDS
CMSIS/Src/*.c
Driver/Src/*.c
)
file(GLOB_RECURSE bsp CONFIGURE_DEPENDS
Components/BSP/Src
)
aux_source_directory(${CMAKE_SOURCE_DIR}/main main)
set(startup ${CMAKE_SOURCE_DIR}/startup_hc32L13x.S)
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/HC32L130.ld)
set(MAP_FILE ${PROJECT_NAME}.map)
set(CMAKE_C_FLAGS "-mlong-calls -fno-common -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections")
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=cortex-m0plus -mthumb -ffunction-sections -T ${LINKER_SCRIPT} -Xlinker --gc-sections -Wl,-Map,${MAP_FILE} --specs=nano.specs --specs=nosys.specs" )
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mcpu=cortex-m0plus -mthumb -nostartfiles -ffunction-sections -Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs --print-memory-usage")
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
add_executable(${PROJECT_NAME}.elf ${main} ${hc32l130lib} ${bsp} ${startup} ${LINKER_SCRIPT})
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMENT "Building ${HEX_FILE}")
赞0
评论
2024-02-26
赞0
评论
2024-02-26
赞0
评论
2024-02-26
赞0
评论
2024-02-26
赞0
评论
2024-02-26
赞0
评论
2024-02-26
赞0
评论
2024-02-23
您需要登录后才可以回复 登录 | 注册