-/**\r
- * @file main.c\r
- * @version 0.01\r
- * @date Jan 2, 2014\r
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com\r
- * @brief ...\r
+/*\r
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
+ * All rights reserved.\r
*\r
- * @note\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
- * @addtogroup group\r
- * @{\r
- * @addtogroup subgroup\r
- * @{\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
#ifndef CONFIG_H_\r
#define CONFIG_H_\r
\r
+\r
/**@brief Main clock frequency.*/\r
#define CFG_CCLK_FREQ 168000000ul\r
\r
+/**@brief EXT partition block size (only when static cache on)*/\r
+#define EXT_LOGICAL_BLOCK_SIZE (1024 * 4)\r
+\r
+\r
#endif /* CONFIG_H_ */\r
\r
\r
-/** @} (end addtogroup subgroup) */\r
-/** @} (end addtogroup group) */\r
-/**\r
- * @file hw_init.c\r
- * @version 0.01\r
- * @date Oct 2, 2012\r
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com\r
- * @brief ...\r
+/*\r
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
+ * All rights reserved.\r
*\r
- * @note\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
- * @addtogroup group\r
- * @{\r
- * @addtogroup subgroup\r
- * @{\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
#include <config.h>\r
#include <stm32f4xx.h>\r
LCD_SetLayer(LCD_FOREGROUND_LAYER);\r
LCD_LOG_Init();\r
\r
- LCD_LOG_SetHeader((uint8_t *)"LWEXT4 DEMO");\r
+ LCD_LOG_SetHeader((uint8_t *)"STM32 LWEXT4 DEMO");\r
}\r
\r
void hw_usb_process(void)\r
{\r
return _systick_;\r
}\r
+\r
+void hw_wait_ms(uint32_t ms)\r
+{\r
+ volatile uint32_t t = _systick_;\r
+\r
+ while((t + ms) > _systick_)\r
+ ;\r
+}\r
-/**\r
- * @file hw_init.h\r
- * @version 0.01\r
- * @date Oct 2, 2012\r
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com\r
- * @brief ...\r
+/*\r
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
+ * All rights reserved.\r
*\r
- * @note\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
- * @addtogroup group\r
- * @{\r
- * @addtogroup subgroup\r
- * @{\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
\r
#ifndef HW_INIT_H_\r
#define HW_INIT_H_\r
\r
void hw_led_red(bool on);\r
void hw_led_green(bool on);\r
+\r
uint32_t hw_get_ms(void);\r
+void hw_wait_ms(uint32_t ms);\r
\r
#endif /* HW_INIT_H_ */\r
#include <usb_msc_lwext4.h>\r
#include <ext4.h>\r
\r
-/**@brief Input stream name.*/\r
-char input_name[128] = "ext2";\r
-\r
/**@brief Read-write size*/\r
#define READ_WRITE_SZIZE 1024 * 8\r
\r
+/**@brief Delay test (slower LCD scroll)*/\r
+#define TEST_DELAY_MS 2000\r
+\r
+/**@brief Input stream name.*/\r
+char input_name[128] = "ext2";\r
+\r
/**@brief Read-write size*/\r
static int rw_szie = READ_WRITE_SZIZE;\r
\r
/**@brief Read-write size*/\r
-static int rw_count = 1000;\r
+static int rw_count = 100;\r
\r
/**@brief Directory test count*/\r
static int dir_cnt = 10;\r
\r
\r
printf("cleanup: remove /mp/dir1\n");\r
- start =get_ms();\r
+ start = get_ms();\r
ext4_dir_rm("/mp/dir1");\r
stop = get_ms();\r
diff = stop - start;\r
printf("RW count: %d\n", rw_count);\r
printf("Cache mode: %s\n", cache_mode ? "dynamic" : "static");\r
\r
+\r
+ hw_wait_ms(TEST_DELAY_MS);\r
if(!mount())\r
return EXIT_FAILURE;\r
\r
-\r
cleanup();\r
\r
- if(sbstat)\r
+ if(sbstat){\r
+ hw_wait_ms(TEST_DELAY_MS);\r
mp_stats();\r
+ }\r
\r
+ hw_wait_ms(TEST_DELAY_MS);\r
dir_ls("/mp/");\r
if(!dir_test(dir_cnt))\r
return EXIT_FAILURE;\r
\r
+ hw_wait_ms(TEST_DELAY_MS);\r
if(!file_test())\r
return EXIT_FAILURE;\r
\r
dir_ls("/mp/");\r
\r
- if(sbstat)\r
+ if(sbstat){\r
+ hw_wait_ms(TEST_DELAY_MS);\r
mp_stats();\r
+ }\r
\r
- if(cleanup_flag)\r
+ if(cleanup_flag){\r
+ hw_wait_ms(TEST_DELAY_MS);\r
cleanup();\r
+ }\r
\r
- if(bstat)\r
+ if(bstat){\r
+ hw_wait_ms(TEST_DELAY_MS);\r
block_stats();\r
+ }\r
\r
if(!umount())\r
return EXIT_FAILURE;\r
\r
- printf("Test finish: OK\n");\r
+ printf("\nTest finished: OK\n");\r
printf("Press RESET to restart\n");\r
- while (1)\r
- {\r
- volatile int count;\r
- for (count = 0; count < 1000000; count++);\r
+\r
+ while (1) {\r
+ hw_wait_ms(500);\r
hw_led_green(1);\r
- for (count = 0; count < 1000000; count++);\r
+ hw_wait_ms(500);\r
hw_led_green(0);\r
\r
}\r
}\r
\r
-/** @} (end addtogroup subgroup) */\r
-/** @} (end addtogroup group) */\r
-/**\r
- * @file pll.c\r
- * @version 0.01\r
- * @date Oct 2, 2012\r
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com\r
- * @brief ...\r
+/*\r
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
+ * All rights reserved.\r
*\r
- * @note\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
- * @addtogroup group\r
- * @{\r
- * @addtogroup subgroup\r
- * @{\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
#include <config.h>\r
#include <pll.h>\r
\r
while (((RCC->CFGR) & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)\r
;\r
}\r
-\r
-\r
-/** @} (end addtogroup subgroup) */\r
-/** @} (end addtogroup group) */\r
-\r
-\r
-\r
-/**\r
- * @file pll.h\r
- * @version 0.01\r
- * @date Oct 2, 2012\r
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com\r
- * @brief ...\r
+/*\r
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
+ * All rights reserved.\r
*\r
- * @note\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
- * @addtogroup group\r
- * @{\r
- * @addtogroup subgroup\r
- * @{\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
\r
#ifndef PLL_H_\r
#define PLL_H_\r
\r
#include <config.h>\r
\r
-\r
/**@brief Clock initialization.*/\r
void pll_init(void);\r
\r
-\r
-\r
-\r
#endif /* PLL_H_ */\r
\r
-/** @} (end addtogroup subgroup) */\r
-/** @} (end addtogroup group) */\r
+/*\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
#include <sys/stat.h>\r
#include <stdlib.h>\r
+/*\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
#include <ext4_config.h>\r
#include <ext4_blockdev.h>\r
#include <usbh_msc_core.h>\r
#include <usbh_usr.h>\r
\r
-\r
/**@brief Block size.*/\r
#define USB_MSC_BLOCK_SIZE 512\r
\r
-extern USB_OTG_CORE_HANDLE USB_OTG_Core;\r
-extern USBH_HOST USB_Host;\r
-\r
/**@brief MBR_block ID*/\r
#define MBR_BLOCK_ID 0\r
#define MBR_PART_TABLE_OFF 446\r
\r
+extern USB_OTG_CORE_HANDLE USB_OTG_Core;\r
+extern USBH_HOST USB_Host;\r
+\r
struct part_tab_entry {\r
uint8_t status;\r
uint8_t chs1[3];\r
);\r
\r
/******************************************************************************/\r
-EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024);\r
+EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, EXT_LOGICAL_BLOCK_SIZE);\r
\r
/******************************************************************************/\r
\r
\r
\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
+SET(CMAKE_C_FLAGS_DEBUG "-O2 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")\r
+SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")\r
SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")\r
\r
SET(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c release compiler flags")\r