Skip to content

Commit 5260e64

Browse files
authored
Merge pull request #1 from RT-Thread/master
同步更新
2 parents 8eb7e02 + f44b8b7 commit 5260e64

File tree

6 files changed

+204
-6
lines changed

6 files changed

+204
-6
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f7.c

Lines changed: 150 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2018-12-5 SummerGift first version
9+
* 2019-3-2 jinsheng add Macro judgment
910
*/
1011

1112
#include "board.h"
@@ -21,7 +22,32 @@
2122
//#define DRV_DEBUG
2223
#define LOG_TAG "drv.flash"
2324
#include <drv_log.h>
24-
25+
#if defined (FLASH_OPTCR_nDBANK)
26+
#define ADDR_FLASH_SECTOR_0 ((rt_uint32_t)0x08000000) /* Base address of Sector 0, 16 Kbytes */
27+
#define ADDR_FLASH_SECTOR_1 ((rt_uint32_t)0x08004000) /* Base address of Sector 1, 16 Kbytes */
28+
#define ADDR_FLASH_SECTOR_2 ((rt_uint32_t)0x08008000) /* Base address of Sector 2, 16 Kbytes */
29+
#define ADDR_FLASH_SECTOR_3 ((rt_uint32_t)0x0800C000) /* Base address of Sector 3, 16 Kbytes */
30+
#define ADDR_FLASH_SECTOR_4 ((rt_uint32_t)0x08010000) /* Base address of Sector 4, 64 Kbytes */
31+
#define ADDR_FLASH_SECTOR_5 ((rt_uint32_t)0x08020000) /* Base address of Sector 5, 128 Kbytes */
32+
#define ADDR_FLASH_SECTOR_6 ((rt_uint32_t)0x08040000) /* Base address of Sector 6, 128 Kbytes */
33+
#define ADDR_FLASH_SECTOR_7 ((rt_uint32_t)0x08060000) /* Base address of Sector 7, 128 Kbytes */
34+
#define ADDR_FLASH_SECTOR_8 ((rt_uint32_t)0x08080000) /* Base address of Sector 8, 128 Kbytes */
35+
#define ADDR_FLASH_SECTOR_9 ((rt_uint32_t)0x080A0000) /* Base address of Sector 9, 128 Kbytes */
36+
#define ADDR_FLASH_SECTOR_10 ((rt_uint32_t)0x080C0000) /* Base address of Sector 10, 128 Kbytes */
37+
#define ADDR_FLASH_SECTOR_11 ((rt_uint32_t)0x080E0000) /* Base address of Sector 11, 128 Kbytes */
38+
#define ADDR_FLASH_SECTOR_12 ((rt_uint32_t)0x08100000) /* Base address of Sector 12, 16 Kbytes */
39+
#define ADDR_FLASH_SECTOR_13 ((rt_uint32_t)0x08104000) /* Base address of Sector 13, 16 Kbytes */
40+
#define ADDR_FLASH_SECTOR_14 ((rt_uint32_t)0x08108000) /* Base address of Sector 14, 16 Kbytes */
41+
#define ADDR_FLASH_SECTOR_15 ((rt_uint32_t)0x0810C000) /* Base address of Sector 15, 16 Kbytes */
42+
#define ADDR_FLASH_SECTOR_16 ((rt_uint32_t)0x08110000) /* Base address of Sector 16, 64 Kbytes */
43+
#define ADDR_FLASH_SECTOR_17 ((rt_uint32_t)0x08120000) /* Base address of Sector 17, 128 Kbytes */
44+
#define ADDR_FLASH_SECTOR_18 ((rt_uint32_t)0x08140000) /* Base address of Sector 18, 128 Kbytes */
45+
#define ADDR_FLASH_SECTOR_19 ((rt_uint32_t)0x08160000) /* Base address of Sector 19, 128 Kbytes */
46+
#define ADDR_FLASH_SECTOR_20 ((rt_uint32_t)0x08180000) /* Base address of Sector 20, 128 Kbytes */
47+
#define ADDR_FLASH_SECTOR_21 ((rt_uint32_t)0x081A0000) /* Base address of Sector 21, 128 Kbytes */
48+
#define ADDR_FLASH_SECTOR_22 ((rt_uint32_t)0x081C0000) /* Base address of Sector 22, 128 Kbytes */
49+
#define ADDR_FLASH_SECTOR_23 ((rt_uint32_t)0x081E0000) /* Base address of Sector 23, 128 Kbytes */
50+
#else
2551
#define ADDR_FLASH_SECTOR_0 ((rt_uint32_t)0x08000000) /* Base address of Sector 0, 32 Kbytes */
2652
#define ADDR_FLASH_SECTOR_1 ((rt_uint32_t)0x08008000) /* Base address of Sector 1, 32 Kbytes */
2753
#define ADDR_FLASH_SECTOR_2 ((rt_uint32_t)0x08010000) /* Base address of Sector 2, 32 Kbytes */
@@ -34,7 +60,7 @@
3460
#define ADDR_FLASH_SECTOR_9 ((rt_uint32_t)0x08140000) /* Base address of Sector 9, 256 Kbytes */
3561
#define ADDR_FLASH_SECTOR_10 ((rt_uint32_t)0x08180000) /* Base address of Sector 10, 256 Kbytes */
3662
#define ADDR_FLASH_SECTOR_11 ((rt_uint32_t)0x081C0000) /* Base address of Sector 11, 256 Kbytes */
37-
63+
#endif
3864
/**
3965
* @brief Gets the sector of a given address
4066
* @param None
@@ -43,7 +69,7 @@
4369
static rt_uint32_t GetSector(rt_uint32_t Address)
4470
{
4571
rt_uint32_t sector = 0;
46-
72+
#if defined (FLASH_OPTCR_nDBANK)
4773
if ((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
4874
{
4975
sector = FLASH_SECTOR_0;
@@ -52,6 +78,7 @@ static rt_uint32_t GetSector(rt_uint32_t Address)
5278
{
5379
sector = FLASH_SECTOR_1;
5480
}
81+
#if (FLASH_SECTOR_TOTAL >= 4)
5582
else if ((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
5683
{
5784
sector = FLASH_SECTOR_2;
@@ -60,6 +87,7 @@ static rt_uint32_t GetSector(rt_uint32_t Address)
6087
{
6188
sector = FLASH_SECTOR_3;
6289
}
90+
#elif (FLASH_SECTOR_TOTAL >= 8)
6391
else if ((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
6492
{
6593
sector = FLASH_SECTOR_4;
@@ -76,6 +104,7 @@ static rt_uint32_t GetSector(rt_uint32_t Address)
76104
{
77105
sector = FLASH_SECTOR_7;
78106
}
107+
#elif (FLASH_SECTOR_TOTAL >= 24)
79108
else if ((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
80109
{
81110
sector = FLASH_SECTOR_8;
@@ -88,10 +117,127 @@ static rt_uint32_t GetSector(rt_uint32_t Address)
88117
{
89118
sector = FLASH_SECTOR_10;
90119
}
91-
else /* (Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_11) */
120+
else if ((Address < ADDR_FLASH_SECTOR_12) && (Address >= ADDR_FLASH_SECTOR_11))
92121
{
93122
sector = FLASH_SECTOR_11;
94123
}
124+
else if ((Address < ADDR_FLASH_SECTOR_13) && (Address >= ADDR_FLASH_SECTOR_12))
125+
{
126+
sector = FLASH_SECTOR_12;
127+
}
128+
else if ((Address < ADDR_FLASH_SECTOR_14) && (Address >= ADDR_FLASH_SECTOR_13))
129+
{
130+
sector = FLASH_SECTOR_13;
131+
}
132+
else if ((Address < ADDR_FLASH_SECTOR_15) && (Address >= ADDR_FLASH_SECTOR_14))
133+
{
134+
sector = FLASH_SECTOR_14;
135+
}
136+
else if ((Address < ADDR_FLASH_SECTOR_16) && (Address >= ADDR_FLASH_SECTOR_15))
137+
{
138+
sector = FLASH_SECTOR_15;
139+
}
140+
else if ((Address < ADDR_FLASH_SECTOR_17) && (Address >= ADDR_FLASH_SECTOR_16))
141+
{
142+
sector = FLASH_SECTOR_16;
143+
}
144+
else if ((Address < ADDR_FLASH_SECTOR_18) && (Address >= ADDR_FLASH_SECTOR_17))
145+
{
146+
sector = FLASH_SECTOR_17;
147+
}
148+
else if ((Address < ADDR_FLASH_SECTOR_19) && (Address >= ADDR_FLASH_SECTOR_18))
149+
{
150+
sector = FLASH_SECTOR_18;
151+
}
152+
else if ((Address < ADDR_FLASH_SECTOR_20) && (Address >= ADDR_FLASH_SECTOR_19))
153+
{
154+
sector = FLASH_SECTOR_19;
155+
}
156+
else if ((Address < ADDR_FLASH_SECTOR_21) && (Address >= ADDR_FLASH_SECTOR_20))
157+
{
158+
sector = FLASH_SECTOR_20;
159+
}
160+
else if ((Address < ADDR_FLASH_SECTOR_22) && (Address >= ADDR_FLASH_SECTOR_21))
161+
{
162+
sector = FLASH_SECTOR_21;
163+
}
164+
else if ((Address < ADDR_FLASH_SECTOR_23) && (Address >= ADDR_FLASH_SECTOR_22))
165+
{
166+
sector = FLASH_SECTOR_22;
167+
}
168+
#else
169+
else
170+
{
171+
#if (FLASH_SECTOR_TOTAL == 4)
172+
sector = FLASH_SECTOR_4;
173+
#elif (FLASH_SECTOR_TOTAL == 8)
174+
sector = FLASH_SECTOR_8;
175+
#elif (FLASH_SECTOR_TOTAL == 24)
176+
sector = FLASH_SECTOR_23;
177+
#endif
178+
}
179+
#endif
180+
#else
181+
if ((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
182+
{
183+
sector = FLASH_SECTOR_0;
184+
}
185+
else if ((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
186+
{
187+
sector = FLASH_SECTOR_1;
188+
}
189+
#if (FLASH_SECTOR_TOTAL >= 4)
190+
else if ((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
191+
{
192+
sector = FLASH_SECTOR_2;
193+
}
194+
else if ((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
195+
{
196+
sector = FLASH_SECTOR_3;
197+
}
198+
#elif (FLASH_SECTOR_TOTAL >= 8)
199+
else if ((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
200+
{
201+
sector = FLASH_SECTOR_4;
202+
}
203+
else if ((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
204+
{
205+
sector = FLASH_SECTOR_5;
206+
}
207+
else if ((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
208+
{
209+
sector = FLASH_SECTOR_6;
210+
}
211+
else if ((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
212+
{
213+
sector = FLASH_SECTOR_7;
214+
}
215+
#elif (FLASH_SECTOR_TOTAL >= 24)
216+
else if ((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
217+
{
218+
sector = FLASH_SECTOR_8;
219+
}
220+
else if ((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
221+
{
222+
sector = FLASH_SECTOR_9;
223+
}
224+
else if ((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
225+
{
226+
sector = FLASH_SECTOR_10;
227+
}
228+
#else
229+
else
230+
{
231+
#if (FLASH_SECTOR_TOTAL == 4)
232+
sector = FLASH_SECTOR_4;
233+
#elif (FLASH_SECTOR_TOTAL == 8)
234+
sector = FLASH_SECTOR_8;
235+
#elif (FLASH_SECTOR_TOTAL == 24)
236+
sector = FLASH_SECTOR_11;
237+
#endif
238+
}
239+
#endif
240+
#endif
95241
return sector;
96242
}
97243

bsp/stm32/stm32f746-st-disco/.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ CONFIG_BSP_USING_GPIO=y
320320
CONFIG_BSP_USING_UART=y
321321
CONFIG_BSP_USING_UART1=y
322322
# CONFIG_BSP_UART1_RX_USING_DMA is not set
323+
# CONFIG_BSP_USING_ON_CHIP_FLASH is not set
323324
# CONFIG_BSP_USING_QSPI is not set
324325
# CONFIG_BSP_USING_SDIO is not set
325326

bsp/stm32/stm32f746-st-disco/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ STM32F746-disco 是 ST 推出的一款基于 ARM Cortex-M7 内核的开发板,
5353
| SPI | 暂不支持 | 即将支持 |
5454
| QSPI | 支持 | QSPI1 |
5555
| I2C | 暂不支持 | 即将支持 |
56-
| FLASH | 暂不支持 | 即将支持 |
56+
| FLASH | 支持 | |
5757
| WDT | 暂不支持 | 即将支持 |
5858
| SDIO | 支持 | 支持 |
5959
| USB Device | 暂不支持 | 即将支持 |

bsp/stm32/stm32f746-st-disco/board/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ menu "On-chip Peripheral Drivers"
6161
depends on BSP_USING_UART1 && RT_SERIAL_USING_DMA
6262
default n
6363
endif
64+
config BSP_USING_ON_CHIP_FLASH
65+
bool "Enable on-chip FLASH"
66+
default n
6467
config BSP_USING_QSPI
6568
bool "Enable QSPI BUS"
6669
select RT_USING_QSPI
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2019-03-02 jinsheng first version
9+
*/
10+
11+
#ifndef _FAL_CFG_H_
12+
#define _FAL_CFG_H_
13+
14+
#include <rtthread.h>
15+
#include <board.h>
16+
17+
#define FLASH_SIZE_GRANULARITY_32K (4 * 32 * 1024)
18+
#define FLASH_SIZE_GRANULARITY_128K (128 * 1024)
19+
#define FLASH_SIZE_GRANULARITY_256K (3 * 256 * 1024)
20+
21+
#define STM32_FLASH_START_ADRESS_32K STM32_FLASH_START_ADRESS
22+
#define STM32_FLASH_START_ADRESS_128K (STM32_FLASH_START_ADRESS_32K + FLASH_SIZE_GRANULARITY_32K)
23+
#define STM32_FLASH_START_ADRESS_256K (STM32_FLASH_START_ADRESS_128K + FLASH_SIZE_GRANULARITY_128K)
24+
25+
extern const struct fal_flash_dev stm32_onchip_flash_32k;
26+
extern const struct fal_flash_dev stm32_onchip_flash_128k;
27+
extern const struct fal_flash_dev stm32_onchip_flash_256k;
28+
29+
/* flash device table */
30+
#define FAL_FLASH_DEV_TABLE \
31+
{ \
32+
&stm32_onchip_flash_32k, \
33+
&stm32_onchip_flash_128k, \
34+
&stm32_onchip_flash_256k, \
35+
}
36+
/* ====================== Partition Configuration ========================== */
37+
#ifdef FAL_PART_HAS_TABLE_CFG
38+
39+
/* partition table */
40+
#define FAL_PART_TABLE \
41+
{ \
42+
{FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_32k", 0 , FLASH_SIZE_GRANULARITY_32K , 0}, \
43+
{FAL_PART_MAGIC_WROD, "param", "onchip_flash_128k", 0 , FLASH_SIZE_GRANULARITY_128K, 0}, \
44+
{FAL_PART_MAGIC_WROD, "app", "onchip_flash_256k", 0 , FLASH_SIZE_GRANULARITY_256K, 0}, \
45+
}
46+
47+
#endif /* FAL_PART_HAS_TABLE_CFG */
48+
#endif /* _FAL_CFG_H_ */

include/libc/libc_errno.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ defined in armcc/errno.h
161161
#define EPROTONOSUPPORT (ERROR_BASE_NO + 93)
162162
#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94)
163163
#define EOPNOTSUPP (ERROR_BASE_NO + 95)
164-
#define ENOTSUP EOPNOTSUPP )
164+
#define ENOTSUP EOPNOTSUPP
165165
#define EPFNOSUPPORT (ERROR_BASE_NO + 96)
166166
#define EAFNOSUPPORT (ERROR_BASE_NO + 97)
167167
#define EADDRINUSE (ERROR_BASE_NO + 98)

0 commit comments

Comments
 (0)