Use CMake build system.

This commit is contained in:
imi415 2021-04-17 23:14:22 +08:00
parent 1565b075b5
commit 9d2eaeed00
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
7 changed files with 621 additions and 16 deletions

179
CMakeLists.txt Normal file
View File

@ -0,0 +1,179 @@
cmake_minimum_required(VERSION 3.10)
project(STM32H750_LCD)
enable_language(CXX)
enable_language(ASM)
# Device specific settings, goes to CFLAGS and LDFLAGS
set(CFLAGS_HARDWARE "-mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb")
# Extra CFlags
set(CFLAGS_EXTRA "-Og")
set(LDFLAGS_EXTRA "-Wl,--print-memory-usage")
# Different linker scripts
set(LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/STM32H750VBTx_FLASH.ld")
set(LDSCRIPT_QSPI_FLASH "${CMAKE_SOURCE_DIR}/STM32H750VBTx_QSPI_FLASH.ld")
set(LDSCRIPT_RAM "${CMAKE_SOURCE_DIR}/STM32H750VBTx_RAM.ld")
# Copy them from Makefile
set(C_SOURCES
"Core/Src/main.c"
"Core/Src/stm32h7xx_it.c"
"Core/Src/stm32h7xx_hal_msp.c"
"Core/Src/otm8009a_lcd.c"
"Core/Src/otm_lcd_impl.c"
"Core/Src/user_tasks.c"
"Core/Src/user_task_lvgl.c"
"Core/Src/user_task_hello.c"
"Core/Src/otm_lcd_lvgl_impl.c"
"Core/Src/kururin_pa.c"
"Core/Src/system_stm32h7xx.c"
"Core/Src/freertos.c"
"Middlewares/Third_Party/FreeRTOS/Source/croutine.c"
"Middlewares/Third_Party/FreeRTOS/Source/event_groups.c"
"Middlewares/Third_Party/FreeRTOS/Source/list.c"
"Middlewares/Third_Party/FreeRTOS/Source/queue.c"
"Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c"
"Middlewares/Third_Party/FreeRTOS/Source/tasks.c"
"Middlewares/Third_Party/FreeRTOS/Source/timers.c"
"Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c"
"Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c"
"Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c"
"Core/Src/stm32h7xx_hal_timebase_tim.c"
"FATFS/App/fatfs.c"
"FATFS/Target/bsp_driver_sd.c"
"FATFS/Target/sd_diskio.c"
"Middlewares/Third_Party/FatFs/src/diskio.c"
"Middlewares/Third_Party/FatFs/src/ff.c"
"Middlewares/Third_Party/FatFs/src/ff_gen_drv.c"
"Middlewares/Third_Party/FatFs/src/option/syscall.c"
"Middlewares/Third_Party/FatFs/src/option/cc932.c"
)
# Copy them from Makefile
set(ASM_SOURCES
"startup_stm32h750xx.s"
)
set(C_LIBRARIES
"lvgl"
"stm32_hal_driver"
)
# Copy them from Makefile
set(C_DEFINES
"LV_LVGL_H_INCLUDE_SIMPLE"
"STM32H750xx"
"USE_HAL_DRIVER"
"USE_FULL_LL_DRIVER"
)
# Copy them from Makefile
set(C_INCLUDES
"Core/Inc"
"Drivers/STM32H7xx_HAL_Driver/Inc"
"Drivers/STM32H7xx_HAL_Driver/Inc/Legacy"
"Drivers/CMSIS/Device/ST/STM32H7xx/Include"
"Drivers/CMSIS/Include"
"Middlewares/Third_Party/FreeRTOS/Source/include"
"Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"
"Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"
"Middlewares/Third_Party/LittleVGL"
"FATFS/Target"
"FATFS/App"
"Middlewares/Third_Party/FatFs/src"
)
# Final compiler flags
set(CMAKE_C_FLAGS "${CFLAGS_HARDWARE} ${CFLAGS_EXTRA} -Wall -fdata-sections -ffunction-sections")
set(CMAKE_CXX_FLAGS "${CFLAGS_HARDWARE} ${CFLAGS_EXTRA} -Wall -fdata-sections -ffunction-sections")
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS "${CFLAGS_HARDWARE} -specs=nano.specs -Wl,--gc-sections -lc -lm -lnosys ${LDFLAGS_EXTRA}")
add_subdirectory(Drivers)
add_subdirectory(Middlewares)
# Main targets are added here
# **** Internal Flash ****
# Create ELF
add_executable("${CMAKE_PROJECT_NAME}_FLASH.elf" ${C_SOURCES} ${ASM_SOURCES})
target_compile_definitions("${CMAKE_PROJECT_NAME}_FLASH.elf" PRIVATE ${C_DEFINES})
target_include_directories("${CMAKE_PROJECT_NAME}_FLASH.elf" PRIVATE ${C_INCLUDES})
target_link_libraries("${CMAKE_PROJECT_NAME}_FLASH.elf" ${C_LIBRARIES})
target_link_options("${CMAKE_PROJECT_NAME}_FLASH.elf"
PRIVATE "-T${LDSCRIPT_FLASH}"
PRIVATE "-Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}_FLASH.map,--cref"
)
target_compile_options("${CMAKE_PROJECT_NAME}_FLASH.elf"
PRIVATE "${FINAL_C_FLAGS}"
)
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_FLASH.hex"
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_FLASH.elf" "${CMAKE_PROJECT_NAME}_FLASH.hex"
DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.elf"
)
add_custom_target("${CMAKE_PROJECT_NAME}_FLASH_HEX"
DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.hex"
)
# **** All In SRAM ****
# Create ELF
add_executable("${CMAKE_PROJECT_NAME}_RAM.elf" ${C_SOURCES} ${ASM_SOURCES})
target_compile_definitions("${CMAKE_PROJECT_NAME}_RAM.elf" PRIVATE ${C_DEFINES})
target_include_directories("${CMAKE_PROJECT_NAME}_RAM.elf" PRIVATE ${C_INCLUDES})
target_link_libraries("${CMAKE_PROJECT_NAME}_RAM.elf" ${C_LIBRARIES})
# Linker script and Map files
target_link_options("${CMAKE_PROJECT_NAME}_RAM.elf"
PRIVATE "-T${LDSCRIPT_RAM}"
PRIVATE "-Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}_RAM.map,--cref"
)
# Additional defines
target_compile_definitions("${CMAKE_PROJECT_NAME}_RAM.elf"
PRIVATE "VECT_TAB_SRAM"
)
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_RAM.hex"
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_RAM.elf" "${CMAKE_PROJECT_NAME}_RAM.hex"
DEPENDS "${CMAKE_PROJECT_NAME}_RAM.elf"
)
add_custom_target("${CMAKE_PROJECT_NAME}_RAM_HEX"
DEPENDS "${CMAKE_PROJECT_NAME}_RAM.hex"
)
# **** QUADSPI XIP ****
# Create ELF
add_executable("${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf" ${C_SOURCES} ${ASM_SOURCES})
target_compile_definitions("${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf" PRIVATE ${C_DEFINES})
target_include_directories("${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf" PRIVATE ${C_INCLUDES})
target_link_libraries("${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf" ${C_LIBRARIES})
# Linker script and Map files
target_link_options("${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf"
PRIVATE "-T${LDSCRIPT_QSPI_FLASH}"
PRIVATE "-Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}_QSPI_FLASH.map,--cref"
)
# Additional defines
target_compile_definitions("${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf"
PRIVATE "VECT_TAB_SRAM"
)
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_QSPI_FLASH.hex"
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf" "${CMAKE_PROJECT_NAME}_QSPI_FLASH.hex"
DEPENDS "${CMAKE_PROJECT_NAME}_QSPI_FLASH.elf"
)
add_custom_target("${CMAKE_PROJECT_NAME}_QSPI_FLASH_HEX"
DEPENDS "${CMAKE_PROJECT_NAME}_QSPI_FLASH.hex"
)

