The platform library folder contains the following:
Source code files relevant for software support for the components specified in the platform
Makefiles for building the project library archive (<platform_name>.a) file
Makefiles that are referenced by the application makefile. These makefiles provide the following information to the application makefile: Compiler flags that are activated when the following components
are selected: hard multiplier, barrel shifter, sign-extend unit, and divider. These automatically activated compiler flags prevent you from having to manually set the appropriate compiler flags based on the CPU configuration.
MANAGED BUILD PROCESSAND DIRECTORY STRUCTURE : LatticeMico C/C++ Project Build Flow
As shown in Figure 118, the platform library folder (PlatformE in the example) contains a subfolder named debug, the name of the build configuration used for this example. This folder contains the platform library contents, source, makefiles, and linker scripts.
The contents of the platform library folder are dynamically created and populated and should not be modified. The platform library folder and its associated contents are generated when you build the project for the first time.
The files and subfolders in the platform library folder are as follows.
The build configuration folder (or debug folder in the example) contains all the files specific to that particular build configuration. As you would expect, these files can differ between build configurations that you might create in your project.
Figure 118: Platform Library Directory Structure
platform E debug drivers.mk inherited_settings. mk linker.ld linker_settings.mk makefile platform_rules.mk settings.xml *.c/*.s *.h ddinit.c ddstructs.c ddstructs.h crtoram.s
Platform library directory
Build-configuration platform library output directory
Makefile that identifies peripheral makefiles for library build
Build settings inherited from application build settings
Makefile identifying linker script to use Makefile for building platform library Platform build variables inherited from application settings
Default linker script for this platform
Platform library build-settings file Platform-specific driver sources Platform-specific driver header files
Driver initialization source file Peripheral instance-specific data structures
Peripheral-specific data structures LatticeMico boot/startup assembly source file
MANAGED BUILD PROCESSAND DIRECTORY STRUCTURE : LatticeMico C/C++ Project Build Flow
The platform-specific component device driver source and header files are either copied from the components directories in the installation path or are automatically generated. The copied files, based on the .msb file, are described in the “Platform Library-Generated Source Files” on page 155. The DDinit.c file is an example of a file that is automatically generated. All platform library sources become part of the application project, aiding debug and source visibility.
The project settings .xml file contains information about the parent project and its settings, as well as information on the platform referenced by the parent project. It is used to derive the makefiles for the platform library. The default linker script, linker.ld, is the default linker script for the
particular platform or project combination and can be used as a starting point for creating a custom linker script file. The linker sections identified in this script are derived from the platform settings (user.pref) file.
The makefiles are necessary for building the platform library, as well as for providing information to the application build. These makefiles facilitate building the application through the LatticeMico C/C++ SPE and the LatticeMico Cygwin shell. The platform library can be built independently of the application, using the LatticeMico Cygwin shell once the contents are populated. The following points provide a summary of the relevant makefiles:
makefile is the platform library makefile. It contains the commands that define the targets, rules, and dependencies that tell the make utility how to construct the software build from its sources.
drivers.mk includes relevant component makefiles. These component makefiles identify the sources and paths for the corresponding component device drivers. This makefile is referenced only by the platform library makefile. It is derived from information present in the .msb file.
inherited_settings.mk contains compiler settings derived from the build configuration. These settings can be changed in the user interface, as shown in Figure 12 on page 27. In addition to compiler settings, this file also contains the location for depositing the built platform library archive (.a) file and its associated compiled or assembled object files. This file is referenced only by the platform library makefile.
linker_settings.mk identifies which linker script to use, that is, either the default or a user-defined makefile. This file is referenced by the application makefile and is not used by the platform library makefile. It is derived from information present in the platform settings (user.pref) file.
platform_rules.mk contains compiler switches. It is referenced by the application makefile, as well as the platform library makefile. These compiler switches are extracted according to the microprocessor configuration information contained in the .msb file.
MANAGED BUILD PROCESSAND DIRECTORY STRUCTURE : LatticeMico C/C++ Project Build Flow
If you create a new build configuration, a new build configuration subfolder is created in the platform library folder.
In Figure 118 on page 152, a newly generated build configuration folder would be placed under the PlatformE folder at the same level as the debug build configuration folder. This new build configuration folder would hold the files specific to that particular build, its makefiles, and linker scripts. All the platform library source files are held in the platform library folder. This single copy of the source is used across all defined build configurations.
Perl scripts invoked from makefiles, included by the application build makefile, generate the contents of the platform library folder. Figure 117 on page 150 shows an outline of the application output folder contents.