PSoC 6 Peripheral Driver Library
Startup (System Configuration Files)

General Description

Provides device startup, system configuration, and linker script files.

The system startup provides the followings features:

Configuration Considerations

Device Memory Definition

The flash and RAM allocation for each CPU is defined by the linker scripts. For dual-core devices, the physical flash and RAM memory is shared between the CPU cores. 2 KB of RAM (allocated at the end of RAM) are reserved for system use. For Single-Core devices the system reserves additional 80 bytes of RAM. Using the reserved memory area for other purposes will lead to unexpected behavior.

Note
The linker files provided with the PDL are generic and handle all common use cases. Your project may not use every section defined in the linker files. In that case you may see warnings during the build process. To eliminate build warnings in your project, you can simply comment out or remove the relevant code in the linker file.

ARM GCC
The flash and RAM sections for the CPU are defined in the linker files: 'xx_yy.ld', where 'xx' is the device group, and 'yy' is the target CPU; for example, 'cy8c6xx7_cm0plus.ld' and 'cy8c6xx7_cm4_dual.ld'.

Note
If the start of the Cortex-M4 application image is changed, the value of the of the CY_CORTEX_M4_APPL_ADDR should also be changed. The CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the Cy_SysEnableCM4() function call.

Change the flash and RAM sizes by editing the macros value in the linker files for both CPUs:

Change the value of the CY_CORTEX_M4_APPL_ADDR macro to the rom ORIGIN's value in the 'xx_cm4_dual.ld' file, where 'xx' is the device group. Do this by either:

ARM MDK
The flash and RAM sections for the CPU are defined in the linker files: 'xx_yy.scat', where 'xx' is the device group, and 'yy' is the target CPU; for example, 'cy8c6xx7_cm0plus.scat' and 'cy8c6xx7_cm4_dual.scat'.

Note
If the start of the Cortex-M4 application image is changed, the value of the of the CY_CORTEX_M4_APPL_ADDR should also be changed. The CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the Cy_SysEnableCM4() function call.
The linker files provided with the PDL are generic and handle all common use cases. Your project may not use every section defined in the linker files. In that case you may see the warnings during the build process: L6314W (no section matches pattern) and/or L6329W (pattern only matches removed unused sections). In your project, you can suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to the linker. You can also comment out or remove the relevant code in the linker file.

Change the flash and RAM sizes by editing the macros value in the linker files for both CPUs:

Change the value of the CY_CORTEX_M4_APPL_ADDR macro to the FLASH_START value in the 'xx_cm4_dual.scat' file, where 'xx' is the device group. Do this by either:

IAR
The flash and RAM sections for the CPU are defined in the linker files: 'xx_yy.icf', where 'xx' is the device group, and 'yy' is the target CPU; for example, 'cy8c6xx7_cm0plus.icf' and 'cy8c6xx7_cm4_dual.icf'.

Note
If the start of the Cortex-M4 application image is changed, the value of the of the CY_CORTEX_M4_APPL_ADDR should also be changed. The CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the Cy_SysEnableCM4() function call.

Change the flash and RAM sizes by editing the macros value in the linker files for both CPUs:

Change the value of the CY_CORTEX_M4_APPL_ADDR macro to the ICFEDIT_region_IROM1_start value in the 'xx_cm4_dual.icf' file, where 'xx' is the device group. Do this by either:

Device Initialization

After a power-on-reset (POR), the boot process is handled by the boot code from the on-chip ROM that is always executed by the Cortex-M0+ core. The boot code passes the control to the Cortex-M0+ startup code located in flash.

Dual-Core Devices

The Cortex-M0+ startup code performs the device initialization by a call to SystemInit() and then calls the main() function. The Cortex-M4 core is disabled by default. Enable the core using the Cy_SysEnableCM4() function. See Cortex-M4 Control for more details.

Note
Startup code executes SystemInit() function for the both Cortex-M0+ and Cortex-M4 cores. The function has a separate implementation on each core. Both function implementations unlock and disable the WDT. Therefore enable the WDT after both cores have been initialized.

Single-Core Devices

The Cortex-M0+ core is not user-accessible on these devices. In this case the Flash Boot handles setup of the CM0+ core and starts the Cortex-M4 core.

Heap and Stack Configuration

There are two ways to adjust heap and stack configurations:

  1. Editing source code files
  2. Specifying via command line

By default, the stack size is set to 0x00001000 and the heap size is set to 0x00000400.

ARM GCC

ARM MDK

IAR

