@@ -9,7 +9,7 @@ GDB SWO Trace Configuration Helpers
99Setup Device
1010------------
1111STM32;
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
1515IMXRT;
@@ -90,18 +90,26 @@ set $CPU_S32K344=6
9090set $CPU_IMXRT117X=7
9191set $CPU_KINETIS=8
9292set $CPU_SAMD5x=9
93+ set $CPU_STM32M33=10
9394
9495# ====================================================================
9596set $CDBBASE=0xE000EDF0
9697set $DWTBASE=0xE0001000
9798set $ITMBASE=0xE0000000
9899set $TPIUBASE=0xE0040000
99100set $ETMBASE=0xE0041000
101+ set $CTIBASE=0xE0042000
100102
101103define _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
105113end
106114
107115define _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
907919end
908920document 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
910923end
911924# ====================================================================
912925define 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
11171143end
11181144document enableSTM32TRACE
11191145enableSTM32TRACE <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
11221149end
11231150# ====================================================================
11241151define enableNRF52TRACE
0 commit comments