MCUSW
|
This document details AUTOSAR BSW Flash module implementation
The Flash Driver provides services for reading, writing, erasing flash memory and Execute-in-Place (XIP) mode for external Flash Device. The driver supports MT35XU512ABA1G12 and S28HS512T OSPI Flash Devices. The main tasks of the FLS driver are:
Please refer the Flash design, which is included as part of release (Fls Design Document)
The Fls Module uses internal OSPI peripheral as the serial bus to transfer data to and from the attached flash device.
Programming of clock source for the flash, is beyond the scope of this document. The Clock programming is taken care by the test application.
1 Fls instance is supported by this driver implementation (in MCU1_0 domain).
The Fls Driver implementation supports multiple configuration variants (refer section Introduction), the driver expects generated Fls_Cfg.h to be present as (File Structure). Please refer (Build) to specify path to generated configuration. The associated Fls configuration generated files Fls_Cfg.c, and Fls_PBcfg.c to be present as shown (File Structure)
The following section details on the unsupported features and additional features added.
This parameter is the switch between Direct Access Mode (DAC) and Indirect Access Mode (INDAC) used by the OSPI module to communicate with the Flash Device. The Flash will be memory mapped when running in DAC mode, and execution in place will happen directly from flash memory. In INDAC mode, data transfer between system memory and external flash occurs through the internal SRAM.
This parameter is the switch to turn on or off XIP mode. Only XIP Read mode is supported in current driver. XIP mode will only be functional in DAC mode of operation.
This parameter defines the Clock Speed for the OSPI peripheral. The supported clock speeds are as follows:
This parameter is the switch between Double Transfer Rate (DTR) and Single Transfer Rate (STR) for OSPI Flash.
This parameter is the switch to turn on and off PHY mode.
Following features outlined in Specification are not supported:
As noted from the previous MCAL implementation, some of the critical configuration registers could potentially be corrupted by other entities (s/w or h/w). One of the recommended detection methods would be to periodically read-back the configuration and confirm configuration is consistent. The service API defined below shall be implemented to enable this detection
Description | Comments | |
Service Name | Ospi_RegisterReadback | Can potentially be turned OFF (Refer to Design Document provided in CSP) |
Syntax | Ospi_RegisterReadback( P2VAR(CSL_ospi_flash_cfgRegs, AUTOMATIC, SPI_APPL_DATA) RegRbPtr) | E_OK: Register read back has been done, E_NOT_OK: Register read back failed |
Service ID | NA | |
Sync / Async | Sync | |
Reentrancy | Reentrant | |
Parameter in | None | |
Parameters out | RegRbPtr | Pointer to where to store the readback values. If this pointer is NULL_PTR, then the API will return E_NOT_OK. |
Return Value | Std_ReturnType | E_OK, E_NOT_OK |
This API Enable Under/Overflow Interrupts of the hardware unit and returns the status.
Description | Comments | |
Service Name | Fls_dataOverflowUnderflowIntrEnable | Fls_dataOverflowUnderflowIntrEnable Enable Under/Overflow Interrupts of the hardware unit |
Syntax | Fls_dataOverflowUnderflowIntrEnable(uint32 intrFlag) | |
Service ID | NA | |
Sync / Async | Sync | |
Reentrancy | Reentrant | |
Parameter in | intrFlag | Interrupt Enable flag for Underflow=2U Interrupt Enable flag for Overflow=128U |
Parameters out | NA | |
Return Value | Std_ReturnType | E_OK: Interrupt Enabled E_NOT_OK: Interrupt Enable failed |
This API Disable Under/Overflow Interrupts of the hardware unit and returns the status.
Description | Comments | |
Service Name | Fls_dataOverflowUnderflowIntrDisable | Spi_dataOverflowUnderflowIntrDisable Disable Under/Overflow Interrupts of the hardware unit and returns the status. |
Syntax | Fls_dataOverflowUnderflowIntrDisable(uint32 intrFlag) | |
Service ID | NA | |
Sync / Async | Sync | |
Reentrancy | Reentrant | |
Parameter in | intrFlag | Interrupt Disable flag for Underflow=2U Interrupt Disable flag for Overflow=128U |
Parameters out | NA | |
Return Value | Std_ReturnType | E_OK: Interrupt Disabled E_NOT_OK: Interrupt Disabled failed |
This API gets status of Under/Overflow Interrupts of the hardware unit and returns the status.
Description | Comments | |
Service Name | Fls_dataOverflowUnderflowIntrGetStatus | Fls_dataOverflowUnderflowIntrGetStatus gets status of Under/Overflow Interrupts of the hardware unit |
Syntax | Fls_dataOverflowUnderflowIntrGetStatus(uint32 intFlags) | |
Service ID | NA | |
Sync / Async | Sync | |
Reentrancy | Reentrant | |
Parameter in | intrFlag | Interrupt Enable flag |
Parameters out | NA | |
Return Value | ospiIrqstatus | OSPI_NO_EVENT: No underflow event OSPI_EVENT_PENDING: Underflow Event OSPI_STATUS_READ_FAIL: Status read fail |
This API clear Under/Overflow Interrupts of the hardware unit and returns the status.
Description | Comments | |
Service Name | Fls_dataOverflowUnderflowIntrStatusClear | Fls_dataOverflowUnderflowIntrStatusClear clear Under/Overflow Interrupts of the hardware unit and returns the status. |
Syntax | Fls_dataOverflowUnderflowIntrStatusClear(uint32 intrFlag) | |
Service ID | NA | |
Sync / Async | Sync | |
Reentrancy | Reentrant | |
Parameter in | intrFlag | Interrupt Enable flag for Underflow=2U Interrupt Enable flag for Overflow=128U |
Parameters out | NA | |
Return Value | Std_ReturnType | E_OK: Interrupt status clears E_NOT_OK: Interrupt status clear failed |
The driver can have unexpected behavior and loss of functionality if unsupported values are passed into configurator or unsupported combinations are used. Below is a list of such constraints.
The Driver does not register any interrupt service routine(ISR), it’s expected that consumer of this driver registers the required interrupt handler.
The interrupt number associated with instance of the Fls is detailed in TRM. Please refer FlsApp_InterruptConfig() in fls_app test application for reference.
Please note that interrupt implementation is only available when running with INDAC mode. BlankCheck and Compare APIs are not supported with interrupt mode.
The driver doesn't configure the functional clock and power for the Fls modules. It's expected that secondary boot loader(SBL) power-up the required modules. Please refer SBL documentation.
To test FLS capability of executing a program from flash, as well as write/erase to flash, fls_app_xip can used. Below are some important points to note.
There PHY algorthm used in J7200 and J721E is based on calibration algorithm. So, the Phy tune data vector must first be flashed into the last sector of flash memory, and then during first read operation, Phy tune will be calibrated.
The example application can be used as reference for this.
Some restrictions that Fls driver has right now with respect to the SoC:
Current FLS driver uses OSPI protocol and supports the two NOR Flash devices for J721E and J7200 (MT35XU512ABA1G12 S28HS512T).
If variation to the supported features are needed, user will need to take care to modify the driver to accommodate changes.
Please follow steps detailed in section (Build) to build library or example. Please note that OSPI Boot mode is not applicable for Fls module.
The below Fls Test Applications are available:
Please follow steps detailed in section (Build) to build example
Poll Mode - Storage Mode
Test Applications fls_app_dac and fls_app_indac will run as packaged, just build and the executable will be generated.
Interrupt Mode - Storage Mode
To test interrupt based INDAC storage mode using fls_app, enable interrupts by changing element "FLS_USE_INTERRUPTS" in Fls_Cfg.h file to "STD_ON" (use Fls_Cfg_Intr_Sample.h as reference). Then build fls_app and run.
XIP Mode
To test XIP read mode, follow below steps:
Install Uniflash 6.1.0 from http://www.ti.com/tool/UNIFLASH
For using OSPI the SW3 switch setting should be : 0XXX_XXXX_XX
Specific SW setting for different boot modes-
Mode | Switch Settings |
---|---|
UART | SW8: 0000_0000, SW9: 0111_0000 |
OSPI (J721E) | SW8: 0000_0000, SW9: 0100_0000 |
OSPI (J7200) | SW8: 1000_0010, SW9: 0011_0000 |
Please refer to the SoC user manual for other SoCs.
This implementation depends on the DET in order to report development errors and can be turned OFF. Refer section (Development Error Reporting) for detailed error codes.
This implementation requires one level of exclusive access to guard critical sections. Invokes SchM_Enter_Fls_FLS_EXCLUSIVE_AREA_0 (), SchM_Exit_Fls_FLS_EXCLUSIVE_AREA_0 () to enter critical section and exit.
In the example implementation (File Structure SchM_Fls.c) , all the interrupts on CPU are disabled. However, disabling of the enabled Fls interrupt should suffice.
This implementation depends on MemIf module and uses its imported types such as MemIf_JobResultType, MemIf_ModeType and MemIf_StatusType.
This implementation depends on Fee module for callback notification to notify the module environment about job end and job error.
Development errors are reported to the DET using the service Det_ReportError(), when enabled. The driver interface (Fls.h) lists the SID.
Type of Error | Related Error code | Value (Hex) |
API service called with wrong parameter | FLS_E_PARAM_CONFIG | 0x01 |
API service called with wrong parameter | FLS_E_PARAM_ADDRESS | 0x02 |
API service called with wrong parameter | FLS_E_PARAM_LENGTH | 0x03 |
API service called with wrong parameter | FLS_E_PARAM_DATA | 0x04 |
API service used without module initialization | FLS_E_UNINIT | 0x05 |
API called when module is busy | FLS_E_BUSY | 0x06 |
API called with a Null Pointer | FLS_E_PARAM_POINTER | 0x0A |
Transient errors are reported to the DET using the service Det_reportDetTransientFault(). The driver interface (Fls.h) lists the SID.
Type of Error | Related Error code | Value (Hex) |
Flash Erase Failed in HW | FLS_E_ERASE_FAILED | 0x01 |
Flash Write Failed in HW | FLS_E_WRITE_FAILED | 0x02 |
Flash Read Failed in HW | FLS_E_READ_FAILED | 0x03 |
Flash Compare Failed in HW | FLS_E_COMPARE_FAILED | 0x04 |
Expected HW ID not matched | FLS_E_UNEXPECTED_FLASH_ID | 0x05 |
The AUTOSAR BSW Flash Driver specification details the APIs required for Flash Driver. Please refer to (Refer to Design Document provided in CSP) for detailed API description.
Refer API Documentation for details
The example application demonstrates use of Fls module, the list below identifies key steps performed the example. The configuration file is present at (File Structure).
Polled Storage Mode (fls_app_dac and fls_app_indac)
XIP Mode (fls_app_xip)
Interrupt Storage Mode (fls_app)
Performance Measurements
FLS_APP_DAC: ------------------FLS Sample Application - STARTS !!! ------------------ FLS_APP_DAC: Running on J7 ES FLS_APP_DAC: FLS spi_test Initiating and Starting. FLS_APP_DAC: Variant - Pre Compile being used !!! FLS_APP_DAC: Configuring Clocks. FLS_APP_DAC: Clock Configured at 166666666Hz FLS MCAL Version Info --------------------- Vendor ID : 44 Module ID : 92 SW Major Version : 1 SW Minor Version : 2 SW Patch Version : 1 FLS_APP_DAC: DATA SIZE TEST is 0x100000 FLS_APP_DAC: Offset is 0x0 FLS_APP_DAC: Writing PHY Tune Data to last sector in memory FLS_APP_DAC: Erasing FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Blank Checking FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Writing FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Comparing FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Writing PHY Tune Data complete FLS_APP_DAC: Erasing FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Blank Checking FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Writing FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Write 1048576 bytes at transfer rate 650 Kbps FLS_APP_DAC: Reading FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Read 1048576 bytes at transfer rate 65811 Kbps FLS_APP_DAC: Comparing FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Reading FLS_APP_DAC: Job Processing in Progress. FLS_APP_DAC: Job Ends: SUCCESS FLS_APP_DAC: Read 1048576 bytes at transfer rate 68202 Kbps FLS_APP_DAC: DONE!
FLS_APP_INDAC: ------------------FLS Sample Application - STARTS !!! ------------------ FLS_APP_INDAC: FLS spi_test Initiating and Starting. FLS_APP_INDAC: Variant - Pre Compile being used !!! FLS_APP_INDAC: Configuring Clocks. FLS_APP_INDAC: Clock Configured at 166666666Hz FLS MCAL Version Info --------------------- Vendor ID : 44 Module ID : 92 SW Major Version : 1 SW Minor Version : 2 SW Patch Version : 1 FLS_APP_INDAC: DATA SIZE TEST is 0x100000 FLS_APP_INDAC: Offset is 0x0 FLS_APP_INDAC: Erasing FLS_APP_INDAC: Job Processing in Progress. FLS_APP_INDAC: Job Ends: SUCCESS FLS_APP_INDAC: Blank Checking FLS_APP_INDAC: Job Processing in Progress. FLS_APP_INDAC: Job Ends: SUCCESS FLS_APP_INDAC: Writing FLS_APP_INDAC: Job Processing in Progress. FLS_APP_INDAC: Job Ends: SUCCESS FLS_APP_INDAC: Write 1048576 bytes at transfer rate 3631 Kbps FLS_APP_INDAC: Reading FLS_APP_INDAC: Job Processing in Progress. FLS_APP_INDAC: Job Ends: SUCCESS FLS_APP_INDAC: Read 1048576 bytes at transfer rate 43728 Kbps FLS_APP_INDAC: Comparing FLS_APP_INDAC: Job Processing in Progress. FLS_APP_INDAC: Job Ends: SUCCESS FLS_APP_INDAC: Changing mode to DAC FLS_APP_INDAC: DONE!
FLS_APP_XIP: ------------------FLS Sample Application - STARTS !!! ------------------ FLS_APP_XIP: Running on J7 ES FLS_APP_XIP: FLS spi_test Initiating and Starting. FLS_APP_XIP: Variant - Pre Compile being used !!! FLS_APP_XIP: Configuring Clocks. FLS_APP_XIP: Clock Configured at 166666666Hz FLS MCAL Version Info --------------------- Vendor ID : 44 Module ID : 92 SW Major Version : 1 SW Minor Version : 2 SW Patch Version : 1 FLS_APP_XIP: DATA SIZE TEST is 0x1000 FLS_APP_XIP: Offset is 0x0 FLS_APP_XIP: Erasing FLS_APP_XIP: Job Processing in Progress. FLS_APP_XIP: Job Ends: SUCCESS FLS_APP_XIP: Blank Checking FLS_APP_XIP: Job Processing in Progress. FLS_APP_XIP: Job Ends: SUCCESS FLS_APP_XIP: Writing FLS_APP_XIP: Job Processing in Progress. FLS_APP_XIP: Job Ends: SUCCESS FLS_APP_XIP: Calling XIP app MCU1_0 running MCU1_0 reports: All tests have passed FLS_APP_XIP: Returning from XIP app, returned value is 0xFEEDFACE FLS_APP_XIP: Reading FLS_APP_XIP: Job Processing in Progress. FLS_APP_XIP: Job Ends: SUCCESS FLS_APP_XIP: Comparing FLS_APP_XIP: Job Processing in Progress. FLS_APP_XIP: Job Ends: SUCCESS FLS_APP_XIP: DONE!
Revision | Date | Author | Description | Status |
---|---|---|---|---|
0.1 | 26 May 2020 | Nikki Shah | First version | Pending Review |
0.1 | 5 June 2020 | Nikki Shah | Addressed Review Comments | Approved |
0.2 | 2 Nov 2020 | Nikki Shah | MCUSW 01_03_00 Release | Pending |
0.3 | 1 Mar 2021 | Nikki Shah | Adding information for driver adaption | Approved |
0.4 | 26 Jun 2023 | Nikki Shah | Updated based on 1.06 release | Approved |