MCUSW
Mcu User Guide

Introduction

This document details AUTOSAR BSW MCU module implementation

  • Supported AUTOSAR Release : 4.3.1
  • Supported Configuration Variants : Pre-Compile & Post-Build
  • Vendor ID : MCU_VENDOR_ID (44)
  • Module ID : MCU_MODULE_ID (101)

The MCU module initializes, configures and controls the internal hardware to realize MCU driver as detailed in AUTOSAR BSW MCU Driver Specification. The MCU functionality is realized through the CLOCK IP available on the device. Following section highlights key aspects of this implementation, which would be of interest to an integrator.


Mcu Driver Architecture/Design

Please refer the MCU design document which is released as part of CSP.


Functional Description

The MCU driver provides MCU services for Clock and RAM initialization. In the MCU configuration set, the MCU specific settings for the Clock (i.e. PLL setting) and RAM (i.e. section base address and size) shall be configured.

The Mcu driver provides the following features:

  • The MCU module shall provide a service for software triggering of a reset.
  • The MCU module shall provide services to get the reset reason of the last reset.
  • The MCU module shall provide service to clear the reset reason of the last reset.
  • Mcu shall provide a service to enable and set the MCU clock. (Super Set Peripherals - ADC, GPIO, TIMER, RTI, MCSPI, ECAP, OSPI, EPWM, CDD IPC ,MCAN)

DMSC

  • DMSC(Device Management Security Controller) hosts the DMSC firmware.
  • Any request for setting up clock frequencies for a peripheral should come to DMSC via scilient.
  • DMSC firmware should be loaded by the SBL.

SCI-CLIENT

Sciclient(System Controller Interface Client) APIs are used by application to request DMSC for clock request.

Clocks

The Clocks and PLLs are expected to be controlled and programmed by DMSC by using the sciclient APIs.

Mapping of Clocks to CPU/Compute cores

  • To be configured by DMSC Firmware. The request is raised by SBL via SciClient.
  • Not expected to change until next power cycle

Mapping of Clocks to Peripherals

  • Configured by DMSC Firmware.
  • Request raised by a SCI Client API on local core.
  • Typically done at start up.
  • Not expected to change until next power cycle.

The example application demonstrates configuring clock sources for CLOCK module.

Back To Top


Configuration

The Mcu Driver implementation supports multiple configuration variants (refer section Introduction), the driver expects generated Mcu_Cfg.h to be present as (File Structure). Please refer (Build) to specify path to generated configuration. The associated Mcu configuration generated files Mcu_Cfg.c and Mcu_PBcfg.c to be present as shown (File Structure)

The following section details on the un-supported/restricted features and additional features added.

Back To Top


Variance / Deviation from the specification

APIs with restricted functionality

APIs (listed below) are dummy.

  • Mcu_InitRamSection
  • Mcu_DistributePllClock
  • Mcu_GetPllStatus
  • Mcu_GetRamState

APIs (listed below) are implemented with restrictions.

Note- McuRamSectionWriteSize is not supported as Mcu_InitRamSection() is a dummy API.

Back To Top


Implementation Specific Configurations

This driver implementation introduces below listed configurable options

Back To Top


McuCBKFunction

Name Mcu_CBK_Function
Description This Callback function will be defined in the application to perform the functionality. The User has to define this function.
Container Name McuModuleConfiguration
Type Enumeration
Value Configuration Class VARIANT-PRE-COMPILE & VARIANT-POST-BUILD

Back To Top


McuDeviceVariant

Name McuDeviceVariant
Description Used to specific family of devices, the variant of the device being used will belong one or more family of devices. Please refer (Supported Devices) to determine the family of device.
Container Name McuGeneral
Type Enumeration
Range TDA4x, AM62x, AM62Ax, AM62Px etc… (new family of devices could be added in future)
Value Configuration Class VARIANT-PRE-COMPILE

Back To Top


McuResetMode

Name McuResetMode
Description This shall allow the user to select between or WARM/ COLD reset.
Container Name McuModuleConfiguration
Type Enumeration
Range WARM & COLD
Value Configuration Class VARIANT-PRE-COMPILE & VARIANT-POST-BUILD

Back To Top


Domain

Name Domain
Description User can select the Domain of a peripheral.
Container Name McuClockSettingConfig
Type Enumeration
Range MCU , MAIN & WKUP
Value Configuration Class VARIANT-PRE-COMPILE & VARIANT-POST-BUILD

Back To Top


McuClockModuleId

Name McuClockModuleId
Description User can select the module id for peripheral.
Container Name McuClockSettingConfig
Type Enumeration
Value Configuration Class VARIANT-PRE-COMPILE & VARIANT-POST-BUILD

Back To Top


McuClockSourceId

Name McuClockSourceId
Description User can select the clock source id for a peripheral.
Container Name McuClockSettingConfig
Type Enumeration
Value Configuration Class VARIANT-PRE-COMPILE & VARIANT-POST-BUILD

Back To Top


McuClockInitializationConfigFlag

Name McuClockInitializationConfigFlag
Description User can switch the configuration flag ON/OFF.
Container Name McuClockSettingConfig
Type Enumeration
Value Configuration Class VARIANT-PRE-COMPILE & VARIANT-POST-BUILD

Back To Top


Build and Running the Example Application

Please follow steps detailed in section (Build) to build library or example

Back To Top


Steps to run example application

Please follow steps detailed in section (Build) to build example

Back To Top


Memory Mapping

