Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NHC-Link042: Convert Keil to Cmake Makefile with tool from https://github.com/phodina/ProjectConverter #251

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions attic/NHC-Link042/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# CMake minimum version
cmake_minimum_required (VERSION 3.1)

# Project Infomation
project( NHC-Link042 )
enable_language(ASM)
enable_language(C)

# Reset output path
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)

# STDLIB
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)

# Set include path
include_directories (./User)
include_directories (./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/CMSIS/Device/ST/STM32F0xx/Include)
include_directories (./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/inc)
include_directories (./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Driver/inc)
include_directories (./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Library/Core/inc)
include_directories (./LibUSB)
include_directories (./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/CMSIS/Include)

# The need build source path and build all files
set (SRC_FILE0 ./User/it.c)
set (SRC_FILE1 ./User/main.c)
set (SRC_FILE2 ./User/usb_bsp.c)
set (SRC_FILE3 ./User/usbd_pwr.c)
set (SRC_FILE4 ./User/usbd_desc.c)
set (SRC_FILE5 ./User/usbd_usr.c)
set (SRC_FILE6 ./User/stm32_it.c)
set (SRC_FILE7 ./User/NHC_WCH_SDI.c)
set (SRC_FILE8 ./User/NHC_WCH_SDI.h)
set (SRC_FILE9 ./User/config.h)
set (SRC_FILE10 ./User/usbd_desc.h)
set (SRC_FILE11 ./LibUSB/LibUSB.c)
set (SRC_FILE12 ./User/system_stm32f0xx.c)
set (SRC_FILE13 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_crs.c)
set (SRC_FILE14 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_exti.c)
set (SRC_FILE15 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_gpio.c)
set (SRC_FILE16 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_rcc.c)
set (SRC_FILE17 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_syscfg.c)
set (SRC_FILE18 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_tim.c)
set (SRC_FILE19 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_misc.c)
set (SRC_FILE20 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Driver/src/usb_core.c)
set (SRC_FILE21 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Driver/src/usb_dcd.c)
set (SRC_FILE22 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Driver/src/usb_dcd_int.c)
set (SRC_FILE23 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c)
set (SRC_FILE24 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c)
set (SRC_FILE25 ./STM32F0x2_USB-FS-Device_Lib_V1.0.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c)


set(CROSS_TARGET_TRIPLET "arm-none-eabi-")

# CC AR LD AS
set(CMAKE_C_COMPILER "${CROSS_TARGET_TRIPLET}gcc")
set(CMAKE_ASM_COMPILER "${CROSS_TARGET_TRIPLET}gcc")

# CFLAGS
set (CMAKE_C_FLAGS "-g -Wextra -Wshadow -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -fno-common -ffunction-sections -fdata-sections -MD -Wall -Wundef -mthumb -mcpu=cortex-m0 " CACHE INTERNAL "c compiler flags")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D USE_STDPERIPH_DRIVER -D STM32F042 -D INTERNAL_PULLUP -D USB_CLOCK_SOURCE_CRS ")

# CXXFLAGS
set (CMAKE_CXX_FLAGS "-Wextra -Wshadow -Wredundant-decls -Weffc++ -fno-common -ffunction-sections -fdata-sections -MD -Wall -Wundef -mthumb -mcpu=cortex-m0 " CACHE INTERNAL "cxx compiler flags")

# ASMFLAGS
set (CMAKE_ASM_FLAGS "-g -mthumb -mcpu=cortex-m0 " CACHE INTERNAL "asm compiler flags")

# LDFLAGS
set (CMAKE_EXE_LINKER_FLAGS "-g -Wl,--gc-sections -Wl,-Map=NHC-Link042.map -mthumb -mcpu=cortex-m0 " CACHE INTERNAL "executable linker flags")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_SOURCE_DIR}/STM32FLASH.ld -L ")


# Generate the target
add_executable (${CMAKE_PROJECT_NAME}.elf ${SRC_FILE0} ${SRC_FILE1} ${SRC_FILE2} ${SRC_FILE3} ${SRC_FILE4} ${SRC_FILE5} ${SRC_FILE6} ${SRC_FILE7} ${SRC_FILE8} ${SRC_FILE9} ${SRC_FILE10} ${SRC_FILE11} ${SRC_FILE12} ${SRC_FILE13} ${SRC_FILE14} ${SRC_FILE15} ${SRC_FILE16} ${SRC_FILE17} ${SRC_FILE18} ${SRC_FILE19} ${SRC_FILE20} ${SRC_FILE21} ${SRC_FILE22} ${SRC_FILE23} ${SRC_FILE24} ${SRC_FILE25} )

