ref: ffa23491f71e6c7b9a4a355e547e485648e48c8b
parent: 273f02b2eb705250f7e53ead6ab41237a0085713
author: gkostka <kostka.grzegorz@gmail.com>
date: Sun Jan 12 12:20:19 EST 2014
Comments and some minor fixes.
--- a/demos/stm32f429_disco/config.h
+++ b/demos/stm32f429_disco/config.h
@@ -1,26 +1,42 @@
-/**
- * @file main.c
- * @version 0.01
- * @date Jan 2, 2014
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com
- * @brief ...
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
*
- * @note
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * @addtogroup group
- * @{
- * @addtogroup subgroup
- * @{
- **********************************************************/
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef CONFIG_H_
#define CONFIG_H_
+
/**@brief Main clock frequency.*/
#define CFG_CCLK_FREQ 168000000ul
+/**@brief EXT partition block size (only when static cache on)*/
+#define EXT_LOGICAL_BLOCK_SIZE (1024 * 4)
+
+
#endif /* CONFIG_H_ */
-/** @} (end addtogroup subgroup) */
-/** @} (end addtogroup group) */
--- a/demos/stm32f429_disco/hw_init.c
+++ b/demos/stm32f429_disco/hw_init.c
@@ -1,17 +1,30 @@
-/**
- * @file hw_init.c
- * @version 0.01
- * @date Oct 2, 2012
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com
- * @brief ...
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
*
- * @note
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * @addtogroup group
- * @{
- * @addtogroup subgroup
- * @{
- **********************************************************/
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include <config.h>
#include <stm32f4xx.h>
@@ -62,7 +75,7 @@
LCD_SetLayer(LCD_FOREGROUND_LAYER);
LCD_LOG_Init();
- LCD_LOG_SetHeader((uint8_t *)"LWEXT4 DEMO");
+ LCD_LOG_SetHeader((uint8_t *)"STM32 LWEXT4 DEMO");
}
void hw_usb_process(void)
@@ -93,4 +106,12 @@
uint32_t hw_get_ms(void)
{
return _systick_;
+}
+
+void hw_wait_ms(uint32_t ms)
+{
+ volatile uint32_t t = _systick_;
+
+ while((t + ms) > _systick_)
+ ;
}
--- a/demos/stm32f429_disco/hw_init.h
+++ b/demos/stm32f429_disco/hw_init.h
@@ -1,18 +1,32 @@
-/**
- * @file hw_init.h
- * @version 0.01
- * @date Oct 2, 2012
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com
- * @brief ...
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
*
- * @note
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * @addtogroup group
- * @{
- * @addtogroup subgroup
- * @{
- **********************************************************/
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef HW_INIT_H_
#define HW_INIT_H_
@@ -27,6 +41,8 @@
void hw_led_red(bool on);
void hw_led_green(bool on);
+
uint32_t hw_get_ms(void);
+void hw_wait_ms(uint32_t ms);
#endif /* HW_INIT_H_ */
--- a/demos/stm32f429_disco/main.c
+++ b/demos/stm32f429_disco/main.c
@@ -41,17 +41,20 @@
#include <usb_msc_lwext4.h>
#include <ext4.h>
+/**@brief Read-write size*/
+#define READ_WRITE_SZIZE 1024 * 8
+
+/**@brief Delay test (slower LCD scroll)*/
+#define TEST_DELAY_MS 2000
+
/**@brief Input stream name.*/
char input_name[128] = "ext2";
/**@brief Read-write size*/
-#define READ_WRITE_SZIZE 1024 * 8
-
-/**@brief Read-write size*/
static int rw_szie = READ_WRITE_SZIZE;
/**@brief Read-write size*/
-static int rw_count = 1000;
+static int rw_count = 100;
/**@brief Directory test count*/
static int dir_cnt = 10;
@@ -346,7 +349,7 @@
printf("cleanup: remove /mp/dir1\n");
- start =get_ms();
+ start = get_ms();
ext4_dir_rm("/mp/dir1");
stop = get_ms();
diff = stop - start;
@@ -423,48 +426,56 @@
printf("RW count: %d\n", rw_count);
printf("Cache mode: %s\n", cache_mode ? "dynamic" : "static");
+
+ hw_wait_ms(TEST_DELAY_MS);
if(!mount())
return EXIT_FAILURE;
-
cleanup();
- if(sbstat)
+ if(sbstat){
+ hw_wait_ms(TEST_DELAY_MS);
mp_stats();
+ }
+ hw_wait_ms(TEST_DELAY_MS);
dir_ls("/mp/");
if(!dir_test(dir_cnt))
return EXIT_FAILURE;
+ hw_wait_ms(TEST_DELAY_MS);
if(!file_test())
return EXIT_FAILURE;
dir_ls("/mp/");
- if(sbstat)
+ if(sbstat){
+ hw_wait_ms(TEST_DELAY_MS);
mp_stats();
+ }
- if(cleanup_flag)
+ if(cleanup_flag){
+ hw_wait_ms(TEST_DELAY_MS);
cleanup();
+ }
- if(bstat)
+ if(bstat){
+ hw_wait_ms(TEST_DELAY_MS);
block_stats();
+ }
if(!umount())
return EXIT_FAILURE;
- printf("Test finish: OK\n");
+ printf("\nTest finished: OK\n");
printf("Press RESET to restart\n");
- while (1)
- {
- volatile int count;
- for (count = 0; count < 1000000; count++);
+
+ while (1) {
+ hw_wait_ms(500);
hw_led_green(1);
- for (count = 0; count < 1000000; count++);
+ hw_wait_ms(500);
hw_led_green(0);
}
}
-/** @} (end addtogroup subgroup) */
-/** @} (end addtogroup group) */
--- a/demos/stm32f429_disco/pll.c
+++ b/demos/stm32f429_disco/pll.c
@@ -1,17 +1,31 @@
-/**
- * @file pll.c
- * @version 0.01
- * @date Oct 2, 2012
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com
- * @brief ...
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
*
- * @note
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * @addtogroup group
- * @{
- * @addtogroup subgroup
- * @{
- **********************************************************/
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include <config.h>
#include <pll.h>
@@ -112,10 +126,3 @@
while (((RCC->CFGR) & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
;
}
-
-
-/** @} (end addtogroup subgroup) */
-/** @} (end addtogroup group) */
-
-
-
--- a/demos/stm32f429_disco/pll.h
+++ b/demos/stm32f429_disco/pll.h
@@ -1,31 +1,39 @@
-/**
- * @file pll.h
- * @version 0.01
- * @date Oct 2, 2012
- * @author Grzegorz Kostka, kostka.grzegorz@gmail.com
- * @brief ...
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
*
- * @note
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * @addtogroup group
- * @{
- * @addtogroup subgroup
- * @{
- **********************************************************/
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef PLL_H_
#define PLL_H_
#include <config.h>
-
/**@brief Clock initialization.*/
void pll_init(void);
-
-
-
#endif /* PLL_H_ */
-/** @} (end addtogroup subgroup) */
-/** @} (end addtogroup group) */
--- a/demos/stm32f429_disco/syscalls.c
+++ b/demos/stm32f429_disco/syscalls.c
@@ -1,3 +1,30 @@
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include <sys/stat.h>
#include <stdlib.h>
--- a/demos/stm32f429_disco/usb_msc_lwext4.c
+++ b/demos/stm32f429_disco/usb_msc_lwext4.c
@@ -1,3 +1,30 @@
+/*
+ * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include <ext4_config.h>
#include <ext4_blockdev.h>
@@ -11,17 +38,16 @@
#include <usbh_msc_core.h>
#include <usbh_usr.h>
-
/**@brief Block size.*/
#define USB_MSC_BLOCK_SIZE 512
-extern USB_OTG_CORE_HANDLE USB_OTG_Core;
-extern USBH_HOST USB_Host;
-
/**@brief MBR_block ID*/
#define MBR_BLOCK_ID 0
#define MBR_PART_TABLE_OFF 446
+extern USB_OTG_CORE_HANDLE USB_OTG_Core;
+extern USBH_HOST USB_Host;
+
struct part_tab_entry {
uint8_t status;
uint8_t chs1[3];
@@ -55,7 +81,7 @@
);
/******************************************************************************/
-EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024);
+EXT4_BCACHE_STATIC_INSTANCE(_usb_msc_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, EXT_LOGICAL_BLOCK_SIZE);
/******************************************************************************/
--- a/toolchain/cortex-m4.cmake
+++ b/toolchain/cortex-m4.cmake
@@ -18,8 +18,8 @@
-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_C_FLAGS_DEBUG "-O2 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -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 "-Os" CACHE INTERNAL "c release compiler flags")