Skip to content

Commit

Permalink
Merge pull request #72 from mysterywolf/master
Browse files Browse the repository at this point in the history
与rtthread仓库的sfud双向同步 并整理代码
  • Loading branch information
armink authored Aug 12, 2022
2 parents d9c3d9a + adfc1c7 commit e35e0c9
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 23 deletions.
6 changes: 3 additions & 3 deletions demo/stm32f10x_non_os/Libraries/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ startup_scripts['STM32F10X_LD'] = 'startup_stm32f10x_ld.s'
startup_scripts['STM32F10X_LD_VL'] = 'startup_stm32f10x_ld_vl.s'
startup_scripts['STM32F10X_MD'] = 'startup_stm32f10x_md.s'
startup_scripts['STM32F10X_MD_VL'] = 'startup_stm32f10x_md_vl.s'
startup_scripts['STM32F10X_XL'] = 'startup_stm32f10x_xl.s'
startup_scripts['STM32F10X_XL'] = 'startup_stm32f10x_xl.s'

# add for startup script
# add for startup script
if rtconfig.CROSS_TOOL == 'gcc':
src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/' + startup_scripts[rtconfig.STM32_TYPE]]
elif rtconfig.CROSS_TOOL == 'keil':
src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/arm/' + startup_scripts[rtconfig.STM32_TYPE]]
elif rtconfig.CROSS_TOOL == 'iar':
src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/iar/' + startup_scripts[rtconfig.STM32_TYPE]]

