-
Notifications
You must be signed in to change notification settings - Fork 51
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
Support for CMake builds. Added Linux stub port for now to allow cross compilation #35
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fbab652
Support for CMake builds. Added Linux stub port for now to allow cross
phelter aad49c0
Fixing A_CUSTOM_PORT usage to make it easier to integrate with extern…
phelter 5f06b6b
Fixing include directories for port.
phelter 342ffe4
Adding in initial Github actions/workflows based on FreeRTOS-Plus-IP …
phelter fc0c6d9
Fixing formatting with uncrustify.
phelter 1ff699c
Commenting out ci workflows that are not currently supported.
phelter 2aed8a0
Merge remote-tracking branch 'upstream/master' into feature/cmake-sup…
phelter 96c215f
Fixing comments referencing TCP to FAT.
phelter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
cmake_policy(SET CMP0048 NEW) # project version | ||
cmake_policy(SET CMP0076 NEW) # full paths | ||
|
||
######################################################################## | ||
# Project Details | ||
project(FreeRTOS-Plus-TCP | ||
VERSION 0.0.1 | ||
DESCRIPTION "FreeRTOS DOS Compatible Embedded FAT File System" | ||
HOMEPAGE_URL https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/index.html | ||
LANGUAGES C) | ||
|
||
# Do not allow in-source build. | ||
if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) | ||
message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) | ||
endif() | ||
|
||
# Options | ||
|
||
# Optional: FREERTOS_PLUS_FAT_DEV_SUPPORT | ||
# - when OFF - device support is disabled and not used. | ||
# - When ON - device support is enabled and the ff_devices.h API is used. | ||
# Optional: FREERTOS_PLUS_FAT_PORT | ||
# - When not defined - identifies native platform Linxu or MinGW and uses that port. | ||
# - When defined as A_CUSTOM_PORT - the port library must be defined in advance. | ||
# - When any of the other supported ports - the port library is defined by portable source files. | ||
option(FREERTOS_PLUS_FAT_DEV_SUPPORT "FreeRTOS Plus FAT Device selection support" OFF) | ||
|
||
# Select the appropriate FAT Port | ||
# This will fail the CMake preparation step if not set to one of those values. | ||
set(FREERTOS_PLUS_FAT_PORT "" CACHE STRING "FreeRTOS Plus FAT Port selection") | ||
set(FREERTOS_PLUS_FAT_PORT_LIST | ||
A_CUSTOM_PORT | ||
ATSAM4E | ||
AVR32_UC3 | ||
LPC18XX | ||
POSIX | ||
STM32FXX | ||
STM32HXX | ||
ZYNQ | ||
ZYNQ_2019_3 | ||
) | ||
if(NOT FREERTOS_PLUS_FAT_PORT) | ||
# Attempt to detect the system. | ||
if(UNIX) | ||
message(STATUS "Detected UNIX/Posix system setting FREERTOS_PLUS_FAT_PORT = POSIX") | ||
set(FREERTOS_PLUS_FAT_PORT POSIX) | ||
elseif(MINGW) | ||
message(STATUS "Detected Windows MinGW system setting FREERTOS_PLUS_FAT_PORT = WIN_MGW") | ||
set(FREERTOS_PLUS_FAT_PORT WIN_PCAP) | ||
endif() | ||
endif() | ||
|
||
if(NOT FREERTOS_PLUS_FAT_PORT IN_LIST FREERTOS_PLUS_FAT_PORT_LIST ) | ||
message(FATAL_ERROR " FREERTOS_PLUS_FAT_PORT is '${FREERTOS_PLUS_FAT_PORT}'.\n" | ||
" Please specify it from top-level CMake file (example):\n" | ||
" set(FREERTOS_PLUS_FAT_PORT POSIX CACHE STRING \"\")\n" | ||
" or from CMake command line option:\n" | ||
" -DFREERTOS_PLUS_FAT_PORT=POSIX\n" | ||
" \n" | ||
" Available port options: (Tested means compiled with that variant)\n" | ||
" A_CUSTOM_PORT Target: User Defined\n" | ||
" ATSAM4E Target: ATSAM4E Tested: TODO\n" | ||
" AVR32_UC3 Target: avr32_uc3 Tested: TODO\n" | ||
" LPC18XX Target: lpc18xx Tested: TODO\n" | ||
" POSIX Target: linux/Posix\n" | ||
" STM32F4XX Target: STM32F4xx Tested: TODO\n" | ||
" STM32F7XX Target: STM32F7xx Tested: TODO\n" | ||
" ZYNQ Target: Xilinx Zynq Tested: TODO\n" | ||
" ZYNQ_2019_3 Target: Xilinx Zynq 2019.3") | ||
elseif((FREERTOS_PLUS_FAT_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_plus_fat_port) ) | ||
message(FATAL_ERROR " FREERTOS_PLUS_FAT_PORT is set to A_CUSTOM_PORT.\n" | ||
" Please specify the custom port target with all necessary files.\n" | ||
" For example, assuming a directory of:\n" | ||
" FreeRTOSPlusFatPort/\n" | ||
" CMakeLists.txt\n" | ||
" ff_sddisk.c\n" | ||
" Where FreeRTOSPlusFatPort/CMakeLists.txt is a modified version of:\n" | ||
" add_library(freertos_plus_fat_port STATIC)\n" | ||
" target_sources(freertos_plus_fat_port\n" | ||
" PRIVATE\n" | ||
" ff_sddisk.c)\n" | ||
" target_link_libraries(freertos_plus_fat_port\n" | ||
" PUBLIC\n" | ||
" freertos_plus_fat_port_common\n" | ||
" PRIVATE\n" | ||
" freertos_kernel\n" | ||
" freertos_plus_fat)") | ||
endif() | ||
|
||
add_library( freertos_plus_fat STATIC ) | ||
|
||
target_sources( freertos_plus_fat | ||
PRIVATE | ||
include/ff_crc.h | ||
include/ff_devices.h | ||
include/ff_dir.h | ||
include/ff_error.h | ||
include/ff_fat.h | ||
include/ff_fatdef.h | ||
include/ff_file.h | ||
include/ff_format.h | ||
include/ff_headers.h | ||
include/ff_ioman.h | ||
include/ff_locking.h | ||
include/ff_memory.h | ||
include/ff_old_config_defines.h | ||
include/ff_stdio.h | ||
include/ff_string.h | ||
include/ff_sys.h | ||
include/ff_time.h | ||
include/FreeRTOS_errno_FAT.h | ||
include/FreeRTOSFATConfigDefaults.h | ||
|
||
ff_crc.c | ||
$<$<BOOL:${FREERTOS_PLUS_FAT_DEV_SUPPORT}>:ff_dev_support.c> | ||
ff_dir.c | ||
ff_error.c | ||
ff_fat.c | ||
ff_file.c | ||
ff_format.c | ||
ff_ioman.c | ||
ff_locking.c | ||
ff_memory.c | ||
ff_stdio.c | ||
ff_string.c | ||
ff_sys.c | ||
ff_time.c | ||
) | ||
|
||
target_include_directories( freertos_plus_fat SYSTEM | ||
PUBLIC | ||
include | ||
) | ||
|
||
target_compile_definitions( freertos_plus_fat | ||
PUBLIC | ||
ffconfigDEV_SUPPORT=$<BOOL:${FREERTOS_PLUS_FAT_DEV_SUPPORT}> | ||
) | ||
|
||
target_compile_options( freertos_plus_fat | ||
PRIVATE | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-constant-conversion> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation-unknown-command> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wno-format> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-implicit-int-conversion> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations> | ||
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-overflow> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded> | ||
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-pedantic> | ||
|
||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-reserved-macro-identifier> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-shorten-64-to-32> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-sign-conversion> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-tautological-constant-out-of-range-compare> | ||
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-type-limits> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-undef> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros> | ||
) | ||
|
||
target_link_libraries( freertos_plus_fat | ||
PUBLIC | ||
freertos_config | ||
PRIVATE | ||
freertos_plus_fat_port | ||
freertos_kernel | ||
) | ||
|
||
add_subdirectory(portable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
add_library( freertos_plus_fat_port_common STATIC ) | ||
|
||
target_sources( freertos_plus_fat_port_common | ||
PRIVATE | ||
common/ff_ramdisk.c | ||
common/ff_ramdisk.h | ||
common/ff_sddisk.h | ||
) | ||
|
||
target_include_directories( freertos_plus_fat_port_common SYSTEM | ||
PUBLIC | ||
common | ||
) | ||
|
||
target_compile_options( freertos_plus_fat_port_common | ||
PRIVATE | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-prototypes> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-reserved-macro-identifier> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-shorten-64-to-32> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-sign-conversion> | ||
) | ||
|
||
target_link_libraries( freertos_plus_fat_port_common | ||
PRIVATE | ||
freertos_kernel | ||
freertos_plus_fat | ||
) | ||
|
||
# ------------------------------------------------------------------- | ||
|
||
if (FREERTOS_PLUS_FAT_PORT STREQUAL "A_CUSTOM_PORT") | ||
message(STATUS "Using a custom FREERTOS_PLUS_FAT_PORT.") | ||
return() | ||
endif() | ||
|
||
add_library( freertos_plus_fat_port STATIC ) | ||
|
||
target_sources( freertos_plus_fat_port | ||
PRIVATE | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},ATSAM4E>: | ||
ATSAM4E/ff_sddisk_r.c | ||
ATSAM4E/ff_sddisk.c> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},AVR32_UC3>: | ||
avr32_uc3/ff_flush.c | ||
avr32_uc3/ff_flush.h | ||
avr32_uc3/ff_locking.c> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},LPC18XX>: | ||
lpc18xx/ff_sddisk.c> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},POSIX>: | ||
linux/ff_sddisk.c> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},STM32F4XX>: | ||
STM32F4xx/ff_sddisk.c | ||
STM32F4xx/stm32f4xx_hal_sd.c | ||
STM32F4xx/stm32f4xx_hal_sd.h | ||
STM32F4xx/stm32f4xx_ll_sdmmc.c | ||
STM32F4xx/stm32f4xx_ll_sdmmc.h> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},STM3F7XX>: | ||
STM32F7xx/ff_sddisk.c | ||
STM32F7xx/stm32f7xx_hal_sd.c | ||
STM32F7xx/stm32f7xx_hal_sd.h> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},ZYNQ>: | ||
Zynq/ff_sddisk.c | ||
Zynq/xsdps_g.c | ||
Zynq/xsdps_hw.h | ||
Zynq/xsdps_info.c | ||
Zynq/xsdps_info.h | ||
Zynq/xsdps_options.c | ||
Zynq/xsdps_sinit.c | ||
Zynq/xsdps.c | ||
Zynq/xsdps.h> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},ZYNQ_2019_3>: | ||
Zynq.2019.3/ff_sddisk.c | ||
Zynq.2019.3/xsdps_g.c | ||
Zynq.2019.3/xsdps_hw.h | ||
Zynq.2019.3/xsdps_info.c | ||
Zynq.2019.3/xsdps_info.h | ||
Zynq.2019.3/xsdps_options.c | ||
Zynq.2019.3/xsdps_sinit.c | ||
Zynq.2019.3/xsdps.c | ||
Zynq.2019.3/xsdps.h> | ||
) | ||
|
||
target_include_directories( freertos_plus_fat_port | ||
PRIVATE | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},AVR32_UC3>:${CMAKE_CURRENT_SOURCE_DIR}/avr32_uc3> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},STM32F4XX>:${CMAKE_CURRENT_SOURCE_DIR}/STM32F4xx> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},STM32F7XX>:${CMAKE_CURRENT_SOURCE_DIR}/STM32F7xx> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},ZYNQ>:${CMAKE_CURRENT_SOURCE_DIR}/Zynq> | ||
$<$<STREQUAL:${FREERTOS_PLUS_FAT_PORT},ZYNQ_2019_3>:${CMAKE_CURRENT_SOURCE_DIR}/Zynq.2019.3> | ||
) | ||
|
||
target_compile_options( freertos_plus_fat_port | ||
PRIVATE | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-gnu-statement-expression> | ||
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-parameter> | ||
) | ||
|
||
target_link_libraries( freertos_plus_fat_port | ||
PUBLIC | ||
freertos_plus_fat_port_common | ||
PRIVATE | ||
freertos_plus_fat | ||
freertos_kernel | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In stead of casting to
unsigned long
, the +FAT library normally usesunsigned
in combination with%u
:It also removes the warning and it works well on 64-bit platforms as well.
Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until now, I didn't comment on this PR ( except about
FF_PRINTF()
) because I am totally inexperienced with cmake ( I only use GNU make ).I checked out your branch and typed "cmake", which doesn't work obviously.
Would you mind to give a short description of how I can compile the project for dummies?
Also, if you open this PR, you will see that "This branch is out-of-date with the base branch", with a button "Update branch". Could you update it with the master branch?
I will talk to the team and see who can further review this PR. Sorry for the long delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@htibosch -
I've added a build check in ci/cd environment similar to the
FreeRTOS-Plus-TCP
repo (the .github directory is a copy and modify from that).I've also updated the main README.md as to how to integrate with CMake in a higher level project.
%8lu
rather than what you requested:See: https://github.com/FreeRTOS/Lab-Project-FreeRTOS-FAT/search?q=%22TotalSectors%22
Leaving as defined since it matches others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is possibly true, but we would like to get rid of all
%ld
and%lu
formats, both in FreeRTOS+TCP and in FreeRTOS+TCP.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@htibosch - My goal was to add the necessary code to have a linux port build similar to other FreeRTOS git repos (Kernel and Plus-TCP) and follow the same coding style and usage of the existing ports inside this
Plus-FAT
repo. Changing some code to reflect an arbitrary request to get rid of a particular format in this and other repos is out of scope (from my perspective) of this particular PR.Since this is an unrelated issue to any of the CMake build support (a different feature/clean-up task), I'll add it to a follow on PR associated with fixing compile warnings of this repo instead (and I'll change all of the various portable code instead of just this new Linux port).
See similar ones for:
FreeRTOS-Kernel
: Fixing clang and gnu compiler warnings. phelter/FreeRTOS-Kernel#1FreeRTOS-Plus-TCP
: phelter/FreeRTOS-Plus-TCP@feature/cmake-support...feature/fixing-clang-gnu-compiler-warningsFreeRTOS-Plus-FAT
: - will do once have this PR completed.I intend to update the above ones and provide them, but have been blocked in continuing with this effort due to the outstanding pull requests.