21
Drivers/CMakeLists.txt Normal file
View File

@ -0,0 +1,21 @@
file(GLOB_RECURSE HAL_DRIVER_SOURCES
"STM32H7xx_HAL_Driver/*.c"
)
set(HAL_DRIVER_INCLUDES
"../Core/Inc"
"STM32H7xx_HAL_Driver/Inc"
"STM32H7xx_HAL_Driver/Inc/Legacy"
"CMSIS/Device/ST/STM32H7xx/Include"
"CMSIS/Include"
)
set(HAL_DRIVER_DEFINES
"STM32H750xx"
"USE_HAL_DRIVER"
"USE_FULL_LL_DRIVER"
)
add_library(stm32_hal_driver STATIC ${HAL_DRIVER_SOURCES})
target_include_directories(stm32_hal_driver PRIVATE ${HAL_DRIVER_INCLUDES})
target_compile_definitions(stm32_hal_driver PRIVATE ${HAL_DRIVER_DEFINES})

View File

@ -0,0 +1,15 @@
file(GLOB_RECURSE LVGL_SOURCES
"Third_Party/LittleVGL/src/*.c"
)
set(LVGL_INCLUDES
"../Core/Inc"
)
set(LVGL_DEFINES
"LV_CONF_INCLUDE_SIMPLE"
)
add_library(lvgl STATIC ${LVGL_SOURCES})
target_include_directories(lvgl PRIVATE ${LVGL_INCLUDES})
target_compile_definitions(lvgl PRIVATE ${LVGL_DEFINES})