Merging CM0+ and CM4 Executables

The CM0+ project and linker script build the CM0+ application image. Similarly, the CM4 linker script builds the CM4 application image. Each specifies locations, sizes, and contents of sections in memory. See Device Memory Definition for the symbols and default values.

The cymcuelftool is invoked by a post-build command. The precise project setting is IDE-specific.

The cymcuelftool combines the two executables. The tool examines the executables to ensure that memory regions either do not overlap, or contain identical bytes (shared). If there are no problems, it creates a new ELF file with the merged image, without changing any of the addresses or data.

Default Interrupt Handlers Definition

The default interrupt handler functions are defined as weak functions to a dummy handler in the startup file. The naming convention for the interrupt handler names is <interrupt_name>_IRQHandler. A default interrupt handler can be overwritten in user code by defining the handler function using the same name. For example:

void scb_0_interrupt_IRQHandler(void)
{
...
}

Vectors Table Copy from Flash to RAM

This process uses memory sections defined in the linker script. The startup code actually defines the contents of the vector table and performs the copy.

ARM GCC

The linker script file is 'xx_yy.ld', where 'xx' is the device family, and 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4_dual.ld. It defines sections and locations in memory.
Copy interrupt vectors from flash to RAM:
From:

LONG (__Vectors)

To:

LONG (__ram_vectors_start__)

Size:

LONG (__Vectors_End - __Vectors)

The vector table address (and the vector table itself) are defined in the assembler startup files (e.g. startup_psoc6_01_cm0plus.S and startup_psoc6_01_cm4.S). The code in these files copies the vector table from Flash to RAM.

ARM MDK

The linker script file is 'xx_yy.scat', where 'xx' is the device family, and 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.scat and cy8c6xx7_cm4_dual.scat. The linker script specifies that the vector table (RESET_RAM) shall be first in the RAM section.
RESET_RAM represents the vector table. It is defined in the assembler startup files (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s). The code in these files copies the vector table from Flash to RAM.

IAR

The linker script file is 'xx_yy.icf', where 'xx' is the device family, and 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.icf and cy8c6xx7_cm4_dual.icf. This file defines the .intvec_ram section and its location.

place at start of IRAM1_region { readwrite section .intvec_ram};

The vector table address (and the vector table itself) are defined in the assembler startup files (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s). The code in these files copies the vector table from Flash to RAM.

More Information

Refer to the PDL User Guide for the more details.

MISRA Compliance

MISRA Rule Rule Class (Required/Advisory) Rule Description Description of Deviation(s)
2.3 R The character sequence // shall not be used within a comment. The comments provide a useful WEB link to the documentation.

Changelog

Version Changes Reason for Change
2.60 Updated linker scripts. Provided support for new devices, updated usage of CM0p prebuilt image.
2.50 Updated assembler files, C files, linker scripts. Dynamic allocated HEAP size for Arm Compiler 6, IAR 8.
2.40 Updated assembler files, C files, linker scripts. Added Arm Compiler 6 support.
2.30 Added assembler files, linker scripts for Mbed OS. Added Arm Mbed OS embedded operating system support.
Updated linker scripts to extend the Flash and Ram memories size available for the CM4 core. Enhanced PDL usability.
2.20 Moved the Cy_IPC_SystemSemaInit(), Cy_IPC_SystemPipeInit() functions implementation from IPC to Startup. Changed the IPC driver configuration method from compile time to run time.
2.10 Added constructor attribute to SystemInit() function declaration for ARM MDK compiler.
Removed $Sub$$main symbol for ARM MDK compiler.
uVision Debugger support.
Updated description of the Startup behavior for Single-Core Devices.
Added note about WDT disabling by SystemInit() function.
Documentation improvement.
2.0 Added restoring of FLL registers to the default state in SystemInit() API for single core devices. Single core device support.
Added Normal Access Restrictions, Public Key, TOC part2 and TOC part2 copy to Supervisory flash linker memory regions.
Renamed 'wflash' memory region to 'em_eeprom'.
Linker scripts usability improvement.
Added Cy_IPC_SystemSemaInit(), Cy_IPC_SystemPipeInit(), Cy_Flash_Init() functions call to SystemInit() API. Reserved system resources for internal operations.
Added clearing and releasing of IPC structure #7 (reserved for the Deep-Sleep operations) to SystemInit() API. To avoid deadlocks in case of SW or WDT reset during Deep-Sleep entering.
1.0 Initial version

API Reference

 Macro
 
 Functions
 
 Global Variables