Skip to content

Commit fdf7799

Browse files
committed
Release 6.1.9
1 parent 61f92c0 commit fdf7799

File tree

6 files changed

+90
-70
lines changed

6 files changed

+90
-70
lines changed

common/inc/lx_api.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* APPLICATION INTERFACE DEFINITION RELEASE */
2727
/* */
2828
/* lx_api.h PORTABLE C */
29-
/* 6.1.8 */
29+
/* 6.1.9 */
3030
/* AUTHOR */
3131
/* */
3232
/* William E. Lamie, Microsoft Corporation */
@@ -58,6 +58,10 @@
5858
/* 08-02-2021 William E. Lamie Modified comment(s), and */
5959
/* updated product constants, */
6060
/* resulting in version 6.1.8 */
61+
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
62+
/* updated configuration for */
63+
/* nand flash */
64+
/* resulting in version 6.1.9 */
6165
/* */
6266
/**************************************************************************/
6367

@@ -162,7 +166,7 @@ typedef unsigned long long ULONG64;
162166
#define AZURE_RTOS_LEVELX
163167
#define LEVELX_MAJOR_VERSION 6
164168
#define LEVELX_MINOR_VERSION 1
165-
#define LEVELX_PATCH_VERSION 8
169+
#define LEVELX_PATCH_VERSION 9
166170

167171

168172
/* Define general LevelX Constants. */
@@ -254,6 +258,10 @@ typedef unsigned long long ULONG64;
254258
#define LX_NAND_ERASE_COUNT_WRITE_SIZE (nand_flash -> lx_nand_flash_pages_per_block + 1)
255259
#endif
256260

261+
#ifndef LX_NAND_FLASH_MAPPING_LIST_UPDATE_DISABLE
262+
#define LX_NAND_FLASH_MAPPING_LIST_UPDATE_DISABLE
263+
#endif
264+
257265

258266
/* Define the mask for the hash index into the NAND sector mapping cache table. The sector mapping cache is divided
259267
into 4 entry pieces that are indexed by the formula:

common/src/lx_nand_flash_block_obsoleted_check.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/* FUNCTION RELEASE */
4141
/* */
4242
/* _lx_nand_flash_block_obsoleted_check PORTABLE C */
43-
/* 6.1.7 */
43+
/* 6.1.9 */
4444
/* AUTHOR */
4545
/* */
4646
/* William E. Lamie, Microsoft Corporation */
@@ -86,6 +86,10 @@
8686
/* resulting in version 6.1 */
8787
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
8888
/* resulting in version 6.1.7 */
89+
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
90+
/* removed multiple write */
91+
/* to page 0, */
92+
/* resulting in version 6.1.9 */
8993
/* */
9094
/**************************************************************************/
9195
VOID _lx_nand_flash_block_obsoleted_check(LX_NAND_FLASH *nand_flash, ULONG block)
@@ -316,21 +320,10 @@ UINT status;
316320
}
317321

318322
/* Now store the erase count. */
319-
page_word_ptr[0] = (erase_count | LX_BLOCK_ERASED);
323+
page_word_ptr[0] = (erase_count);
320324

321325
/* Write the erase count for the block. */
322326
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
323-
324-
/* Check to see if the write was successful. */
325-
if (status == LX_SUCCESS)
326-
{
327-
328-
/* Now store the erase count. */
329-
page_word_ptr[0] = erase_count;
330-
331-
/* Write the erase count for the block. */
332-
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
333-
}
334327

335328
/* Check for an error from flash driver. */
336329
if (status)

common/src/lx_nand_flash_block_reclaim.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/* FUNCTION RELEASE */
4141
/* */
4242
/* _lx_nand_flash_block_reclaim PORTABLE C */
43-
/* 6.1.8 */
43+
/* 6.1.9 */
4444
/* AUTHOR */
4545
/* */
4646
/* William E. Lamie, Microsoft Corporation */
@@ -91,6 +91,10 @@
9191
/* 08-02-2021 Bhupendra Naphade Modified comment(s), updated */
9292
/* obselete page count check, */
9393
/* resulting in version 6.1.8 */
94+
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
95+
/* removed multiple write */
96+
/* to page 0, */
97+
/* resulting in version 6.1.9 */
9498
/* */
9599
/**************************************************************************/
96100
UINT _lx_nand_flash_block_reclaim(LX_NAND_FLASH *nand_flash)
@@ -218,22 +222,11 @@ UINT status;
218222
}
219223

