summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/flash.c
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2015-07-30 09:50:58 -0700
committerDamien George <damien.p.george@gmail.com>2015-08-03 00:39:27 +0100
commit8f1eced69da2275b70f0c6426290a5370cd250f2 (patch)
tree8b543c55b667a24bf164d3468b5311e14f8b5dbc /stmhal/flash.c
parent751485fe6b7eeb93f171c2f2b0417803f6e78c05 (diff)
downloadmicropython-8f1eced69da2275b70f0c6426290a5370cd250f2.tar.gz
micropython-8f1eced69da2275b70f0c6426290a5370cd250f2.zip
stmhal: Add STM32F7 support for USB serial and storage.
USB serial is now working for F7. Internal file storage is now working for F7. The flash is laid out a bit differently to the F4 - 4 x 32K, 1 x 128K with the rest 256K, so the internal storage is 96K. Added more pind definitions for STM32F7DISC board. Made USART1 be the default HWUART repl. The STLINK usb connector also looks like a USB serial port which is attached to USART1 on the STM32F7DISC.
Diffstat (limited to 'stmhal/flash.c')
-rw-r--r--stmhal/flash.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/stmhal/flash.c b/stmhal/flash.c
index 670c4cd3ad..54f5f85c69 100644
--- a/stmhal/flash.c
+++ b/stmhal/flash.c
@@ -34,6 +34,21 @@
#define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
#endif
+#if defined(STM32F7)
+
+/* Base address of the Flash sectors */
+#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 32 Kbytes */
+#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08008000) /* Base @ of Sector 1, 32 Kbytes */
+#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08010000) /* Base @ of Sector 2, 32 Kbytes */
+#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x08018000) /* Base @ of Sector 3, 32 Kbytes */
+#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08020000) /* Base @ of Sector 4, 128 Kbytes */
+#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08040000) /* Base @ of Sector 5, 256 Kbytes */
+#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08080000) /* Base @ of Sector 6, 256 Kbytes */
+#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x080C0000) /* Base @ of Sector 7, 256 Kbytes */
+#define ADDR_FLASH_END ((uint32_t)0x08100000) /* 1 Mbytes total */
+
+#else
+
/* Base address of the Flash sectors */
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
@@ -43,11 +58,16 @@
#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
-#if defined(FLASH_SECTOR_8)
+#if !defined(FLASH_SECTOR_8)
+#define ADDR_FLASH_END ((uint32_t)0x08080000) /* 512 Kbytes total */
+#else
#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */
#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */
#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */
#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */
+#define ADDR_FLASH_END ((uint32_t)0x08100000) /* 1 Mbytes total */
+#endif
+
#endif
static const uint32_t flash_info_table[26] = {
@@ -64,10 +84,8 @@ static const uint32_t flash_info_table[26] = {
ADDR_FLASH_SECTOR_9, FLASH_SECTOR_9,
ADDR_FLASH_SECTOR_10, FLASH_SECTOR_10,
ADDR_FLASH_SECTOR_11, FLASH_SECTOR_11,
- ADDR_FLASH_SECTOR_11 + 0x20000, 0,
- #else
- ADDR_FLASH_SECTOR_7 + 0x20000, 0,
#endif
+ ADDR_FLASH_END, 0,
};
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {