diff --git a/CMakeLists.txt b/CMakeLists.txt index 3068d0a..0d22c07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,34 +2,34 @@ project(lwext4 C) cmake_minimum_required(VERSION 2.8) +include_directories(lwext4) +include_directories(blockdev/filedev) +include_directories(blockdev/filedev_win) -#LIBRARY -include_directories(. lwext4) -aux_source_directory(lwext4 LWEXT4_SRC) -add_library(lwext4 ${LWEXT4_SRC}) + +#Library build +add_subdirectory(lwext4) +#Detect all possible warnings for lwext4 target +set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic") #Examples -if(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m3) - #Library size print - add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a) +if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m3) + #cortex-m3 demos + #... elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m4) - #Library size print - add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a) - #Discoery disco demo - include(demos/stm32f429_disco/stm32f429_demo.cmake) + #cortex-m4 demos + add_subdirectory(demos/stm32f429_disco) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL bf518) - #Library size print - add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a) + #bf518 demos + #... else() - #Warning setup - set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic -std=gnu99") - #Library size print - add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND size -B liblwext4.a) #Generic example target - include(demos/generic/generic.cmake) - include(fs_test/fs_test.cmake) + add_subdirectory(blockdev) + add_subdirectory(fs_test) + add_subdirectory(demos/generic) endif() + #DISTRIBUTION set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MINOR "4") diff --git a/Makefile b/Makefile index a4e1476..610fc5d 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ PROJECT_SETUP = "Eclipse CDT4 - Unix Makefiles" generic: rm -R -f build_generic mkdir build_generic - cd build_generic && cmake -G$(PROJECT_SETUP) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. + cd build_generic && cmake -G$(PROJECT_SETUP) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=../toolchain/generic.cmake .. bf518: rm -R -f build_bf518 diff --git a/blockdev/CMakeLists.txt b/blockdev/CMakeLists.txt new file mode 100644 index 0000000..0f1f20b --- /dev/null +++ b/blockdev/CMakeLists.txt @@ -0,0 +1,5 @@ +#Blockdev library +aux_source_directory(filedev BLOCKDEV_SRC) +aux_source_directory(filedev_win BLOCKDEV_SRC) +add_library(blockdev ${BLOCKDEV_SRC}) + diff --git a/demos/generic/CMakeLists.txt b/demos/generic/CMakeLists.txt new file mode 100644 index 0000000..42c4681 --- /dev/null +++ b/demos/generic/CMakeLists.txt @@ -0,0 +1,4 @@ +#Generic demo +add_executable(fileimage_demo main.c) +target_link_libraries(fileimage_demo lwext4) +target_link_libraries(fileimage_demo blockdev) \ No newline at end of file diff --git a/demos/generic/generic.cmake b/demos/generic/generic.cmake deleted file mode 100644 index ae89fd3..0000000 --- a/demos/generic/generic.cmake +++ /dev/null @@ -1,9 +0,0 @@ -include_directories(blockdev/filedev) -include_directories(blockdev/filedev_win) - -aux_source_directory(blockdev/filedev GENERIC_SRC) -aux_source_directory(blockdev/filedev_win GENERIC_SRC) -aux_source_directory(demos/generic GENERIC_SRC) - -add_executable(fileimage_demo ${GENERIC_SRC}) -target_link_libraries(fileimage_demo lwext4) \ No newline at end of file diff --git a/demos/generic/main.c b/demos/generic/main.c index fe304e6..de0e7f8 100644 --- a/demos/generic/main.c +++ b/demos/generic/main.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/demos/stm32f429_disco/CMakeLists.txt b/demos/stm32f429_disco/CMakeLists.txt new file mode 100644 index 0000000..ad0675a --- /dev/null +++ b/demos/stm32f429_disco/CMakeLists.txt @@ -0,0 +1,37 @@ +#Discoery disco demo +enable_language(ASM) +set (STM32F429_DEMO_ASM + startup.S +) + + +include_directories(.) +include_directories(cmsis) +include_directories(stm/lcd_utils) +include_directories(stm/stm32f4_spl/inc) +include_directories(stm/stm32f429) +include_directories(stm/usb_dev/Core/inc) +include_directories(stm/usb_host/Core/inc) +include_directories(stm/usb_host/Class/MSC/inc) +include_directories(stm/usb_otg/inc) +include_directories(stm/usb_user) + +aux_source_directory(. STM32F429_DEMO) +aux_source_directory(cmsis STM32F429_DEMO) +aux_source_directory(stm/lcd_utils STM32F429_DEMO) +aux_source_directory(stm/stm32f4_spl/src STM32F429_DEMO) +aux_source_directory(stm/stm32f429 STM32F429_DEMO) +aux_source_directory(stm/usb_host/Core/src STM32F429_DEMO) +aux_source_directory(stm/usb_host/Class/MSC/src STM32F429_DEMO) +aux_source_directory(stm/usb_otg/src STM32F429_DEMO) +aux_source_directory(stm/usb_user STM32F429_DEMO) +add_executable(stm324f29_demo ${STM32F429_DEMO} ${STM32F429_DEMO_ASM}) + +set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter") +set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-format") +set_target_properties(stm324f29_demo PROPERTIES COMPILE_DEFINITIONS "STM32F429_439xx") + +set_target_properties(stm324f29_demo PROPERTIES LINK_FLAGS "-T${CMAKE_SOURCE_DIR}/demos/stm32f429_disco/stm32f429.ld") +target_link_libraries(stm324f29_demo lwext4) + +add_custom_target(stm32f429_size ALL DEPENDS stm324f29_demo COMMAND ${SIZE} -B stm324f29_demo) \ No newline at end of file diff --git a/demos/stm32f429_disco/stm32f429_demo.cmake b/demos/stm32f429_disco/stm32f429_demo.cmake deleted file mode 100644 index 44474ec..0000000 --- a/demos/stm32f429_disco/stm32f429_demo.cmake +++ /dev/null @@ -1,38 +0,0 @@ -#Discoery disco demo -enable_language(ASM) -set (STM32F429_DEMO_ASM - demos/stm32f429_disco/startup.S -) - - -include_directories(demos/stm32f429_disco) -include_directories(demos/stm32f429_disco/cmsis) -include_directories(demos/stm32f429_disco/stm/lcd_utils) -include_directories(demos/stm32f429_disco/stm/stm32f4_spl/inc) -include_directories(demos/stm32f429_disco/stm/stm32f429) -include_directories(demos/stm32f429_disco/stm/usb_dev/Core/inc) -include_directories(demos/stm32f429_disco/stm/usb_host/Core/inc) -include_directories(demos/stm32f429_disco/stm/usb_host/Class/MSC/inc) -include_directories(demos/stm32f429_disco/stm/usb_otg/inc) -include_directories(demos/stm32f429_disco/stm/usb_user) - -aux_source_directory(demos/stm32f429_disco STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/cmsis STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/lcd_utils STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/stm32f4_spl/src STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/stm32f429 STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/usb_host/Core/src STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/usb_host/Class/MSC/src STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/usb_otg/src STM32F429_DEMO) -aux_source_directory(demos/stm32f429_disco/stm/usb_user STM32F429_DEMO) - -add_executable(stm324f29_demo ${STM32F429_DEMO} ${STM32F429_DEMO_ASM}) - -set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter") -set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-format") -set_target_properties(stm324f29_demo PROPERTIES COMPILE_DEFINITIONS "STM32F429_439xx") - -set_target_properties(stm324f29_demo PROPERTIES LINK_FLAGS "-T${CMAKE_SOURCE_DIR}/demos/stm32f429_disco/stm32f429.ld") -target_link_libraries(stm324f29_demo lwext4) - -add_custom_target(stm32f429_size ALL DEPENDS stm324f29_demo COMMAND ${SIZE} -B stm324f29_demo) \ No newline at end of file diff --git a/fs_test.mk b/fs_test.mk index bb6b7d3..0c9770d 100644 --- a/fs_test.mk +++ b/fs_test.mk @@ -1,10 +1,10 @@ ifeq ($(OS),Windows_NT) -LWEXT4_CLIENT = @build_generic\\lwext4_client -LWEXT4_SERVER = @build_generic\\lwext4_server +LWEXT4_CLIENT = @build_generic\\fs_test\\lwext4_client +LWEXT4_SERVER = @build_generic\\fs_test\\lwext4_server else -LWEXT4_CLIENT = @build_generic/lwext4_client -LWEXT4_SERVER = @build_generic/lwext4_server +LWEXT4_CLIENT = @build_generic/fs_test/lwext4_client +LWEXT4_SERVER = @build_generic/fs_test/lwext4_server endif TEST_DIR = /test @@ -504,4 +504,4 @@ server_ext3: server_ext4: $(LWEXT4_SERVER) -i ext_images/ext4 -all_tests: t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 \ No newline at end of file +tests: t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 \ No newline at end of file diff --git a/fs_test/CMakeLists.txt b/fs_test/CMakeLists.txt new file mode 100644 index 0000000..91691c1 --- /dev/null +++ b/fs_test/CMakeLists.txt @@ -0,0 +1,12 @@ +#fs_test executables +add_executable(lwext4_server lwext4_server.c) +target_link_libraries(lwext4_server lwext4) +target_link_libraries(lwext4_server blockdev) +if(WIN32) +target_link_libraries(lwext4_server ws2_32) +endif(WIN32) +add_executable(lwext4_client lwext4_client.c) +target_link_libraries(lwext4_client lwext4) +if(WIN32) +target_link_libraries(lwext4_client ws2_32) +endif(WIN32) diff --git a/fs_test/fs_test.cmake b/fs_test/fs_test.cmake deleted file mode 100644 index 8bd946b..0000000 --- a/fs_test/fs_test.cmake +++ /dev/null @@ -1,17 +0,0 @@ -include_directories(blockdev/filedev) -include_directories(blockdev/filedev_win) - -aux_source_directory(blockdev/filedev BLOCKDEV_SRC) -aux_source_directory(blockdev/filedev_win BLOCKDEV_SRC) - - -add_executable(lwext4_server fs_test/lwext4_server.c ${BLOCKDEV_SRC}) -target_link_libraries(lwext4_server lwext4) -if(WIN32) -target_link_libraries(lwext4_server ws2_32) -endif(WIN32) -add_executable(lwext4_client fs_test/lwext4_client.c ${BLOCKDEV_SRC}) -target_link_libraries(lwext4_client lwext4) -if(WIN32) -target_link_libraries(lwext4_client ws2_32) -endif(WIN32) \ No newline at end of file diff --git a/fs_test/lwext4_server.c b/fs_test/lwext4_server.c index 00e9196..27024ff 100644 --- a/fs_test/lwext4_server.c +++ b/fs_test/lwext4_server.c @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef WIN32 #include diff --git a/lwext4/CMakeLists.txt b/lwext4/CMakeLists.txt new file mode 100644 index 0000000..2962721 --- /dev/null +++ b/lwext4/CMakeLists.txt @@ -0,0 +1,8 @@ + +#LIBRARY +include_directories(.) +aux_source_directory(. LWEXT4_SRC) +add_library(lwext4 ${LWEXT4_SRC}) +add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a) + + diff --git a/ext4.h b/lwext4/ext4.h similarity index 100% rename from ext4.h rename to lwext4/ext4.h diff --git a/toolchain/bf518.cmake b/toolchain/bf518.cmake index d471ac5..523919b 100644 --- a/toolchain/bf518.cmake +++ b/toolchain/bf518.cmake @@ -1,5 +1,5 @@ # Name of the target -SET(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_NAME bfin-elf) set(CMAKE_SYSTEM_PROCESSOR bf518) # Toolchain settings @@ -12,9 +12,9 @@ set(OBJDUMP bfin-elf-objdump) set(SIZE bfin-elf-size) set(CMAKE_C_FLAGS "-mcpu=bf518 -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") -set(CMAKE_CXX_FLAGS "-mcpu=bf518 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") +set(CMAKE_CXX_FLAGS "-mcpu=bf518 -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") set(CMAKE_ASM_FLAGS "-mcpu=bf518 -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags") -set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mcpu=bf592" CACHE INTERNAL "exe link flags") +set(CMAKE_EXE_LINKER_FLAGS "-mcpu=bf592 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags") diff --git a/toolchain/cortex-m3.cmake b/toolchain/cortex-m3.cmake index 873ed1f..3ad9e07 100644 --- a/toolchain/cortex-m3.cmake +++ b/toolchain/cortex-m3.cmake @@ -1,5 +1,5 @@ # Name of the target -SET(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_NAME arm-none-eabi) set(CMAKE_SYSTEM_PROCESSOR cortex-m3) # Toolchain settings @@ -14,7 +14,7 @@ set(SIZE arm-none-eabi-size) set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m3" CACHE INTERNAL "asm compiler flags") -set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m3" CACHE INTERNAL "exe link flags") +set(CMAKE_EXE_LINKER_FLAGS "-mthumb -mcpu=cortex-m3 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags") diff --git a/toolchain/cortex-m4.cmake b/toolchain/cortex-m4.cmake index c4b097a..659018a 100644 --- a/toolchain/cortex-m4.cmake +++ b/toolchain/cortex-m4.cmake @@ -1,5 +1,5 @@ # Name of the target -SET(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_NAME arm-none-eabi) set(CMAKE_SYSTEM_PROCESSOR cortex-m4) # Toolchain settings @@ -14,7 +14,7 @@ set(SIZE arm-none-eabi-size) set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m4" CACHE INTERNAL "asm compiler flags") -set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m4" CACHE INTERNAL "exe link flags") +set(CMAKE_EXE_LINKER_FLAGS " -mthumb -mcpu=cortex-m4 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags") @@ -24,5 +24,4 @@ SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags") SET(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c release compiler flags") SET(CMAKE_CXX_FLAGS_RELEASE "-Os" CACHE INTERNAL "cxx release compiler flags") -SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags") - +SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags") \ No newline at end of file diff --git a/toolchain/generic.cmake b/toolchain/generic.cmake new file mode 100644 index 0000000..d9f5ef6 --- /dev/null +++ b/toolchain/generic.cmake @@ -0,0 +1,25 @@ +# Name of the target +set(CMAKE_SYSTEM_PROCESSOR generic) + +# Toolchain settings +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) +set(AS as) +set(AR ar) +set(OBJCOPY objcopy) +set(OBJDUMP objdump) +set(SIZE size) + +set(CMAKE_C_FLAGS "-std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags") +set(CMAKE_CXX_FLAGS "-fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags") +set(CMAKE_ASM_FLAGS "" CACHE INTERNAL "asm compiler flags") +set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections" CACHE INTERNAL "exe link flags") + + +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags") +SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags") + +SET(CMAKE_C_FLAGS_RELEASE "-O2" CACHE INTERNAL "c release compiler flags") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE INTERNAL "cxx release compiler flags") +SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags") \ No newline at end of file