220224
/* Now store the erase count. */
221-
page_word_ptr[0] = (erase_count | LX_BLOCK_ERASED);
225+
page_word_ptr[0] = (erase_count);
222226

223227
/* Write the erase count for the block. */
224228
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
225229

226-
/* Check the status. */
227-
if (status == LX_SUCCESS)
228-
{
229-
230-
/* Now store the erase count. */
231-
page_word_ptr[0] = erase_count;
232-
233-
/* Write the erase count for the block. */
234-
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
235-
}
236-
237230
/* Check for an error from flash driver. */
238231
if (status)
239232
{
@@ -578,21 +571,10 @@ UINT status;
578571
}
579572

580573
/* Now store the erase count. */
581-
page_word_ptr[0] = (erase_count | LX_BLOCK_ERASED);
574+
page_word_ptr[0] = (erase_count);
582575

583576
/* Write the erase count for the block. */
584577
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
585-
586-
/* Determine if the write was successful. */
587-
if (status == LX_SUCCESS)
588-
{
589-
590-
/* Now store the erase count. */
591-
page_word_ptr[0] = erase_count;
592-
593-
/* Write the erase count for the block. */
594-
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
595-
}
596578

597579
/* Check for an error from flash driver. */
598580
if (status)

common/src/lx_nand_flash_open.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/* FUNCTION RELEASE */
4141
/* */
4242
/* _lx_nand_flash_open PORTABLE C */
43-
/* 6.1.7 */
43+
/* 6.1.9 */
4444
/* AUTHOR */
4545
/* */
4646
/* William E. Lamie, Microsoft Corporation */
@@ -94,6 +94,10 @@
9494
/* resulting in version 6.1 */
9595
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
9696
/* resulting in version 6.1.7 */
97+
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
98+
/* removed multiple write */
99+
/* to page 0, */
100+
/* resulting in version 6.1.9 */
97101
/* */
98102
/**************************************************************************/
99103
UINT _lx_nand_flash_open(LX_NAND_FLASH *nand_flash, CHAR *name, UINT (*nand_driver_initialize)(LX_NAND_FLASH *))
@@ -282,22 +286,11 @@ LX_INTERRUPT_SAVE_AREA
282286
}
283287

284288
/* Setup the initial erase count to 1. */
285-
page_word_ptr[0] = (((ULONG) 1) | LX_BLOCK_ERASED);
289+
page_word_ptr[0] = (((ULONG) 1));
286290

287291
/* Write the initial erase count for the block. */
288292
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
289293

290-
/* Check for status after the block erase. */
291-
if (status == LX_SUCCESS)
292-
{
293-
294-
/* Setup the initial erase count to 1. */
295-
page_word_ptr[0] = ((ULONG) 1);
296-
297-
/* Write the initial erase count for the block. */
298-
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
299-
}
300-
301294
/* Check for an error from flash driver. */
302295
if (status)
303296
{
@@ -497,20 +490,11 @@ LX_INTERRUPT_SAVE_AREA
497490
/* Continue with next block. */
498491
continue;
499492
}
493+
494+
/* Write the final erase count for the block. */
495+
page_word_ptr[0] = max_erased_count;
496+
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, 1);
500497

