Skip to content

Commit eb7704e

Browse files
committed
Effective Split of Peripheral Drivers
What's Wrong: * The peripheral definitions of the f4xx and h7xx are different. * Old templates had dated information. How Was it Fixed (if not obvious): * Made duplicates of all common peripheral headers from peripheralyzer. * Checked in the naming maps and altered SVDs * Updated template types to have updated information for openocd debug. What side effects does this have (could be none): * Include structure is a bit more complicated. This can be simplified in the future. Which builds did you run to make sure they build? [X] arm-none-eabi-gcc Cortex M4 [X] arm-none-eabi-gcc Cortex M7 [ ] (Apple) Native Clang [ ] (Apple) Homebrew GCC [X] (Apple) Homebrew LLVM How Do We Know and Can Show It's Fixed: * Builds. Which Unittest Series did you Check? [ ] (Apple) Native Clang [ ] (Apple) Homebrew GCC [X] (Apple) Homebrew LLVM Did this affect any on-target builds? If so which were tested? [X] STM32F407VE board [ ] STM32H753ZI board
1 parent 9f8614f commit eb7704e

101 files changed

Lines changed: 118126 additions & 12860 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.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
# Ignore Build Output
3535
build/
3636

37+
# Ingnore Testing Output like Jlink/Ozone or GDB configuration
38+
testing/*.jdebug*
39+
testing/*.gdb
40+
3741
# Ignore Python virtual environments
3842
venv/
3943
.venv/

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,40 +43,45 @@ add_configuration(NAME full)
4343
add_configuration(NAME basic)
4444
add_configuration(NAME qemu)
4545

46-
add_family(FAMILY stm32f40xxx
46+
add_family(FAMILY stm32f4xx
4747
VENDOR stm32
4848
DESCRIPTION "ST STM32F4xx family"
4949
MODULES stm32
5050
CORTEX_M 4
5151
ARCHITECTURE armv7e-m
5252
PRECISION SINGLE
53+
NAMESPACE f4xx
5354
)
5455

5556
add_chip(NAME stm32f407ve
56-
FAMILY stm32f40xxx
57+
FAMILY stm32f4xx
5758
DEVICE STM32F407VE
5859
PACKAGE LQFP100
60+
DEFINES CORTEX_INTERRUPT_CHANNELS=82
5961
)
6062

6163
add_chip(NAME stm32f405rg
62-
FAMILY stm32f40xxx
64+
FAMILY stm32f4xx
6365
DEVICE STM32F405RG
6466
PACKAGE LQFP64
67+
DEFINES CORTEX_INTERRUPT_CHANNELS=82
6568
)
6669

67-
add_family(FAMILY stm32h7xxxx
70+
add_family(FAMILY stm32h7xx
6871
VENDOR stm32
6972
DESCRIPTION "ST STM32H7xx family"
7073
MODULES stm32
7174
CORTEX_M 7
7275
ARCHITECTURE armv7e-m
7376
PRECISION DOUBLE
77+
NAMESPACE h7xx
7478
)
7579

7680
add_chip(NAME stm32h753zi
77-
FAMILY stm32h7xxxx
81+
FAMILY stm32h7xx
7882
DEVICE STM32H753ZI
7983
PACKAGE LQFP144
84+
DEFINES CORTEX_INTERRUPT_CHANNELS=150
8085
)
8186

8287
# After we define all the chips, families and configurations,

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,24 @@ target remote localhost:1234
228228

229229
The superloop on-target unit test now builds against a configuration for qemu which disables some things (ClockTree) which aren't implemented and cause hangs.
230230

231+
### Debugging with OpenOCD
232+
233+
OpenOCD is an open source tool which can be used to debug on-target using a variety of hardware debuggers. It is a bit more complex to set up than the Segger JLink tools but it is free and open source.
234+
235+
```bash
236+
# In a separate terminal, start the OpenOCD server with the appropriate configuration for your board and debugger (observe the port here is 2331, not 3333 which is the default for OpenOCD)
237+
openocd --file modules/stm32/scripts/stm32h753zi.cfg
238+
239+
# then in another terminal, start the GDB client and connect to the OpenOCD server
240+
cgdb -d `which arm-none-eabi-gdb` -x testing/firmware-nucleo-demo-basic-nucleo_h753zi.gdb
241+
(gdb) target remote localhost:2331
242+
243+
# Or just normal GDB
244+
arm-none-eabi-gdb -x testing/firmware-nucleo-demo-basic-nucleo_h753zi.gdb
245+
```
246+
247+
Once you are inside, run `setup` and then `reset` to start the program. You should see the output in the OpenOCD terminal.
248+
231249
## Modules
232250

233251
Components are separated into modules which are independent and require build support to interwork. This is done to prevent accidental inclusion in single `include/` folder systems for all components. After a dependency is formed in the build system, the appropriate include paths, defines, sources, etc. will be provided.
@@ -329,11 +347,11 @@ extern Timer2 volatile timer2;
329347
} // namespace stm32
330348
```
331349
332-
Thus only the memory map in the linker needs to know it's real address. If it needs to be known in code, we simply refer to it naturally as `&stm32::peripherals::timer2`. This works seemlessly in unit test and on-target, where we simply define a structure out in a global location for each peripheral.
350+
Thus only the memory map in the linker needs to know it's real address. If it needs to be known in code, we simply refer to it naturally as `&stm32::f4xx::timer2`. This works seemlessly in unit test and on-target, where we simply define a structure out in a global location for each peripheral.
333351
334352
```c++
335353
// in peripherals.cpp for the board, used by unit tests
336-
stm32::peripherals::Timer2 volatile timer2;
354+
stm32::f4xx::Timer2 volatile timer2;
337355
```
338356

339357
These should be moved to the chip specific vendor area for per-mcu builds.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
INCLUDE stm32f40xxx-zero-table.ld
1+
INCLUDE stm32f4xx-zero-table.ld

boards/netduinoplus2/scripts/client.gdb.in

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# define hookpost-connect
2+
# monitor swo EnableTarget 0 0 0xFFFFFFFF 0
3+
# monitor swo start 480000000 64000
4+
# end
5+
6+
define reset
7+
target remote localhost:2331
8+
# Reset configuration
9+
monitor reset halt
10+
monitor flash probe 0
11+
load @LOCAL_TARGET_BINARY_PATH@
12+
end
13+
14+
define setup
15+
file @LOCAL_TARGET_BINARY_PATH@
16+
break cortex::initialize::on_startup
17+
break vendor::initialize::clocks
18+
break cortex::system::main
19+
layout split
20+
set print asm-demangle on
21+
set print frame-arguments all
22+
# Users may have their own breakpoints, so we want to load those after the reset sequence
23+
source -s -v testing/breakpoints.gdb
24+
end
25+
File renamed without changes.

boards/netduinoplus2/source/BoardContext.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ ClockConfiguration const default_clock_configuration = {
3535
namespace jarnax {
3636

3737
BoardContext::BoardContext()
38-
: timer_{stm32::peripherals::timer2}
39-
, random_number_generator_{}
38+
: timer_{stm32::f4xx::timer2}
39+
, random_number_generator_{stm32::f4xx::random_number_generator}
4040
, wakeup_pin_{stm32::gpio::Port::A, 0}
4141
, mco1_pin_{stm32::gpio::Port::A, 8}
4242
, mco2_pin_{stm32::gpio::Port::C, 9}
@@ -61,12 +61,12 @@ BoardContext::BoardContext()
6161
, spi2_miso_{stm32::gpio::Port::B, 14}
6262
, spi2_sclk_{stm32::gpio::Port::B, 13}
6363
, spi2_nss_{stm32::gpio::Port::B, 12}
64-
, dma_manager_{stm32::peripherals::direct_memory_access}
65-
, spi1_driver_{stm32::peripherals::spi1, dma_manager_, stm32::SPI1_RX, stm32::SPI1_TX}
66-
, spi2_driver_{stm32::peripherals::spi2, dma_manager_, stm32::SPI2_RX, stm32::SPI2_TX}
64+
, dma_manager_{stm32::f4xx::direct_memory_access}
65+
, spi1_driver_{stm32::f4xx::spi1, dma_manager_, stm32::SPI1_RX, stm32::SPI1_TX}
66+
, spi2_driver_{stm32::f4xx::spi2, dma_manager_, stm32::SPI2_RX, stm32::SPI2_TX}
6767
, usart1_tx_{stm32::gpio::Port::A, 9}
6868
, usart1_rx_{stm32::gpio::Port::A, 10}
69-
, usart1_driver_{stm32::peripherals::usart1, dma_manager_, stm32::USART1_RX, stm32::USART1_TX, GetDmaAllocator(), stm32::usart_dma_buffer_size}
69+
, usart1_driver_{stm32::f4xx::usart1, dma_manager_, stm32::USART1_RX, stm32::USART1_TX, GetDmaAllocator(), stm32::usart_dma_buffer_size}
7070
, usart_console_{usart1_driver_} {
7171
// construct the driver objects as part of the constructor above.
7272
}
@@ -144,41 +144,41 @@ core::Status BoardContext::Initialize(void) {
144144
.SetOutputSpeed(stm32::gpio::Speed::High)
145145
.SetOutputType(stm32::gpio::OutputType::PushPull);
146146

147-
stm32::peripherals::ResetAndClockControl::AHB1PeripheralClockEnable ahb1_enable;
148-
stm32::peripherals::ResetAndClockControl::AHB2PeripheralClockEnable ahb2_enable;
149-
stm32::peripherals::ResetAndClockControl::APB1PeripheralClockEnable apb1_enable;
150-
stm32::peripherals::ResetAndClockControl::APB2PeripheralClockEnable apb2_enable;
147+
stm32::f4xx::ResetAndClockControl::AHB1PeripheralClockEnable ahb1_enable;
148+
stm32::f4xx::ResetAndClockControl::AHB2PeripheralClockEnable ahb2_enable;
149+
stm32::f4xx::ResetAndClockControl::APB1PeripheralClockEnable apb1_enable;
150+
stm32::f4xx::ResetAndClockControl::APB2PeripheralClockEnable apb2_enable;
151151

152152
// Enable the RNG in the AHB2 Periperhals
153-
ahb2_enable = stm32::peripherals::reset_and_clock_control.ahb2_peripheral_clock_enable; // read
153+
ahb2_enable = stm32::f4xx::reset_and_clock_control.ahb2_peripheral_clock_enable; // read
154154
ahb2_enable.bits.random_number_generator_enable = 1U;
155-
stm32::peripherals::reset_and_clock_control.ahb2_peripheral_clock_enable = ahb2_enable; // write
155+
stm32::f4xx::reset_and_clock_control.ahb2_peripheral_clock_enable = ahb2_enable; // write
156156

157157
// Reset the RNG
158-
stm32::peripherals::ResetAndClockControl::AHB2PeripheralReset reset;
159-
reset = stm32::peripherals::reset_and_clock_control.ahb2_peripheral_reset; // read
158+
stm32::f4xx::ResetAndClockControl::AHB2PeripheralReset reset;
159+
reset = stm32::f4xx::reset_and_clock_control.ahb2_peripheral_reset; // read
160160
reset.bits.random_number_generator_reset = 1U;
161-
stm32::peripherals::reset_and_clock_control.ahb2_peripheral_reset = reset; // write
161+
stm32::f4xx::reset_and_clock_control.ahb2_peripheral_reset = reset; // write
162162
reset.bits.random_number_generator_reset = 0U;
163-
stm32::peripherals::reset_and_clock_control.ahb2_peripheral_reset = reset; // write
163+
stm32::f4xx::reset_and_clock_control.ahb2_peripheral_reset = reset; // write
164164

165165
// enable the APB1 peripherals in the Reset and Clock Control register
166-
apb1_enable = stm32::peripherals::reset_and_clock_control.apb1_peripheral_clock_enable; // read
167-
apb1_enable.bits.tim2en = 1U; // modify
168-
apb1_enable.bits.spi2en = 1U; // modify
169-
stm32::peripherals::reset_and_clock_control.apb1_peripheral_clock_enable = apb1_enable; // write
166+
apb1_enable = stm32::f4xx::reset_and_clock_control.apb1_peripheral_clock_enable; // read
167+
apb1_enable.bits.tim2en = 1U; // modify
168+
apb1_enable.bits.spi2en = 1U; // modify
169+
stm32::f4xx::reset_and_clock_control.apb1_peripheral_clock_enable = apb1_enable; // write
170170

171171
// enable the AHB1 peripherals in the Reset and Clock Control register
172-
ahb1_enable = stm32::peripherals::reset_and_clock_control.ahb1_peripheral_clock_enable; // read
173-
ahb1_enable.bits.dma1en = 1; // modify
174-
ahb1_enable.bits.dma2en = 1; // modify
175-
stm32::peripherals::reset_and_clock_control.ahb1_peripheral_clock_enable = ahb1_enable; // write
172+
ahb1_enable = stm32::f4xx::reset_and_clock_control.ahb1_peripheral_clock_enable; // read
173+
ahb1_enable.bits.dma1en = 1; // modify
174+
ahb1_enable.bits.dma2en = 1; // modify
175+
stm32::f4xx::reset_and_clock_control.ahb1_peripheral_clock_enable = ahb1_enable; // write
176176

177177
// enable the ABP2 peripherals in the Reset and Clock Control register
178-
apb2_enable = stm32::peripherals::reset_and_clock_control.apb2_peripheral_clock_enable; // read
179-
apb2_enable.bits.spi1en = 1; // modify
180-
apb2_enable.bits.usart1en = 1; // modify
181-
stm32::peripherals::reset_and_clock_control.apb2_peripheral_clock_enable = apb2_enable; // write
178+
apb2_enable = stm32::f4xx::reset_and_clock_control.apb2_peripheral_clock_enable; // read
179+
apb2_enable.bits.spi1en = 1; // modify
180+
apb2_enable.bits.usart1en = 1; // modify
181+
stm32::f4xx::reset_and_clock_control.apb2_peripheral_clock_enable = apb2_enable; // write
182182

183183
jarnax::print(
184184
"Feature Clock is%" PRIu32
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
INCLUDE stm32h7xxxx-zero-table.ld
1+
INCLUDE stm32h7xx-zero-table.ld

boards/nucleo_h753zi/scripts/client.gdb.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)