Skip to content

Commit e3d78e6

Browse files
committed
Add support for STM32 M33 devices (Specifically tested on STM32U5A5)
1 parent 1ec6487 commit e3d78e6

2 files changed

Lines changed: 44 additions & 13 deletions

File tree

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 2.3.0 In progress
2+
* Add support for ITM rollover counters in orbtop (if they deliver information, they will be displayed)
3+
* Add STM32 CORTEX-M33 support (Tested on STM32U5A5)
4+
15
21st Sept 2024 (Version 2.2.0)
26

37
* Add COBS draining state to re-sync as quickly as possible

Support/gdbtrace.init

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GDB SWO Trace Configuration Helpers
99
Setup Device
1010
------------
1111
STM32;
12-
enableSTM32SWO : Enable SWO on STM32 pins (for F4 or F7 if 4/7 is passed as first argument)
12+
enableSTM32SWO : Enable SWO on STM32 pins
1313
enableSTM32TRACE: Start TRACE on STM32 pins
1414

1515
IMXRT;
@@ -90,18 +90,26 @@ set $CPU_S32K344=6
9090
set $CPU_IMXRT117X=7
9191
set $CPU_KINETIS=8
9292
set $CPU_SAMD5x=9
93+
set $CPU_STM32M33=10
9394

9495
# ====================================================================
9596
set $CDBBASE=0xE000EDF0
9697
set $DWTBASE=0xE0001000
9798
set $ITMBASE=0xE0000000
9899
set $TPIUBASE=0xE0040000
99100
set $ETMBASE=0xE0041000
101+
set $CTIBASE=0xE0042000
100102

101103
define _setAddressesSTM32
102104
# Locations in the memory map for interesting things on STM32
103-
set $RCCBASE = 0x40023800
104-
set $GPIOBASE = 0x40020000
105+
if ($CPU == $CPU_STM32M33)
106+
set $RCCBASE = 0x46020c00
107+
set $GPIOBASE = 0x42020000
108+
set $DBGMCUBASE = 0xE0044000
109+
else
110+
set $RCCBASE = 0x40023800
111+
set $GPIOBASE = 0x40020000
112+
set $DBGMCUBASE = 0xE0042000
105113
end
106114

107115
define _setAddressesIMXRT
@@ -886,7 +894,11 @@ define enableSTM32SWO
886894
set $tgt = $arg0
887895
end
888896

889-
set $CPU=$CPU_STM32
897+
if ($tgt==33)
898+
set $CPU=$CPU_STM32M33
899+
else
900+
set $CPU=$CPU_STM32
901+
end
890902
_setAddressesSTM32
891903

892904
if (($tgt==4) || ($tgt==7))
@@ -901,12 +913,13 @@ define enableSTM32SWO
901913
end
902914
# Common initialisation.
903915
# DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN;
904-
set *0xE0042004 |= 0x20
916+
set *($DBGMCUBASE+4) |= 0x20
905917

906918
#set language auto
907919
end
908920
document enableSTM32SWO
909-
enableSTM32SWO Configure output pin on STM32 for SWO use.
921+
enableSTM32SWO <Type> Configure output pin on STM32 for SWO use.
922+
<Type> : Type of STM32 Device 4=f4, 7=f7, 33=M33
910923
end
911924
# ====================================================================
912925
define enableSAMD5XSWD
@@ -1011,7 +1024,11 @@ define enableSTM32Pin
10111024
set $_GPIOPORT = $GPIOBASE + 0x400 * $arg0
10121025

10131026
# Enable GPIO port in RCC
1014-
set *($RCCBASE + 0x30) |= (0x1<<$arg0)
1027+
if ($CPU == $CPU_STM32M33)
1028+
set *($RCCBASE + 0x8c) |= (0x1<<$arg0)
1029+
else
1030+
set *($RCCBASE + 0x30) |= (0x1<<$arg0)
1031+
end
10151032

10161033
# MODER: Alternate Function
10171034
set *($_GPIOPORT+0x00) &= ~(0x3<<2*$arg1)
@@ -1055,6 +1072,7 @@ define enableSTM32TRACE
10551072

10561073
set $bits=4
10571074
set $drive=1
1075+
set $type=1
10581076

10591077
if $argc >= 1
10601078
set $bits = $arg0
@@ -1067,13 +1085,21 @@ define enableSTM32TRACE
10671085
set $drive = $arg1
10681086
end
10691087

1088+
if $type >= 3
1089+
set $drive = $arg2
1090+
end
1091+
10701092
if ($drive > 3)
10711093
help enableSTM32TRACE
10721094
end
10731095

10741096
set $bits = $bits-1
1075-
set $CPU=$CPU_STM32
10761097

1098+
if ($type==33)
1099+
set $CPU=$CPU_STM32M33
1100+
else
1101+
set $CPU=$CPU_STM32
1102+
end
10771103
_setAddressesSTM32
10781104

10791105
# Enable Trace TRCENA (DCB DEMCR) needed for clocks
@@ -1099,12 +1125,12 @@ define enableSTM32TRACE
10991125
end
11001126

11011127
# Set number of bits in DBGMCU_CR
1102-
set *0xE0042004 &= ~(3<<6)
1128+
set *($DBGMCUBASE+4) &= ~(3<<6)
11031129

11041130
if ($bits<3)
1105-
set *0xE0042004 |= ((($bits+1)<<6) | (1<<5))
1131+
set *($DBGMCUBASE+4) |= ((($bits+1)<<6) | (1<<5))
11061132
else
1107-
set *0xE0042004 |= ((3<<6) | (1<<5))
1133+
set *$(DBGMCUBASE+4) |= ((3<<6) | (1<<5))
11081134
end
11091135

11101136
# Enable Trace TRCENA (DCB DEMCR)
@@ -1117,8 +1143,9 @@ define enableSTM32TRACE
11171143
end
11181144
document enableSTM32TRACE
11191145
enableSTM32TRACE <Width> <Drive>: Enable TRACE on STM32 pins
1120-
<Width> : Number of bits wide (1,2 or 4 only)
1121-
<Drive> : Drive strength (0=lowest, 3=highest)
1146+
<Width> : Number of bits wide (1,2 or 4 only, default=4)
1147+
<Drive> : Drive strength (0=lowest, 3=highest, default=1)
1148+
<Type> : Device type, 33=special for CORTEX-M33, otherwise default
11221149
end
11231150
# ====================================================================
11241151
define enableNRF52TRACE

0 commit comments

Comments
 (0)