Commit 40d7ce87 authored by Bc. Petr Elexa's avatar Bc. Petr Elexa

panel: fix cmake build

parent f6a86038
......@@ -10,20 +10,22 @@ project(acs-panel VERSION 1.0 LANGUAGES C)
set(CMAKE_EXECUTABLE_SUFFIX ".axf")
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}")
set(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}")
set(CMAKE_INSTALL_PREFIX "${PROJECT_ROOT}")
# LPCOpen chip library
add_library(lpc_chip_11cxx STATIC IMPORTED)
target_include_directories(lpc_chip_11cxx INTERFACE
lib/include
"${PROJECT_ROOT}/lib/include"
)
set_target_properties(lpc_chip_11cxx
PROPERTIES
IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/Debug/liblpc_chip_11cxx.a"
IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/Release/liblpc_chip_11cxx.a"
IMPORTED_LOCATION_DEBUG "${PROJECT_ROOT}/lib/Debug/liblpc_chip_11cxx.a"
IMPORTED_LOCATION_RELEASE "${PROJECT_ROOT}/lib/Release/liblpc_chip_11cxx.a"
)
......@@ -32,39 +34,39 @@ set_target_properties(lpc_chip_11cxx
add_executable(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PRIVATE
app
bsp
bsp/board
bsp/can
bsp/weigand
freertos/include
"${PROJECT_ROOT}/app"
"${PROJECT_ROOT}/bsp"
"${PROJECT_ROOT}/bsp/board"
"${PROJECT_ROOT}/bsp/can"
"${PROJECT_ROOT}/bsp/weigand"
"${PROJECT_ROOT}/freertos/include"
)
target_sources(${PROJECT_NAME} PRIVATE
app/crp.c
app/start.c
app/static_cache.c
app/terminal.c
app/terminal_config.c
bsp/brownout.c
bsp/reader.c
bsp/storage.c
bsp/watchdog.c
bsp/board/board.c
bsp/board/board_sysinit.c
bsp/board/cr_startup_lpc11xx.c
bsp/board/sysinit.c
bsp/can/can_term_driver.c
bsp/weigand/weigand.c
freertos/croutine.c
freertos/event_groups.c
freertos/heap_1.c
freertos/list.c
freertos/port.c
freertos/queue.c
freertos/stream_buffer.c
freertos/tasks.c
freertos/timers.c
"${PROJECT_ROOT}/app/crp.c"
"${PROJECT_ROOT}/app/start.c"
"${PROJECT_ROOT}/app/static_cache.c"
"${PROJECT_ROOT}/app/terminal.c"
"${PROJECT_ROOT}/app/terminal_config.c"
"${PROJECT_ROOT}/bsp/brownout.c"
"${PROJECT_ROOT}/bsp/reader.c"
"${PROJECT_ROOT}/bsp/storage.c"
"${PROJECT_ROOT}/bsp/watchdog.c"
"${PROJECT_ROOT}/bsp/board/board.c"
"${PROJECT_ROOT}/bsp/board/board_sysinit.c"
"${PROJECT_ROOT}/bsp/board/cr_startup_lpc11xx.c"
"${PROJECT_ROOT}/bsp/board/sysinit.c"
"${PROJECT_ROOT}/bsp/can/can_term_driver.c"
"${PROJECT_ROOT}/bsp/weigand/weigand.c"
"${PROJECT_ROOT}/freertos/croutine.c"
"${PROJECT_ROOT}/freertos/event_groups.c"
"${PROJECT_ROOT}/freertos/heap_1.c"
"${PROJECT_ROOT}/freertos/list.c"
"${PROJECT_ROOT}/freertos/port.c"
"${PROJECT_ROOT}/freertos/queue.c"
"${PROJECT_ROOT}/freertos/stream_buffer.c"
"${PROJECT_ROOT}/freertos/tasks.c"
"${PROJECT_ROOT}/freertos/timers.c"
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
......@@ -116,13 +118,13 @@ else()
endif()
linker_script_add(${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}_${CMAKE_BUILD_TYPE}.ld")
linker_script_target_dependency(${PROJECT_NAME} "${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}_${CMAKE_BUILD_TYPE}.ld")
linker_script_add(${PROJECT_NAME} "${PROJECT_ROOT}/cmake/${PROJECT_NAME}_${CMAKE_BUILD_TYPE}.ld")
linker_script_target_dependency(${PROJECT_NAME} "${PROJECT_ROOT}/cmake/${PROJECT_NAME}_${CMAKE_BUILD_TYPE}.ld")
# Post build steps
firmware_size(${PROJECT_NAME})
generate_object(${PROJECT_NAME} .bin binary)
if(${CMAKE_BUILD_TYPE} STREQUAL Release)
calculate_checksum(${PROJECT_NAME})
endif()
# generate BIN from AXF
generate_object(${PROJECT_NAME} ${CMAKE_EXECUTABLE_SUFFIX} .bin binary)
calculate_bin_checksum(${PROJECT_NAME})
# generate HEX from BIN with checksum
generate_object(${PROJECT_NAME} ${CMAKE_EXECUTABLE_SUFFIX} .hex ihex)
This is Access control system panel source code and project for MCUXpresso IDE.
This is Access control system panel source code
Main firmware behavior setting can be controlled in app/terminal_config.h.
- There are projects for MCUXpresso IDE and CMake.
- Main firmware behavior settings are in file app/terminal_config.h.
To build firmware from IDE:
Import enclosed project for MCUXpresso IDE 10.3.1.
To build release fimware with CMake:
- This requires CMake 3.11+ (https://cmake.org) and NXP version of ARM GCC Toolchain which can be obtained only by installing MCUXpresso IDE.
- Run build_release_fw.bat (you may need to edit path to arm-none-eabi-gcc.exe according to your location of MCUXpresso IDE installation)
- Firmware files will be in Release folder
To build fimware from command line:
Run build_release_fw.bat.
This requires CMake 3.11+ (https://cmake.org) and NXP version of ARM GCC Toolchain which can be obtained only by installing MCUXpresso IDE.
\ No newline at end of file
To build or debug firmware with IDE:
- Import enclosed project for MCUXpresso IDE 10.3.1.
- Use as usual
......@@ -9,8 +9,32 @@
* MCUXpresso IDE v10.3.1 [Build 2233] [2019-02-20] on 18.11.2019 0:01:44
*/
INCLUDE "acs-panel_Debug_library.ld"
INCLUDE "acs-panel_Debug_memory.ld"
GROUP (
"libgcc.a"
"libc_nano.a"
"libm.a"
"libcr_newlib_nohost.a"
)
MEMORY
{
/* Define each memory region */
MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32K bytes (alias Flash) */
RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K bytes (alias RAM) */
}
/* Define a symbol for the top of each memory region */
__base_MFlash32 = 0x0 ; /* MFlash32 */
__base_Flash = 0x0 ; /* Flash */
__top_MFlash32 = 0x0 + 0x8000 ; /* 32K bytes */
__top_Flash = 0x0 + 0x8000 ; /* 32K bytes */
__base_RamLoc8 = 0x10000000 ; /* RamLoc8 */
__base_RAM = 0x10000000 ; /* RAM */
__top_RamLoc8 = 0x10000000 + 0x2000 ; /* 8K bytes */
__top_RAM = 0x10000000 + 0x2000 ; /* 8K bytes */
ENTRY(ResetISR)
......
/*
* GENERATED FILE - DO NOT EDIT
* Copyright (c) 2008 - 2013 Code Red Technologies Ltd,
* Copyright 2015, 2018 NXP
* (c) NXP Semiconductors 2013-2019
* Generated linker script file for LPC11C24/301
* Created from library.ldt by FMCreateLinkLibraries
* Using Freemarker v2.3.23
* MCUXpresso IDE v10.3.1 [Build 2233] [2019-02-20] on 18.11.2019 0:01:44
*/
GROUP (
"libgcc.a"
"libc_nano.a"
"libm.a"
"libcr_newlib_nohost.a"
)
/*
* GENERATED FILE - DO NOT EDIT
* Copyright (c) 2008 - 2013 Code Red Technologies Ltd,
* Copyright 2015, 2018 NXP
* (c) NXP Semiconductors 2013-2019
* Generated linker script file for LPC11C24/301
* Created from memory.ldt by FMCreateLinkMemory
* Using Freemarker v2.3.23
* MCUXpresso IDE v10.3.1 [Build 2233] [2019-02-20] on 18.11.2019 0:01:44
*/
MEMORY
{
/* Define each memory region */
MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32K bytes (alias Flash) */
RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K bytes (alias RAM) */
}
/* Define a symbol for the top of each memory region */
__base_MFlash32 = 0x0 ; /* MFlash32 */
__base_Flash = 0x0 ; /* Flash */
__top_MFlash32 = 0x0 + 0x8000 ; /* 32K bytes */
__top_Flash = 0x0 + 0x8000 ; /* 32K bytes */
__base_RamLoc8 = 0x10000000 ; /* RamLoc8 */
__base_RAM = 0x10000000 ; /* RAM */
__top_RamLoc8 = 0x10000000 + 0x2000 ; /* 8K bytes */
__top_RAM = 0x10000000 + 0x2000 ; /* 8K bytes */
......@@ -9,8 +9,31 @@
* MCUXpresso IDE v10.3.1 [Build 2233] [2019-02-20] on 17.11.2019 18:39:25
*/
INCLUDE "acs-panel_Release_library.ld"
INCLUDE "acs-panel_Release_memory.ld"
GROUP (
"libgcc.a"
"libc_nano.a"
"libm.a"
"libcr_newlib_nohost.a"
)
MEMORY
{
/* Define each memory region */
MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32K bytes (alias Flash) */
RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K bytes (alias RAM) */
}
/* Define a symbol for the top of each memory region */
__base_MFlash32 = 0x0 ; /* MFlash32 */
__base_Flash = 0x0 ; /* Flash */
__top_MFlash32 = 0x0 + 0x8000 ; /* 32K bytes */
__top_Flash = 0x0 + 0x8000 ; /* 32K bytes */
__base_RamLoc8 = 0x10000000 ; /* RamLoc8 */
__base_RAM = 0x10000000 ; /* RAM */
__top_RamLoc8 = 0x10000000 + 0x2000 ; /* 8K bytes */
__top_RAM = 0x10000000 + 0x2000 ; /* 8K bytes */
ENTRY(ResetISR)
......
/*
* GENERATED FILE - DO NOT EDIT
* Copyright (c) 2008 - 2013 Code Red Technologies Ltd,
* Copyright 2015, 2018 NXP
* (c) NXP Semiconductors 2013-2019
* Generated linker script file for LPC11C24/301
* Created from library.ldt by FMCreateLinkLibraries
* Using Freemarker v2.3.23
* MCUXpresso IDE v10.3.1 [Build 2233] [2019-02-20] on 17.11.2019 18:39:25
*/
GROUP (
"libgcc.a"
"libc_nano.a"
"libm.a"
"libcr_newlib_nohost.a"
)
/*
* GENERATED FILE - DO NOT EDIT
* Copyright (c) 2008 - 2013 Code Red Technologies Ltd,
* Copyright 2015, 2018 NXP
* (c) NXP Semiconductors 2013-2019
* Generated linker script file for LPC11C24/301
* Created from memory.ldt by FMCreateLinkMemory
* Using Freemarker v2.3.23
* MCUXpresso IDE v10.3.1 [Build 2233] [2019-02-20] on 17.11.2019 18:39:25
*/
MEMORY
{
/* Define each memory region */
MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32K bytes (alias Flash) */
RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K bytes (alias RAM) */
}
/* Define a symbol for the top of each memory region */
__base_MFlash32 = 0x0 ; /* MFlash32 */
__base_Flash = 0x0 ; /* Flash */
__top_MFlash32 = 0x0 + 0x8000 ; /* 32K bytes */
__top_Flash = 0x0 + 0x8000 ; /* 32K bytes */
__base_RamLoc8 = 0x10000000 ; /* RamLoc8 */
__base_RAM = 0x10000000 ; /* RAM */
__top_RamLoc8 = 0x10000000 + 0x2000 ; /* 8K bytes */
__top_RAM = 0x10000000 + 0x2000 ; /* 8K bytes */
cmake_minimum_required(VERSION 3.11)
#---------------------
# ARM GCC Toolchain for cross-compiling to LPC11C24_301
# ARM GCC Toolchain for cross-compiling to NXP LPC11C24_301
#---------------------
set(CMAKE_SYSTEM_NAME Generic)
......@@ -30,13 +30,14 @@ get_filename_component(ARM_TOOLCHAIN_DIR "${ARM_COMPILER_PATH}" DIRECTORY)
message(STATUS "Using ARM GCC toolchain:\"${ARM_TOOLCHAIN_DIR}\"")
set(CMAKE_C_COMPILER "${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}gcc${EXE}")
set(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}")
set(CMAKE_ASM_COMPILER "${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}gcc${EXE}")
set(CMAKE_CXX_COMPILER "${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}g++${EXE}")
set(CMAKE_OBJCOPY "${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy${EXE}" CACHE INTERNAL "objcopy tool")
set(CMAKE_SIZE_UTIL "${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size${EXE}" CACHE INTERNAL "size tool")
set(CMAKE_SYSROOT "${ARM_TOOLCHAIN_DIR}/../arm-none-eabi")
set(CMAKE_PREFIX_PATH "${ARM_TOOLCHAIN_DIR}/../arm-none-eabi")
set(CMAKE_FIND_ROOT_PATH "${ARM_TOOLCHAIN_DIR}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
......@@ -59,19 +60,21 @@ function(firmware_size target)
endfunction()
# Add a command to generate firmare in a provided format
function(generate_object target suffix type)
function(generate_object target in_suffix suffix type)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND echo Generating ${type}...
COMMAND ${CMAKE_OBJCOPY} -v -O ${type}
"${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/${target}${suffix}"
COMMENT "Generating binary..."
"${CMAKE_CURRENT_BINARY_DIR}/${target}${in_suffix}" "${CMAKE_CURRENT_BINARY_DIR}/${target}${suffix}"
COMMENT "Generating ${type}..."
)
endfunction()
function(calculate_checksum target)
function(calculate_bin_checksum target)
if(CHECKSUM_BIN)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND echo Calculating binary checksum...
COMMAND ${CHECKSUM_BIN} -p LPC11C24_301 -d "${CMAKE_CURRENT_BINARY_DIR}/${target}.bin"
COMMENT "Calculating checksum..."
COMMENT "Calculating binary checksum..."
)
endif()
endfunction()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment