Build system refactoring.
authorgkostka <kostka.grzegorz@gmail.com>
Tue, 20 May 2014 23:41:24 +0000 (23:41 +0000)
committergkostka <kostka.grzegorz@gmail.com>
Tue, 20 May 2014 23:41:24 +0000 (23:41 +0000)
19 files changed:
CMakeLists.txt
Makefile
blockdev/CMakeLists.txt [new file with mode: 0644]
demos/generic/CMakeLists.txt [new file with mode: 0644]
demos/generic/generic.cmake [deleted file]
demos/generic/main.c
demos/stm32f429_disco/CMakeLists.txt [new file with mode: 0644]
demos/stm32f429_disco/stm32f429_demo.cmake [deleted file]
ext4.h [deleted file]
fs_test.mk
fs_test/CMakeLists.txt [new file with mode: 0644]
fs_test/fs_test.cmake [deleted file]
fs_test/lwext4_server.c
lwext4/CMakeLists.txt [new file with mode: 0644]
lwext4/ext4.h [new file with mode: 0644]
toolchain/bf518.cmake
toolchain/cortex-m3.cmake
toolchain/cortex-m4.cmake
toolchain/generic.cmake [new file with mode: 0644]

index 3068d0a3f05c95d28f26baf8c9766a239e0c7662..0d22c079f669e8d0c4fa1f948a803efe772dab00 100644 (file)
@@ -2,34 +2,34 @@ project(lwext4 C)
 cmake_minimum_required(VERSION 2.8)\r
 \r
 \r
+include_directories(lwext4)\r
+include_directories(blockdev/filedev)\r
+include_directories(blockdev/filedev_win)\r
 \r
-#LIBRARY\r
-include_directories(. lwext4)\r
-aux_source_directory(lwext4 LWEXT4_SRC)\r
-add_library(lwext4  ${LWEXT4_SRC})\r
+\r
+#Library build\r
+add_subdirectory(lwext4)\r
+#Detect all possible warnings for lwext4 target\r
+set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic")\r
 \r
 #Examples\r
-if(CMAKE_SYSTEM_PROCESSOR STREQUAL  cortex-m3)\r
-    #Library size print\r
-    add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)\r
+if    (CMAKE_SYSTEM_PROCESSOR STREQUAL  cortex-m3)\r
+    #cortex-m3 demos\r
+    #...\r
 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  cortex-m4)\r
-    #Library size print\r
-    add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)\r
-    #Discoery disco demo\r
-    include(demos/stm32f429_disco/stm32f429_demo.cmake)\r
+    #cortex-m4 demos\r
+    add_subdirectory(demos/stm32f429_disco)\r
 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL  bf518)\r
-    #Library size print\r
-    add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)\r
+    #bf518 demos\r
+    #...\r
 else()\r
-    #Warning setup\r
-    set_target_properties(lwext4 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic -std=gnu99")\r
-    #Library size print\r
-    add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND size -B liblwext4.a)\r
     #Generic example target\r
-    include(demos/generic/generic.cmake)\r
-    include(fs_test/fs_test.cmake)\r
+    add_subdirectory(blockdev)\r
+    add_subdirectory(fs_test)\r
+    add_subdirectory(demos/generic)\r
 endif()\r
 \r
+\r
 #DISTRIBUTION\r
 set(CPACK_PACKAGE_VERSION_MAJOR "0")\r
 set(CPACK_PACKAGE_VERSION_MINOR "4")\r
index a4e1476fecb56775c880c500c300ea7fd822e76b..610fc5dcd019509c85373088816310ee1f4b86b6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ PROJECT_SETUP = "Eclipse CDT4 - Unix Makefiles"
 generic:\r
        rm -R -f build_generic\r
        mkdir build_generic\r
-       cd build_generic && cmake -G$(PROJECT_SETUP) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) ..\r
+       cd build_generic && cmake -G$(PROJECT_SETUP) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_TOOLCHAIN_FILE=../toolchain/generic.cmake ..\r
        \r
 bf518:\r
        rm -R -f build_bf518\r
diff --git a/blockdev/CMakeLists.txt b/blockdev/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0f1f20b
--- /dev/null
@@ -0,0 +1,5 @@
+#Blockdev library\r
+aux_source_directory(filedev BLOCKDEV_SRC)\r
+aux_source_directory(filedev_win BLOCKDEV_SRC)\r
+add_library(blockdev  ${BLOCKDEV_SRC})\r
+\r
diff --git a/demos/generic/CMakeLists.txt b/demos/generic/CMakeLists.txt
new file mode 100644 (file)
index 0000000..42c4681
--- /dev/null
@@ -0,0 +1,4 @@
+#Generic demo\r
+add_executable(fileimage_demo main.c)\r
+target_link_libraries(fileimage_demo lwext4)\r
+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 (file)
index ae89fd3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-include_directories(blockdev/filedev)\r
-include_directories(blockdev/filedev_win)\r
-\r
-aux_source_directory(blockdev/filedev GENERIC_SRC)\r
-aux_source_directory(blockdev/filedev_win GENERIC_SRC)\r
-aux_source_directory(demos/generic GENERIC_SRC)\r
-\r
-add_executable(fileimage_demo ${GENERIC_SRC})\r
-target_link_libraries(fileimage_demo lwext4)
\ No newline at end of file
index fe304e6fc43451bb3639a5c324c889eb7fe94c4a..de0e7f84b1fac3d3ecb6f4bda894edd2eca603c0 100644 (file)
@@ -34,6 +34,7 @@
 #include <stdbool.h>\r
 #include <time.h>\r
 #include <unistd.h>\r
+#include <sys/time.h>\r
 \r
 #include <ext4_filedev.h>\r
 #include <io_raw.h>\r
diff --git a/demos/stm32f429_disco/CMakeLists.txt b/demos/stm32f429_disco/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ad0675a
--- /dev/null
@@ -0,0 +1,37 @@
+#Discoery disco demo\r
+enable_language(ASM)\r
+set (STM32F429_DEMO_ASM\r
+    startup.S\r
+)\r
+\r
+\r
+include_directories(.)\r
+include_directories(cmsis)\r
+include_directories(stm/lcd_utils)\r
+include_directories(stm/stm32f4_spl/inc)\r
+include_directories(stm/stm32f429)\r
+include_directories(stm/usb_dev/Core/inc)\r
+include_directories(stm/usb_host/Core/inc)\r
+include_directories(stm/usb_host/Class/MSC/inc)\r
+include_directories(stm/usb_otg/inc)\r
+include_directories(stm/usb_user)\r
+\r
+aux_source_directory(. STM32F429_DEMO)\r
+aux_source_directory(cmsis STM32F429_DEMO)\r
+aux_source_directory(stm/lcd_utils STM32F429_DEMO)\r
+aux_source_directory(stm/stm32f4_spl/src STM32F429_DEMO)\r
+aux_source_directory(stm/stm32f429 STM32F429_DEMO)\r
+aux_source_directory(stm/usb_host/Core/src STM32F429_DEMO)\r
+aux_source_directory(stm/usb_host/Class/MSC/src STM32F429_DEMO)\r
+aux_source_directory(stm/usb_otg/src STM32F429_DEMO)\r
+aux_source_directory(stm/usb_user STM32F429_DEMO)\r
+add_executable(stm324f29_demo ${STM32F429_DEMO} ${STM32F429_DEMO_ASM})\r
+\r
+set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter")\r
+set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-format")\r
+set_target_properties(stm324f29_demo PROPERTIES COMPILE_DEFINITIONS "STM32F429_439xx")\r
+\r
+set_target_properties(stm324f29_demo PROPERTIES LINK_FLAGS "-T${CMAKE_SOURCE_DIR}/demos/stm32f429_disco/stm32f429.ld")\r
+target_link_libraries(stm324f29_demo lwext4)\r
+\r
+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 (file)
index 44474ec..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#Discoery disco demo\r
-enable_language(ASM)\r
-set (STM32F429_DEMO_ASM\r
-    demos/stm32f429_disco/startup.S\r
-)\r
-\r
-\r
-include_directories(demos/stm32f429_disco)\r
-include_directories(demos/stm32f429_disco/cmsis)\r
-include_directories(demos/stm32f429_disco/stm/lcd_utils)\r
-include_directories(demos/stm32f429_disco/stm/stm32f4_spl/inc)\r
-include_directories(demos/stm32f429_disco/stm/stm32f429)\r
-include_directories(demos/stm32f429_disco/stm/usb_dev/Core/inc)\r
-include_directories(demos/stm32f429_disco/stm/usb_host/Core/inc)\r
-include_directories(demos/stm32f429_disco/stm/usb_host/Class/MSC/inc)\r
-include_directories(demos/stm32f429_disco/stm/usb_otg/inc)\r
-include_directories(demos/stm32f429_disco/stm/usb_user)\r
-\r
-aux_source_directory(demos/stm32f429_disco STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/cmsis STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/lcd_utils STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/stm32f4_spl/src STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/stm32f429 STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/usb_host/Core/src STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/usb_host/Class/MSC/src STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/usb_otg/src STM32F429_DEMO)\r
-aux_source_directory(demos/stm32f429_disco/stm/usb_user STM32F429_DEMO)\r
-\r
-add_executable(stm324f29_demo ${STM32F429_DEMO} ${STM32F429_DEMO_ASM})\r
-\r
-set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter")\r
-set_target_properties(stm324f29_demo PROPERTIES COMPILE_FLAGS "-Wno-format")\r
-set_target_properties(stm324f29_demo PROPERTIES COMPILE_DEFINITIONS "STM32F429_439xx")\r
-\r
-set_target_properties(stm324f29_demo PROPERTIES LINK_FLAGS "-T${CMAKE_SOURCE_DIR}/demos/stm32f429_disco/stm32f429.ld")\r
-target_link_libraries(stm324f29_demo lwext4)\r
-\r
-add_custom_target(stm32f429_size ALL DEPENDS stm324f29_demo COMMAND ${SIZE} -B stm324f29_demo)
\ No newline at end of file
diff --git a/ext4.h b/ext4.h
deleted file mode 100644 (file)
index 26ac023..0000000
--- a/ext4.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/*\r
- * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * - Redistributions of source code must retain the above copyright\r
- *   notice, this list of conditions and the following disclaimer.\r
- * - Redistributions in binary form must reproduce the above copyright\r
- *   notice, this list of conditions and the following disclaimer in the\r
- *   documentation and/or other materials provided with the distribution.\r
- * - The name of the author may not be used to endorse or promote products\r
- *   derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-/** @addtogroup lwext4\r
- * @{\r
- */\r
-/**\r
- * @file  ext4.h\r
- * @brief Ext4 high level operations (files, directories, mount points...).\r
- *        Client has to include only this file.\r
- */\r
-\r
-#ifndef EXT4_H_\r
-#define EXT4_H_\r
-\r
-#include <ext4_config.h>\r
-#include <ext4_blockdev.h>\r
-#include <stdint.h>\r
-\r
-/********************************FILE OPEN FLAGS*****************************/\r
-\r
-#ifndef O_RDONLY\r
-#define O_RDONLY    00\r
-#endif\r
-\r
-#ifndef O_WRONLY\r
-#define O_WRONLY    01\r
-#endif\r
-\r
-#ifndef O_RDWR\r
-#define O_RDWR      02\r
-#endif\r
-\r
-#ifndef O_CREAT\r
-#define O_CREAT     0100\r
-#endif\r
-\r
-#ifndef O_EXCL\r
-#define O_EXCL      0200\r
-#endif\r
-\r
-#ifndef O_TRUNC\r
-#define O_TRUNC     01000\r
-#endif\r
-\r
-#ifndef O_APPEND\r
-#define O_APPEND    02000\r
-#endif\r
-\r
-/********************************FILE SEEK FLAGS*****************************/\r
-\r
-#ifndef SEEK_SET\r
-#define SEEK_SET    0\r
-#endif\r
-\r
-#ifndef SEEK_CUR\r
-#define SEEK_CUR    1\r
-#endif\r
-\r
-#ifndef SEEK_END\r
-#define SEEK_END    2\r
-#endif\r
-\r
-/********************************OS LOCK INFERFACE***************************/\r
-\r
-/**@brief   OS dependent lock interface.*/\r
-struct ext4_lock {\r
-\r
-    /**@brief   Lock access to mount point*/\r
-    void (*lock)(void);\r
-\r
-    /**@brief   Unlock access to mount point*/\r
-    void (*unlock)(void);\r
-};\r
-\r
-\r
-/********************************FILE DESCRIPTOR*****************************/\r
-\r
-/**@brief   File descriptor*/\r
-typedef struct ext4_file {\r
-\r
-    /**@brief   Mount point handle.*/\r
-    struct ext4_mountpoint *mp;\r
-\r
-    /**@brief   File inode id*/\r
-    uint32_t inode;\r
-\r
-    /**@brief   Open flags.*/\r
-    uint32_t flags;\r
-\r
-    /**@brief   File size.*/\r
-    uint64_t fsize;\r
-\r
-    /**@brief   File position*/\r
-    uint64_t fpos;\r
-}ext4_file;\r
-\r
-/*****************************DIRECTORY DESCRIPTOR***************************/\r
-/**@brief   Directory entry types. Copy from ext4_types.h*/\r
-enum  {\r
-    EXT4_DIRENTRY_UNKNOWN = 0,\r
-    EXT4_DIRENTRY_REG_FILE,\r
-    EXT4_DIRENTRY_DIR,\r
-    EXT4_DIRENTRY_CHRDEV,\r
-    EXT4_DIRENTRY_BLKDEV,\r
-    EXT4_DIRENTRY_FIFO,\r
-    EXT4_DIRENTRY_SOCK,\r
-    EXT4_DIRENTRY_SYMLINK\r
-};\r
-\r
-/**@brief   Directory entry descriptor. Copy from ext4_types.h*/\r
-typedef struct {\r
-    uint32_t inode;\r
-    uint16_t entry_length;\r
-    uint8_t name_length;\r
-    uint8_t inode_type;\r
-    uint8_t name[255];\r
-}ext4_direntry;\r
-\r
-typedef struct  {\r
-    /**@brief   File descriptor*/\r
-    ext4_file f;\r
-    /**@brief   Current directory entry.*/\r
-    ext4_direntry de;\r
-}ext4_dir;\r
-\r
-/********************************MOUNT OPERATIONS****************************/\r
-\r
-/**@brief   Register a block device to a name.\r
- *          @warning Block device has to be filled by\r
- *          @ref EXT4_BLOCKDEV_STATIC_INSTANCE. Block cache may be created\r
- *          @ref EXT4_BCACHE_STATIC_INSTANCE.\r
- *          Block cache may by created automatically when bc parameter is 0.\r
- * @param   bd block device\r
- * @param   bd block device cache (0 = automatic cache mode)\r
- * @param   dev_name register name\r
- * @param   standard error code*/\r
-int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,\r
-        const char *dev_name);\r
-\r
-/**@brief   Mount a block device with EXT4 partition to the mount point.\r
- * @param   dev_name block device name (@ref ext4_device_register)\r
- * @param   mount_point mount point, for example\r
- *          -   /\r
- *          -   /my_partition/\r
- *          -   /my_second_partition/\r
- *\r
- * @return standard error code */\r
-int ext4_mount(const char * dev_name,  char *mount_point);\r
-\r
-/**@brief   Umount operation.\r
- * @param   mount_point mount name\r
- * @return  standard error code */\r
-int ext4_umount(char *mount_point);\r
-\r
-\r
-/**@brief   Some of the filesystem stats.*/\r
-struct ext4_mount_stats {\r
-    uint32_t inodes_count;\r
-    uint32_t free_inodes_count;\r
-    uint64_t blocks_count;\r
-    uint64_t free_blocks_count;\r
-\r
-    uint32_t block_size;\r
-    uint32_t block_group_count;\r
-    uint32_t blocks_per_group;\r
-    uint32_t inodes_per_group;\r
-\r
-    char volume_name[16];\r
-};\r
-\r
-/**@brief   Get file system params.\r
- * @param   mount_point mount path\r
- * @param   stats ext fs stats\r
- * @return  standard error code */\r
-int ext4_mount_point_stats(const char *mount_point,\r
-    struct ext4_mount_stats *stats);\r
-\r
-\r
-/**@brief   Enable/disable write back cache mode.\r
- * @warning Default model of cache is write trough. It means that when You do:\r
- *\r
- *          ext4_fopen(...);\r
- *          ext4_fwrie(...);\r
- *                           < --- data is flushed to physical drive\r
- *\r
- *          When you do:\r
- *          ext4_cache_write_back(..., 1);\r
- *          ext4_fopen(...);\r
- *          ext4_fwrie(...);\r
- *                           < --- data is NOT flushed to physical drive\r
- *          ext4_cache_write_back(..., 0);\r
- *                           < --- when write back mode is disabled all\r
- *                                 cache data will be flushed\r
- * To enable write back mode permanently just call this function\r
- * once after ext4_mount (and disable before ext4_umount).\r
- *\r
- * Some of the function use write back cache mode internally.\r
- * If you enable write back mode twice you have to disable it twice\r
- * to flush all data:\r
- *\r
- *      ext4_cache_write_back(..., 1);\r
- *      ext4_cache_write_back(..., 1);\r
- *\r
- *      ext4_cache_write_back(..., 0);\r
- *      ext4_cache_write_back(..., 0);\r
- *\r
- * Write back mode is useful when you want to create a lot of empty\r
- * files/directories.\r
- *\r
- * @param   path mount point path\r
- * @param   on enable/disable\r
- *\r
- * @return  standard error code */\r
-int ext4_cache_write_back(const char *path, bool on);\r
-\r
-/********************************FILE OPERATIONS*****************************/\r
-\r
-/**@brief   Remove file by path.\r
- * @param   path path to file\r
- * @return  standard error code */\r
-int ext4_fremove(const char *path);\r
-\r
-/**@brief   File open function.\r
- * @param   filename, (has to start from mount point)\r
- *          /my_partition/my_file\r
- * @param   flags open file flags\r
- *  |---------------------------------------------------------------|\r
- *  |   r or rb                 O_RDONLY                            |\r
- *  |---------------------------------------------------------------|\r
- *  |   w or wb                 O_WRONLY|O_CREAT|O_TRUNC            |\r
- *  |---------------------------------------------------------------|\r
- *  |   a or ab                 O_WRONLY|O_CREAT|O_APPEND           |\r
- *  |---------------------------------------------------------------|\r
- *  |   r+ or rb+ or r+b        O_RDWR                              |\r
- *  |---------------------------------------------------------------|\r
- *  |   w+ or wb+ or w+b        O_RDWR|O_CREAT|O_TRUNC              |\r
- *  |---------------------------------------------------------------|\r
- *  |   a+ or ab+ or a+b        O_RDWR|O_CREAT|O_APPEND             |\r
- *  |---------------------------------------------------------------|\r
- *\r
- * @return  standard error code*/\r
-int ext4_fopen (ext4_file *f, const char *path, const char *flags);\r
-\r
-/**@brief   File close function.\r
- * @param   f file handle\r
- * @return  standard error code*/\r
-int ext4_fclose(ext4_file *f);\r
-\r
-/**@brief   Read data from file.\r
- * @param   f file handle\r
- * @param   buf output buffer\r
- * @param   size bytes to read\r
- * @param   rcnt bytes read (may be NULL)\r
- * @return  standard error code*/\r
-int ext4_fread (ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt);\r
-\r
-/**@brief   Write data to file.\r
- * @param   f file handle\r
- * @param   buf data to write\r
- * @param   size write length\r
- * @param   wcnt bytes written (may be NULL)\r
- * @return  standard error code*/\r
-int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt);\r
-\r
-/**@brief   File seek operation.\r
- * @param   f file handle\r
- * @param   offset offset to seek\r
- * @param   origin seek type:\r
- *              @ref SEEK_SET\r
- *              @ref SEEK_CUR\r
- *              @ref SEEK_END\r
- * @return  standard error code*/\r
-int ext4_fseek (ext4_file *f, uint64_t offset, uint32_t origin);\r
-\r
-/**@brief   Get file position.\r
- * @param   f file handle\r
- * @return  actual file position */\r
-uint64_t ext4_ftell (ext4_file *f);\r
-\r
-/**@brief   Get file size.\r
- * @param   f file handle\r
- * @return  file size */\r
-uint64_t ext4_fsize (ext4_file *f);\r
-\r
-/*********************************DIRECTORY OPERATION***********************/\r
-\r
-/**@brief   Recursive directory remove.\r
- * @param   path directory path to remove\r
- * @return  standard error code*/\r
-int ext4_dir_rm(const char *path);\r
-\r
-/**@brief   Create new directory.\r
- * @param   name new directory name\r
- * @return  standard error code*/\r
-int ext4_dir_mk(const char *path);\r
-\r
-/**@brief   Directory open.\r
- * @param   d directory handle\r
- * @param   path directory path\r
- * @return  standard error code*/\r
-int ext4_dir_open (ext4_dir *d, const char *path);\r
-\r
-/**@brief   Directory close.\r
- * @param   d directory handle\r
- * @return  standard error code*/\r
-int ext4_dir_close(ext4_dir *d);\r
-\r
-\r
-/**@brief   Return directory entry by id.\r
- * @param   d directory handle\r
- * @param   id entry id\r
- * @return  directory entry id (NULL id no entry)*/\r
-ext4_direntry* ext4_dir_entry_get(ext4_dir *d, uint32_t id);\r
-\r
-#endif /* EXT4_H_ */\r
-\r
-/**\r
- * @}\r
- */\r
index bb6b7d3dacb446f6a80c97d0edebd22feca71755..0c9770d728500d78ae3b0e0bf871d1670e440803 100644 (file)
@@ -1,10 +1,10 @@
 \r
 ifeq ($(OS),Windows_NT)\r
-LWEXT4_CLIENT = @build_generic\\lwext4_client\r
-LWEXT4_SERVER = @build_generic\\lwext4_server\r
+LWEXT4_CLIENT = @build_generic\\fs_test\\lwext4_client\r
+LWEXT4_SERVER = @build_generic\\fs_test\\lwext4_server\r
 else\r
-LWEXT4_CLIENT = @build_generic/lwext4_client\r
-LWEXT4_SERVER = @build_generic/lwext4_server\r
+LWEXT4_CLIENT = @build_generic/fs_test/lwext4_client\r
+LWEXT4_SERVER = @build_generic/fs_test/lwext4_server\r
 endif\r
 \r
 TEST_DIR = /test\r
@@ -504,4 +504,4 @@ server_ext3:
 server_ext4:\r
        $(LWEXT4_SERVER) -i ext_images/ext4\r
 \r
-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 (file)
index 0000000..91691c1
--- /dev/null
@@ -0,0 +1,12 @@
+#fs_test executables\r
+add_executable(lwext4_server lwext4_server.c)\r
+target_link_libraries(lwext4_server lwext4)\r
+target_link_libraries(lwext4_server blockdev)\r
+if(WIN32)\r
+target_link_libraries(lwext4_server ws2_32)\r
+endif(WIN32)\r
+add_executable(lwext4_client lwext4_client.c)\r
+target_link_libraries(lwext4_client lwext4)\r
+if(WIN32)\r
+target_link_libraries(lwext4_client ws2_32)\r
+endif(WIN32)\r
diff --git a/fs_test/fs_test.cmake b/fs_test/fs_test.cmake
deleted file mode 100644 (file)
index 8bd946b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-include_directories(blockdev/filedev)\r
-include_directories(blockdev/filedev_win)\r
-\r
-aux_source_directory(blockdev/filedev BLOCKDEV_SRC)\r
-aux_source_directory(blockdev/filedev_win BLOCKDEV_SRC)\r
-\r
-\r
-add_executable(lwext4_server fs_test/lwext4_server.c ${BLOCKDEV_SRC})\r
-target_link_libraries(lwext4_server lwext4)\r
-if(WIN32)\r
-target_link_libraries(lwext4_server ws2_32)\r
-endif(WIN32)\r
-add_executable(lwext4_client fs_test/lwext4_client.c ${BLOCKDEV_SRC})\r
-target_link_libraries(lwext4_client lwext4)\r
-if(WIN32)\r
-target_link_libraries(lwext4_client ws2_32)\r
-endif(WIN32)
\ No newline at end of file
index 00e9196edd6963a308c4739d6affc05e4307e391..27024ffe4eb014bf881b28814e917da9cd05b416 100644 (file)
@@ -35,6 +35,7 @@
 #include <stdbool.h>\r
 #include <getopt.h>\r
 #include <time.h>\r
+#include <sys/time.h>\r
 \r
 #ifdef WIN32\r
 #include <winsock2.h>\r
diff --git a/lwext4/CMakeLists.txt b/lwext4/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2962721
--- /dev/null
@@ -0,0 +1,8 @@
+\r
+#LIBRARY\r
+include_directories(.)\r
+aux_source_directory(. LWEXT4_SRC)\r
+add_library(lwext4  ${LWEXT4_SRC})\r
+add_custom_target(lib_size ALL DEPENDS lwext4 COMMAND ${SIZE} -B liblwext4.a)\r
+\r
+\r
diff --git a/lwext4/ext4.h b/lwext4/ext4.h
new file mode 100644 (file)
index 0000000..26ac023
--- /dev/null
@@ -0,0 +1,345 @@
+/*\r
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright\r
+ *   notice, this list of conditions and the following disclaimer.\r
+ * - Redistributions in binary form must reproduce the above copyright\r
+ *   notice, this list of conditions and the following disclaimer in the\r
+ *   documentation and/or other materials provided with the distribution.\r
+ * - The name of the author may not be used to endorse or promote products\r
+ *   derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/** @addtogroup lwext4\r
+ * @{\r
+ */\r
+/**\r
+ * @file  ext4.h\r
+ * @brief Ext4 high level operations (files, directories, mount points...).\r
+ *        Client has to include only this file.\r
+ */\r
+\r
+#ifndef EXT4_H_\r
+#define EXT4_H_\r
+\r
+#include <ext4_config.h>\r
+#include <ext4_blockdev.h>\r
+#include <stdint.h>\r
+\r
+/********************************FILE OPEN FLAGS*****************************/\r
+\r
+#ifndef O_RDONLY\r
+#define O_RDONLY    00\r
+#endif\r
+\r
+#ifndef O_WRONLY\r
+#define O_WRONLY    01\r
+#endif\r
+\r
+#ifndef O_RDWR\r
+#define O_RDWR      02\r
+#endif\r
+\r
+#ifndef O_CREAT\r
+#define O_CREAT     0100\r
+#endif\r
+\r
+#ifndef O_EXCL\r
+#define O_EXCL      0200\r
+#endif\r
+\r
+#ifndef O_TRUNC\r
+#define O_TRUNC     01000\r
+#endif\r
+\r
+#ifndef O_APPEND\r
+#define O_APPEND    02000\r
+#endif\r
+\r
+/********************************FILE SEEK FLAGS*****************************/\r
+\r
+#ifndef SEEK_SET\r
+#define SEEK_SET    0\r
+#endif\r
+\r
+#ifndef SEEK_CUR\r
+#define SEEK_CUR    1\r
+#endif\r
+\r
+#ifndef SEEK_END\r
+#define SEEK_END    2\r
+#endif\r
+\r
+/********************************OS LOCK INFERFACE***************************/\r
+\r
+/**@brief   OS dependent lock interface.*/\r
+struct ext4_lock {\r
+\r
+    /**@brief   Lock access to mount point*/\r
+    void (*lock)(void);\r
+\r
+    /**@brief   Unlock access to mount point*/\r
+    void (*unlock)(void);\r
+};\r
+\r
+\r
+/********************************FILE DESCRIPTOR*****************************/\r
+\r
+/**@brief   File descriptor*/\r
+typedef struct ext4_file {\r
+\r
+    /**@brief   Mount point handle.*/\r
+    struct ext4_mountpoint *mp;\r
+\r
+    /**@brief   File inode id*/\r
+    uint32_t inode;\r
+\r
+    /**@brief   Open flags.*/\r
+    uint32_t flags;\r
+\r
+    /**@brief   File size.*/\r
+    uint64_t fsize;\r
+\r
+    /**@brief   File position*/\r
+    uint64_t fpos;\r
+}ext4_file;\r
+\r
+/*****************************DIRECTORY DESCRIPTOR***************************/\r
+/**@brief   Directory entry types. Copy from ext4_types.h*/\r
+enum  {\r
+    EXT4_DIRENTRY_UNKNOWN = 0,\r
+    EXT4_DIRENTRY_REG_FILE,\r
+    EXT4_DIRENTRY_DIR,\r
+    EXT4_DIRENTRY_CHRDEV,\r
+    EXT4_DIRENTRY_BLKDEV,\r
+    EXT4_DIRENTRY_FIFO,\r
+    EXT4_DIRENTRY_SOCK,\r
+    EXT4_DIRENTRY_SYMLINK\r
+};\r
+\r
+/**@brief   Directory entry descriptor. Copy from ext4_types.h*/\r
+typedef struct {\r
+    uint32_t inode;\r
+    uint16_t entry_length;\r
+    uint8_t name_length;\r
+    uint8_t inode_type;\r
+    uint8_t name[255];\r
+}ext4_direntry;\r
+\r
+typedef struct  {\r
+    /**@brief   File descriptor*/\r
+    ext4_file f;\r
+    /**@brief   Current directory entry.*/\r
+    ext4_direntry de;\r
+}ext4_dir;\r
+\r
+/********************************MOUNT OPERATIONS****************************/\r
+\r
+/**@brief   Register a block device to a name.\r
+ *          @warning Block device has to be filled by\r
+ *          @ref EXT4_BLOCKDEV_STATIC_INSTANCE. Block cache may be created\r
+ *          @ref EXT4_BCACHE_STATIC_INSTANCE.\r
+ *          Block cache may by created automatically when bc parameter is 0.\r
+ * @param   bd block device\r
+ * @param   bd block device cache (0 = automatic cache mode)\r
+ * @param   dev_name register name\r
+ * @param   standard error code*/\r
+int ext4_device_register(struct ext4_blockdev *bd, struct ext4_bcache *bc,\r
+        const char *dev_name);\r
+\r
+/**@brief   Mount a block device with EXT4 partition to the mount point.\r
+ * @param   dev_name block device name (@ref ext4_device_register)\r
+ * @param   mount_point mount point, for example\r
+ *          -   /\r
+ *          -   /my_partition/\r
+ *          -   /my_second_partition/\r
+ *\r
+ * @return standard error code */\r
+int ext4_mount(const char * dev_name,  char *mount_point);\r
+\r
+/**@brief   Umount operation.\r
+ * @param   mount_point mount name\r
+ * @return  standard error code */\r
+int ext4_umount(char *mount_point);\r
+\r
+\r
+/**@brief   Some of the filesystem stats.*/\r
+struct ext4_mount_stats {\r
+    uint32_t inodes_count;\r
+    uint32_t free_inodes_count;\r
+    uint64_t blocks_count;\r
+    uint64_t free_blocks_count;\r
+\r
+    uint32_t block_size;\r
+    uint32_t block_group_count;\r
+    uint32_t blocks_per_group;\r
+    uint32_t inodes_per_group;\r
+\r
+    char volume_name[16];\r
+};\r
+\r
+/**@brief   Get file system params.\r
+ * @param   mount_point mount path\r
+ * @param   stats ext fs stats\r
+ * @return  standard error code */\r
+int ext4_mount_point_stats(const char *mount_point,\r
+    struct ext4_mount_stats *stats);\r
+\r
+\r
+/**@brief   Enable/disable write back cache mode.\r
+ * @warning Default model of cache is write trough. It means that when You do:\r
+ *\r
+ *          ext4_fopen(...);\r
+ *          ext4_fwrie(...);\r
+ *                           < --- data is flushed to physical drive\r
+ *\r
+ *          When you do:\r
+ *          ext4_cache_write_back(..., 1);\r
+ *          ext4_fopen(...);\r
+ *          ext4_fwrie(...);\r
+ *                           < --- data is NOT flushed to physical drive\r
+ *          ext4_cache_write_back(..., 0);\r
+ *                           < --- when write back mode is disabled all\r
+ *                                 cache data will be flushed\r
+ * To enable write back mode permanently just call this function\r
+ * once after ext4_mount (and disable before ext4_umount).\r
+ *\r
+ * Some of the function use write back cache mode internally.\r
+ * If you enable write back mode twice you have to disable it twice\r
+ * to flush all data:\r
+ *\r
+ *      ext4_cache_write_back(..., 1);\r
+ *      ext4_cache_write_back(..., 1);\r
+ *\r
+ *      ext4_cache_write_back(..., 0);\r
+ *      ext4_cache_write_back(..., 0);\r
+ *\r
+ * Write back mode is useful when you want to create a lot of empty\r
+ * files/directories.\r
+ *\r
+ * @param   path mount point path\r
+ * @param   on enable/disable\r
+ *\r
+ * @return  standard error code */\r
+int ext4_cache_write_back(const char *path, bool on);\r
+\r
+/********************************FILE OPERATIONS*****************************/\r
+\r
+/**@brief   Remove file by path.\r
+ * @param   path path to file\r
+ * @return  standard error code */\r
+int ext4_fremove(const char *path);\r
+\r
+/**@brief   File open function.\r
+ * @param   filename, (has to start from mount point)\r
+ *          /my_partition/my_file\r
+ * @param   flags open file flags\r
+ *  |---------------------------------------------------------------|\r
+ *  |   r or rb                 O_RDONLY                            |\r
+ *  |---------------------------------------------------------------|\r
+ *  |   w or wb                 O_WRONLY|O_CREAT|O_TRUNC            |\r
+ *  |---------------------------------------------------------------|\r
+ *  |   a or ab                 O_WRONLY|O_CREAT|O_APPEND           |\r
+ *  |---------------------------------------------------------------|\r
+ *  |   r+ or rb+ or r+b        O_RDWR                              |\r
+ *  |---------------------------------------------------------------|\r
+ *  |   w+ or wb+ or w+b        O_RDWR|O_CREAT|O_TRUNC              |\r
+ *  |---------------------------------------------------------------|\r
+ *  |   a+ or ab+ or a+b        O_RDWR|O_CREAT|O_APPEND             |\r
+ *  |---------------------------------------------------------------|\r
+ *\r
+ * @return  standard error code*/\r
+int ext4_fopen (ext4_file *f, const char *path, const char *flags);\r
+\r
+/**@brief   File close function.\r
+ * @param   f file handle\r
+ * @return  standard error code*/\r
+int ext4_fclose(ext4_file *f);\r
+\r
+/**@brief   Read data from file.\r
+ * @param   f file handle\r
+ * @param   buf output buffer\r
+ * @param   size bytes to read\r
+ * @param   rcnt bytes read (may be NULL)\r
+ * @return  standard error code*/\r
+int ext4_fread (ext4_file *f, void *buf, uint32_t size, uint32_t *rcnt);\r
+\r
+/**@brief   Write data to file.\r
+ * @param   f file handle\r
+ * @param   buf data to write\r
+ * @param   size write length\r
+ * @param   wcnt bytes written (may be NULL)\r
+ * @return  standard error code*/\r
+int ext4_fwrite(ext4_file *f, void *buf, uint32_t size, uint32_t *wcnt);\r
+\r
+/**@brief   File seek operation.\r
+ * @param   f file handle\r
+ * @param   offset offset to seek\r
+ * @param   origin seek type:\r
+ *              @ref SEEK_SET\r
+ *              @ref SEEK_CUR\r
+ *              @ref SEEK_END\r
+ * @return  standard error code*/\r
+int ext4_fseek (ext4_file *f, uint64_t offset, uint32_t origin);\r
+\r
+/**@brief   Get file position.\r
+ * @param   f file handle\r
+ * @return  actual file position */\r
+uint64_t ext4_ftell (ext4_file *f);\r
+\r
+/**@brief   Get file size.\r
+ * @param   f file handle\r
+ * @return  file size */\r
+uint64_t ext4_fsize (ext4_file *f);\r
+\r
+/*********************************DIRECTORY OPERATION***********************/\r
+\r
+/**@brief   Recursive directory remove.\r
+ * @param   path directory path to remove\r
+ * @return  standard error code*/\r
+int ext4_dir_rm(const char *path);\r
+\r
+/**@brief   Create new directory.\r
+ * @param   name new directory name\r
+ * @return  standard error code*/\r
+int ext4_dir_mk(const char *path);\r
+\r
+/**@brief   Directory open.\r
+ * @param   d directory handle\r
+ * @param   path directory path\r
+ * @return  standard error code*/\r
+int ext4_dir_open (ext4_dir *d, const char *path);\r
+\r
+/**@brief   Directory close.\r
+ * @param   d directory handle\r
+ * @return  standard error code*/\r
+int ext4_dir_close(ext4_dir *d);\r
+\r
+\r
+/**@brief   Return directory entry by id.\r
+ * @param   d directory handle\r
+ * @param   id entry id\r
+ * @return  directory entry id (NULL id no entry)*/\r
+ext4_direntry* ext4_dir_entry_get(ext4_dir *d, uint32_t id);\r
+\r
+#endif /* EXT4_H_ */\r
+\r
+/**\r
+ * @}\r
+ */\r
index d471ac531cf85b5c670a3a3a6623b84a4d315bdc..523919baa59e11c60746654975a37d00a0b67fff 100644 (file)
@@ -1,5 +1,5 @@
 # Name of the target\r
-SET(CMAKE_SYSTEM_NAME Generic)\r
+set(CMAKE_SYSTEM_NAME bfin-elf)\r
 set(CMAKE_SYSTEM_PROCESSOR bf518)\r
 \r
 # Toolchain settings\r
@@ -12,9 +12,9 @@ set(OBJDUMP             bfin-elf-objdump)
 set(SIZE                bfin-elf-size)\r
 \r
 set(CMAKE_C_FLAGS   "-mcpu=bf518 -Wall -std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")\r
-set(CMAKE_CXX_FLAGS "-mcpu=bf518 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
+set(CMAKE_CXX_FLAGS "-mcpu=bf518 -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
 set(CMAKE_ASM_FLAGS "-mcpu=bf518 -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")\r
-set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mcpu=bf592" CACHE INTERNAL "exe link flags")\r
+set(CMAKE_EXE_LINKER_FLAGS "-mcpu=bf592 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags")\r
 \r
 \r
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")\r
index 873ed1fd89569d2dd56b2e75c3537d6f2835f01f..3ad9e07803af1e05ac24bf9ab87d1fef34fa810b 100644 (file)
@@ -1,5 +1,5 @@
 # Name of the target\r
-SET(CMAKE_SYSTEM_NAME Generic)\r
+set(CMAKE_SYSTEM_NAME arm-none-eabi)\r
 set(CMAKE_SYSTEM_PROCESSOR cortex-m3)\r
 \r
 # Toolchain settings\r
@@ -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")\r
 set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m3 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
 set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m3" CACHE INTERNAL "asm compiler flags")\r
-set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m3" CACHE INTERNAL "exe link flags")\r
+set(CMAKE_EXE_LINKER_FLAGS "-mthumb -mcpu=cortex-m3 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags")\r
 \r
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")\r
 SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")\r
index c4b097a8810687b4aa138c9e9340a6947af2198f..659018ac2344345e95a5266232d789554de4d119 100644 (file)
@@ -1,5 +1,5 @@
 # Name of the target\r
-SET(CMAKE_SYSTEM_NAME Generic)\r
+set(CMAKE_SYSTEM_NAME arm-none-eabi)\r
 set(CMAKE_SYSTEM_PROCESSOR cortex-m4)\r
 \r
 # Toolchain settings\r
@@ -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")\r
 set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m4 -fno-builtin -Wall -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")\r
 set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m4" CACHE INTERNAL "asm compiler flags")\r
-set(CMAKE_EXE_LINKER_FLAGS "-nostartfiles -Wl,--gc-sections -mthumb -mcpu=cortex-m4" CACHE INTERNAL "exe link flags")\r
+set(CMAKE_EXE_LINKER_FLAGS " -mthumb -mcpu=cortex-m4 -nostartfiles -Wl,--gc-sections" CACHE INTERNAL "exe link flags")\r
 \r
 \r
 \r
@@ -24,5 +24,4 @@ SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")
 \r
 SET(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c release compiler flags")\r
 SET(CMAKE_CXX_FLAGS_RELEASE "-Os" CACHE INTERNAL "cxx release compiler flags")\r
-SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")\r
-\r
+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 (file)
index 0000000..d9f5ef6
--- /dev/null
@@ -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