View File

@ -62,12 +62,11 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
MEMORY
{
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
QSPI_FLASH (rx) : ORIGIN = 0x90000000, LENGTH = 16M
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
}
/* Define output sections */
@ -79,7 +78,7 @@ SECTIONS
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >QSPI_FLASH
} >FLASH
/* The program code and other data goes into FLASH */
.text :
@ -96,7 +95,7 @@ SECTIONS
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >QSPI_FLASH
} >FLASH
/* Constant data goes into FLASH */
.rodata :
@ -105,35 +104,35 @@ SECTIONS
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >QSPI_FLASH
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >QSPI_FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >QSPI_FLASH
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >QSPI_FLASH
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >QSPI_FLASH
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >QSPI_FLASH
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
@ -148,7 +147,7 @@ SECTIONS
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM_D1 AT> QSPI_FLASH
} >DTCMRAM AT> FLASH
/* Uninitialized data section */
@ -165,7 +164,7 @@ SECTIONS
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM_D1
} >DTCMRAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
@ -176,7 +175,7 @@ SECTIONS
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM_D1
} >DTCMRAM

193
STM32H750VBTx_QSPI_FLASH.ld Normal file
View File

@ -0,0 +1,193 @@
/*
******************************************************************************
**
** File : LinkerScript.ld
**
** Author : Auto-generated by System Workbench for STM32
**
** Abstract : Linker script for STM32H750VBTx series
** 128Kbytes FLASH and 1056Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed “as is,” without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
**
** Redistribution and use in source and binary forms, with or without modification,
** are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** 3. Neither the name of STMicroelectronics nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*****************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x24080000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x90000000, LENGTH = 16M
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM_D1 AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM_D1
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM_D1
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}

193
STM32H750VBTx_RAM.ld Normal file
View File

@ -0,0 +1,193 @@
/*
******************************************************************************
**
** File : LinkerScript.ld
**
** Author : Auto-generated by System Workbench for STM32
**
** Abstract : Linker script for STM32H750VBTx series
** 128Kbytes FLASH and 1056Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed “as is,” without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
**
** Redistribution and use in source and binary forms, with or without modification,
** are permitted provided that the following conditions are met:
** 1. Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer in the documentation
** and/or other materials provided with the distribution.
** 3. Neither the name of STMicroelectronics nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*****************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x30048000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x90000000, LENGTH = 16M
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >RAM_D1
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >RAM_D1
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >RAM_D1
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM_D1
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >RAM_D1
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >RAM_D1
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >RAM_D1
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >RAM_D1
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM_D2 AT> RAM_D1
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM_D2
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM_D2
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}

5
arm-none-eabi.cmake Normal file
View File

@ -0,0 +1,5 @@
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
# Make CMake happy about those compilers
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")