path = [cwd + '/STM32F10x_StdPeriph_Driver/inc',
path = [cwd + '/STM32F10x_StdPeriph_Driver/inc',
cwd + '/CMSIS/CM3/CoreSupport',
cwd + '/CMSIS/CM3/DeviceSupport/ST/STM32F10x']

Expand Down
6 changes: 3 additions & 3 deletions demo/stm32f2xx_rtt/Libraries/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ startup_scripts['STM32F10X_LD'] = 'startup_stm32f10x_ld.s'
startup_scripts['STM32F10X_LD_VL'] = 'startup_stm32f10x_ld_vl.s'
startup_scripts['STM32F10X_MD'] = 'startup_stm32f10x_md.s'
startup_scripts['STM32F10X_MD_VL'] = 'startup_stm32f10x_md_vl.s'
startup_scripts['STM32F10X_XL'] = 'startup_stm32f10x_xl.s'
startup_scripts['STM32F10X_XL'] = 'startup_stm32f10x_xl.s'

# add for startup script
# add for startup script
if rtconfig.CROSS_TOOL == 'gcc':
src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/' + startup_scripts[rtconfig.STM32_TYPE]]
elif rtconfig.CROSS_TOOL == 'keil':
src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/arm/' + startup_scripts[rtconfig.STM32_TYPE]]
elif rtconfig.CROSS_TOOL == 'iar':
src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/iar/' + startup_scripts[rtconfig.STM32_TYPE]]

path = [cwd + '/STM32F10x_StdPeriph_Driver/inc',
path = [cwd + '/STM32F10x_StdPeriph_Driver/inc',
cwd + '/CMSIS/CM3/CoreSupport',
cwd + '/CMSIS/CM3/DeviceSupport/ST/STM32F10x']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ filesystems/yaffs2/yaffs_nandcfg.c
filesystems/yaffs2/yaffs/yaffs_allocator.c
filesystems/yaffs2/yaffs/yaffs_bitmap.c
filesystems/yaffs2/yaffs/yaffs_checkptrw.c
filesystems/yaffs2/yaffs/yaffs_ecc.c
filesystems/yaffs2/yaffs/yaffs_ecc.c
filesystems/yaffs2/yaffs/yaffs_guts.c
filesystems/yaffs2/yaffs/yaffs_nameval.c
filesystems/yaffs2/yaffs/yaffs_nand.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
src = Glob('*.c')
CPPPATH = [cwd + '/../include']

if not GetDepend('RT_USING_HEAP'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ if rtconfig.CROSS_TOOL == 'keil':
if not GetDepend('FINSH_USING_MSH_ONLY'):
LINKFLAGS = LINKFLAGS + ' --keep *.o(VSymTab) '
else:
LINKFLAGS = ''
LINKFLAGS = ''

if GetDepend('FINSH_USING_MSH'):
src = src + msh_src
src = src + msh_src
if not GetDepend('FINSH_USING_MSH_ONLY'):
src = src + fsh_src

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
src = Glob('*.c')
CPPPATH = [cwd]

group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH)
Expand Down
4 changes: 2 additions & 2 deletions sfud/inc/sfud_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ if (!(EXPR)) \
#define SFUD_CMD_READ_DATA 0x03
#endif

#ifndef SFUD_CMD_DUAL_OUTPUT_READ_DATA
#ifndef SFUD_CMD_DUAL_OUTPUT_READ_DATA
#define SFUD_CMD_DUAL_OUTPUT_READ_DATA 0x3B
#endif

#ifndef SFUD_CMD_DUAL_IO_READ_DATA
#ifndef SFUD_CMD_DUAL_IO_READ_DATA
#define SFUD_CMD_DUAL_IO_READ_DATA 0xBB
#endif

Expand Down
18 changes: 11 additions & 7 deletions sfud/inc/sfud_flash_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ typedef struct {
#define SFUD_MF_ID_ATMEL 0x1F
#define SFUD_MF_ID_MICRON 0x20
#define SFUD_MF_ID_AMIC 0x37
#define SFUD_MF_ID_NOR_MEM 0x52
#define SFUD_MF_ID_SANYO 0x62
#define SFUD_MF_ID_INTEL 0x89
#define SFUD_MF_ID_ESMT 0x8C
#define SFUD_MF_ID_FUDAN 0xA1
#define SFUD_MF_ID_HYUNDAI 0xAD
#define SFUD_MF_ID_SST 0xBF
#define SFUD_MF_ID_MICRONIX 0xC2
#define SFUD_MF_ID_MACRONIX 0xC2
#define SFUD_MF_ID_GIGADEVICE 0xC8
#define SFUD_MF_ID_ISSI 0xD5
#define SFUD_MF_ID_WINBOND 0xEF
#define SFUD_MF_ID_NOR_MEM 0x52

/* SFUD supported manufacturer information table */
#define SFUD_MF_TABLE \
Expand All @@ -111,8 +111,8 @@ typedef struct {
{"GigaDevice", SFUD_MF_ID_GIGADEVICE}, \
{"ISSI", SFUD_MF_ID_ISSI}, \
{"Winbond", SFUD_MF_ID_WINBOND}, \
{"Micronix", SFUD_MF_ID_MICRONIX}, \
{"Nor-Mem", SFUD_MF_ID_NOR_MEM}, \
{"Macronix", SFUD_MF_ID_MACRONIX}, \
{"NOR-MEM", SFUD_MF_ID_NOR_MEM}, \
}

#ifdef SFUD_USING_FLASH_INFO_TABLE
Expand Down Expand Up @@ -147,12 +147,12 @@ typedef struct {
{"A25L080", SFUD_MF_ID_AMIC, 0x30, 0x14, 1L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
{"F25L004", SFUD_MF_ID_ESMT, 0x20, 0x13, 512L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
{"PCT25VF016B", SFUD_MF_ID_SST, 0x25, 0x41, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
{"NM25Q128EV", SFUD_MF_ID_NOR_MEM, 0x21, 0x18, 16L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
{"NM25Q128EVB", SFUD_MF_ID_NOR_MEM, 0x21, 0x18, 16L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
}
#endif /* SFUD_USING_FLASH_INFO_TABLE */

#ifdef SFUD_USING_QSPI
/* This table saves flash read-fast instructions in QSPI mode,
/* This table saves flash read-fast instructions in QSPI mode,
* SFUD can use this table to select the most appropriate read instruction for flash.
* | mf_id | type_id | capacity_id | qspi_read_mode |
*/
Expand Down Expand Up @@ -181,9 +181,13 @@ typedef struct {
/* A25LQ64 */ \
{SFUD_MF_ID_AMIC, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_IO}, \
/* MX25L3206E and KH25L3206E */ \
{SFUD_MF_ID_MICRONIX, 0x20, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT}, \
{SFUD_MF_ID_MACRONIX, 0x20, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT}, \
/* MX25L51245G */ \
{SFUD_MF_ID_MACRONIX, 0x20, 0x1A, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
/* GD25Q64B */ \
{SFUD_MF_ID_GIGADEVICE, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT}, \
/* NM25Q128EVB */ \
{SFUD_MF_ID_NOR_MEM, 0x21, 0x18, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
}
#endif /* SFUD_USING_QSPI */

Expand Down
4 changes: 2 additions & 2 deletions sfud/src/sfud.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ sfud_err sfud_qspi_fast_read_enable(sfud_flash *flash, uint8_t data_line_width)
break;
case 2:
if (read_mode & DUAL_IO) {
qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_IO_READ_DATA, 1, 2, 8, 2);
qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_IO_READ_DATA, 1, 2, 4, 2);
} else if (read_mode & DUAL_OUTPUT) {
qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_OUTPUT_READ_DATA, 1, 1, 8, 2);
} else {
Expand Down Expand Up @@ -359,7 +359,7 @@ static sfud_err hardware_init(sfud_flash *flash) {
}
if (result != SFUD_SUCCESS) {
return result;
}
}

/* if the flash is large than 16MB (256Mb) then enter in 4-Byte addressing mode */
if (flash->chip.capacity > (1L << 24)) {
Expand Down
2 changes: 1 addition & 1 deletion sfud/src/sfud_sfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static bool read_basic_table(sfud_flash *flash, sfdp_para_header *basic_header)
return false;
}
/* get write granularity */
//TODO 目前为 1.0 所提供的方式,后期支持 V1.5 及以上的方式读取 page size
//TODO 目前为 1.0 所提供的方式,后期支持 V1.5 及以上的方式读取 page size
switch ((table[0] & (0x01 << 2)) >> 2) {
case 0:
sfdp->write_gran = 1;
Expand Down

0 comments on commit e35e0c9

Please sign in to comment.