Skip to content

Commit c8235db

Browse files
committed
enrich README.md
1 parent 5eaec36 commit c8235db

File tree

1 file changed

+114
-6
lines changed

1 file changed

+114
-6
lines changed

README.md

Lines changed: 114 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,117 @@
11
# Development Environment for Tricore GCC + ERIKA Enterprise
22

3-
# Setup
3+
## Setup
4+
This repository serves as an aggregator for 3 conceptually different projects, but tightly bound to each other:
5+
1. A containerized cross-compiler for TriCore architecture
6+
2. A flasher for AURIX development boards (WIP)
7+
3. A utility Python package for interacting with both of them (mimicking the Platform IO workflow: build, flash, monitor)
8+
9+
### The easy way
10+
Both the cross-compiler container and the Python package are published "pre-coocked" on an online repository:
11+
- [tricore-dev-env on Docker Hub](https://hub.docker.com/repository/docker/francescomecatti/tricore-dev-env)
12+
- [tricore-cli on PyPI](https://pypi.org/project/tricore-cli/)
13+
14+
Make sure that Python3 and a Docker Engine are installed on your system and run:
15+
```bash
16+
docker pull francescomecatti/tricore-dev-env:1.0
17+
pip3 install tricore-cli
18+
```
19+
20+
You shold now be able to run:
21+
```bash
22+
docker run -it CONTAINER_TAG
23+
```
24+
25+
And, in case it exits:
26+
```bash
27+
docker start -ai CONTAINER_ID
28+
```
29+
to restore it.
30+
31+
This is exactly what `tricorecli SUBCMD DIR` runs under the hood (through the Docker SDK for Python). To mount a **host**'s directory into the container, a **bind mount** is used by the script.
32+
33+
That's all! Move to [Examples - Containerized installation](#containerized-installation) for the build process.
34+
35+
### Manual system-wide installation
36+
First of all, clone this repository:
437
```bash
538
git clone --recurse-submodules --shallow-submodules https://github.com/mc-cat-tty/tricore-dev-env
639
```
740

41+
In order to install the toolchain on your system, the following steps are required:
42+
1. Build _binutils_ for TC target
43+
2. Build GCC for TC traget
44+
3. Build, at least, _libgcc_ for TC target
45+
4. Build _newlib_ for TC target
46+
47+
Apart from the third point, this sequence must be kept in order, since _bintuils_ (`as`, `ar`, `ld`, etc.) are needed by `gcc`; and, in turn, `newlib` requires a fully-functional `gcc` to be bult (plus the linker and the assembler).
48+
49+
The build procedure is automated by _build-toolchain/install.sh_ script. Feel free to tinker around with the build script.
50+
The proposed set of flags make the compilation successfull on both _Darwin/arm64_ and _Linux/amd64_ platforms.
51+
52+
The install directory of the script can be customized with `INSTALL_PATH` environment variable:
53+
```bash
54+
INSTALL_PATH=/home/foo bash build-toolchain/install.sh
55+
```
56+
57+
In case of missing `nproc` in your system, replace `JOBS` variable with a reasonable value; typically 1.5 times the number of cores on your machine.
58+
59+
### Manual containerized installation
60+
First of all, clone this repository:
61+
```bash
62+
git clone --recurse-submodules --shallow-submodules https://github.com/mc-cat-tty/tricore-dev-env
63+
```
64+
65+
Make sure that a Docker Engine is installed on your system and run:
66+
```bash
67+
cd tricore-dev-env
68+
docker build -t CONTAINER_TAG .
69+
```
70+
71+
The `build` subcommand requires a _Dockerfile_ to be present in the build directory. This file instructs the docker client about the building steps.
72+
73+
You might want to avoid the copy of some source files during the build process - for instance, they are not ready to be embedded into the container; _.dockerignore_ serves exactly this purpose.
74+
75+
Both the aforementioned files are located in the top-directory of this project, so that you can build up your own on top of them.
76+
77+
You shold now be able to run:
78+
```bash
79+
docker run -it CONTAINER_TAG
80+
```
81+
82+
And, in case it exits:
83+
```bash
84+
docker start -ai CONTAINER_ID
85+
```
86+
to restore it.
87+
888
## Examples
989
Please, note that the linker script _.lsl_ file is not the default one provided by [Infineon Code Examples](https://github.com/Infineon/AURIX_code_examples). It has been downloaded from this [URL](https://nextcloud.hightec-rt.com/index.php/s/BG72PCMP7jrEcki), as suggested by [AURIX Development Studio - Guide for HighTec Toolchains](https://free-entry-toolchain.hightec-rt.com/aurix_dev_studio_with_hightec_gcc.pdf).
1090

1191
### How to build and example?
92+
#### Containerized Installation
93+
Make sure that the dependencies [here](#the-easy-way) are installed - and running, in the case of the Docker Engine - on your system.
94+
95+
Pick and example, for instance _Blinky_LED\_1\_KIT\_TC397\_TFT_:
96+
```bash
97+
cd examples/Blinky_LED_1_KIT_TC397_TFT
98+
tricorecli build .
99+
```
100+
101+
If the build process is successful, a new _build_ directory should appear in the project's top folder. Inside _build_ you can find two **compilation artifacts**:
102+
- _Blinky_
103+
- _Blinky.hex_
104+
105+
_Blinky.hex_ is the format expected by Infineon MemTool.
106+
107+
#### System-wide installation
12108
If you have not already exported binutils and gcc paths into PATH env var, do the following:
13109
```bash
14-
export PATH=/Users/francesco/Downloads/binutils-tc/install/bin/:$PATH
15-
export PATH=/Users/francesco/Downloads/gcc-tc/install/bin/:$PATH
110+
export PATH=/your/path/binutils-tc/install/bin/:$PATH
111+
export PATH=your/path/gcc-tc/install/bin/:$PATH
16112
```
17113

18-
Be aware that your path may change. It is tightly bound to the configuration of your environment.
114+
Be aware that your path may change. It depends on the configuration of your environment.
19115

20116
```bash
21117
cd examples/Blinky_LED_1_KIT_TC397_TFT
@@ -24,8 +120,20 @@ cd build
24120
cmake --toolchain tricore_toolchain.cmake .. && make -j12
25121
```
26122

27-
_12_ is the number of jobs I decided to pass to `make`; find your own tuning.
123+
_12_ is the number of jobs I decided to pass to `make`; find your own tuning. Usually `1.5 * $(nproc)`.
28124

29125
You should now see the result of the compilation, namely _Blinky_ - for this specific project -, in the _build_ folder: `file Blinky`. If `file` spits out something like `ELF 32-bit [...] Siemens Tricore Embedded Processor`, everything should be ok.
30126

31-
Now let's convert the ELF to the HEX format (if not already done by the build system): `tricore-elf-objcopy -j .text -j .data -O ihex Blinky Blinky.hex`
127+
Now let's convert the ELF to the HEX format (already done by the build system, in the latest version of the project): `tricore-elf-objcopy -j .text -j .data -O ihex Blinky Blinky.hex`.
128+
129+
### Internals
130+
The _CMakeLists.txt_ and _tricore\_toolchain.cmake_ do the trick. Noteworthy directives are:
131+
- `set(CMAKE_C_COMPILER tricore-elf-gcc)` chooses the right cross-compiler. Omitting this leads to the use of the system's compiler (host == build == target), which is not - almost for sure - a compier that supports TriCore architecture as a target.
132+
- `set(CMAKE_SYSROOT /tricore-build-tools/tricore-elf)` sets the compiler _sysroot_, namely the path where libraries (both heaers, under _/include_ and static/dynamic libraries, under _/lib_) like `libc`, `libm`, `crt` (C RunTime), etc. are searched. Read more about it on the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html).
133+
- `project(... LANGUAGES C)` disables C++ language. Enabling C++ raises some errors at the moment.
134+
- `add_compile_definitions(__HIGHTEC__)` defines a macro required by iLLD libraires.
135+
- `add_compiler_options(...) and add_link_options(...)` are described [here](https://free-entry-toolchain.hightec-rt.com/aurix_dev_studio_with_hightec_gcc.pdf). `-mcpu=XXXX` must be coheret with the CPU of your board. Run `tricore-elf-gcc --target-help` to get the complete list of supported CPUs and architectures.
136+
- `include_directories(... /tricore-build-tools/tricore-elf/include)` includes the header files of _newlib_.
137+
138+
Note that `set(CMAKE_SYSROOT /tricore-build-tools/tricore-elf)` and `include_directories(... /tricore-build-tools/tricore-elf/include)` are probably useless in the context of an installation path for GCC, binutils and newlib; but, they are necessary if the installation paths of these tools differ.
139+
In particular, they should point to the install directory of _newlib_.

0 commit comments

Comments
 (0)