-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cargo.toml
272 lines (238 loc) · 7.21 KB
/
Cargo.toml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
[package]
name = "air-gradient-pro-rs"
description = "Rust firmware for the AirGradient Pro"
version = "0.4.2"
edition = "2021"
authors = ["Jon Lamb"]
build = "build.rs"
[[bin]]
name = "air-gradient-pro"
path = "src/main.rs"
[dependencies]
cortex-m = "0.7"
cortex-m-rt = "0.7"
rtic-monotonic = "1.0"
cortex-m-rtic = "1.1"
log = "0.4"
static_assertions = "1.1"
gas-index-algorithm = "0.1"
profont = "0.7"
heapless = "0.7"
sh1106 = "0.5"
[dependencies.wire-protocols]
path = "../libraries/wire-protocols"
[dependencies.bootloader-support]
path = "../libraries/bootloader-support"
[dependencies.update-manager]
path = "../libraries/update-manager"
[dependencies.agp-bootloader]
path = "../bootloader"
[dependencies.aqi]
version = "0.2"
default-features = false
# TODO - upstream these changes
[dependencies.pms-7003]
git = "https://github.com/jonlamb-gh/pms-7003.git"
branch = "various-changes"
# TODO - upstream these changes
[dependencies.sgp41]
git = "https://github.com/jonlamb-gh/sgp41.git"
branch = "various-changes"
# TODO - upstream these changes
[dependencies.sht3x]
git = "https://github.com/jonlamb-gh/sht3x-rs.git"
branch = "various-changes"
# TODO - upstream these changes
[dependencies.enc28j60]
git = "https://github.com/jonlamb-gh/enc28j60.git"
branch = "cleanup"
[dependencies.stm32f4xx-hal]
version = "0.17"
features = ["rt", "stm32f411", "rtic"]
[dependencies.smoltcp]
version = "0.10"
default-features = false
features = [
"medium-ethernet",
"medium-ip",
"proto-ipv4",
"socket-icmp",
"socket-udp",
"socket-tcp",
#"log",
#"verbose"
]
[dependencies.embedded-graphics]
version = "0.8"
default-features = false
[dependencies.shared-bus]
version = "0.3"
default-features = false
features = ["cortex-m"]
[build-dependencies.built]
version = "0.7"
features = ["git2", "chrono"]
[build-dependencies.env-config]
path = "../libraries/env-config"
[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
[package.metadata.renode]
machine-name = 'agp'
using-sysbus = true
# NOTE: currently requires nightly build until next release, using 1.14.0+20231008gitebcb1b6b
# https://builds.renode.io/renode-latest.linux-portable.tar.gz
# renode = '/opt/renode_1.14.0+20231008gitebcb1b6b_portable/renode'
init-commands = [
'include @../renode/peripherals/STM32F4_RCC.cs',
'include @../renode/peripherals/STM32_Timer.cs',
'include @../renode/peripherals/STM32_UART.cs',
'include @../renode/peripherals/ENC28J60.cs',
'include @../renode/peripherals/SH1106.cs',
'include @../renode/peripherals/SGP41.cs',
'include @../renode/peripherals/SHT31.cs',
'include @../renode/peripherals/PMS5003.cs',
'include @../renode/peripherals/S8LP.cs',
]
variables = [
'$tap ?= "renode-tap0"',
# Set random board UNIQUE ID
'''
python "import _random"
python "rand = _random.Random()"
$id1 = `python "print rand.getrandbits(32)"`
$id2 = `python "print rand.getrandbits(32)"`
$id3 = `python "print rand.getrandbits(32)"`
''',
]
platform-descriptions = [
'../renode/platform/stm32f411.repl',
'led: Miscellaneous.LED @ gpioPortC',
'''
gpioPortC:
13 -> led@0
''',
'''
ethernet: Network.ENC28J60_CUSTOM @ spi2i2s2
-> gpioPortA@8
''',
'''
gpioPortB:
12 -> ethernet@0
''',
'''
sh1106 : Video.SH1106 @ i2c2 0x3C
FramesPerVirtualSecond: 10
''',
'''
sgp41 : Sensors.SGP41 @ i2c2 0x59
SerialNumber: 0xBBFF
VocTicks: 1024
NoxTicks: 2048
''',
'''
sht31 : Sensors.SHT31 @ i2c2 0x44
SerialNumber: 0xAABB
Temperature: 40
Humidity: 85
''',
'''
pms5003 : UART.PMS5003 @ usart2
PM2_5_atm: 10
''',
'''
s8lp : UART.S8LP @ usart1
Co2: 20
''',
]
pre-start-commands = [
'cpu PerformanceInMips 1',
# Suppress most warnings
'logLevel 3 sysbus',
'logLevel 3 flash_controller',
'logLevel 3 rcc',
'logLevel 3 usart6',
'logLevel 3 usart1',
'logLevel 3 usart2',
'logLevel 3 gpioPortB',
# NOTE: these frequencies are the default in stm32f411.repl so they get picked up after machine
# resets.
# Setup the timer frequencies to match the systick frequency, so that
# the HAL RCC/Timer config routines work, they use timclk1 which is set
# to systick (64 MHz) based on the NVIC systickFrequency in stm32f411.repl
#
# TIM2 monotonic us RTIC timer, 1 MHz
'timer2 Frequency 64000000',
#'timer2 Frequency 1000000',
# TIM3 IP stack timer, 25 Hz
'timer3 Frequency 64000000',
# TIM4 common ms delay timer, 1 KHz
# NOTE: scaled up to speed up the polling impls the HAL uses
# they slow down virtual time a lot
'timer4 Frequency 640000000',
# TIM5 PMS5003 ms delay timer, 1 KHz
# NOTE: scaled up to speed up the polling impls the HAL uses
# they slow down virtual time a lot
'timer5 Frequency 640000000',
# TIM10 SHT31 delay timer, 1 MHz
# NOTE: scaled up to speed up the polling impls the HAL uses
'timer10 Frequency 640000000',
# TIM11 SGP41 delay timer, 1 MHz
# NOTE: scaled up to speed up the polling impls the HAL uses
'timer11 Frequency 640000000',
# Ignore set-freq-difference warnings
'logLevel 3 timer2',
'logLevel 3 timer3',
'logLevel 3 timer4',
'logLevel 3 timer10',
'logLevel 3 timer11',
#'logLevel -1 usart2.pms5003',
#'logLevel -1 usart1.s8lp',
#'logLevel -1 i2c2.sht31',
#'logLevel -1 i2c2.sgp41',
#'logLevel -1 spi2i2s2.ethernet',
#'logFile @/tmp/agp_renode.log true',
#'logLevel -1 file',
#'usart6 CreateFileBackend @/tmp/agp_uart.txt true',
'showAnalyzer usart6',
'showAnalyzer i2c2.sh1106',
'''
spi2i2s2.ethernet MAC "02:00:04:03:07:04"
emulation CreateSwitch "switch"
connector Connect spi2i2s2.ethernet switch
''',
'''
emulation CreateTap $tap "tap"
connector Connect host.tap switch
''',
# Reset reason: power-on reset RCC.CSR.PORRSTF
'rcc resetReason PowerOnReset',
# When we see a write of 0x5fa0004 to SCB.AIRCR (0xE000ED0C)
# then set the SFTRSTF bit (bit 28) in reset-reset RCC.CSR (0x40023874)
'''
sysbus AddWatchpointHook 0xE000ED0C DoubleWord Write "if value == 0x5fa0004: self.NoisyLog('sw triggered reset'); self.Machine['sysbus.rcc'].SetResetReasonSoftwareReset()"
''',
# TODO - check that these are working...
'''
sysbus.usart2 AddLineHook "Reset reason: Could not determine the cause" "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, line)"
sysbus.usart2 AddLineHook "PANIC" "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, line)"
sysbus.usart2 AddLineHook "test result: ok" "Antmicro.Renode.Emulator.Exit()"
''',
]
reset = '''
sysbus LoadELF $bin
sysbus.cpu VectorTableOffset 0x8000000
# Device ID
sysbus WriteDoubleWord 0x1FFF7A10 $id1
sysbus WriteDoubleWord 0x1FFF7A14 $id2
sysbus WriteDoubleWord 0x1FFF7A18 $id3
# Default boot config in flash
sysbus.flash ZeroRange 0xC000 16
sysbus.flash WriteByte 0xC000 0xDE
sysbus.flash WriteByte 0xC001 0xC0
sysbus.flash WriteByte 0xC002 0xED
sysbus.flash WriteByte 0xC003 0xFE
# Flash size KB
sysbus WriteDoubleWord 0x1FFF7A22 512
'''