# Link the library to the target
target_link_libraries (${CMAKE_PROJECT_NAME}.elf )

# Generate the binary file
add_custom_target (${CMAKE_PROJECT_NAME}.bin ALL arm-none-eabi-objcopy -Obinary "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.elf" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.bin" DEPENDS ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.elf)

# Generate the hex file
add_custom_target (${CMAKE_PROJECT_NAME}.hex ALL arm-none-eabi-objcopy -Oihex "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.elf" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.hex" DEPENDS ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.elf)

# Echo the size Infomation
add_custom_target (size ALL arm-none-eabi-size "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.elf" DEPENDS ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.elf)

# Make flash to the board by st-link
add_custom_target (flash COMMAND st-flash write ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_PROJECT_NAME}.bin 0x8000000)

# Make clean-all
add_custom_target (clean-all COMMAND rm -rf ${CMAKE_BINARY_DIR}/*)
30 changes: 15 additions & 15 deletions attic/NHC-Link042/NHC-Link042.uvprojx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
<MiscControls></MiscControls>
<Define>USE_STDPERIPH_DRIVER,STM32F042, INTERNAL_PULLUP, USB_CLOCK_SOURCE_CRS</Define>
<Undefine></Undefine>
<IncludePath>.\User;.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\CMSIS\Device\ST\STM32F0xx\Include;.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\inc;.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Driver\inc;.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Library\Core\inc;.\LibUSB;.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\CMSIS\Include</IncludePath>
<IncludePath>.\User;.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\CMSIS\Device\ST\STM32F0xx\Include;.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\inc;.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Driver\inc;.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Library\Core\inc;.\LibUSB;.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\CMSIS\Include</IncludePath>
</VariousControls>
</Cads>
<Aads>
Expand Down Expand Up @@ -462,7 +462,7 @@
<File>
<FileName>startup_stm32f042.s</FileName>
<FileType>2</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\CMSIS\Device\ST\STM32F0xx\Source\Templates\arm\startup_stm32f042.s</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\CMSIS\Device\ST\STM32F0xx\Source\Templates\arm\startup_stm32f042.s</FilePath>
</File>
</Files>
</Group>
Expand All @@ -472,37 +472,37 @@
<File>
<FileName>stm32f0xx_crs.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_crs.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_crs.c</FilePath>
</File>
<File>
<FileName>stm32f0xx_exti.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_exti.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_exti.c</FilePath>
</File>
<File>
<FileName>stm32f0xx_gpio.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_gpio.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_gpio.c</FilePath>
</File>
<File>
<FileName>stm32f0xx_rcc.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_rcc.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_rcc.c</FilePath>
</File>
<File>
<FileName>stm32f0xx_syscfg.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_syscfg.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_syscfg.c</FilePath>
</File>
<File>
<FileName>stm32f0xx_tim.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_tim.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_tim.c</FilePath>
</File>
<File>
<FileName>stm32f0xx_misc.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_misc.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_misc.c</FilePath>
</File>
</Files>
</Group>
Expand All @@ -512,32 +512,32 @@
<File>
<FileName>usb_core.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Driver\src\usb_core.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Driver\src\usb_core.c</FilePath>
</File>
<File>
<FileName>usb_dcd.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Driver\src\usb_dcd.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Driver\src\usb_dcd.c</FilePath>
</File>
<File>
<FileName>usb_dcd_int.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Driver\src\usb_dcd_int.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Driver\src\usb_dcd_int.c</FilePath>
</File>
<File>
<FileName>usbd_core.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Library\Core\src\usbd_core.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Library\Core\src\usbd_core.c</FilePath>
</File>
<File>
<FileName>usbd_ioreq.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Library\Core\src\usbd_ioreq.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Library\Core\src\usbd_ioreq.c</FilePath>
</File>
<File>
<FileName>usbd_req.c</FileName>
<FileType>1</FileType>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib V1.0.0\Libraries\STM32_USB_Device_Library\Core\src\usbd_req.c</FilePath>
<FilePath>.\STM32F0x2_USB-FS-Device_Lib_V1.0.0\Libraries\STM32_USB_Device_Library\Core\src\usbd_req.c</FilePath>
</File>
</Files>
</Group>
Expand Down
187 changes: 187 additions & 0 deletions attic/NHC-Link042/STM32FLASH.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
*****************************************************************************
**

** File : LinkerScript.ld
**
** Abstract : Linker script for STM32F030R8Tx Device with
** 64KByte FLASH, 8KByte 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) 2014 Ac6</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 Ac6 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 = 0x20002000; /* 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
{
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
}

/* 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 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

/* 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



/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

.ARM.attributes 0 : { *(.ARM.attributes) }
}