Skip to content

Commit a8e2f18

Browse files
authored
Devel (#2)
* Add local sel4twinkle-alloc crate for development * Add initial port of sel4twinkle-alloc * Enable app init function in the root task context * WIP vspace, working IPC, root task recieves notifications * Move fault handler in to application * Add internals to test 'vspace_new_ipc_buffer()' * Thread data contains mapped vaddr's to to IO with * Cleanup and README updates * Update README
1 parent f47717c commit a8e2f18

17 files changed

+1393
-18
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/target
22
**/*.rs.bk
33
/artifacts
4-
src/bin/root-task.rs
4+
5+
# tracked for now
6+
#src/bin/root-task.rs

Cargo.lock

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ authors = ["jonlamb-gh <[email protected]>"]
88
#libsel4-sys = {git = "https://github.com/jonlamb-gh/libsel4-sys.git", branch = "devel"}
99
libsel4-sys = {path = "libsel4-sys"}
1010
rlibc = "1.0"
11+
# TODO - move to a real repo
12+
sel4twinkle-alloc = {path = "sel4twinkle-alloc"}
1113

1214
[dependencies.wee_alloc]
1315
version = "0.4"
@@ -21,6 +23,6 @@ features = ["alloc", "nightly"]
2123
optional = true
2224

2325
[features]
24-
default = []
26+
default = ["alloc"]
2527
alloc = ["wee_alloc"]
2628
test = ["alloc", "proptest"]

README.md

+157-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,26 @@
44

55
The [Nitrogen6 SoloX][solox] SoC has both an A9 core and an M4 core.
66

7-
The seL4 root task runs on the A9 core.
7+
Here's a good [article][bd-article] that describes the platform.
88

9-
It first initializes the system, then runs a separate Rust application on the M4 core.
9+
See the [TRM][trm] for register details.
10+
11+
## About the project
12+
13+
The seL4 kernel, root-task and threads run on the A9 core.
14+
15+
A bare metal Rust cortex-m project runs on the M4 core.
16+
17+
- U-boot does initial bootstrapping of the A9 core and loads the master ELF binary
18+
- seL4 kernel is started on the A9 core
19+
- seL4 root task initializes some memory, devices and I/O for a thread
20+
- seL4 thread loads the M4 core firmware from the CPIO archive linked into the master ELF binary
21+
- seL4 thread starts up the M4 core and clock
1022

1123
## Building
1224

25+
** REQUIRES a cargo-fel4 that doesn't overwrite the root-task.rs **
26+
1327
Note that the L2 cache memory is currently defined as OCRAM for the M4 core.
1428

1529
Modify U-boot environment:
@@ -18,7 +32,7 @@ Modify U-boot environment:
1832
# default loadaddr
1933
loadaddr=0x82000000
2034

21-
# move it up a bit so we don't overlap with the elf-loader
35+
# move it up a bit so we don't overlap with the elf-loader, Rust binaries are big right now
2236
setenv loadaddr 0x83000000
2337

2438
# boot alias command
@@ -31,8 +45,148 @@ Apply local patches to convert the imx6/sabre-lite platform into something the S
3145
./scripts/apply-patches
3246

3347
# a build.rs script is used to invoke the 'm4-firmware' project build
48+
# required because we can't have a normal dependency on a thing for a different target (A9/M4)
3449
cargo fel4 build
3550
```
3651

52+
## Running
53+
54+
On UART1 (U-boot/A9) console:
55+
56+
```text
57+
U-Boot 2017.07-28767-g87d490f (Jun 20 2018 - 10:29:54 -0700)
58+
59+
CPU: Freescale i.MX6SX rev1.3 at 792 MHz
60+
Reset cause: POR
61+
Board: nitrogen6sx
62+
I2C: ready
63+
DRAM: 1 GiB
64+
MMC: FSL_SDHC: 0, FSL_SDHC: 1
65+
SF: Detected sst25vf016b with page size 256 Bytes, erase size 4 KiB, total 2 MiB
66+
Display: lcd:1280x720M@60 (1280x720)
67+
In: serial
68+
Out: serial
69+
Err: serial
70+
Net: AR8035 at 4
71+
AR8035 at 5
72+
FEC0 [PRIME], FEC1, usb_ether
73+
Hit any key to stop autoboot: 0
74+
Using FEC0 device
75+
Filename 'feL4img'.
76+
Load address: 0x83000000
77+
Loading: #################################################################
78+
############################
79+
7.7 MiB/s
80+
done
81+
Bytes transferred = 1363524 (14ce44 hex)
82+
## Starting application at 0x83000000 ...
83+
84+
ELF-loader started on CPU: ARM Ltd. Cortex-A9 r2p10
85+
paddr=[83000000..8315ffff]
86+
ELF-loading image 'kernel'
87+
paddr=[80000000..80032fff]
88+
vaddr=[e0000000..e0032fff]
89+
virt_entry=e0000000
90+
ELF-loading image 'root-task'
91+
paddr=[80033000..82080fff]
92+
vaddr=[10000..205dfff]
93+
virt_entry=10554
94+
Enabling MMU and paging
95+
Jumping to kernel-image entry point...
96+
97+
Bootstrapping kernel
98+
Booting all finished, dropped to user space
99+
feL4 app init
100+
101+
hello from a feL4 thread!
102+
103+
SRC paddr = 0x20D8000 -- vaddr = 0x10000000
104+
CCM paddr = 0x20C4000 -- vaddr = 0x10001000
105+
TCM paddr = 0x7F8000 -- vaddr = 0x10002000
106+
107+
created new CPIO reader
108+
Reader {
109+
archive_size: 3584,
110+
base_ptr: 0x00044010
111+
}
112+
113+
parsed CPIO entry 'm4-firmware.bin'
114+
115+
enabling M4 core clock
116+
copying M4 binary to TCM - 3044 bytes
117+
enabling and starting the M4 core
118+
waiting for SRC_SCR reset auto-clear (bit 3) to clear
119+
120+
thread work all done, sitting on loop
121+
```
122+
123+
On UART2 (M4) console:
124+
125+
```text
126+
M4 core is up and running
127+
128+
Hello world from Rust on Cortex-M4
129+
Hello world from Rust on Cortex-M4
130+
Hello world from Rust on Cortex-M4
131+
Hello world from Rust on Cortex-M4
132+
Hello world from Rust on Cortex-M4
133+
Hello world from Rust on Cortex-M4
134+
...
135+
```
136+
137+
### A9 Test Deployment
138+
139+
```bash
140+
tftp ${a9ocramloadaddr} ${serverip}:a9.bin
141+
142+
go ${a9ocramloadaddr}
143+
```
144+
145+
### M4 Test Deployment
146+
147+
```bash
148+
tftp ${m4loadaddr} ${serverip}:m4.bin
149+
150+
dcache flush
151+
152+
bootaux ${m4loadaddr}
153+
```
154+
155+
## Notes
156+
157+
### L2 Cache
158+
159+
seL4 is attempting to use the TCM region for L2 cache.
160+
Since we're using it for the M4 core, can we instead use the
161+
region at `0x009C_0000`; which is 256 KB, labeled as
162+
`L2 cache memory used as OCRAM aliased`?
163+
164+
Could just be an issue with my config.
165+
166+
L2 cache is configured as OCRAM by default I think.
167+
See Table 8-2 in the TRM, fuse `USE_L2_CACHE_AS_OCRAM BOOT_CFG2`.
168+
169+
### Memory Map
170+
171+
The i.MX6 SoloX has two cores with different address mapping.
172+
173+
The ARM IP Bus (AIPS) memory map shows there is a `0x4000_0000` offset
174+
from the A9's address space to the M4's.
175+
176+
Refer to Table 2-1 (System memory map) for Cortex-A9 core and
177+
to Table 2-2 (CM4 memory map) for Cortex-M4 of the i.MX6 SoloX
178+
reference ranual.
179+
180+
To run Cortex-M4 it is needed to fill `TCM(L)`, that
181+
is addressed as `TCML ALIAS` (from zero).
182+
183+
The same memory is mapped to `0x007f8000` of the
184+
Cortex-A9 (non-reflected in the Table 2-1).
185+
186+
Note, this area is accessible by the Cortex-A9 after M4 clock
187+
is enabled in `CCM_CCGR3`.
188+
37189
[solox]: https://boundarydevices.com/product/nit6_solox-imx6/
190+
[bd-article]: https://boundarydevices.com/using-the-cortex-m4-mcu-on-the-nit6_solox/
191+
[trm]: http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6SXRM.pdf
38192
[open-amp]: https://github.com/OpenAMP/open-amp/wiki

sel4twinkle-alloc/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "sel4twinkle-alloc"
3+
version = "0.0.1"
4+
authors = ["jonlamb-gh <[email protected]>"]
5+
6+
[dependencies]
7+
#libsel4-sys = {git = "https://github.com/jonlamb-gh/libsel4-sys.git", branch = "master"}
8+
libsel4-sys = {path = "../libsel4-sys"}

0 commit comments

Comments
 (0)