501-
/* Write the initial erase count for the block. */
502-
page_word_ptr[0] = (max_erased_count | LX_BLOCK_ERASED);
503-
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
504-
505-
/* Determine if the write was successful. */
506-
if (status == LX_SUCCESS)
507-
{
508-
509-
/* Write the initial erase count for the block. */
510-
page_word_ptr[0] = max_erased_count;
511-
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
512-
}
513-
514498
/* Check for an error from flash driver. */
515499
if (status)
516500
{

common/src/lx_nand_flash_simulator.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#define EXTRA_BYTE_POSITION 2 /* 2 is the extra bytes starting byte postion */
3838
#define ECC_BYTE_POSITION 40 /* 40 is the ECC starting byte position */
3939

40-
4140
/* Definition of the spare area is relative to the block size of the NAND part and perhaps manufactures of the NAND part.
4241
Here are some common definitions:
4342
@@ -169,8 +168,14 @@ UINT _lx_nand_flash_simulator_write(ULONG block, ULONG page, ULONG *source, ULO
169168
{
170169

171170
ULONG *flash_address;
171+
UCHAR *flash_spare_address;
172+
UINT bytes_computed;
173+
UINT ecc_bytes =0;
174+
UCHAR new_ecc_buffer[24];
175+
UCHAR *new_ecc_buffer_ptr = new_ecc_buffer;
176+
UCHAR *ecc_buffer_ptr = new_ecc_buffer_ptr;
177+
ULONG *page_ptr = &(nand_memory_area[block].physical_pages[page].memory[0]);
172178

173-
174179
/* Increment the diag info. */
175180
nand_block_diag[block].page_writes[page]++;
176181
if (nand_block_diag[block].page_writes[page] > nand_block_diag[block].max_page_writes[page])
@@ -192,6 +197,41 @@ ULONG *flash_address;
192197
*flash_address++ = *source++;
193198
}
194199

200+
/* Loop to compute the ECC over the entire NAND flash page. */
201+
bytes_computed = 0;
202+
203+
while (bytes_computed < BYTES_PER_PHYSICAL_PAGE)
204+
{
205+
206+
/* Compute the ECC for this 256 byte piece of the page. */
207+
_lx_nand_flash_256byte_ecc_compute((UCHAR *)page_ptr, (UCHAR *)new_ecc_buffer_ptr);
208+
209+
/* Move to the next 256 byte portion of the page. */
210+
bytes_computed = bytes_computed + 256;
211+
212+
/* Move the page buffer forward. */
213+
page_ptr = page_ptr + 256;
214+
215+
ecc_bytes = ecc_bytes + 3;
216+
217+
/* Move the ECC buffer forward, note there are 3 bytes of ECC per page. */
218+
new_ecc_buffer_ptr = new_ecc_buffer_ptr + 3;
219+
}
220+
221+
/* Setup destination pointer in the spare area. */
222+
flash_spare_address = (UCHAR *) &(nand_memory_area[block].physical_pages[page].spare[ECC_BYTE_POSITION]);
223+
while(ecc_bytes--)
224+
{
225+
226+
/* Can the word be written? We can clear new bits, but just can't unclear
227+
in a NAND device. */
228+
if ((*ecc_buffer_ptr & *flash_spare_address) != *ecc_buffer_ptr)
229+
return(LX_INVALID_WRITE);
230+
231+
/* Set an ecc byte in the spare area. */
232+
*flash_spare_address++ = *ecc_buffer_ptr++;
233+
234+
}
195235
return(LX_SUCCESS);
196236
}
197237

common/src/lx_nor_flash_extended_cache_enable.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/* FUNCTION RELEASE */
4141
/* */
4242
/* _lx_nor_flash_extended_cache_enable PORTABLE C */
43-
/* 6.1.7 */
43+
/* 6.1.9 */
4444
/* AUTHOR */
4545
/* */
4646
/* William E. Lamie, Microsoft Corporation */
@@ -80,6 +80,10 @@
8080
/* 06-02-2021 Bhupendra Naphade Modified comment(s), and */
8181
/* updated product constants */
8282
/* resulting in version 6.1.7 */
83+
/* 10-15-2021 Bhupendra Naphade Modified comment(s), and */
84+
/* added check for out of */
85+
/* bound memory access, */
86+
/* resulting in version 6.1.9 */
8387
/* */
8488
/**************************************************************************/
8589
UINT _lx_nor_flash_extended_cache_enable(LX_NOR_FLASH *nor_flash, VOID *memory, ULONG size)
@@ -135,7 +139,16 @@ ULONG *cache_memory;
135139
}
136140

137141
/* Save the number of cache entries. */
138-
nor_flash -> lx_nor_flash_extended_cache_entries = i;
142+
if(i > LX_NOR_EXTENDED_CACHE_SIZE)
143+
{
144+
145+
nor_flash -> lx_nor_flash_extended_cache_entries = LX_NOR_EXTENDED_CACHE_SIZE;
146+
}
147+
else
148+
{
149+
150+
nor_flash -> lx_nor_flash_extended_cache_entries = i;
151+
}
139152

140153
#ifdef LX_THREAD_SAFE_ENABLE
141154

0 commit comments

Comments
 (0)