Porting ERIKA: writing the makefiles and first compilation
From ErikaWiki
Please notice that this page has been created while porting Erika to the Cosmic S12 environment. Several file names reflect this.
Contents |
Important notice
Erika makefiles are in continuous evolution. If you are looking for example makefiles to start with, your best option probably is the Freescale PPC e200 (MPC 56xx) architecture. If the compiler toolchain is based on Cygwin, Lattice Mico32 is a better start.
See the page Erika Makefiles for an overview of the compilation process.
Reference test
examples/s12xs/porting_examples/monostack/EEtest0
Description
- The idea is that we have to replicate the compiling structure which will be then used inside RT-Druid, to test a fake example to demonstrate that the compile toolchain is integrated into the makefiles
- inside EEtest0, put the minimal set of files needed to compile an application
- for s12xs, the files are:
- conf.oil - a fake OIL file (to be removed)
- crtsx.S - the microcontroller boot code
- hs12xsregs.h - the microcontroller registers as provided by the cosmic compiler
- main.c - the test application
- mc9s12xs128.lkf - the linker script
- vector_s12x.c - the interrupt vector
- Then, we replicate the compilation structure generated by RT-Druid.
- RT-Druid generates a Debug directory. For that reason, we added a Debug directory inside the EEtest0 directory
- inside the Debug directory, we placed a makefile similar to the one which will be generated by RT-Druid
- (the basic structure is inspired to the Microchip PIC30 port)
- Then, the following makefiles have to be adjusted to consider the compiler:
- ee/pkg/cfg/rules.mk - the collector for the makefile rules
- ee/pkg/cfg/compiler.mk - the collector for the compiler
- ee/pkg/cfg/arch/cc_s12x_cosmic.mk - the compiler commands
- ee/pkg/cfg/arch/rules_freescale_s12x_cosmic.mk - the compilation rules for the cosmic compiler
- Then, we replicated the CPU layer in the HAL with the following points:
- we copied the ee/pkg/cpu/pic30 directory content inside the new directory ee/pkg/cpu/cosmic_hs12xs
- we changed all the occurrences of the string "pic30" with the string "h12xs"
- we commented out all the assembler directives and assembler instructions which were PIC30 specific
- Please notice that in ee/pkg/cpu/common there are several files that are architecture-neutral and that can be used as building blocks for HAL implementations. See the Mico32 porting of Erika for an example of use (it is currently the only version that uses them) and the page Common files for the HAL for more information.
- Then, the following include files have to be modified
- ee/pkg/ee.h and ee/pkg/ee_internal.h - these files are collectors and the new architecture has been added
- Finally, we created inside the EEtest0 a C file with a main() function. That function simply is an infinite cycle for(;;). Please note that this small application is not meant to be executed but only to test that the main system components can be linked without problems resulting in an executable fully linked.
Expected output
When everything is done in the right way, the following commands should work:
- open a Cygwin shell
- cd into the Debug directory
- the commands make clean and make all should work correctly producing an executable inside the Debug directory.