Compare commits

...

7 commits

Author SHA1 Message Date
c43df6e576 Setup /src/CmakeLists.txt for variable usage
The cmake file in the source directory is now using the variable project
name.
2024-11-10 06:37:20 -08:00
cb8fa86c6f Updated the cmakelists.txt
changed the project name variable along with the project description.
2024-11-10 06:36:19 -08:00
73a11f1abd Simplified project name.
Removed some uneeded letters from the project name.
2024-11-10 06:35:47 -08:00
120b0ba301 Updated todo items
Added on items for tasks that still need done.
2024-11-10 06:35:24 -08:00
b966fccf75 Added linker.ld file
Added a half-finished linker file with lots of comments.
2024-11-10 06:35:01 -08:00
a28d4dd937 Added main sections
Added sections to readme for requirements, instructions and how to test.
2024-11-07 00:50:38 -08:00
c0faa2322f Created STM32 toolchain file
Created an toolchain file `stm32-toolchain.cmake` in the root dir of the
repo.
2024-11-07 00:36:49 -08:00
6 changed files with 119 additions and 4 deletions

View file

@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
# Use the fancy version substitution # Use the fancy version substitution
project(cmake-cpputest-template project(main
VERSION 1.0 VERSION 1.0
DESCRIPTION "template for cmake + cpputest" DESCRIPTION "STM32 template for cmake + cpputest"
LANGUAGES C CXX LANGUAGES C CXX
) )
enable_testing() enable_testing()

View file

@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places. # title of most generated pages and in a few other places.
# The default value is: My Project. # The default value is: My Project.
PROJECT_NAME = "My Project" PROJECT_NAME = "Project"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version

View file

@ -0,0 +1,27 @@
# STM32 CMake+CppuTest Template
## Requirements
- An ARM compiler and linker.
- Bash or a POSIX shell.
- CMAKE version 3.20 or newer.
- Cpputest 3.8 or newer.
- Clangd LSP.
- Git version control.
## Instructions
1. Clone/copy the repo locally.
2. Check the requirements to make sure you're development enviroment is ready.
3. Update the linker script files to target your current uC.
## Running Tests
## TODO
- [ ] Create or copy a linker.ld file.
- [ ] Add a startup file for at least the stm32f103c8t6.
- [ ] Add messages for case where tool-chain is missing.
- [ ] Check for FreeBSD & Linux compat.
- [ ] Add in RTOS stuff.

47
linker.ld Normal file
View file

@ -0,0 +1,47 @@
/*
* Filename: linker.ld
* Micro-Controller: stm32f103c8t6
*/
/*
* Program Entry Point:
* This part is put into the elf file header.
*/
ENTRY(Reset_Handler)
/*
* FORMAT:
* R: Read only section.
* W: Read/Write section.
* X: Executable section.
* A: Allocation section.
* I: Initialized section.
* !: Invert following attribute.
*/
/*
* MEMORY Format:
* name [(attr)] : ORIGIN = origin, LENGTH = len
*/
/* You will want to change these values to match your uC.*/
MEMORY
{
FLASH(rx):ORIGIN =0x08000000,LENGTH =64K
SRAM(rwx):ORIGIN =0x20000000,LENGTH =20K
}
floating_point = 0;
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
. = 0x8000000;
.data : { *(.data) }
.bss : { *(.bss) }
}

View file

@ -1,3 +1,8 @@
add_executable(main add_executable(${PROJECT_NAME}
main.c main.c
) )
# Ensure the build rules are defined
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".elf")

36
stm32-toolchain.cmake Normal file
View file

@ -0,0 +1,36 @@
# ###############################
# STM32 toolchain file
# ###############################
# Specify the cross-compiler
set(CROSS_TOOLCHAIN arm-none-eabi-)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_SYSTEM_VERSION 1)
# Specify the exact Chip
# Programmer and debugging
set(PROGRAMMER serialupdi)
set(PORT /dev/ttyU0)
# Define the toolchain executables
set(CMAKE_C_COMPILER avr-gcc)
set(CMAKE_CXX_COMPILER avr-g++)
set(CMAKE_ASM_COMPILER avr-gcc)
set(CMAKE_LINKER avr-ld)
set(CMAKE_OBJCOPY avr-objcopy)
set(CMAKE_SIZE avr-size)
# Define compile options
set(CMAKE_C_FLAGS " -Os -mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
set(CMAKE_CXX_FLAGS "-mmcu=${AVR_MCU} -DF_CPU=${F_CPU}")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mmcu=${AVR_MCU}")