Repository navigation
Expand file tree
/
Copy pathxmake.lua
More file actions
154 lines (134 loc) · 4.46 KB
/
Copy pathxmake.lua
File metadata and controls
154 lines (134 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---@diagnostic disable: undefined-global, lowercase-global
set_project("CHERIoT smart plant node")
sdkdir = "../sonata-software/cheriot-rtos/sdk"
netstackdir = "../sonata-software/network-stack/lib"
libsdir = "../sonata-software/libraries"
includes(sdkdir)
includes(netstackdir)
includes(libsdir)
set_toolchains("cheriot-clang")
option("board")
set_default("sail")
-- Display compartment
compartment("display")
add_files("src/display/display.cc")
add_includedirs("src", "../sonata-software/libraries")
add_deps("freestanding", "debug", "lcd")
-- Application compartments
compartment("telemetry")
add_files("src/telemetry.cc")
add_includedirs("src", "../sonata-software/network-stack/include")
add_deps("freestanding", "debug", "SNTP")
compartment("comms")
add_files("src/comms.cc")
add_includedirs("src", "../sonata-software/network-stack/include", "../sonata-software/network-stack/examples/04.MQTT")
add_deps("freestanding", "debug", "DNS", "TCPIP", "NetAPI", "TLS", "Firewall", "SNTP", "MQTT", "time_helpers", "stdio")
add_rules("cheriot.network-stack.ipv6")
compartment("policy_engine")
add_files("src/policy_engine.cc")
add_includedirs("src")
add_deps("freestanding", "debug")
-- attestation: MOCK measurer. Returns a canned firmware measurement and builds
-- a mock quote, calling tpm to "sign" it. No longer reads flash or hashes, so
-- it needs no SPI capability and no libhydrogen.
compartment("attestation")
add_files("src/attestation.cc")
add_includedirs("src")
add_deps("freestanding", "debug")
-- tpm: MOCK signing oracle (NOT a real TPM). Returns canned bytes; no real key,
-- no libhydrogen.
compartment("tpm")
add_files("src/tpm.cc")
add_includedirs("src")
add_deps("freestanding", "debug")
compartment("crypto")
add_files("src/crypto.cc")
add_files("../cheriot-demos/third_party/crypto/libhydrogen/hydrogen.c")
add_includedirs("src", "../cheriot-demos/third_party/crypto/libhydrogen")
add_defines("CHERIOT_NO_AMBIENT_MALLOC")
add_deps("freestanding", "debug")
compartment("irrigation")
add_files("src/irrigation.cc")
add_includedirs("src", "../sonata-software/network-stack/include")
add_deps("freestanding", "debug", "locks", "time_helpers", "SNTP")
-- Driver compartments
compartment("i2c_driver")
add_files("src/drivers/i2c_driver.cc")
add_includedirs("src")
add_deps("freestanding", "debug", "locks")
compartment("moisture_sensor")
add_files("src/drivers/moisture_sensor.cc")
add_includedirs("src")
add_deps("freestanding", "debug")
compartment("temperature_sensor")
add_files("src/drivers/temperature_sensor.cc")
add_includedirs("src")
add_deps("freestanding", "debug")
compartment("pump_driver")
add_files("src/drivers/pump_driver.cc")
add_includedirs("src")
add_deps("freestanding", "debug")
-- Firmware image
firmware("plantnode")
add_deps("freestanding", "debug")
-- Application
add_deps("telemetry", "comms", "policy_engine", "attestation", "tpm", "crypto", "display", "irrigation")
-- Drivers
add_deps("i2c_driver", "moisture_sensor", "temperature_sensor", "pump_driver")
-- Network stack
add_deps("TCPIP", "TLS", "MQTT", "Firewall", "NetAPI", "DNS", "SNTP")
-- Required for RSA certificate validation)
add_options("tls-rsa")
after_link(function(target)
local fw = target:targetfile()
local outdir = path.join(os.projectdir(), "build/uf2")
os.mkdir(outdir)
os.execv("llvm-strip", { fw, "-o", fw .. ".strip" })
os.execv(
"uf2conv",
{ fw .. ".strip", "-b0x00000000", "-f0x6CE29E60", "-co", path.join(outdir, "plantnode.slot1.uf2") }
)
os.execv(
"uf2conv",
{ fw .. ".strip", "-b0x10000000", "-f0x6CE29E60", "-co", path.join(outdir, "plantnode.slot2.uf2") }
)
os.execv(
"uf2conv",
{ fw .. ".strip", "-b0x20000000", "-f0x6CE29E60", "-co", path.join(outdir, "plantnode.slot3.uf2") }
)
end)
on_load(function(target)
target:values_set("board", "sonata-1.1")
target:values_set("threads", {
{
compartment = "irrigation",
priority = 3,
entry_point = "irrigation_loop",
stack_size = 4096,
trusted_stack_frames = 6,
},
{
-- Telemetry thread. Stack must cover the full
-- cross-compartment call chain incl. TLS in comms.
compartment = "telemetry",
priority = 1,
entry_point = "telemetry_loop",
stack_size = 8160,
trusted_stack_frames = 8,
},
{
compartment = "TCPIP",
priority = 1,
entry_point = "ip_thread_entry",
stack_size = 0x1000,
trusted_stack_frames = 5,
},
{
compartment = "Firewall",
priority = 2,
entry_point = "ethernet_run_driver",
stack_size = 0x1000,
trusted_stack_frames = 5,
},
}, { expand = false })
end)