NetBurner 3.1
onchipflash.h
1 /* Revision: 2.8.7 */
2 
3 /******************************************************************************
4 * Copyright 1998-2018 NetBurner, Inc. ALL RIGHTS RESERVED
5 *
6 * Permission is hereby granted to purchasers of NetBurner Hardware to use or
7 * modify this computer program for any use as long as the resultant program
8 * is only executed on NetBurner provided hardware.
9 *
10 * No other rights to use this program or its derivatives in part or in
11 * whole are granted.
12 *
13 * It may be possible to license this or other NetBurner software for use on
14 * non-NetBurner Hardware. Contact sales@Netburner.com for more information.
15 *
16 * NetBurner makes no representation or warranties with respect to the
17 * performance of this computer program, and specifically disclaims any
18 * responsibility for any damages, special or consequential, connected with
19 * the use of this program.
20 *
21 * NetBurner
22 * 5405 Morehouse Dr.
23 * San Diego, CA 92121
24 * www.netburner.com
25 ******************************************************************************/
26 
27 
28 #ifndef _ONCHIPFLASH_H_
29 #define _ONCHIPFLASH_H_
30 
31 /*
32  *-------------------------------------------------------------------
33  * Embedded Flash File System for on-chip flash memory (EFFS-STD)
34  * configuration file for common parameters.
35  * This file is part of an example that allocates flash space
36  * to the file system, and the rest to the application.
37  *
38  * Note:
39  * COMPCODEFLAGS contain starting and ending addresses
40  * of application. To add file system you must modify the ending
41  * address to provide for the flash used. Not to do so will result
42  * in unpredictable results.
43  *
44  * See"
45  * "NetBurner Embedded Flash File System, Hardware and Software
46  * Guide" for detailed information.
47  *
48  *-------------------------------------------------------------------
49  */
50 
51 #include <file/fsf.h>
52 #include "nbfactory.h"
53 
54 /*
55  ******************************************************************************
56  *
57  * Flash component file system dependent settings
58  *
59  ******************************************************************************
60  */
61 #ifdef NB_FACTORY_FLASH_2MB_16KB_SECTORS
62 /*
63  * Part Numbers:
64  * AM29LV160DB-90EF
65  * S29AL016D-90TFI-020
66  *
67  * Size:
68  * 2MB bytes
69  *
70  * Sector Size:
71  * Constant
72  * 16 KB
73  *
74  */
75 #define FLASH_SIZE ( 2 * 1024 * 1024 )
76 #define SECTORSIZE ( 16 * 1024 )
77 /*
78  * File system allocations:
79  * FS_SIZE - File system size in bytes
80  * BLOCKSIZE - File system block
81  * SECTORPERBLOCK - Sectors per block
82  * FS_FLASHBASE - Start of flash
83  * FIRST_ADDR - Start of file system
84  *
85  */
86 #define FS_SIZE ( 512 * 1024 ) // file system size. 0x20 0000, 0xFFBF FFFF
87 #define BLOCKSIZE ( 64 * 1024 ) // flash physical sector size
88 #define SECTORPERBLOCK ( BLOCKSIZE / SECTORSIZE )
89 #define FS_FLASHBASE ( 0xFFC00000 )
90 #define FIRST_ADDR ( FLASH_SIZE - FS_SIZE )
91 
92 /*
93  * Descriptor Blocks:
94  * DESCSIZE - Size of one descriptor
95  *
96  */
97 #define DESCSIZE ( 8 * 1024 )
98 
99 #elif defined( NB_FACTORY_FLASH_500KB_1KB_SECTORS )
100 /*
101  * Part Numbers:
102  * SST39VF040-90-4C-NH
103  *
104  * Size:
105  * 500 KB bytes
106  *
107  * Sector Size:
108  * Constant
109  * 1 KB
110  *
111  */
112 #define FLASH_SIZE ( 512 * 1024 )
113 #define SECTORSIZE ( 1 * 1024 )
114 /*
115  * File system allocations:
116  * FS_SIZE - File system size in bytes
117  * BLOCKSIZE - File system block
118  * SECTORPERBLOCK - Sectors per block
119  * FS_FLASHBASE - Start of flash
120  * FIRST_ADDR - Start of file system
121  *
122  */
123 #define FS_SIZE ( 64 * 1024 ) // file system size is 16 blocks (physical sectors)0x4000, 0xFFC7C000
124 #define BLOCKSIZE ( 4 * 1024 ) // flash physical sector size
125 #define SECTORPERBLOCK ( BLOCKSIZE / SECTORSIZE )
126 #define FS_FLASHBASE ( 0xFFC00000 )
127 #define FIRST_ADDR ( FLASH_SIZE - FS_SIZE )
128 
129 /*
130  * Descriptor Blocks:
131  * DESCSIZE - Size of one descriptor
132  *
133  */
134 #define DESCSIZE ( 4 * 1024 )
135 
136 #elif defined( NB_FACTORY_FLASH_SPI_8MB_4KB_SECTORS )
137 /*
138  * Part Numbers:
139  * SPI SERIAL FLASH
140  *
141  * Size:
142  * 8M bytes
143  *
144  * Sector Size:
145  * Constant
146  * 4 KB
147  *
148  */
149 #define FLASH_SIZE ( 8 * 1024 * 1024 ) // 8MBytes
150 #define SECTORSIZE ( 1 * 1024 ) // This is NOT the physical flash sector size
151 /*
152  * File system allocations:
153  * FS_SIZE - File system size in bytes
154  * BLOCKSIZE - File system block
155  * SECTORPERBLOCK - Sectors per block
156  * FS_FLASHBASE - Start of flash
157  * FIRST_ADDR - Start of file system
158  *
159  */
160 #define FS_SIZE ( 64 * 1024 ) // Size of file system, including desc blocks
161 #define BLOCKSIZE ( 4 * 1024 ) // This IS the physical flash sector size
162 #define SECTORPERBLOCK ( BLOCKSIZE / SECTORSIZE )
163 // #define FS_FLASHBASE ( 0x040000 ) // Not used for SPI flash
164 #define FIRST_ADDR ( FLASH_SIZE - FS_SIZE )
165 
166 /*
167  * Descriptor Blocks:
168  * DESCSIZE - Size of one descriptor
169  *
170  */
171 #define DESCSIZE ( 4 * 1024 )
172 
173 #elif defined ( NB_FACTORY_FLASH_4MB_64KB_SECTORS )
174 /*
175  * Part Numbers:
176  * S29GL064N90FFIR20
177  *
178  * Size:
179  * 4 MB
180  *
181  * Sector Size:
182  * Constant
183  * 64 kB
184  *
185  */
186 #define FLASH_SIZE ( 4 * 1024 * 1024 ) // 4 MB
187 #define SECTORSIZE ( 64 * 1024 )
188 /*
189  * File system allocations:
190  * FS_SIZE - File system size in bytes
191  * BLOCKSIZE - File system block
192  * SECTORPERBLOCK - Sectors per block
193  * FS_FLASHBASE - Start of flash
194  * FIRST_ADDR - Start of file system
195  *
196  */
197 #define FS_SIZE ( 512 * 1024 ) // Size of file system, including desc blocks
198 #define BLOCKSIZE ( 256 * 1024 )
199 #define SECTORPERBLOCK ( BLOCKSIZE / SECTORSIZE )
200 #define FS_FLASHBASE ( 0xFF800000 )
201 #define FIRST_ADDR ( FLASH_SIZE - FS_SIZE )
202 
203 /*
204  * Descriptor Blocks:
205  * DESCSIZE - Size of one descriptor
206  *
207  */
208 #define DESCSIZE ( 4 * 1024 )
209 
210 #else
211  #error FLASH chip not supported
212 #endif
213 
214 /*
215  ******************************************************************************
216  *
217  * Flash common file system settings
218  *
219  ******************************************************************************
220  */
221 /*
222  * Specify the total amount of flash memory in the system, and the amount
223  * allocated to be used by the file system (the rest is used by the
224  * application.
225  * BLOCKSTART - First block where file system data starts
226  */
227 #define BLOCKSTART ( 2 )
228 
229 /*
230  * Descriptor Blocks:
231  * These blocks contain critical information about the file system, block allocation,
232  * wear information and file/directory information. At least two descriptor blocks
233  * must be included in the system, which can be erased independently. An optional
234  * descriptor write cache may be configured which improves the performance of the
235  * file system. Please refer to the EFFS-STD implementation guide for additional
236  * information.
237  * DESCBLOCKSTART - Position of first descriptor
238  * DESCBLOCKEND - Position of last descriptor
239  * DESCCACHE - Descriptor cache size
240  */
241 #define DESCBLOCKSTART ( 0 )
242 #define DESCBLOCKEND ( 1 )
243 #define DESCCACHE ( 2048 )
244 
245 /* functions implemented */
246 extern int fs_phy_OnChipFlash( FS_FLASH *flash );
247 
248 #endif
249 
Embedded Flash File System API - STD.