mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 20:48:51 +08:00
Compare commits
8
Commits
v6.1.8_rel
...
v6.2.0_rel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b3a8293ce | ||
|
|
2f639bac26 | ||
|
|
9075ca321b | ||
|
|
c53a6c6bca | ||
|
|
bbab2bbf6b | ||
|
|
79cefa16a4 | ||
|
|
e848ac3db2 | ||
|
|
fdf7799991 |
@@ -6,6 +6,7 @@ project(levelx
|
|||||||
)
|
)
|
||||||
|
|
||||||
option(LX_STANDALONE_ENABLE "Enable LevelX in standalone mode" OFF)
|
option(LX_STANDALONE_ENABLE "Enable LevelX in standalone mode" OFF)
|
||||||
|
option(LX_ENABLE_FILE_SERVERS "Includes a dependency on FileX" ON)
|
||||||
|
|
||||||
if(NOT DEFINED THREADX_ARCH)
|
if(NOT DEFINED THREADX_ARCH)
|
||||||
message(FATAL_ERROR "Error: THREADX_ARCH not defined")
|
message(FATAL_ERROR "Error: THREADX_ARCH not defined")
|
||||||
@@ -25,6 +26,11 @@ if(NOT LX_STANDALONE_ENABLE)
|
|||||||
"azrtos::threadx")
|
"azrtos::threadx")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LX_ENABLE_FILE_SERVERS)
|
||||||
|
message(STATUS "LX_ENABLE_FILE_SERVERS - defined")
|
||||||
|
target_link_libraries(${PROJECT_NAME} PUBLIC "azrtos::filex")
|
||||||
|
endif()
|
||||||
|
|
||||||
# A place for generated/copied include files (no need to change)
|
# A place for generated/copied include files (no need to change)
|
||||||
set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
|
set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
|
||||||
|
|
||||||
|
|||||||
@@ -1,91 +1,98 @@
|
|||||||
# Azure RTOS LevelX
|
# Azure RTOS LevelX
|
||||||
|
|
||||||
LevelX provides NAND and NOR flash wear leveling facilities to embedded applications. Since both NAND and NOR flash memory can only be erased a finite number of times, it’s critical to distribute the flash memory use evenly. This is typically called “wear leveling” and is the purpose behind LevelX. LevelX presents to the user an array of logical sectors that are mapped to physical flash memory inside of LevelX. Applications may use LevelX in conjunction with FileX or may read/write logical sectors directly. LevelX is designed for fault tolerance. Flash updates are performed in a multiple-step process that can be interrupted in each step. LevelX automatically recovers to the optimal state during the next operation.
|
LevelX provides NAND and NOR flash wear leveling facilities to embedded applications. Since both NAND and NOR flash memory can only be erased a finite number of times, it’s critical to distribute the flash memory use evenly. This is typically called **wear leveling** and is the purpose behind LevelX. LevelX presents to the user an array of logical sectors that are mapped to physical flash memory inside of LevelX. Applications may use LevelX in conjunction with FileX or may read/write logical sectors directly. LevelX is designed for fault tolerance. Flash updates are performed in a multiple-step process that can be interrupted in each step. LevelX automatically recovers to the optimal state during the next operation.
|
||||||
|
|
||||||
## Documentation
|
## Getting Started
|
||||||
|
|
||||||
Documentation for this library can be found here: https://github.com/azure-rtos/levelx/releases/download/v6.0_rel/Azure_RTOS_LevelX_User_Guide.pdf
|
Azure RTOS LevelX as part of Azure RTOS has been integrated to the semiconductor's SDKs and development environment. You can develop using the tools of choice from [STMicroelectronics](https://www.st.com/content/st_com/en/campaigns/x-cube-azrtos-azure-rtos-stm32.html), [NXP](https://www.nxp.com/design/software/embedded-software/azure-rtos-for-nxp-microcontrollers:AZURE-RTOS), [Renesas](https://github.com/renesas/azure-rtos) and [Microchip](https://mu.microchip.com/get-started-simplifying-your-iot-design-with-azure-rtos).
|
||||||
|
|
||||||
# Understanding inter-component dependencies
|
See [Overview of Azure RTOS LevelX](https://learn.microsoft.com/azure/rtos/levelx/overview-levelx) for the high-level overview, and all documentation and APIs can be found in: [Azure RTOS LevelX documentation](https://learn.microsoft.com/azure/rtos/levelx/).
|
||||||
|
|
||||||
The main components of Azure RTOS are each provided in their own repository, but there are dependencies between them--shown in the following graph--that are important to understand when setting up your builds.
|
## Repository Structure and Usage
|
||||||
|
|
||||||
|
### Directory layout
|
||||||
|
|
||||||
|
.
|
||||||
|
├── cmake # CMakeList files for building the project
|
||||||
|
├── common # Core LevelX files
|
||||||
|
├── samples # Sample codes
|
||||||
|
├── LICENSE.txt # License terms
|
||||||
|
├── LICENSE-HARDWARE.txt # Licensed hardware from semiconductors
|
||||||
|
├── CONTRIBUTING.md # Contribution guidance
|
||||||
|
└── SECURITY.md # Microsoft repo security guidance
|
||||||
|
|
||||||
|
### Branches & Releases
|
||||||
|
|
||||||
|
The master branch has the most recent code with all new features and bug fixes. It does not represent the latest General Availability (GA) release of the library. Each official release (preview or GA) will be tagged to mark the commit and push it into the Github releases tab, e.g. `v6.2-rel`.
|
||||||
|
|
||||||
|
## Component dependencies
|
||||||
|
|
||||||
|
The main components of Azure RTOS are each provided in their own repository, but there are dependencies between them, as shown in the following graph. This is important to understand when setting up your builds.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
# Building and using the library
|
> You will have to take the dependency graph above into account when building anything other than ThreadX itself.
|
||||||
|
|
||||||
## Prerequisites
|
### Building and using the library
|
||||||
|
|
||||||
Install the following tools:
|
Instruction for building the LevelX as static library using Arm GNU Toolchain and CMake. If you are using toolchain and IDE from semiconductor, you might follow its own instructions to use Azure RTOS components as explained in the [Getting Started](#getting-started) section.
|
||||||
|
|
||||||
|
1. Install the following tools:
|
||||||
|
|
||||||
* [CMake](https://cmake.org/download/) version 3.0 or later
|
* [CMake](https://cmake.org/download/) version 3.0 or later
|
||||||
* [GCC compilers for arm-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
|
* [Arm GNU Toolchain for arm-none-eabi](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)
|
||||||
* [Ninja](https://ninja-build.org/)
|
* [Ninja](https://ninja-build.org/)
|
||||||
|
|
||||||
## Cloning the repo
|
1. Build the [ThreadX library](https://github.com/azure-rtos/threadx#building-and-using-the-library) as the dependency.
|
||||||
|
|
||||||
|
1. Cloning the repo.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ git clone https://github.com/azure-rtos/levelx.git
|
$ git clone --recursive https://github.com/azure-rtos/levelx.git
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building as a static library
|
1. Define the features and addons you need in `lx_user.h` and build together with the component source code. You can refer to [`lx_user_sample.h`](https://github.com/azure-rtos/levelx/blob/master/common/inc/lx_user_sample.h) as an example.
|
||||||
|
|
||||||
Each component of Azure RTOS comes with a composible CMake-based build system that supports many different MCUs and host systems. Integrating any of these components into your device app code is as simple as adding a git submodule and then including it in your build using the CMake command `add_subdirectory()`.
|
1. Building as a static library
|
||||||
|
|
||||||
While the typical usage pattern is to include threadx into your device code source tree to be built & linked with your code, you can compile this project as a standalone static library to confirm your build is set up correctly.
|
Each component of Azure RTOS comes with a composable CMake-based build system that supports many different MCUs and host systems. Integrating any of these components into your device app code is as simple as adding a git submodule and then including it in your build using the CMake `add_subdirectory()`.
|
||||||
|
|
||||||
|
While the typical usage pattern is to include LevelX into your device code source tree to be built & linked with your code, you can compile this project as a standalone static library to confirm your build is set up correctly.
|
||||||
|
|
||||||
|
An example of building the library for Cortex-M4:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake -GNinja .
|
$ cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake .
|
||||||
|
|
||||||
$ cmake --build ./build
|
$ cmake --build ./build
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: You will have to take the dependency graph above into account when building anything other than threadx itself.
|
## Professional support
|
||||||
|
|
||||||
# Repository Structure and Usage
|
[Professional support plans](https://azure.microsoft.com/support/options/) are available from Microsoft. For community support and others, see the [Resources](#resources) section below.
|
||||||
|
|
||||||
## Branches & Releases
|
## Licensing
|
||||||
|
|
||||||
The master branch has the most recent code with all new features and bug fixes. It does not represent the latest General Availability (GA) release of the library.
|
License terms for using Azure RTOS are defined in the LICENSE.txt file of this repo. Please refer to this file for all definitive licensing information. No additional license fees are required for deploying Azure RTOS on hardware defined in the [LICENSED-HARDWARE.txt](./LICENSED-HARDWARE.txt) file. If you are using hardware not listed in the file or having licensing questions in general, please contact Microsoft directly at https://aka.ms/azrtos-license.
|
||||||
|
|
||||||
## Releases
|
## Resources
|
||||||
|
|
||||||
Each official release (preview or GA) will be tagged to mark the commit and push it into the Github releases tab, e.g. `v6.0-rel`.
|
The following are references to additional Azure RTOS resources:
|
||||||
|
|
||||||
## Directory layout
|
- **Product introduction and white papers**: https://azure.com/rtos
|
||||||
|
- **General technical questions**: https://aka.ms/QnA/azure-rtos
|
||||||
|
- **Product issues and bugs, or feature requests**: https://github.com/azure-rtos/levelx/issues
|
||||||
|
- **Licensing and sales questions**: https://aka.ms/azrtos-license
|
||||||
|
- **Product roadmap and support policy**: https://aka.ms/azrtos/lts
|
||||||
|
- **Blogs and videos**: http://msiotblog.com and https://aka.ms/iotshow
|
||||||
|
- **Azure RTOS TraceX Installer**: https://aka.ms/azrtos-tracex-installer
|
||||||
|
|
||||||
```
|
You can also check [previous questions](https://stackoverflow.com/questions/tagged/azure-rtos+levelx) or ask new ones on StackOverflow using the `azure-rtos` and `levelx` tags.
|
||||||
- cmake
|
|
||||||
- common
|
|
||||||
- inc
|
|
||||||
- src
|
|
||||||
- samples
|
|
||||||
```
|
|
||||||
|
|
||||||
# Security
|
## Security
|
||||||
|
|
||||||
Azure RTOS provides OEMs with components to secure communication and to create code and data isolation using underlying MCU/MPU hardware protection mechanisms. It is ultimately the responsibility of the device builder to ensure the device fully meets the evolving security requirements associated with its specific use case.
|
Azure RTOS provides OEMs with components to secure communication and to create code and data isolation using underlying MCU/MPU hardware protection mechanisms. It is ultimately the responsibility of the device builder to ensure the device fully meets the evolving security requirements associated with its specific use case.
|
||||||
|
|
||||||
# Licensing
|
## Contribution
|
||||||
|
|
||||||
License terms for using Azure RTOS are defined in the LICENSE.txt file of this repo. Please refer to this file for all definitive licensing information. No additional license fees are required for deploying Azure RTOS on hardware defined in the LICENSED-HARDWARE.txt file. If you are using hardware not defined in the LICENSED-HARDWARE.txt file or have licensing questions in general, please contact Microsoft directly at https://azure-rtos.ms-iot-contact.com/
|
Please follow the instructions provided in the [CONTRIBUTING.md](./CONTRIBUTING.md) for the corresponding repository.
|
||||||
|
|
||||||
# Contribution, feedback, issues, and professional support
|
|
||||||
|
|
||||||
If you encounter any bugs, have suggestions for new features, or if you would like to become an active contributor to this project, please follow the instructions provided in the contribution guideline for the corresponding repo.
|
|
||||||
|
|
||||||
For basic support, click Issues in the command bar or post a question to [Stack Overflow](http://stackoverflow.com/questions/tagged/azure-rtos+threadx) using the `threadx` and `azure-rtos` tags.
|
|
||||||
|
|
||||||
Professional support plans (https://azure.microsoft.com/en-us/support/options/) are available from Microsoft.
|
|
||||||
|
|
||||||
# Additional Resources
|
|
||||||
|
|
||||||
The following are references to additional Azure RTOS and Azure IoT in general:
|
|
||||||
| | |
|
|
||||||
|---|---|
|
|
||||||
| Azure RTOS Documenation and Guides: | https://docs.microsoft.com/azure/rtos |
|
|
||||||
| Azure RTOS Website: | https://azure.microsoft.com/services/rtos/ |
|
|
||||||
| Azure RTOS Sales Questions: | https://azure-rtos.ms-iot-contact.com/ |
|
|
||||||
| For technical questions check out Microsoft Q/A for Azure IoT: | https://aka.ms/QnA/azure-rtos |
|
|
||||||
| Internet of Things Show for latest announcements and online training: | https://aka.ms/iotshow |
|
|
||||||
| IoT Tech Community: | https://aka.ms/community/azure-rtos |
|
|
||||||
|
|||||||
+30
-9
@@ -26,7 +26,7 @@
|
|||||||
/* APPLICATION INTERFACE DEFINITION RELEASE */
|
/* APPLICATION INTERFACE DEFINITION RELEASE */
|
||||||
/* */
|
/* */
|
||||||
/* lx_api.h PORTABLE C */
|
/* lx_api.h PORTABLE C */
|
||||||
/* 6.1.8 */
|
/* 6.2.0 */
|
||||||
/* AUTHOR */
|
/* AUTHOR */
|
||||||
/* */
|
/* */
|
||||||
/* William E. Lamie, Microsoft Corporation */
|
/* William E. Lamie, Microsoft Corporation */
|
||||||
@@ -58,6 +58,23 @@
|
|||||||
/* 08-02-2021 William E. Lamie Modified comment(s), and */
|
/* 08-02-2021 William E. Lamie Modified comment(s), and */
|
||||||
/* updated product constants, */
|
/* updated product constants, */
|
||||||
/* resulting in version 6.1.8 */
|
/* resulting in version 6.1.8 */
|
||||||
|
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
|
||||||
|
/* updated configuration for */
|
||||||
|
/* nand flash */
|
||||||
|
/* resulting in version 6.1.9 */
|
||||||
|
/* 01-31-2022 Bhupendra Naphade Modified comment(s), */
|
||||||
|
/* updated include order for */
|
||||||
|
/* standalone mode, */
|
||||||
|
/* resulting in version 6.1.10 */
|
||||||
|
/* 04-25-2022 William E. Lamie Modified comment(s), and */
|
||||||
|
/* updated product constants, */
|
||||||
|
/* resulting in version 6.1.11 */
|
||||||
|
/* 07-29-2022 William E. Lamie Modified comment(s), and */
|
||||||
|
/* updated product constants, */
|
||||||
|
/* resulting in version 6.1.12 */
|
||||||
|
/* 10-31-2022 Xiuwen Cai Modified comment(s), and */
|
||||||
|
/* updated product constants, */
|
||||||
|
/* resulting in version 6.2.0 */
|
||||||
/* */
|
/* */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
@@ -75,12 +92,6 @@ extern "C" {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Include necessary system files. */
|
|
||||||
|
|
||||||
#ifndef LX_STANDALONE_ENABLE
|
|
||||||
#include "tx_api.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Determine if the optional LevelX user define file should be used. */
|
/* Determine if the optional LevelX user define file should be used. */
|
||||||
|
|
||||||
#ifdef LX_INCLUDE_USER_DEFINE_FILE
|
#ifdef LX_INCLUDE_USER_DEFINE_FILE
|
||||||
@@ -92,6 +103,12 @@ extern "C" {
|
|||||||
#include "lx_user.h"
|
#include "lx_user.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Include the ThreadX api file. */
|
||||||
|
|
||||||
|
#ifndef LX_STANDALONE_ENABLE
|
||||||
|
#include "tx_api.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef LX_STANDALONE_ENABLE
|
#ifdef LX_STANDALONE_ENABLE
|
||||||
|
|
||||||
@@ -161,8 +178,8 @@ typedef unsigned long long ULONG64;
|
|||||||
/* Define basic constants for the LevelX Stack. */
|
/* Define basic constants for the LevelX Stack. */
|
||||||
#define AZURE_RTOS_LEVELX
|
#define AZURE_RTOS_LEVELX
|
||||||
#define LEVELX_MAJOR_VERSION 6
|
#define LEVELX_MAJOR_VERSION 6
|
||||||
#define LEVELX_MINOR_VERSION 1
|
#define LEVELX_MINOR_VERSION 2
|
||||||
#define LEVELX_PATCH_VERSION 8
|
#define LEVELX_PATCH_VERSION 0
|
||||||
|
|
||||||
|
|
||||||
/* Define general LevelX Constants. */
|
/* Define general LevelX Constants. */
|
||||||
@@ -254,6 +271,10 @@ typedef unsigned long long ULONG64;
|
|||||||
#define LX_NAND_ERASE_COUNT_WRITE_SIZE (nand_flash -> lx_nand_flash_pages_per_block + 1)
|
#define LX_NAND_ERASE_COUNT_WRITE_SIZE (nand_flash -> lx_nand_flash_pages_per_block + 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LX_NAND_FLASH_MAPPING_LIST_UPDATE_DISABLE
|
||||||
|
#define LX_NAND_FLASH_MAPPING_LIST_UPDATE_DISABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Define the mask for the hash index into the NAND sector mapping cache table. The sector mapping cache is divided
|
/* Define the mask for the hash index into the NAND sector mapping cache table. The sector mapping cache is divided
|
||||||
into 4 entry pieces that are indexed by the formula:
|
into 4 entry pieces that are indexed by the formula:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/* FUNCTION RELEASE */
|
/* FUNCTION RELEASE */
|
||||||
/* */
|
/* */
|
||||||
/* _lx_nand_flash_block_obsoleted_check PORTABLE C */
|
/* _lx_nand_flash_block_obsoleted_check PORTABLE C */
|
||||||
/* 6.1.7 */
|
/* 6.1.9 */
|
||||||
/* AUTHOR */
|
/* AUTHOR */
|
||||||
/* */
|
/* */
|
||||||
/* William E. Lamie, Microsoft Corporation */
|
/* William E. Lamie, Microsoft Corporation */
|
||||||
@@ -86,6 +86,10 @@
|
|||||||
/* resulting in version 6.1 */
|
/* resulting in version 6.1 */
|
||||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||||
/* resulting in version 6.1.7 */
|
/* resulting in version 6.1.7 */
|
||||||
|
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
|
||||||
|
/* removed multiple write */
|
||||||
|
/* to page 0, */
|
||||||
|
/* resulting in version 6.1.9 */
|
||||||
/* */
|
/* */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
VOID _lx_nand_flash_block_obsoleted_check(LX_NAND_FLASH *nand_flash, ULONG block)
|
VOID _lx_nand_flash_block_obsoleted_check(LX_NAND_FLASH *nand_flash, ULONG block)
|
||||||
@@ -316,22 +320,11 @@ UINT status;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now store the erase count. */
|
/* Now store the erase count. */
|
||||||
page_word_ptr[0] = (erase_count | LX_BLOCK_ERASED);
|
page_word_ptr[0] = (erase_count);
|
||||||
|
|
||||||
/* Write the erase count for the block. */
|
/* Write the erase count for the block. */
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
||||||
|
|
||||||
/* Check to see if the write was successful. */
|
|
||||||
if (status == LX_SUCCESS)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Now store the erase count. */
|
|
||||||
page_word_ptr[0] = erase_count;
|
|
||||||
|
|
||||||
/* Write the erase count for the block. */
|
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for an error from flash driver. */
|
/* Check for an error from flash driver. */
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/* FUNCTION RELEASE */
|
/* FUNCTION RELEASE */
|
||||||
/* */
|
/* */
|
||||||
/* _lx_nand_flash_block_reclaim PORTABLE C */
|
/* _lx_nand_flash_block_reclaim PORTABLE C */
|
||||||
/* 6.1.8 */
|
/* 6.1.9 */
|
||||||
/* AUTHOR */
|
/* AUTHOR */
|
||||||
/* */
|
/* */
|
||||||
/* William E. Lamie, Microsoft Corporation */
|
/* William E. Lamie, Microsoft Corporation */
|
||||||
@@ -91,6 +91,10 @@
|
|||||||
/* 08-02-2021 Bhupendra Naphade Modified comment(s), updated */
|
/* 08-02-2021 Bhupendra Naphade Modified comment(s), updated */
|
||||||
/* obselete page count check, */
|
/* obselete page count check, */
|
||||||
/* resulting in version 6.1.8 */
|
/* resulting in version 6.1.8 */
|
||||||
|
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
|
||||||
|
/* removed multiple write */
|
||||||
|
/* to page 0, */
|
||||||
|
/* resulting in version 6.1.9 */
|
||||||
/* */
|
/* */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
UINT _lx_nand_flash_block_reclaim(LX_NAND_FLASH *nand_flash)
|
UINT _lx_nand_flash_block_reclaim(LX_NAND_FLASH *nand_flash)
|
||||||
@@ -218,22 +222,11 @@ UINT status;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now store the erase count. */
|
/* Now store the erase count. */
|
||||||
page_word_ptr[0] = (erase_count | LX_BLOCK_ERASED);
|
page_word_ptr[0] = (erase_count);
|
||||||
|
|
||||||
/* Write the erase count for the block. */
|
/* Write the erase count for the block. */
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
||||||
|
|
||||||
/* Check the status. */
|
|
||||||
if (status == LX_SUCCESS)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Now store the erase count. */
|
|
||||||
page_word_ptr[0] = erase_count;
|
|
||||||
|
|
||||||
/* Write the erase count for the block. */
|
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for an error from flash driver. */
|
/* Check for an error from flash driver. */
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
@@ -578,22 +571,11 @@ UINT status;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now store the erase count. */
|
/* Now store the erase count. */
|
||||||
page_word_ptr[0] = (erase_count | LX_BLOCK_ERASED);
|
page_word_ptr[0] = (erase_count);
|
||||||
|
|
||||||
/* Write the erase count for the block. */
|
/* Write the erase count for the block. */
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
||||||
|
|
||||||
/* Determine if the write was successful. */
|
|
||||||
if (status == LX_SUCCESS)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Now store the erase count. */
|
|
||||||
page_word_ptr[0] = erase_count;
|
|
||||||
|
|
||||||
/* Write the erase count for the block. */
|
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, erase_block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for an error from flash driver. */
|
/* Check for an error from flash driver. */
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/* FUNCTION RELEASE */
|
/* FUNCTION RELEASE */
|
||||||
/* */
|
/* */
|
||||||
/* _lx_nand_flash_open PORTABLE C */
|
/* _lx_nand_flash_open PORTABLE C */
|
||||||
/* 6.1.7 */
|
/* 6.1.9 */
|
||||||
/* AUTHOR */
|
/* AUTHOR */
|
||||||
/* */
|
/* */
|
||||||
/* William E. Lamie, Microsoft Corporation */
|
/* William E. Lamie, Microsoft Corporation */
|
||||||
@@ -94,6 +94,10 @@
|
|||||||
/* resulting in version 6.1 */
|
/* resulting in version 6.1 */
|
||||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
/* 06-02-2021 Bhupendra Naphade Modified comment(s), */
|
||||||
/* resulting in version 6.1.7 */
|
/* resulting in version 6.1.7 */
|
||||||
|
/* 10-15-2021 Bhupendra Naphade Modified comment(s), */
|
||||||
|
/* removed multiple write */
|
||||||
|
/* to page 0, */
|
||||||
|
/* resulting in version 6.1.9 */
|
||||||
/* */
|
/* */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
UINT _lx_nand_flash_open(LX_NAND_FLASH *nand_flash, CHAR *name, UINT (*nand_driver_initialize)(LX_NAND_FLASH *))
|
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
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the initial erase count to 1. */
|
/* Setup the initial erase count to 1. */
|
||||||
page_word_ptr[0] = (((ULONG) 1) | LX_BLOCK_ERASED);
|
page_word_ptr[0] = (((ULONG) 1));
|
||||||
|
|
||||||
/* Write the initial erase count for the block. */
|
/* Write the initial erase count for the block. */
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
||||||
|
|
||||||
/* Check for status after the block erase. */
|
|
||||||
if (status == LX_SUCCESS)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Setup the initial erase count to 1. */
|
|
||||||
page_word_ptr[0] = ((ULONG) 1);
|
|
||||||
|
|
||||||
/* Write the initial erase count for the block. */
|
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for an error from flash driver. */
|
/* Check for an error from flash driver. */
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
@@ -498,18 +491,9 @@ LX_INTERRUPT_SAVE_AREA
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the initial erase count for the block. */
|
/* Write the final erase count for the block. */
|
||||||
page_word_ptr[0] = (max_erased_count | LX_BLOCK_ERASED);
|
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
|
||||||
|
|
||||||
/* Determine if the write was successful. */
|
|
||||||
if (status == LX_SUCCESS)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Write the initial erase count for the block. */
|
|
||||||
page_word_ptr[0] = max_erased_count;
|
page_word_ptr[0] = max_erased_count;
|
||||||
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, LX_NAND_ERASE_COUNT_WRITE_SIZE);
|
status = _lx_nand_flash_driver_write(nand_flash, block, 0, page_word_ptr, 1);
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for an error from flash driver. */
|
/* Check for an error from flash driver. */
|
||||||
if (status)
|
if (status)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#define EXTRA_BYTE_POSITION 2 /* 2 is the extra bytes starting byte postion */
|
#define EXTRA_BYTE_POSITION 2 /* 2 is the extra bytes starting byte postion */
|
||||||
#define ECC_BYTE_POSITION 40 /* 40 is the ECC starting byte position */
|
#define ECC_BYTE_POSITION 40 /* 40 is the ECC starting byte position */
|
||||||
|
|
||||||
|
|
||||||
/* Definition of the spare area is relative to the block size of the NAND part and perhaps manufactures of the NAND part.
|
/* Definition of the spare area is relative to the block size of the NAND part and perhaps manufactures of the NAND part.
|
||||||
Here are some common definitions:
|
Here are some common definitions:
|
||||||
|
|
||||||
@@ -169,7 +168,13 @@ UINT _lx_nand_flash_simulator_write(ULONG block, ULONG page, ULONG *source, ULO
|
|||||||
{
|
{
|
||||||
|
|
||||||
ULONG *flash_address;
|
ULONG *flash_address;
|
||||||
|
UCHAR *flash_spare_address;
|
||||||
|
UINT bytes_computed;
|
||||||
|
UINT ecc_bytes =0;
|
||||||
|
UCHAR new_ecc_buffer[24];
|
||||||
|
UCHAR *new_ecc_buffer_ptr = new_ecc_buffer;
|
||||||
|
UCHAR *ecc_buffer_ptr = new_ecc_buffer_ptr;
|
||||||
|
ULONG *page_ptr = &(nand_memory_area[block].physical_pages[page].memory[0]);
|
||||||
|
|
||||||
/* Increment the diag info. */
|
/* Increment the diag info. */
|
||||||
nand_block_diag[block].page_writes[page]++;
|
nand_block_diag[block].page_writes[page]++;
|
||||||
@@ -192,6 +197,41 @@ ULONG *flash_address;
|
|||||||
*flash_address++ = *source++;
|
*flash_address++ = *source++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Loop to compute the ECC over the entire NAND flash page. */
|
||||||
|
bytes_computed = 0;
|
||||||
|
|
||||||
|
while (bytes_computed < BYTES_PER_PHYSICAL_PAGE)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Compute the ECC for this 256 byte piece of the page. */
|
||||||
|
_lx_nand_flash_256byte_ecc_compute((UCHAR *)page_ptr, (UCHAR *)new_ecc_buffer_ptr);
|
||||||
|
|
||||||
|
/* Move to the next 256 byte portion of the page. */
|
||||||
|
bytes_computed = bytes_computed + 256;
|
||||||
|
|
||||||
|
/* Move the page buffer forward. */
|
||||||
|
page_ptr = page_ptr + 256;
|
||||||
|
|
||||||
|
ecc_bytes = ecc_bytes + 3;
|
||||||
|
|
||||||
|
/* Move the ECC buffer forward, note there are 3 bytes of ECC per page. */
|
||||||
|
new_ecc_buffer_ptr = new_ecc_buffer_ptr + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup destination pointer in the spare area. */
|
||||||
|
flash_spare_address = (UCHAR *) &(nand_memory_area[block].physical_pages[page].spare[ECC_BYTE_POSITION]);
|
||||||
|
while(ecc_bytes--)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Can the word be written? We can clear new bits, but just can't unclear
|
||||||
|
in a NAND device. */
|
||||||
|
if ((*ecc_buffer_ptr & *flash_spare_address) != *ecc_buffer_ptr)
|
||||||
|
return(LX_INVALID_WRITE);
|
||||||
|
|
||||||
|
/* Set an ecc byte in the spare area. */
|
||||||
|
*flash_spare_address++ = *ecc_buffer_ptr++;
|
||||||
|
|
||||||
|
}
|
||||||
return(LX_SUCCESS);
|
return(LX_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +285,7 @@ UINT i, j;
|
|||||||
pointer = (ULONG *) &nand_memory_area[0];
|
pointer = (ULONG *) &nand_memory_area[0];
|
||||||
|
|
||||||
/* Loop to erase block. */
|
/* Loop to erase block. */
|
||||||
words = sizeof(nand_memory_area)/sizeof(ULONG);
|
words = sizeof(nand_memory_area)/(sizeof(ULONG));
|
||||||
while (words--)
|
while (words--)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/* FUNCTION RELEASE */
|
/* FUNCTION RELEASE */
|
||||||
/* */
|
/* */
|
||||||
/* _lx_nor_flash_extended_cache_enable PORTABLE C */
|
/* _lx_nor_flash_extended_cache_enable PORTABLE C */
|
||||||
/* 6.1.7 */
|
/* 6.1.9 */
|
||||||
/* AUTHOR */
|
/* AUTHOR */
|
||||||
/* */
|
/* */
|
||||||
/* William E. Lamie, Microsoft Corporation */
|
/* William E. Lamie, Microsoft Corporation */
|
||||||
@@ -80,6 +80,10 @@
|
|||||||
/* 06-02-2021 Bhupendra Naphade Modified comment(s), and */
|
/* 06-02-2021 Bhupendra Naphade Modified comment(s), and */
|
||||||
/* updated product constants */
|
/* updated product constants */
|
||||||
/* resulting in version 6.1.7 */
|
/* resulting in version 6.1.7 */
|
||||||
|
/* 10-15-2021 Bhupendra Naphade Modified comment(s), and */
|
||||||
|
/* added check for out of */
|
||||||
|
/* bound memory access, */
|
||||||
|
/* resulting in version 6.1.9 */
|
||||||
/* */
|
/* */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
UINT _lx_nor_flash_extended_cache_enable(LX_NOR_FLASH *nor_flash, VOID *memory, ULONG size)
|
UINT _lx_nor_flash_extended_cache_enable(LX_NOR_FLASH *nor_flash, VOID *memory, ULONG size)
|
||||||
@@ -135,7 +139,16 @@ ULONG *cache_memory;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Save the number of cache entries. */
|
/* Save the number of cache entries. */
|
||||||
|
if(i > LX_NOR_EXTENDED_CACHE_SIZE)
|
||||||
|
{
|
||||||
|
|
||||||
|
nor_flash -> lx_nor_flash_extended_cache_entries = LX_NOR_EXTENDED_CACHE_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
nor_flash -> lx_nor_flash_extended_cache_entries = i;
|
nor_flash -> lx_nor_flash_extended_cache_entries = i;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LX_THREAD_SAFE_ENABLE
|
#ifdef LX_THREAD_SAFE_ENABLE
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ ULONG words;
|
|||||||
pointer = (ULONG *) &nor_memory_area[0];
|
pointer = (ULONG *) &nor_memory_area[0];
|
||||||
|
|
||||||
/* Loop to erase block. */
|
/* Loop to erase block. */
|
||||||
words = sizeof(nor_memory_area)/sizeof(ULONG);
|
words = sizeof(nor_memory_area)/(sizeof(ULONG));
|
||||||
while (words--)
|
while (words--)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ int main(void)
|
|||||||
tx_kernel_enter();
|
tx_kernel_enter();
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Initialize NAND flash. */
|
/* Initialize NOR flash. */
|
||||||
lx_nand_flash_initialize();
|
lx_nor_flash_initialize();
|
||||||
|
|
||||||
/* Initialize FileX. */
|
/* Initialize FileX. */
|
||||||
fx_system_initialize();
|
fx_system_initialize();
|
||||||
|
|||||||
Reference in New Issue
Block a user