Skip to content

Commit 41d2764

Browse files
committed
apollo-kernel: Apllo Kernel for Apollo 1.0 Release
0 parents  commit 41d2764

52,228 files changed

Lines changed: 20927262 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AUTHORS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
| Github account | name |
2+
|---|---|
3+
| apollo-jingaowang | Jingao Wang |
4+
| jmtao | Jiaming Tao |
5+
| bjtulynn | Liming Xia |
6+
| Capri2014 | Qi Luo |
7+
| chinasunlei07 | Lei Sun |
8+
| fengqikai1414 | Kaiwen Feng |
9+
| GoLancer | Wei He |
10+
| henryhu6 | Sen Hu |
11+
| hillbrook | Lei Zhang |
12+
| jinghaomiao | Jinghao Miao |
13+
| joaospinto | Joao Sousa-Pinto |
14+
| journey-wang | Peng Wang |
15+
| kechxu | Kecheng Xu |
16+
| lianglia-apollo | Liangliang Zhang |
17+
| qiankunzhu | Zhenguang Zhu |
18+
| quning78 | Ning Qu |
19+
| siyangy | Siyang Yu |
20+
| startcode | Dong Li |
21+
| wanglei828 | Lei Wang |
22+
| weidezhang | Weide Zhang |
23+
| xczhanjun | Jun Zhan |
24+
| xiaoxq | Xiangquan Xiao |
25+
| YajiaZhang | Yajia Zhang |
26+
| ycool | Jiangtao Hu |
27+
| ygcn | Guang Yang |
28+
| yifeijiang | Yifei Jiang |
29+
| breakds | Break Yang |
30+
| zhoudawen | David Zhou |
31+
| aiguo159 | Aiguo Fei |

README.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Apollo Kernel
2+
3+
The Apollo Kernel provides the necessary kernel level support to run Apollo software stack.
4+
In the first release, we add the most popular solution, Linux Kernel, under the linux directory.
5+
6+
## Linux Kernel
7+
8+
Apollo Linux Kernel is based on Linux Kernel 4.4.32 with some modifications.
9+
10+
### What is the difference
11+
12+
* Realtime patch (https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO)
13+
* Latest e1000e intel ethernet driver
14+
* Bugfix for Nvidia driver under realtime patch
15+
* Double free in the inet_csk_clone_lock function patch (https://bugzilla.redhat.com/show_bug.cgi?id=1450972)
16+
* Other cve security patches
17+
18+
The Apollo team would like to thank everybody in the open source community. The GitHub apollo-kernel/linux is based on Linux. Currently, Apollo team maintains this repository. In near future, we’ll send patches back to Linux community.
19+
20+
### Add ESD CAN Support
21+
22+
You will need to add ESD CAN driver to run Apollo software using ESD CAN card. Please refer to linux/ESDCAN-README.md for more information.
23+
24+
### How to Download the Release Package
25+
26+
Download the release packages from the release section on github:
27+
28+
```
29+
https://github.com/ApolloAuto/apollo-kernel/releases
30+
```
31+
32+
### How to Install
33+
34+
After having the release package downloaded:
35+
36+
```
37+
tar zxvf linux-4.4.32-apollo-1.0.0.tar.gz
38+
cd install
39+
sudo ./install_kernel.sh
40+
```
41+
42+
### How to Build
43+
44+
45+
If you would like cutomize and build your own kernel, simply run:
46+
47+
```
48+
./build.sh
49+
```
50+
51+
You can find the installation kernel package under directory:
52+
53+
```
54+
./install/rt
55+
```
56+
57+
### Realtime "Hello World" Example
58+
(https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#A_Realtime_.22Hello_World.22_Example)
59+
60+
* Setting a real time scheduling policy and priority
61+
* Locking memory so that page faults caused by virtual memory will not undermine deterministic behavior
62+
* Pre-faulting the stack, so that a future stack fault will not undermine deterministic behavior
63+
64+
The following example contains some very basic example code of a real time application with realtime preemption patch. Compile as follows:
65+
```
66+
gcc -o test_rt test_rt.c -lrt
67+
```
68+
69+
Source code as below:
70+
```
71+
#include <stdlib.h>
72+
#include <stdio.h>
73+
#include <time.h>
74+
#include <sched.h>
75+
#include <sys/mman.h>
76+
#include <string.h>
77+
78+
#define MY_PRIORITY (49) /* we use 49 as the PRREMPT_RT use 50
79+
as the priority of kernel tasklets
80+
and interrupt handler by default */
81+
82+
#define MAX_SAFE_STACK (8*1024) /* The maximum stack size which is
83+
guaranteed safe to access without
84+
faulting */
85+
86+
#define NSEC_PER_SEC (1000000000) /* The number of nsecs per sec. */
87+
88+
void stack_prefault(void) {
89+
90+
unsigned char dummy[MAX_SAFE_STACK];
91+
92+
memset(dummy, 0, MAX_SAFE_STACK);
93+
return;
94+
}
95+
96+
int main(int argc, char* argv[])
97+
{
98+
struct timespec t;
99+
struct sched_param param;
100+
int interval = 50000; /* 50us*/
101+
102+
/* Declare ourself as a real time task */
103+
104+
param.sched_priority = MY_PRIORITY;
105+
if(sched_setscheduler(0, SCHED_FIFO, &param) == -1) {
106+
perror("sched_setscheduler failed");
107+
exit(-1);
108+
}
109+
110+
/* Lock memory */
111+
112+
if(mlockall(MCL_CURRENT|MCL_FUTURE) == -1) {
113+
perror("mlockall failed");
114+
exit(-2);
115+
}
116+
117+
/* Pre-fault our stack */
118+
119+
stack_prefault();
120+
121+
clock_gettime(CLOCK_MONOTONIC ,&t);
122+
/* start after one second */
123+
t.tv_sec++;
124+
125+
while(1) {
126+
/* wait until next shot */
127+
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t, NULL);
128+
129+
/* do the stuff */
130+
131+
/* calculate next shot */
132+
t.tv_nsec += interval;
133+
134+
while (t.tv_nsec >= NSEC_PER_SEC) {
135+
t.tv_nsec -= NSEC_PER_SEC;
136+
t.tv_sec++;
137+
}
138+
}
139+
}
140+
```
141+
142+
### Disclaimer
143+
The patched Linux kernel is specifically for running Apollo software stack on an Apollo 1.0 Reference Hardware Platform (see [*Apollo 1.0 Hardware and System Installation Guide*](https://github.com/ApolloAuto/apollo/blob/master/docs/quickstart/apollo_1_0_hardware_system_installation_guide.md) for more information). It is not recommended for any other purposes.

0 commit comments

Comments
 (0)