10 Commits
Author SHA1 Message Date
Xiuwen Cai e74a289b41 Update release date and version
Update release date and version
2023-12-28 17:43:14 +08:00
Xiuwen Cai 9551a4cda1 Update release date and version. 2023-12-28 09:01:01 +00:00
TiejunZhou 268e4edf97 Merge pull request #25 Add regression test
Add regression test
2023-12-04 13:37:29 +08:00
TiejunZhou fcce06af34 Add scripts 2023-12-01 02:16:43 +00:00
TiejunZhou 521fe0bacb Add GitHub action to run regression test 2023-12-01 01:45:45 +00:00
TiejunZhou 772f99b415 Add test files 2023-11-30 09:26:50 +00:00
Xiuwen Cai df4ecd8404 Update on 30 Nov 2023. Expand to see details.
dd0abfd Fix sequential checking logic
6d0382a Add configuration checks
2023-11-30 05:23:36 +00:00
Xiuwen Cai cef8e4ffeb Update on 23 Oct 2023. Expand to see details.
f203c27 Update headers and readme for 6.3.0 release.
40d3d10 Avoid clearing user extension in flash control block on opening flash
689dcc1 Added obsolete count and mapping bitmap cache for NOR flash. optimized block seraching logic.
b183526 Enable weekly pipeline build to avoid CodeQL expiration
2eec506 Enable codeql in onebranch pipeline
2023-10-23 05:31:43 +00:00
Xiuwen Cai e1a2752d6c Update on 12 May 2023. Expand to see details.
14f4439 Update CFS usage
9b8b2f0 Update CFS usage
0a78a87 Onboard to Central Feed Services
2bd4393 create LevelX cmsis-pack
2023-05-12 07:01:11 +00:00
Tiejun Zhou 39de3e54bd Update hardware license 2023-03-22 10:38:19 +08:00
31 changed files with 6648 additions and 163 deletions
+13
View File
@@ -0,0 +1,13 @@
{
"image": "ghcr.io/tiejunms/azure_rtos_docker",
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
],
"remoteUser": "vscode",
"runArgs": [ "--cap-add=NET_ADMIN"]
}
+25
View File
@@ -0,0 +1,25 @@
# This is a basic workflow that is manually triggered
name: regression_test
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "linux_job"
run_tests:
permissions:
contents: read
issues: read
checks: write
pull-requests: write
pages: write
id-token: write
uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master
+24 -21
View File
@@ -2,7 +2,6 @@ MICROSOFT SOFTWARE LICENSE TERMS
MICROSOFT AZURE RTOS
Shape
These license terms are an agreement between you and Microsoft Corporation (or
one of its affiliates). They apply to the software named above and any Microsoft
@@ -14,10 +13,11 @@ HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.
1. INSTALLATION AND USE RIGHTS.
a) General. You may install and use the software and the included Microsoft
applications solely for internal development, testing and evaluation purposes.
Any distribution or production use requires a separate license as set forth in
Section 2.
a) General. You may (I) install, use and modify the software and (ii) install and use the included Microsoft
Applications (if any), each solely for internal development, testing and evaluation purposes.
Distribution or production use is governed by the license terms set forth in
Section 2. You may also obtain distribution or production use rights through a separate agreement with
Microsoft.
b) Contributions. Microsoft welcomes contributions to this software. In the event
that you make a contribution to this software you will be required to agree to a
@@ -25,7 +25,7 @@ Contributor License Agreement (CLA) declaring that you have the right to, and
actually do, grant Microsoft the rights to use your contribution. For details,
visit https://cla.microsoft.com.
c) Included Microsoft Applications. The software includes other Microsoft
c) Included Microsoft Applications. The software may include other Microsoft
applications which are governed by the licenses embedded in or made available
with those applications.
@@ -57,7 +57,6 @@ i. You may use the software in production (e.g. program the modified or unmodifi
software to devices you own or control) and distribute (i.e. make available to
third parties) the modified or unmodified binary image produced from this code.
ii. You may permit your device distributors or developers to copy and distribute the
binary image as programmed or to be programmed to your devices.
@@ -70,17 +69,12 @@ b) Requirements. For any code you distribute, you must:
i. when distributed in binary form, except as embedded in a device, include with
such distribution the terms of this agreement;
ii. when distributed in source code form to distributors or developers of your
devices, include with such distribution the terms of this agreement; and
iii. indemnify, defend and hold harmless Microsoft from any claims, including
attorneys fees, related to the distribution or use of your devices, except to
the extent that any claim is based solely on the unmodified software.
iii. indemnify, defend and hold harmless Microsoft from any claims, including claims arising from any High Risk Uses, and inclusive of attorneys fees, related to the distribution or use of your devices that include the software, except to the extent that any intellectual property claim is based solely on the unmodified software.
c) Restrictions. You may not:
i. use or modify the software to create a competing real time operating system
i. use or modify the software to create competing real time operating system
software;
ii. remove any copyright notices or licenses contained in the software;
@@ -179,12 +173,13 @@ breach of which would endanger the purpose of this agreement and the compliance
with which a party may constantly trust in (so-called "cardinal obligations").
In other cases of slight negligence, Microsoft will not be liable for slight
negligence.
12. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF
12. DISCLAIMER OF WARRANTY.
a) THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF
USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO
THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED
WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
NON-INFRINGEMENT.
b) HIGH RISK USE DISCLAIMER. WARNING: THE SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE WHERE FAILURE OR FAULT OF ANY KIND OF THE SOFTWARE COULD RESULT IN DEATH OR SERIOUS BODILY INJURY, OR IN PHYSICAL OR ENVIRONMENTAL DAMAGE (“collectively High Risk Use”). Accordingly, You must design and implement your hardware and software such that, in the event of any interruption, defect, error, or other failure of the software, the safety of people, property, and the environment are not reduced below a level that is reasonable, appropriate, and legal, whether in general or for a specific industry. Your High Risk Use of the software is at Your own risk.
13. LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING
DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM
@@ -203,21 +198,29 @@ possibility of the damages. The above limitation or exclusion may not apply to
you because your state, province, or country may not allow the exclusion or
limitation of incidental, consequential, or other damages.
Please note: As this software is distributed in Canada, some of the clauses in
Please note: As this software is distributed in Canada, some of the clauses in
this agreement are provided below in French.
Remarque: Ce logiciel étant distribué au Canada, certaines des clauses dans ce
contrat sont fournies ci-dessous en français.
EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel
EXONÉRATION DE GARANTIE.
a) Le logiciel visé par une licence est offert « tel quel
». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft
naccorde aucune autre garantie expresse. Vous pouvez bénéficier de droits
additionnels en vertu du droit local sur la protection des consommateurs, que ce
contrat ne peut modifier. La ou elles sont permises par le droit locale, les
garanties implicites de qualité marchande, dadéquation à un usage particulier
et dabsence de contrefaçon sont exclues.
b) CLAUSE DEXCLUSION DE RESPONSABILITÉ RELATIVE À LUTILISATION À HAUT RISQUE.
AVERTISSEMENT: LE LOGICIEL NEST PAS CONÇU OU DESTINÉ À ÊTRE UTILISÉ LORSQUUNE
DÉFAILLANCE OU UN DÉFAUT DE QUELQUE NATURE QUE CE SOIT POURRAIT ENTRAÎNER LA
MORT OU DES BLESSURES CORPORELLES GRAVES, OU DES DOMMAGES PHYSIQUES OU
ENVIRONNEMENTAUX (« Utilisation à haut risque »). Par conséquent, vous devez concevoir et mettre en
œuvre votre équipement et votre logiciel de manière à ce que, en cas dinterruption, de défaut, derreur
ou de toute autre défaillance du logiciel, la sécurité des personnes, des biens et de lenvironnement ne
soit pas réduite en dessous dun niveau raisonnable, approprié et légal, que ce soit en général ou pour
un secteur spécifique. Votre utilisation à haut risque du logiciel est à vos propres risques.
LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES
DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une
@@ -243,4 +246,4 @@ ci-dessus ne sappliquera pas à votre égard.
EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous
pourriez avoir dautres droits prévus par les lois de votre pays. Le présent
contrat ne modifie pas les droits que vous confèrent les lois de votre pays si
celles-ci ne le permettent pas.
celles-ci ne le permettent pas.
+1 -1
View File
@@ -38,7 +38,7 @@ Renesas:
Synergy Platform
RX Family of MCUs
RA Family of MCUs
RZ/A, RZ/N and RZ/T Family of MPUs
RZ Family of MPUs
--------------------------------------------------------------------------------
+43 -4
View File
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* lx_api.h PORTABLE C */
/* 6.2.1 */
/* 6.4.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -79,7 +79,16 @@
/* modified NAND logic, */
/* added new driver interface */
/* and user extension, */
/* resulting in version 6.2.1 */
/* resulting in version 6.2.1 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* made LX_NOR_SECTOR_SIZE */
/* configurable, added mapping */
/* bitmap and obsolete count */
/* cache for NOR flash, */
/* resulting in version 6.3.0 */
/* 12-31-2023 Xiuwen Cai Modified comment(s), */
/* added configuration checks, */
/* resulting in version 6.4.0 */
/* */
/**************************************************************************/
@@ -191,8 +200,8 @@ typedef unsigned long long ULONG64;
/* Define basic constants for the LevelX Stack. */
#define AZURE_RTOS_LEVELX
#define LEVELX_MAJOR_VERSION 6
#define LEVELX_MINOR_VERSION 2
#define LEVELX_PATCH_VERSION 1
#define LEVELX_MINOR_VERSION 4
#define LEVELX_PATCH_VERSION 0
/* Define general LevelX Constants. */
@@ -233,7 +242,9 @@ typedef unsigned long long ULONG64;
#define LX_NOR_FLASH_OPENED ((ULONG) 0x4E4F524F)
#define LX_NOR_FLASH_CLOSED ((ULONG) 0x4E4F5244)
#ifndef LX_NOR_SECTOR_SIZE
#define LX_NOR_SECTOR_SIZE (512/sizeof(ULONG))
#endif
#define LX_NOR_FLASH_MIN_LOGICAL_SECTOR_OFFSET 1
#define LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET 2
#ifndef LX_NOR_FLASH_MAX_ERASE_COUNT_DELTA
@@ -246,6 +257,11 @@ typedef unsigned long long ULONG64;
#ifndef LX_NOR_EXTENDED_CACHE_SIZE
#define LX_NOR_EXTENDED_CACHE_SIZE 8 /* Maximum number of extended cache sectors. */
#endif
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
#ifndef LX_NOR_OBSOLETE_COUNT_CACHE_TYPE
#define LX_NOR_OBSOLETE_COUNT_CACHE_TYPE UCHAR
#endif
#endif
/* Define the mask for the hash index into the sector mapping cache table. The sector mapping cache is divided
@@ -266,6 +282,19 @@ typedef unsigned long long ULONG64;
#define LX_NOR_PHYSICAL_SECTOR_FREE 0xFFFFFFFF
/* Check extended cache configurations. */
#ifdef LX_NOR_DISABLE_EXTENDED_CACHE
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
#error "To enable mapping bitmap, you need to undefine LX_NOR_DISABLE_EXTENDED_CACHE."
#endif
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
#error "To enable obsolete count cache, you need to undefine LX_NOR_DISABLE_EXTENDED_CACHE."
#endif
#endif
/* Define NAND flash constants. */
#define LX_NAND_GOOD_BLOCK 0xFF
@@ -566,6 +595,7 @@ typedef struct LX_NOR_FLASH_STRUCT
ULONG lx_nor_flash_mapped_physical_sectors;
ULONG lx_nor_flash_obsolete_physical_sectors;
ULONG lx_nor_flash_minimum_erase_count;
ULONG lx_nor_flash_minimum_erased_blocks;
ULONG lx_nor_flash_maximum_erase_count;
ULONG lx_nor_flash_free_block_search;
@@ -616,6 +646,15 @@ typedef struct LX_NOR_FLASH_STRUCT
lx_nor_flash_extended_cache[LX_NOR_EXTENDED_CACHE_SIZE];
ULONG lx_nor_flash_extended_cache_hits;
ULONG lx_nor_flash_extended_cache_misses;
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
ULONG *lx_nor_flash_extended_cache_mapping_bitmap;
ULONG lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector;
#endif
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
LX_NOR_OBSOLETE_COUNT_CACHE_TYPE
*lx_nor_flash_extended_cache_obsolete_count;
ULONG lx_nor_flash_extended_cache_obsolete_count_max_block;
#endif
#endif
#ifdef LX_THREAD_SAFE_ENABLE
+33 -4
View File
@@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* lx_user.h PORTABLE C */
/* 6.2.1 */
/* 6.3.0 */
/* */
/* AUTHOR */
/* */
@@ -50,7 +50,12 @@
/* resulting in version 6.1.7 */
/* 03-08-2023 Xiuwen Cai Modified comment(s), and */
/* added new NAND options, */
/* resulting in version 6.2.1 */
/* resulting in version 6.2.1 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added options for mapping , */
/* bitmap cache and obsolete */
/* count cache, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
@@ -113,15 +118,39 @@
/* #define LX_STANDALONE_ENABLE */
/* Define user extension for NOR flash control block. */
/* Define user extension for NOR flash control block. User extension is placed at the end of flash control block and it is not cleared on opening flash. */
/*
#define LX_NOR_FLASH_USER_EXTENSION ????
*/
/* Define user extension for NAND flash control block. */
/* Define user extension for NAND flash control block. User extension is placed at the end of flash control block and it is not cleared on opening flash. */
/*
#define LX_NAND_FLASH_USER_EXTENSION ????
*/
/* Determine if logical sector mapping bitmap should be enabled in extended cache.
Cache memory will be allocated to sector mapping bitmap first. One bit can be allocated for each physical sector. */
/*
#define LX_NOR_ENABLE_MAPPING_BITMAP
*/
/* Determine if obsolete count cache should be enabled in extended cache.
Cache memory will be allocated to obsolete count cache after the mapping bitmap if enabled,
and the rest of the cache memory is allocated to sector cache. */
/*
#define LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
*/
/* Defines obsolete count cache element size. If number of sectors per block is greater than 256, use USHORT instead of UCHAR. */
/*
#define LX_NOR_OBSOLETE_COUNT_CACHE_TYPE UCHAR
*/
/* Define the logical sector size for NOR flash. The sector size is in units of 32-bit words.
This sector size should match the sector size used in file system. */
/*
#define LX_NOR_SECTOR_SIZE (512/sizeof(ULONG))
*/
#endif
+24 -15
View File
@@ -36,19 +36,19 @@ LX_NOR_FLASH nor_flash;
the fx_media_open call.
fx_media_format(&ram_disk,
_fx_nor_sim_driver, // Driver entry
FX_NULL, // Unused
media_memory, // Media buffer pointer
sizeof(media_memory), // Media buffer size
"MY_NOR_DISK", // Volume Name
1, // Number of FATs
32, // Directory Entries
0, // Hidden sectors
120, // Total sectors
512, // Sector size
1, // Sectors per cluster
1, // Heads
1); // Sectors per track
_fx_nor_sim_driver, // Driver entry
FX_NULL, // Unused
media_memory, // Media buffer pointer
sizeof(media_memory), // Media buffer size
"MY_NOR_DISK", // Volume Name
1, // Number of FATs
32, // Directory Entries
0, // Hidden sectors
120, // Total sectors
LX_NOR_SECTOR_SIZE * sizeof(ULONG), // Sector size
1, // Sectors per cluster
1, // Heads
1); // Sectors per track
*/
@@ -231,7 +231,7 @@ UINT status;
/* Move to the next entries. */
logical_sector++;
destination_buffer = destination_buffer + 512;
destination_buffer = destination_buffer + media_ptr -> fx_media_bytes_per_sector;
}
/* Successful driver request. */
@@ -265,7 +265,7 @@ UINT status;
/* Move to the next entries. */
logical_sector++;
source_buffer = source_buffer + 512;
source_buffer = source_buffer + media_ptr -> fx_media_bytes_per_sector;
}
/* Successful driver request. */
@@ -428,6 +428,15 @@ UINT status;
case FX_DRIVER_BOOT_WRITE:
{
/* Make sure the media bytes per sector equals to the LevelX logical sector size. */
if (media_ptr -> fx_media_bytes_per_sector != (LX_NOR_SECTOR_SIZE) * sizeof(ULONG))
{
/* Sector size mismatch, return error. */
media_ptr -> fx_media_driver_status = FX_IO_ERROR;
break;
}
/* Write the boot record and return to the caller. */
/* Setup the source buffer. */
+7 -3
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nand_flash_data_page_copy PORTABLE C */
/* 6.2.1 */
/* 6.4.0 */
/* AUTHOR */
/* */
/* Xiuwen Cai, Microsoft Corporation */
@@ -78,7 +78,11 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
/* 12-31-2023 Xiuwen Cai Modified comment(s), */
/* fixed sequential checking */
/* logic, */
/* resulting in version 6.4.0 */
/* */
/**************************************************************************/
UINT _lx_nand_flash_data_page_copy(LX_NAND_FLASH* nand_flash, ULONG logical_sector, ULONG source_block, USHORT src_block_status,
@@ -168,7 +172,7 @@ ULONG number_of_pages;
}
/* Check if the pages in destination block is still sequential. */
if ((destination_page) != (logical_sector + i % nand_flash -> lx_nand_flash_pages_per_block))
if (destination_page != ((logical_sector + i) % nand_flash -> lx_nand_flash_pages_per_block))
{
/* Mark the block status as non sequential. */
dest_block_status |= LX_NAND_BLOCK_STATUS_NON_SEQUENTIAL;
+9 -4
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nand_flash_format PORTABLE C */
/* 6.2.1 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Xiuwen Cai, Microsoft Corporation */
@@ -87,7 +87,12 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* avoided clearing user */
/* extension in flash control */
/* block, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nand_flash_format(LX_NAND_FLASH* nand_flash, CHAR* name,
@@ -102,8 +107,8 @@ UCHAR *page_buffer_ptr;
LX_PARAMETER_NOT_USED(name);
/* Clear the NAND flash control block. */
LX_MEMSET(nand_flash, 0, sizeof(LX_NAND_FLASH));
/* Clear the NAND flash control block. User extension is not cleared. */
LX_MEMSET(nand_flash, 0, (ULONG)((UCHAR*)&(nand_flash -> lx_nand_flash_open_previous) - (UCHAR*)nand_flash) + sizeof(nand_flash -> lx_nand_flash_open_previous));
/* Call the flash driver's initialization function. */
(nand_driver_initialize)(nand_flash);
+10 -5
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nand_flash_open PORTABLE C */
/* 6.2.1 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Xiuwen Cai, Microsoft Corporation */
@@ -85,7 +85,12 @@
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* avoided clearing user */
/* extension in flash control */
/* block, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nand_flash_open(LX_NAND_FLASH *nand_flash, CHAR *name, UINT (*nand_driver_initialize)(LX_NAND_FLASH *),
@@ -107,9 +112,9 @@ LX_INTERRUPT_SAVE_AREA
LX_PARAMETER_NOT_USED(name);
/* Clear the NAND flash control block. */
LX_MEMSET(nand_flash, 0, sizeof(LX_NAND_FLASH));
/* Clear the NAND flash control block. User extension is not cleared. */
LX_MEMSET(nand_flash, 0, (ULONG)((UCHAR*)&(nand_flash -> lx_nand_flash_open_previous) - (UCHAR*)nand_flash) + sizeof(nand_flash -> lx_nand_flash_open_previous));
/* Call the flash driver's initialization function. */
(nand_driver_initialize)(nand_flash);
+43 -2
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_block_reclaim PORTABLE C */
/* 6.1.7 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -83,6 +83,11 @@
/* resulting in version 6.1 */
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
/* resulting in version 6.1.7 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added count for minimum */
/* erased blocks, added */
/* obsolete count cache, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_block_reclaim(LX_NOR_FLASH *nor_flash)
@@ -156,7 +161,15 @@ UINT status;
/* Return the error. */
return(status);
}
/* Determine if the erase count is at the minimum. */
if (erase_count == nor_flash -> lx_nor_flash_minimum_erase_count)
{
/* Yes, decrement the minimum erased block count. */
nor_flash -> lx_nor_flash_minimum_erased_blocks--;
}
/* Increment the erase count. */
erase_count++;
@@ -225,6 +238,16 @@ UINT status;
/* Update parameters of this flash. */
nor_flash -> lx_nor_flash_free_physical_sectors = nor_flash -> lx_nor_flash_free_physical_sectors + obsolete_sectors;
nor_flash -> lx_nor_flash_obsolete_physical_sectors = nor_flash -> lx_nor_flash_obsolete_physical_sectors - obsolete_sectors;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Check if the block is cached by obsolete count cache. */
if (erase_block < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Yes, clear the obsolete count for this block. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count[erase_block] = 0;
}
#endif
}
else
{
@@ -489,6 +512,14 @@ UINT status;
return(status);
}
/* Determine if the erase count is at the minimum. */
if (erase_count == nor_flash -> lx_nor_flash_minimum_erase_count)
{
/* Yes, decrement the minimum erased block count. */
nor_flash -> lx_nor_flash_minimum_erased_blocks--;
}
/* Increment the erase count. */
erase_count++;
@@ -557,6 +588,16 @@ UINT status;
/* Update parameters of this flash. */
nor_flash -> lx_nor_flash_free_physical_sectors = nor_flash -> lx_nor_flash_free_physical_sectors + obsolete_sectors;
nor_flash -> lx_nor_flash_obsolete_physical_sectors = nor_flash -> lx_nor_flash_obsolete_physical_sectors - obsolete_sectors;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Check if the block is cached by obsolete count cache. */
if (erase_block < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Yes, clear the obsolete count for this block. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count[erase_block] = 0;
}
#endif
}
}
+172 -1
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_extended_cache_enable PORTABLE C */
/* 6.1.9 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -84,6 +84,10 @@
/* added check for out of */
/* bound memory access, */
/* resulting in version 6.1.9 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added mapping bitmap cache, */
/* added obsolete count cache, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_extended_cache_enable(LX_NOR_FLASH *nor_flash, VOID *memory, ULONG size)
@@ -93,6 +97,22 @@ UINT _lx_nor_flash_extended_cache_enable(LX_NOR_FLASH *nor_flash, VOID *memory,
UINT i;
ULONG cache_size;
ULONG *cache_memory;
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
ULONG mapping_bitmap_words;
ULONG mapping_bitmap_word;
ULONG logical_sector;
ULONG *mapping_bitmap_ptr;
#endif
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
ULONG obsolete_count_words;
ULONG obsolete_sectors;
#endif
#if defined(LX_NOR_ENABLE_MAPPING_BITMAP) || defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
ULONG *block_word_ptr;
UINT j;
UINT status;
ULONG block_word;
#endif
/* Determine if memory was specified but with an invalid size (less than one NOR sector). */
@@ -118,6 +138,157 @@ ULONG *cache_memory;
/* Setup cache memory pointer. */
cache_memory = (ULONG *) memory;
#if defined(LX_NOR_ENABLE_MAPPING_BITMAP) || defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
/* Check if the NOR flash is opened. */
if (nor_flash -> lx_nor_flash_state == LX_NOR_FLASH_OPENED)
{
#if defined(LX_NOR_ENABLE_MAPPING_BITMAP)
/* Get the mapping bitmap cache size. */
mapping_bitmap_words = (nor_flash -> lx_nor_flash_total_physical_sectors + 31) / 32;
/* Check if the mapping bitmap cache fits in the suppiled cache memory. */
if (cache_size < mapping_bitmap_words)
{
/* Update the cache size. */
mapping_bitmap_words = cache_size;
}
/* Setup the mapping bitmap cache. */
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap = cache_memory;
/* Setup the mapping bitmap cache size. */
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector = mapping_bitmap_words * 32;
/* Clear the mapping bitmap cache. */
for (i = 0; i < mapping_bitmap_words; i++)
{
cache_memory[i] = 0;
}
/* Update the cache memory pointer. */
mapping_bitmap_ptr = cache_memory;
/* Update the cache size. */
cache_size = cache_size - mapping_bitmap_words;
/* Update the cache memory pointer. */
cache_memory = cache_memory + mapping_bitmap_words;
#endif
#if defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
/* Get the obsolete count cache size. */
obsolete_count_words = nor_flash -> lx_nor_flash_total_blocks * sizeof(LX_NOR_OBSOLETE_COUNT_CACHE_TYPE) / 4;
/* Check if the obsolete count cache fits in the suppiled cache memory. */
if (cache_size < obsolete_count_words)
{
/* Update the cache size. */
obsolete_count_words = cache_size;
}
/* Setup the obsolete count cache. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count = (LX_NOR_OBSOLETE_COUNT_CACHE_TYPE*)cache_memory;
/* Setup the obsolete count cache size. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block = obsolete_count_words * 4 / sizeof(LX_NOR_OBSOLETE_COUNT_CACHE_TYPE);
/* Update the cache size. */
cache_size = cache_size - obsolete_count_words;
/* Update the cache memory pointer. */
cache_memory = cache_memory + obsolete_count_words;
#endif
/* Loop through the blocks. */
for (i = 0; i < nor_flash -> lx_nor_flash_total_blocks; i++)
{
/* Setup the block word pointer to the first word of the block. */
block_word_ptr = (nor_flash -> lx_nor_flash_base_address + (i * nor_flash -> lx_nor_flash_words_per_block));
#if defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
/* Initialize the obsolete count cache. */
obsolete_sectors = 0;
#endif
/* Now walk the list of logical-physical sector mapping. */
for (j = 0; j < nor_flash ->lx_nor_flash_physical_sectors_per_block; j++)
{
/* Read this word of the sector mapping list. */
#ifdef LX_DIRECT_READ
/* Read the word directly. */
block_word = *(block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset + j);
#else
status = _lx_nor_flash_driver_read(nor_flash, (block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset + j), &block_word, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Return an error. */
return(LX_ERROR);
}
#endif
/* Determine if the entry hasn't been used. */
if (block_word == LX_NOR_PHYSICAL_SECTOR_FREE)
{
break;
}
/* Is this entry valid? */
if ((block_word & (LX_NOR_PHYSICAL_SECTOR_VALID | LX_NOR_PHYSICAL_SECTOR_MAPPING_NOT_VALID)) == LX_NOR_PHYSICAL_SECTOR_VALID)
{
#if defined(LX_NOR_ENABLE_MAPPING_BITMAP)
/* Yes, get the logical sector. */
logical_sector = block_word & LX_NOR_LOGICAL_SECTOR_MASK;
/* Get the mapping bitmap word. */
mapping_bitmap_word = logical_sector >> 5;
/* Check if the mapping bitmap word is within the cache. */
if (mapping_bitmap_word < mapping_bitmap_words)
{
/* Set the bit in the mapping bitmap. */
mapping_bitmap_ptr[mapping_bitmap_word] |= (ULONG)(1 << (logical_sector & 31));
}
#endif
}
else
{
#if defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
/* Increment the obsolete sector count. */
obsolete_sectors++;
#endif
}
}
#if defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
/* Check if the block is cached by obsolete count cache. */
if (i < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Yes, cache the obsolete sector count. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count[i] = (LX_NOR_OBSOLETE_COUNT_CACHE_TYPE)obsolete_sectors;
}
#endif
}
}
#endif
/* Loop through the memory supplied and assign to cache entries. */
i = 0;
while (cache_size >= LX_NOR_SECTOR_SIZE)
+137 -35
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_logical_sector_find PORTABLE C */
/* 6.1.7 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -70,6 +70,7 @@
/* CALLS */
/* */
/* _lx_nor_flash_driver_read Driver flash sector read */
/* _lx_nor_flash_driver_write Driver flash sector write */
/* _lx_nor_flash_system_error Internal system error handler */
/* */
/* CALLED BY */
@@ -85,6 +86,12 @@
/* resulting in version 6.1 */
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
/* resulting in version 6.1.7 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added mapping bitmap cache, */
/* added obsolete count cache, */
/* optimized full obsoleted */
/* block searching logic, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_logical_sector_find(LX_NOR_FLASH *nor_flash, ULONG logical_sector, ULONG superceded_check, ULONG **physical_sector_map_entry, ULONG **physical_sector_address)
@@ -102,7 +109,10 @@ ULONG i, j;
ULONG search_start;
LX_NOR_SECTOR_MAPPING_CACHE_ENTRY *sector_mapping_cache_entry_ptr = LX_NULL;
LX_NOR_SECTOR_MAPPING_CACHE_ENTRY temp_sector_mapping_cache_entry;
#ifndef LX_DIRECT_READ
#ifndef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
ULONG valid_sector_found;
#endif
#if !defined(LX_DIRECT_READ) || !defined(LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
UINT status;
#endif
@@ -118,6 +128,24 @@ UINT status;
/* No mapped sector so nothing can be found!. */
return(LX_SECTOR_NOT_FOUND);
}
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
/* Determine if the logical sector is in the range of mapping bitmap cache. */
if (logical_sector < nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector)
{
/* Determine if the logical sector is mapped. */
if ((nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap[logical_sector >> 5] & (ULONG)(1 << (logical_sector & 31))) == 0)
{
/* Not mapped, return not found. */
return(LX_SECTOR_NOT_FOUND);
}
}
#endif
#endif
/* Determine if the sector mapping cache is enabled. */
if (nor_flash -> lx_nor_flash_sector_mapping_cache_enabled)
@@ -223,6 +251,36 @@ UINT status;
/* Loop through the blocks to attempt to find the mapped logical sector. */
while (total_blocks--)
{
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Determine if the obsolete sector count is available in the cache. */
if (i < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Check if the block contains obsolete sectors only. */
if ((ULONG)nor_flash -> lx_nor_flash_extended_cache_obsolete_count[i] == nor_flash -> lx_nor_flash_physical_sectors_per_block)
{
/* Move to the next block. */
i++;
/* Determine if we have wrapped. */
if (i >= nor_flash -> lx_nor_flash_total_blocks)
{
/* Yes, we have wrapped, set to block 0. */
i = 0;
}
/* Start at the first sector in the next block. */
j = 0;
/* No point in looking further into this block, just continue the loop. */
continue;
}
}
#endif
/* Setup the block word pointer to the first word of the search block. */
block_word_ptr = (nor_flash -> lx_nor_flash_base_address + (i * nor_flash -> lx_nor_flash_words_per_block));
@@ -249,52 +307,68 @@ UINT status;
return(status);
}
#endif
/* Is the value valid? */
if (min_logical_sector != LX_ALL_ONES)
{
#ifdef LX_DIRECT_READ
/* Read the word directly. */
max_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET);
/* Read the word directly. */
max_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET);
#else
status = _lx_nor_flash_driver_read(nor_flash, block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET, &max_logical_sector, 1);
status = _lx_nor_flash_driver_read(nor_flash, block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET, &max_logical_sector, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Return the error. */
return(status);
}
/* Return the error. */
return(status);
}
#endif
/* Are the values valid? */
if ((min_logical_sector != LX_ALL_ONES) && (max_logical_sector != LX_ALL_ONES))
{
/* Now let's check to see if the search sector is within this range. */
if ((logical_sector < min_logical_sector) || (logical_sector > max_logical_sector))
/* Is the value valid? */
if (max_logical_sector != LX_ALL_ONES)
{
/* Move to the next block. */
i++;
/* Determine if we have wrapped. */
if (i >= nor_flash -> lx_nor_flash_total_blocks)
/* Now let's check to see if the search sector is within this range. */
if ((logical_sector < min_logical_sector) || (logical_sector > max_logical_sector))
{
/* Yes, we have wrapped, set to block 0. */
i = 0;
}
/* Start at the first sector in the next block. */
j = 0;
/* No point in looking further into this block, just continue the loop. */
continue;
/* Move to the next block. */
i++;
/* Determine if we have wrapped. */
if (i >= nor_flash -> lx_nor_flash_total_blocks)
{
/* Yes, we have wrapped, set to block 0. */
i = 0;
}
/* Start at the first sector in the next block. */
j = 0;
/* No point in looking further into this block, just continue the loop. */
continue;
}
}
}
else
{
/* Set the max logical sector to all ones. */
max_logical_sector = LX_ALL_ONES;
}
#ifndef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Clear the valid sector found flag. */
valid_sector_found = LX_FALSE;
#endif
/* Setup the total number of sectors. */
total_sectors = nor_flash -> lx_nor_flash_physical_sectors_per_block;
@@ -440,6 +514,11 @@ UINT status;
return(LX_SUCCESS);
}
}
#ifndef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Set the valid sector found flag. */
valid_sector_found = LX_TRUE;
#endif
}
/* Move to the next list entry. */
@@ -453,6 +532,29 @@ UINT status;
j = 0;
}
}
#ifndef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Check if the block contains no valid sectors. */
if ((valid_sector_found == LX_FALSE) && (max_logical_sector != LX_ALL_ONES))
{
/* Clear max logical sector to indicate sectors are all obsoleted. */
max_logical_sector = 0;
/* Write the max logical sector to the block header. */
status = _lx_nor_flash_driver_write(nor_flash, block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET, &max_logical_sector, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Return the error. */
return(status);
}
}
#endif
/* Determine if there are any more mapped sectors. */
if (mapped_sectors == 0)
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_next_block_to_erase_find PORTABLE C */
/* 6.1.7 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -81,6 +81,12 @@
/* resulting in version 6.1 */
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
/* resulting in version 6.1.7 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added mapping bitmap cache, */
/* added obsolete count cache, */
/* optimized full obsoleted */
/* block searching logic, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_next_block_to_erase_find(LX_NOR_FLASH *nor_flash, ULONG *return_erase_block, ULONG *return_erase_count, ULONG *return_mapped_sectors, ULONG *return_obsolete_sectors)
@@ -97,16 +103,23 @@ ULONG min_block_erase = 0;
ULONG min_block_erase_count;
ULONG min_block_obsolete_count = 0;
ULONG min_block_mapped_count = 0;
ULONG min_block_mapped_count_available = LX_FALSE;
ULONG max_obsolete_sectors;
ULONG max_obsolete_block = 0;
ULONG max_obsolete_erase_count = 0;
ULONG max_obsolete_mapped_count = 0;
ULONG max_obsolete_mapped_count_available = LX_FALSE;
ULONG min_system_block_erase_count;
ULONG system_min_erased_blocks;
ULONG max_system_block_erase_count;
ULONG erase_count_threshold;
ULONG min_logical_sector;
ULONG max_logical_sector;
#ifndef LX_DIRECT_READ
UINT status;
#endif
UINT obsolete_sectors_available;
UINT mapped_sectors_available;
/* Setup the block word pointer to the first word of the search block. */
@@ -117,6 +130,7 @@ UINT status;
/* Initialize the system minimum and maximum erase counts. */
min_system_block_erase_count = LX_ALL_ONES;
system_min_erased_blocks = 0;
max_system_block_erase_count = 0;
/* Initialize the maximum obsolete sector count. */
@@ -161,34 +175,71 @@ UINT status;
#endif
/* Update the system minimum and maximum erase counts. */
if (erase_count == min_system_block_erase_count)
{
system_min_erased_blocks ++;
}
if (erase_count < min_system_block_erase_count)
{
min_system_block_erase_count = erase_count;
system_min_erased_blocks = 1;
}
if (erase_count > max_system_block_erase_count)
max_system_block_erase_count = erase_count;
/* Compute the number of obsolete and mapped sectors for this block. */
obsolete_sectors = 0;
mapped_sectors = 0;
/* Initialize the obsolete and mapped sector count available flags. */
obsolete_sectors_available = LX_FALSE;
mapped_sectors_available = LX_FALSE;
/* Setup a pointer to the mapped list. */
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Loop through the mapped list for this block. */
for (j = 0; j < nor_flash -> lx_nor_flash_physical_sectors_per_block; j++)
/* Determine if the obsolete sector count is available in the cache. */
if (i < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Yes, the obsolete sector count is available. */
obsolete_sectors_available = LX_TRUE;
/* Pickup the obsolete sector count from the cache. */
obsolete_sectors = (ULONG)nor_flash -> lx_nor_flash_extended_cache_obsolete_count[i];
}
else
{
#endif
/* Read the minimum and maximum logical sector values in this block. */
#ifdef LX_DIRECT_READ
/* Read the word directly. */
min_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MIN_LOGICAL_SECTOR_OFFSET);
#else
status = _lx_nor_flash_driver_read(nor_flash, block_word_ptr + LX_NOR_FLASH_MIN_LOGICAL_SECTOR_OFFSET, &min_logical_sector, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Read the current mapping entry. */
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Return the error. */
return(status);
}
#endif
/* Determine if the minimum logical sector is valid. */
if (min_logical_sector != LX_ALL_ONES)
{
#ifdef LX_DIRECT_READ
/* Read the word directly. */
list_word = *(list_word_ptr);
max_logical_sector = *(block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET);
#else
status = _lx_nor_flash_driver_read(nor_flash, list_word_ptr, &list_word, 1);
status = _lx_nor_flash_driver_read(nor_flash, block_word_ptr + LX_NOR_FLASH_MAX_LOGICAL_SECTOR_OFFSET, &max_logical_sector, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
@@ -196,33 +247,104 @@ UINT status;
return(status);
}
#endif
/* Determine if the entry hasn't been used. */
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
{
/* Since allocations are done sequentially in the block, we know nothing
else exists after this point. */
break;
}
/* Is this entry obsolete? */
if ((list_word & LX_NOR_PHYSICAL_SECTOR_VALID) == 0)
{
/* Increment the number of obsolete sectors. */
obsolete_sectors++;
}
else
{
/* Increment the number of mapped sectors. */
mapped_sectors++;
}
/* Move the list pointer ahead. */
list_word_ptr++;
/* Are the values valid? */
/* Now let's check to see if all the sector are obsoleted. */
if ((max_logical_sector != LX_ALL_ONES) && (max_logical_sector < min_logical_sector))
{
obsolete_sectors_available = LX_TRUE;
obsolete_sectors = nor_flash -> lx_nor_flash_physical_sectors_per_block;
}
}
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
}
#endif
/* Determine if the mapped sector count is available. */
if (obsolete_sectors_available == LX_FALSE)
{
/* Compute the number of obsolete and mapped sectors for this block. */
/* Initialize the obsolete and mapped sector counts. */
obsolete_sectors = 0;
mapped_sectors = 0;
/* Set the mapped sector count and obsolete sector count available flags. */
mapped_sectors_available = LX_TRUE;
obsolete_sectors_available = LX_TRUE;
/* Setup a pointer to the mapped list. */
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset;
/* Loop through the mapped list for this block. */
for (j = 0; j < nor_flash -> lx_nor_flash_physical_sectors_per_block; j++)
{
/* Read the current mapping entry. */
#ifdef LX_DIRECT_READ
/* Read the word directly. */
list_word = *(list_word_ptr);
#else
status = _lx_nor_flash_driver_read(nor_flash, list_word_ptr, &list_word, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Return the error. */
return(status);
}
#endif
/* Determine if the entry hasn't been used. */
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
{
/* Since allocations are done sequentially in the block, we know nothing
else exists after this point. */
break;
}
/* Is this entry obsolete? */
if ((list_word & LX_NOR_PHYSICAL_SECTOR_VALID) == 0)
{
/* Increment the number of obsolete sectors. */
obsolete_sectors++;
}
else
{
/* Increment the number of mapped sectors. */
mapped_sectors++;
}
/* Move the list pointer ahead. */
list_word_ptr++;
}
}
/* Determine if this block contains full obsoleted sectors and the erase count is minimum. */
if ((obsolete_sectors == nor_flash -> lx_nor_flash_physical_sectors_per_block) &&
(erase_count == nor_flash -> lx_nor_flash_minimum_erase_count) &&
(nor_flash -> lx_nor_flash_minimum_erased_blocks > 0))
{
/* Yes, we have a full obsoleted block with minimum erase count. */
*return_erase_block = i;
*return_erase_count = erase_count;
*return_obsolete_sectors = obsolete_sectors;
*return_mapped_sectors = mapped_sectors;
break;
}
/* Determine if we have a block with a new maximum number of obsolete sectors. */
if ((obsolete_sectors > max_obsolete_sectors) && (erase_count <= erase_count_threshold))
@@ -233,6 +355,8 @@ UINT status;
max_obsolete_block = i;
max_obsolete_erase_count = erase_count;
max_obsolete_mapped_count = mapped_sectors;
max_obsolete_mapped_count_available = mapped_sectors_available;
}
else if ((max_obsolete_sectors) && (obsolete_sectors == max_obsolete_sectors) && (erase_count <= erase_count_threshold))
{
@@ -247,6 +371,7 @@ UINT status;
max_obsolete_block = i;
max_obsolete_erase_count = erase_count;
max_obsolete_mapped_count = mapped_sectors;
max_obsolete_mapped_count_available = mapped_sectors_available;
}
}
@@ -259,36 +384,105 @@ UINT status;
min_block_erase = i;
min_block_obsolete_count = obsolete_sectors;
min_block_mapped_count = mapped_sectors;
min_block_mapped_count_available = mapped_sectors_available;
}
/* Move to the next block. */
block_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_words_per_block;
}
/* Determine if we can erase the block with the most obsolete sectors. */
if (max_obsolete_sectors)
/* Determine if we found a block with full obsoleted sector and the erase count is minimum. */
if (i == nor_flash -> lx_nor_flash_total_blocks)
{
/* Erase the block with the most obsolete sectors. */
*return_erase_block = max_obsolete_block;
*return_erase_count = max_obsolete_erase_count;
*return_obsolete_sectors = max_obsolete_sectors;
*return_mapped_sectors = max_obsolete_mapped_count;
}
else
{
/* Otherwise, choose the block with the smallest erase count. */
*return_erase_block = min_block_erase;
*return_erase_count = min_block_erase_count;
*return_obsolete_sectors = min_block_obsolete_count;
*return_mapped_sectors = min_block_mapped_count;
/* Determine if we can erase the block with the most obsolete sectors. */
if (max_obsolete_sectors)
{
/* Erase the block with the most obsolete sectors. */
*return_erase_block = max_obsolete_block;
*return_erase_count = max_obsolete_erase_count;
*return_obsolete_sectors = max_obsolete_sectors;
*return_mapped_sectors = max_obsolete_mapped_count;
mapped_sectors_available = max_obsolete_mapped_count_available;
}
else
{
/* Otherwise, choose the block with the smallest erase count. */
*return_erase_block = min_block_erase;
*return_erase_count = min_block_erase_count;
*return_obsolete_sectors = min_block_obsolete_count;
*return_mapped_sectors = min_block_mapped_count;
mapped_sectors_available = min_block_mapped_count_available;
}
/* Update the overall minimum and maximum erase count. */
nor_flash -> lx_nor_flash_minimum_erase_count = min_system_block_erase_count;
nor_flash -> lx_nor_flash_minimum_erased_blocks = system_min_erased_blocks;
nor_flash -> lx_nor_flash_maximum_erase_count = max_system_block_erase_count;
}
/* Update the overall minimum and maximum erase count. */
nor_flash -> lx_nor_flash_minimum_erase_count = min_system_block_erase_count;
nor_flash -> lx_nor_flash_maximum_erase_count = max_system_block_erase_count;
/* Determine if the mapped sector count is available. */
if (mapped_sectors_available == LX_FALSE)
{
/* Compute the number of obsolete and mapped sectors for this block. */
mapped_sectors = 0;
/* Setup a pointer to the mapped list. */
block_word_ptr = nor_flash -> lx_nor_flash_base_address + *return_erase_block * nor_flash -> lx_nor_flash_words_per_block;
list_word_ptr = block_word_ptr + nor_flash -> lx_nor_flash_block_physical_sector_mapping_offset;
/* Loop through the mapped list for this block. */
for (j = 0; j < nor_flash -> lx_nor_flash_physical_sectors_per_block; j++)
{
/* Read the current mapping entry. */
#ifdef LX_DIRECT_READ
/* Read the word directly. */
list_word = *(list_word_ptr);
#else
status = _lx_nor_flash_driver_read(nor_flash, list_word_ptr, &list_word, 1);
/* Check for an error from flash driver. Drivers should never return an error.. */
if (status)
{
/* Call system error handler. */
_lx_nor_flash_system_error(nor_flash, status);
/* Return the error. */
return(status);
}
#endif
/* Determine if the entry hasn't been used. */
if (list_word == LX_NOR_PHYSICAL_SECTOR_FREE)
{
/* Since allocations are done sequentially in the block, we know nothing
else exists after this point. */
break;
}
/* Is this entry mapped? */
if ((list_word & LX_NOR_PHYSICAL_SECTOR_VALID) != 0)
{
/* Increment the number of mapped sectors. */
mapped_sectors++;
}
/* Move the list pointer ahead. */
list_word_ptr++;
}
/* Return the mapped sector count. */
*return_mapped_sectors = mapped_sectors;
}
/* Return success. */
return(LX_SUCCESS);
}
+28 -6
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_open PORTABLE C */
/* 6.2.1 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -94,7 +94,15 @@
/* resulting in version 6.1.7 */
/* 03-08-2023 Xiuwen Cai Modified comment(s), */
/* added new driver interface, */
/* resulting in version 6.2.1 */
/* resulting in version 6.2.1 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added count for minimum */
/* erased blocks, added */
/* obsolete count cache, */
/* avoided clearing user */
/* extension in flash control */
/* block, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_open(LX_NOR_FLASH *nor_flash, CHAR *name, UINT (*nor_driver_initialize)(LX_NOR_FLASH *))
@@ -112,7 +120,7 @@ ULONG free_sectors;
ULONG used_sectors;
ULONG *new_map_entry;
ULONG *new_sector_address;
ULONG erased_count, min_erased_count, max_erased_count, temp_erased_count;
ULONG erased_count, min_erased_count, max_erased_count, temp_erased_count, min_erased_blocks;
ULONG j, k, l;
UINT status;
#ifdef LX_FREE_SECTOR_DATA_VERIFY
@@ -124,8 +132,8 @@ LX_INTERRUPT_SAVE_AREA
LX_PARAMETER_NOT_USED(name);
/* Clear the NOR flash control block. */
LX_MEMSET(nor_flash, 0, sizeof(LX_NOR_FLASH));
/* Clear the NOR flash control block. User extension is not cleared. */
LX_MEMSET(nor_flash, 0, (ULONG)((UCHAR*)&(nor_flash -> lx_nor_flash_open_previous) - (UCHAR*)nor_flash) + sizeof(nor_flash -> lx_nor_flash_open_previous));
/* Call the flash driver's initialization function. */
(nor_driver_initialize)(nor_flash);
@@ -213,6 +221,7 @@ LX_INTERRUPT_SAVE_AREA
/* Setup default values for the max/min erased counts. */
min_erased_count = LX_ALL_ONES;
min_erased_blocks = 0;
max_erased_count = 0;
/* Setup the block word pointer to the first word of the first block, which is effectively the
@@ -254,13 +263,24 @@ LX_INTERRUPT_SAVE_AREA
/* No, valid block. Isolate the erased count. */
erased_count = (block_word & LX_BLOCK_ERASE_COUNT_MASK);
/* Is the erased count the minimum? */
if (erased_count == min_erased_count)
{
/* Yes, increment the minimum erased block count. */
min_erased_blocks++;
}
/* Is this the new minimum? */
if (erased_count < min_erased_count)
{
/* Yes, remember the new minimum. */
min_erased_count = erased_count;
/* Reset the minimum erased block count. */
min_erased_blocks = 1;
}
/* Is this the new maximum? */
@@ -327,6 +347,7 @@ LX_INTERRUPT_SAVE_AREA
/* Update the overall minimum and maximum erase count. */
nor_flash -> lx_nor_flash_minimum_erase_count = 1;
nor_flash -> lx_nor_flash_minimum_erased_blocks = nor_flash -> lx_nor_flash_total_blocks;
nor_flash -> lx_nor_flash_maximum_erase_count = 1;
/* Update the number of free physical sectors. */
@@ -806,6 +827,7 @@ LX_INTERRUPT_SAVE_AREA
/* Update the overall minimum and maximum erase count. */
nor_flash -> lx_nor_flash_minimum_erase_count = min_erased_count;
nor_flash -> lx_nor_flash_minimum_erased_blocks = min_erased_blocks;
nor_flash -> lx_nor_flash_maximum_erase_count = max_erased_count;
/* Determine if we need to update the free sector search pointer. */
+16 -1
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_sector_read PORTABLE C */
/* 6.1.7 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -84,6 +84,9 @@
/* resulting in version 6.1 */
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
/* resulting in version 6.1.7 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added mapping bitmap cache, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_sector_read(LX_NOR_FLASH *nor_flash, ULONG logical_sector, VOID *buffer)
@@ -179,6 +182,18 @@ ULONG *sector_address;
/* Return status. */
return(LX_ERROR);
}
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
/* Determine if the logical sector is within the mapping bitmap. */
if (logical_sector < nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector)
{
/* Set the bit in the mapping bitmap. */
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap[logical_sector >> 5] |= (ULONG)(1 << (logical_sector & 31));
}
#endif
#endif
/* Increment the number of mapped physical sectors. */
nor_flash -> lx_nor_flash_mapped_physical_sectors++;
+35 -1
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_sector_release PORTABLE C */
/* 6.1.7 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -84,6 +84,10 @@
/* resulting in version 6.1 */
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
/* resulting in version 6.1.7 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added mapping bitmap cache, */
/* added obsolete count cache, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_sector_release(LX_NOR_FLASH *nor_flash, ULONG logical_sector)
@@ -94,6 +98,9 @@ ULONG *mapping_address;
ULONG mapping_entry;
ULONG *sector_address;
ULONG i;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
ULONG block;
#endif
#ifdef LX_THREAD_SAFE_ENABLE
@@ -164,9 +171,36 @@ ULONG i;
return(LX_ERROR);
}
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
/* Determine if the logical sector is within the mapping bitmap. */
if (logical_sector < nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector)
{
/* Set the bit in the mapping bitmap. */
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap[logical_sector >> 5] &= (ULONG)~(1 << (logical_sector & 31));
}
#endif
#endif
/* Increment the number of obsolete physical sectors. */
nor_flash -> lx_nor_flash_obsolete_physical_sectors++;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Get the block number from mapping address. */
block = (ULONG)(mapping_address - nor_flash -> lx_nor_flash_base_address) / nor_flash -> lx_nor_flash_words_per_block;
/* Determine if this block is within the range of the obsolete count cache. */
if (block < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Increment the obsolete count for this block. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count[block] ++;
}
#endif
/* Decrement the number of mapped physical sectors. */
nor_flash -> lx_nor_flash_mapped_physical_sectors--;
+34 -2
View File
@@ -40,7 +40,7 @@
/* FUNCTION RELEASE */
/* */
/* _lx_nor_flash_sector_write PORTABLE C */
/* 6.1.7 */
/* 6.3.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -87,6 +87,10 @@
/* resulting in version 6.1 */
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
/* resulting in version 6.1.7 */
/* 10-31-2023 Xiuwen Cai Modified comment(s), */
/* added mapping bitmap cache, */
/* added obsolete count cache, */
/* resulting in version 6.3.0 */
/* */
/**************************************************************************/
UINT _lx_nor_flash_sector_write(LX_NOR_FLASH *nor_flash, ULONG logical_sector, VOID *buffer)
@@ -101,7 +105,9 @@ ULONG new_mapping_entry;
ULONG i;
LX_NOR_SECTOR_MAPPING_CACHE_ENTRY *sector_mapping_cache_entry_ptr;
UINT status;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
ULONG block;
#endif
#ifdef LX_THREAD_SAFE_ENABLE
@@ -269,6 +275,18 @@ UINT status;
/* Return status. */
return(LX_ERROR);
}
#ifndef LX_NOR_DISABLE_EXTENDED_CACHE
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
/* Determine if the logical sector is within the mapping bitmap. */
if (logical_sector < nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap_max_logical_sector)
{
/* Set the bit in the mapping bitmap. */
nor_flash -> lx_nor_flash_extended_cache_mapping_bitmap[logical_sector >> 5] |= (ULONG)(1 << (logical_sector & 31));
}
#endif
#endif
/* Increment the number of mapped physical sectors. */
nor_flash -> lx_nor_flash_mapped_physical_sectors++;
@@ -303,6 +321,20 @@ UINT status;
/* Increment the number of obsolete physical sectors. */
nor_flash -> lx_nor_flash_obsolete_physical_sectors++;
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
/* Get the block number from mapping address. */
block = (ULONG)(old_mapping_address - nor_flash -> lx_nor_flash_base_address) / nor_flash -> lx_nor_flash_words_per_block;
/* Determine if this block is within the range of the obsolete count cache. */
if (block < nor_flash -> lx_nor_flash_extended_cache_obsolete_count_max_block)
{
/* Increment the obsolete count for this block. */
nor_flash -> lx_nor_flash_extended_cache_obsolete_count[block] ++;
}
#endif
/* Decrement the number of mapped physical sectors. */
nor_flash -> lx_nor_flash_mapped_physical_sectors--;
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
$(dirname `realpath $0`)/../test/cmake/run.sh build all
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Remove large folder
rm -rf /opt/hostedtoolcache
# Install necessary softwares for Ubuntu.
sudo apt-get update
sudo apt-get install -y \
gcc-multilib \
git \
g++ \
python3-pip \
ninja-build \
unifdef \
p7zip-full \
tofrodos \
gawk \
software-properties-common
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
CODENAME=$(lsb_release -c | cut -f2 -d':' | sed 's/\t//')
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $CODENAME main"
python3 -m pip install --upgrade pip
pip3 install gcovr==4.1
pip install --upgrade cmake
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
$(dirname `realpath $0`)/../test/cmake/run.sh test all
+4
View File
@@ -0,0 +1,4 @@
threadx
filex
coverage_report
.run.sh
+128
View File
@@ -0,0 +1,128 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0057 NEW)
project(levelx_test LANGUAGES C)
# Set build configurations
set(BUILD_CONFIGURATIONS default_build_coverage
free_sector_verify_build
full_build
standalone_build
standalone_free_sector_verify_build
standalone_full_build
new_driver_interface_build
nor_obsolete_cache_build
nor_mapping_cache_build
nor_obsolete_mapping_cache_build)
set(CMAKE_CONFIGURATION_TYPES
${BUILD_CONFIGURATIONS}
CACHE STRING "list of supported configuration types" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
${CMAKE_CONFIGURATION_TYPES})
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE)
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST
CMAKE_CONFIGURATION_TYPES)))
set(CMAKE_BUILD_TYPE
"${BUILD_TYPE}"
CACHE STRING "Build Type of the project" FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
set(FX_FAULT_TOLERANT_DEFINITIONS
-DFX_ENABLE_FAULT_TOLERANT -DFX_UPDATE_FILE_SIZE_ON_ALLOCATE
-DFX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION)
set(default_build_coverage "")
set(free_sector_verify_build -DLX_FREE_SECTOR_DATA_VERIFY)
set(full_build -DLX_FREE_SECTOR_DATA_VERIFY
-DLX_DIRECT_READ
-DLX_NAND_FLASH_DIRECT_MAPPING_CACHE
-DLX_NOR_DISABLE_EXTENDED_CACHE
-DLX_THREAD_SAFE_ENABLE)
# For Standalone builds LX_STANADLONE_ENABLE is defined in line 61
set(standalone_build -DLX_STANDALONE_ENABLE)
set(standalone_free_sector_verify_build -DLX_STANDALONE_ENABLE ${free_sector_verify_build})
set(standalone_full_build -DLX_STANDALONE_ENABLE ${full_build})
set(new_driver_interface_build -DLX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
-DLX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE)
set(nor_obsolete_cache_build -DLX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
set(nor_mapping_cache_build -DLX_NOR_ENABLE_MAPPING_BITMAP)
set(nor_obsolete_mapping_cache_build -DLX_NOR_ENABLE_MAPPING_BITMAP
-DLX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
add_compile_options(
-m32
-std=c99
-ggdb
-g3
-gdwarf-2
-fdiagnostics-color
-Werror
${${CMAKE_BUILD_TYPE}})
add_link_options(-m32)
enable_testing()
if(CMAKE_BUILD_TYPE MATCHES "standalone.*")
set(LX_STANDALONE_ENABLE
ON
CACHE BOOL "LevelX standalone enabled(No Azure RTOS ThreadX)" FORCE)
set(FX_STANDALONE_ENABLE
ON
CACHE BOOL "FileX standalone enabled(No Azure RTOS ThreadX)" FORCE)
endif()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../.. levelx)
add_subdirectory(regression)
add_subdirectory(samples)
# Coverage
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage")
target_compile_options(levelx PRIVATE -fprofile-arcs -ftest-coverage)
target_link_options(levelx PRIVATE -fprofile-arcs -ftest-coverage)
endif()
# Build ThreadX library once
execute_process(COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh build_libs)
add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh
build_libs)
add_dependencies(levelx build_libs)
target_include_directories(levelx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc)
if(NOT LX_STANDALONE_ENABLE)
add_library(threadx SHARED IMPORTED GLOBAL)
add_library("azrtos::threadx" ALIAS threadx)
set_target_properties(
threadx PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so)
add_library(filex SHARED IMPORTED GLOBAL)
add_library("azrtos::filex" ALIAS filex)
set_target_properties(filex PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so)
else()
get_filename_component(
externals ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
add_subdirectory(${externals}/filex filex)
add_library("azrtos::filex" ALIAS filex)
endif()
target_compile_options(
levelx
PRIVATE -Werror
-Wall
-Wextra
-pedantic
-fmessage-length=0
-fsigned-char
-ffunction-sections
-fdata-sections
-Wunused
-Wuninitialized
-Wmissing-declarations
-Wconversion
-Wpointer-arith
-Wshadow
-Wlogical-op
-Waggregate-return
-Wfloat-equal)
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
cd $(dirname $0)
mkdir -p coverage_report/$1
gcovr --object-directory=build/$1/levelx/CMakeFiles/levelx.dir/common/src -r ../../common/src --xml-pretty --output coverage_report/$1.xml
gcovr --object-directory=build/$1/levelx/CMakeFiles/levelx.dir/common/src -r ../../common/src --html --html-details --output coverage_report/$1/index.html
+38
View File
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(libs LANGUAGES C)
if($ENV{ENABLE_64})
message(STATUS "Building for 64bit")
else()
add_compile_options(-m32)
add_link_options(-m32)
message(STATUS "Building for 32bit")
endif()
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
get_filename_component(
externals ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE)
if(NOT LX_STANDALONE_ENABLE)
add_subdirectory(${externals}/threadx threadx)
endif()
add_subdirectory(${externals}/filex filex)
target_compile_options(threadx PRIVATE -DTX_ENABLE_EVENT_TRACE)
if(NOT DEFINED ENV{ENABLE_IDLE})
target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE)
endif()
if((NOT LX_STANDALONE_ENABLE) OR (NOT FX_STANDALONE_ENABLE))
foreach(lib threadx filex)
get_target_property(dirs ${lib} INCLUDE_DIRECTORIES)
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc)
foreach(dir ${dirs})
file(GLOB header_files ${dir}/*.h)
foreach(header_file ${header_files})
execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc)
endforeach()
endforeach()
endforeach()
endif()
+20
View File
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
cmake_policy(SET CMP0057 NEW)
project(regression_test LANGUAGES C)
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../regression)
set(regression_test_cases
${SOURCE_DIR}/levelx_nand_flash_test.c
${SOURCE_DIR}/levelx_nor_flash_test.c
${SOURCE_DIR}/levelx_nor_flash_test_cache.c)
foreach(test_case ${regression_test_cases} ${regression_test_cases_exfat})
get_filename_component(test_name ${test_case} NAME_WE)
add_executable(${test_name} ${test_case})
target_link_libraries(${test_name} PRIVATE azrtos::filex)
target_link_libraries(${test_name} PRIVATE azrtos::levelx)
target_compile_definitions(${test_name} PRIVATE BATCH_TEST)
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
endforeach()
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
cd $(dirname $0)
# if threadx repo does not exist, clone it
[ -d threadx ] || git clone https://github.com/azure-rtos/threadx.git --depth 1
[ -d filex ] || git clone https://github.com/azure-rtos/filex.git --depth 1
[ -f .run.sh ] || ln -sf threadx/scripts/cmake_bootstrap.sh .run.sh
./.run.sh $*
+17
View File
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
cmake_policy(SET CMP0057 NEW)
project(samples LANGUAGES C)
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../samples)
set(sample_files
${SOURCE_DIR}/demo_filex_nand_flash.c
${SOURCE_DIR}/demo_filex_nor_flash.c)
foreach(sample_file ${sample_files})
get_filename_component(sample_file_name ${sample_file} NAME_WE)
add_executable(${sample_file_name} ${sample_file})
target_link_libraries(${sample_file_name} PRIVATE azrtos::filex)
target_link_libraries(${sample_file_name} PRIVATE azrtos::levelx)
endforeach()
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff