Skip to content

Commit b79b0e7

Browse files
authored
Merge pull request #1040 from cla7aye15I4nd/stm32f4
Some STM32 updates
2 parents 4641091 + 2120d0f commit b79b0e7

27 files changed

+1429
-1148
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+
6+
import sys
7+
sys.path.append("../..")
8+
9+
from qiling.core import Qiling
10+
from qiling.const import QL_VERBOSE
11+
from qiling.extensions.mcu.stm32f4 import stm32f407
12+
from qiling.hw.external_device.oled.ssd1306 import PyGameSSD1306Spi
13+
14+
15+
ql = Qiling(["../rootfs/mcu/stm32f407/ai-sine-test.elf"],
16+
archtype="cortex_m", env=stm32f407, verbose=QL_VERBOSE.DEFAULT)
17+
18+
ql.hw.create('rcc')
19+
ql.hw.create('pwr')
20+
ql.hw.create('flash interface')
21+
ql.hw.create('gpioa')
22+
ql.hw.create('gpiob')
23+
ql.hw.create('gpiod')
24+
ql.hw.create('spi1')
25+
ql.hw.create('crc')
26+
27+
oled = PyGameSSD1306Spi(dc=(ql.hw.gpiod, 5))
28+
ql.hw.spi1.connect(oled)
29+
30+
def indicator(ql):
31+
ql.log.info('PA7 set')
32+
33+
ql.hw.gpioa.hook_set(7, indicator, ql)
34+
ql.hw.systick.ratio = 1000
35+
36+
ql.run(count=800000)

qiling/extensions/mcu/stm32f4/stm32f401.py

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
"ADC1": {
88
"base": 0x40012000,
99
"struct": "STM32F4xxAdc",
10-
"type": "periperal"
10+
"type": "peripheral"
1111
},
1212
"CRC": {
1313
"base": 0x40023000,
1414
"struct": "STM32F4xxCrc",
15-
"type": "periperal"
15+
"type": "peripheral"
1616
},
1717
"DBGMCU": {
1818
"base": 0xe0042000,
1919
"struct": "STM32F4xxDbgmcu",
20-
"type": "periperal"
20+
"kwargs": {
21+
"dev_id": 0x413,
22+
},
23+
"type": "core peripheral"
2124
},
2225
"DMA1": {
2326
"base": 0x40026000,
@@ -32,7 +35,7 @@
3235
"stream6_intn": 17,
3336
"stream7_intn": 47
3437
},
35-
"type": "periperal"
38+
"type": "peripheral"
3639
},
3740
"DMA2": {
3841
"base": 0x40026400,
@@ -47,12 +50,12 @@
4750
"stream6_intn": 69,
4851
"stream7_intn": 70
4952
},
50-
"type": "periperal"
53+
"type": "peripheral"
5154
},
5255
"EXTI": {
5356
"base": 0x40013c00,
5457
"struct": "STM32F4xxExti",
55-
"type": "periperal"
58+
"type": "peripheral"
5659
},
5760
"FLASH": {
5861
"base": 0x8000000,
@@ -64,35 +67,43 @@
6467
"size": 0x400,
6568
"type": "memory"
6669
},
70+
"FLASH INTERFACE": {
71+
"base": 0x40023c00,
72+
"struct": "STM32F4xxFlash",
73+
"kwargs": {
74+
"intn": 4,
75+
},
76+
"type": "peripheral"
77+
},
6778
"GPIOA": {
6879
"base": 0x40020000,
6980
"struct": "STM32F4xxGpio",
70-
"type": "periperal"
81+
"type": "peripheral"
7182
},
7283
"GPIOB": {
7384
"base": 0x40020400,
7485
"struct": "STM32F4xxGpio",
75-
"type": "periperal"
86+
"type": "peripheral"
7687
},
7788
"GPIOC": {
7889
"base": 0x40020800,
7990
"struct": "STM32F4xxGpio",
80-
"type": "periperal"
91+
"type": "peripheral"
8192
},
8293
"GPIOD": {
8394
"base": 0x40020c00,
8495
"struct": "STM32F4xxGpio",
85-
"type": "periperal"
96+
"type": "peripheral"
8697
},
8798
"GPIOE": {
8899
"base": 0x40021000,
89100
"struct": "STM32F4xxGpio",
90-
"type": "periperal"
101+
"type": "peripheral"
91102
},
92103
"GPIOH": {
93104
"base": 0x40021c00,
94105
"struct": "STM32F4xxGpio",
95-
"type": "periperal"
106+
"type": "peripheral"
96107
},
97108
"I2C1": {
98109
"base": 0x40005400,
@@ -101,7 +112,7 @@
101112
"er_intn": 32,
102113
"ev_intn": 31
103114
},
104-
"type": "periperal"
115+
"type": "peripheral"
105116
},
106117
"I2C2": {
107118
"base": 0x40005800,
@@ -110,7 +121,7 @@
110121
"er_intn": 34,
111122
"ev_intn": 33
112123
},
113-
"type": "periperal"
124+
"type": "peripheral"
114125
},
115126
"I2C3": {
116127
"base": 0x40005c00,
@@ -119,22 +130,22 @@
119130
"er_intn": 73,
120131
"ev_intn": 72
121132
},
122-
"type": "periperal"
133+
"type": "peripheral"
123134
},
124135
"I2S2ext": {
125136
"base": 0x40003400,
126137
"struct": "STM32F4xxSpi",
127-
"type": "periperal"
138+
"type": "peripheral"
128139
},
129140
"I2S3ext": {
130141
"base": 0x40004000,
131142
"struct": "STM32F4xxSpi",
132-
"type": "periperal"
143+
"type": "peripheral"
133144
},
134145
"IWDG": {
135146
"base": 0x40003000,
136147
"struct": "STM32F4xxIwdg",
137-
"type": "periperal"
148+
"type": "peripheral"
138149
},
139150
"NVIC": {
140151
"base": 0xe000e100,
@@ -154,21 +165,21 @@
154165
},
155166
"PPB": {
156167
"base": 0xe0000000,
157-
"size": 0x10000,
168+
"size": 0x100000,
158169
"type": "mmio"
159170
},
160171
"PWR": {
161172
"base": 0x40007000,
162173
"struct": "STM32F4xxPwr",
163-
"type": "periperal"
174+
"type": "peripheral"
164175
},
165176
"RCC": {
166177
"base": 0x40023800,
167178
"struct": "STM32F4xxRcc",
168179
"kwargs": {
169180
"intn": 5
170181
},
171-
"type": "periperal"
182+
"type": "peripheral"
172183
},
173184
"RTC": {
174185
"base": 0x40002800,
@@ -177,7 +188,7 @@
177188
"alarm_intn": 41,
178189
"wkup_intn": 3
179190
},
180-
"type": "periperal"
191+
"type": "peripheral"
181192
},
182193
"SCB": {
183194
"base": 0xe000ed00,
@@ -190,39 +201,39 @@
190201
"kwargs": {
191202
"intn": 49
192203
},
193-
"type": "periperal"
204+
"type": "peripheral"
194205
},
195206
"SPI1": {
196207
"base": 0x40013000,
197208
"struct": "STM32F4xxSpi",
198209
"kwargs": {
199210
"intn": 35
200211
},
201-
"type": "periperal"
212+
"type": "peripheral"
202213
},
203214
"SPI2": {
204215
"base": 0x40003800,
205216
"struct": "STM32F4xxSpi",
206217
"kwargs": {
207218
"intn": 36
208219
},
209-
"type": "periperal"
220+
"type": "peripheral"
210221
},
211222
"SPI3": {
212223
"base": 0x40003c00,
213224
"struct": "STM32F4xxSpi",
214225
"kwargs": {
215226
"intn": 51
216227
},
217-
"type": "periperal"
228+
"type": "peripheral"
218229
},
219230
"SPI4": {
220231
"base": 0x40013400,
221232
"struct": "STM32F4xxSpi",
222233
"kwargs": {
223234
"intn": 84
224235
},
225-
"type": "periperal"
236+
"type": "peripheral"
226237
},
227238
"SRAM": {
228239
"base": 0x20000000,
@@ -238,7 +249,7 @@
238249
"SYSCFG": {
239250
"base": 0x40013800,
240251
"struct": "STM32F4xxSyscfg",
241-
"type": "periperal"
252+
"type": "peripheral"
242253
},
243254
"SYSTEM": {
244255
"base": 0x1fff0000,
@@ -259,85 +270,85 @@
259270
"trg_com_tim11_intn": 26,
260271
"up_tim10_intn": 25
261272
},
262-
"type": "periperal"
273+
"type": "peripheral"
263274
},
264275
"TIM10": {
265276
"base": 0x40014400,
266277
"struct": "STM32F4xxTim",
267-
"type": "periperal"
278+
"type": "peripheral"
268279
},
269280
"TIM11": {
270281
"base": 0x40014800,
271282
"struct": "STM32F4xxTim",
272-
"type": "periperal"
283+
"type": "peripheral"
273284
},
274285
"TIM2": {
275286
"base": 0x40000000,
276287
"struct": "STM32F4xxTim",
277288
"kwargs": {
278289
"intn": 28
279290
},
280-
"type": "periperal"
291+
"type": "peripheral"
281292
},
282293
"TIM3": {
283294
"base": 0x40000400,
284295
"struct": "STM32F4xxTim",
285296
"kwargs": {
286297
"intn": 29
287298
},
288-
"type": "periperal"
299+
"type": "peripheral"
289300
},
290301
"TIM4": {
291302
"base": 0x40000800,
292303
"struct": "STM32F4xxTim",
293304
"kwargs": {
294305
"intn": 30
295306
},
296-
"type": "periperal"
307+
"type": "peripheral"
297308
},
298309
"TIM5": {
299310
"base": 0x40000c00,
300311
"struct": "STM32F4xxTim",
301312
"kwargs": {
302313
"intn": 50
303314
},
304-
"type": "periperal"
315+
"type": "peripheral"
305316
},
306317
"TIM9": {
307318
"base": 0x40014000,
308319
"struct": "STM32F4xxTim",
309-
"type": "periperal"
320+
"type": "peripheral"
310321
},
311322
"USART1": {
312323
"base": 0x40011000,
313324
"struct": "STM32F4xxUsart",
314325
"kwargs": {
315326
"intn": 37
316327
},
317-
"type": "periperal"
328+
"type": "peripheral"
318329
},
319330
"USART2": {
320331
"base": 0x40004400,
321332
"struct": "STM32F4xxUsart",
322333
"kwargs": {
323334
"intn": 38
324335
},
325-
"type": "periperal"
336+
"type": "peripheral"
326337
},
327338
"USART6": {
328339
"base": 0x40011400,
329340
"struct": "STM32F4xxUsart",
330341
"kwargs": {
331342
"intn": 71
332343
},
333-
"type": "periperal"
344+
"type": "peripheral"
334345
},
335346
"WWDG": {
336347
"base": 0x40002c00,
337348
"struct": "STM32F4xxWwdg",
338349
"kwargs": {
339350
"intn": 0
340351
},
341-
"type": "periperal"
352+
"type": "peripheral"
342353
}
343354
}

0 commit comments

Comments
 (0)