Various objects of this implementation (e.g. variables, functions, constants) are defined under different sections. The linker command file at (Examples Linker File (Select memory location to hold example binary)) defines separate section for these objects. When the driver is integrated, its expected that these sections are created and placed in appropriate memory locations. (Locations of these objects depend on the system design and performance needs)

Section MCU_CODE MCU_VAR_INIT MCU_VAR_NOINIT MCU_CONST MCU_CONFIG
MCU_START_SEC_VAR_INIT_UNSPECIFIED (.data) USED
MCU_DATA_INIT_32_SECTION USED
MCU_TEXT_SECTION USED
MCU_DATA_NO_INIT_UNSPECIFIED_SECTION USED
MCU_CONST_32_SECTION USED
MCU_ISR_TEXT_SECTION USED
MCU_CONFIG_SECTION USED

Back To Top


Cache

This driver implementation has been validated with cache enabled. For optimal performance it’s recommended to place (Memory Mapping) sections in cache enabled memory area.

Back To Top


Dependencies on SW Modules


DET

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.

Back To Top


SchM

This implementation requires 1 level of exclusive access to guard critical sections. Invokes SchM_Enter_Mcu_MCU_EXCLUSIVE_AREA_0 (), SchM_Exit_Mcu_MCU_EXCLUSIVE_AREA_0 () to enter critical section and exit.

Back To Top


File Structure

mcu_file_structure.png
Detailed Directory Structure
  1. Driver implemented by : Mcu.h, Mcu.c, Mcu_Priv.c and Mcu_Priv.h

Example Application :

  • There is one example application provided: mcu_app. Please refer to below directory structures.
  • Config files for mcu_app are located along with other applications' demo configs at /workarea/mcusw/mcal_drv/mcal/example/Mcu/mcu_app/Mcu_Demo_Cfg.
  • Mcu_Cfg.h: Contains static configuration of this module.
  • Mcu_Cfg.c: Shall implement the generated configuration for pre-compile variant.
  • Mcu_PBcfg.c: Shall implement the generated configuration for post-build variant
  • McuApp_Startup.c and McuApp_Startup.h: Shall implement the start-up code sequence and register interrupts.
  • McuApp.c and McuApp.h: Shall implement the example application that demonstrates the use of the driver

Back To Top


Error Handling


Development Error Reporting

Development errors are reported to the DET using the service Det_ReportError(), when enabled. The driver interface (Mcu.h File Structure) lists the SID.

Back To Top


Error codes

Type of Error Related Error code Value (Hex)
API service called with wrong configuration parameter MCU_E_PARAM_CONFIG 0x0A
API service used with wrong clock value MCU_E_PARAM_CLOCK 0x0B
API service used with wrong mode MCU_E_PARAM_MODE 0x0C
API service called with invalid/wrong RAM section MCU_E_PARAM_RAMSECTION 0x0D
API service is called while PLL is not locked MCU_E_PLL_NOT_LOCKED 0x0E
Mcu Driver API service is called before initialization of MCU Driver MCU_E_UNINIT 0x0F
API service is called with NULL/Wrong pointer MCU_E_PARAM_POINTER 0x10
Initialization of the MCU Driver Failed MCU_E_INIT_FAILED 0x11

Back To Top


API Description

The AUTOSAR BSW MCU Driver specification details the APIs required for Mcu Driver. Please refer to ( Please refer to CSP for Design Document ) for detailed API description. APIs which are not supported or are implemented with restriction , please refer to (Variance / Deviation from the specification).

Refer API Documentation for details

Back To Top


Example Application

McuApp

The example application demonstrate use of CLOCK based Mcu module, the list below identifies key steps performed the example. The configuration file is present at (File Structure)

To run the mcu_app:

Please refer to section (Build and Running the Example Application)

  • McuApp_Startup ()
    • Mcu_CBK_Function is called with the configurations.
      • Calls Sciclient APIs for Clock requests and setting frequency
  • Mcu_Init ()
    • Called with module configuration as configured in the tresos tool
  • Mcu_InitClock ()
    • Called with clocksetting as configured in the tresos tool
  • Mcu_GetResetReason ()
    • Fetches the reset reason
  • Mcu_ClearResetReason ()
  • Mcu_PerformReset ()
    • Performs the reset according to the reset type configured in the tresos tool.
    • Warm reset triggers whole device(SoC) reset
  • Checks for error status, stack corruption and prints result
NOTE: For AM62AX, AM62PX and J722S to get the log, keep breakpoint at Mcu_PerformReset() and run. Once log is taken execute Mcu_Perform_Reset() which resets the entire SOC.

Back To Top


Example Log

Logs will vary per device.

    McuApp: Sample Application - STARTS !!!

    MCU MCAL Version Info
    ---------------------
    Vendor ID           : 44
    Module ID           : 101
    SW Major Version    : 9
    SW Minor Version    : 0
    SW Patch Version    : 0

    Module clock request successful !!!
    Module clock frequency set. Module = 172 , Freq = 80000000 !!!
    Module clock request successful !!!
    Module clock frequency set. Module = 173 , Freq = 80000000 !!!
    Module clock request successful !!!
    Module clock frequency set. Module = 252 , Freq = 125000000 !!!
    MCU Reset Reason:4 
    MCU Reset Reason Raw Value:0x100000 
    MCU Stack Usage: 2860 bytes
    MCU_APP: MCU Test Passed!!!

Back To Top


Clock Source Reference

Clock source ID should be selected as per the below documents. Input clock/Input muxed clock to be selected for the respective peripheral.

Back To Top


References

Back To Top