Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for sam 5x mcu trace #150

Merged
merged 4 commits into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion Support/gdbtrace.init
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ IMXRT;

SAM5X;
enableSAMD5XSWD : Enable SWO on SAM5X output pin on SAM5X
enableSAMD5XTRACE : Enable TRACE on SAM5x pins

NRF;
enableNRF52TRACE : Start TRACE on NRF52 (not nrf52833 or nrf52840) pins
Expand Down Expand Up @@ -88,6 +89,7 @@ set $CPU_TM4C=5
set $CPU_S32K344=6
set $CPU_IMXRT117X=7
set $CPU_KINETIS=8
set $CPU_SAMD5x=9

# ====================================================================
set $CDBBASE=0xE000EDF0
Expand Down Expand Up @@ -923,7 +925,6 @@ end
document enableSAMD5XSWD
enableSAMD5XSWD Configure output pin on SAM5X for SWO use.
end

# ====================================================================
define enableEFR32MG12SWO
#set language c
Expand Down Expand Up @@ -1488,7 +1489,88 @@ document enableLPC176xTRACE
enableLPC176xTRACE Enable TRACE on LPC176x pins.
<Width> : Number of bits wide (1,2 or 4 only)
end
# ====================================================================
define enableSAMD5XTRACE
#set language c

set $bits=4
set $drive=1

if $argc >= 1
set $bits = $arg0
end
if (($bits<1) || ($bits==3) || ($bits>4))
help enableSAMD5XTRACE
end

if $argc >= 2
set $drive = $arg1
end

if ($drive > 1)
help enableSAMD5XTRACE
end

set $bits = $bits-1
set $CPU=$CPU_SAMD5x

# Enable peripheral channel clock on GCLK#0
# GCLK->PHCTRL[47] = GCLK_PCHCTRL_GEN(0)
set *(unsigned char *)0x40001D3C = 0
# GCLK->PHCTRL[47] |= GCLK_PCHCTRL_CHEN
set *(unsigned char *)0x40001D3C |= 0x40

# Setup PC28 - pmux 7
set *(unsigned char *)(0x41008000+0x80*2+0x30+28/2) &= ~0x0f
set *(unsigned char *)(0x41008000+0x80*2+0x30+28/2) |= 0x07
set *(unsigned char *)(0x41008000+0x80*2+0x40+28) = (($drive) << 6) | 1

# Setup PC27 - pmux 7
set *(unsigned char *)(0x41008000+0x80*2+0x30+27/2) &= ~0xf0
set *(unsigned char *)(0x41008000+0x80*2+0x30+27/2) |= 0x70
set *(unsigned char *)(0x41008000+0x80*2+0x40+27) = (($drive) << 6) | 1

if ($bits>0)
# Setup PC26 - pmux 7
set *(unsigned char *)(0x41008000+0x80*2+0x30+26/2) &= ~0x0f
set *(unsigned char *)(0x41008000+0x80*2+0x30+26/2) |= 0x07
set *(unsigned char *)(0x41008000+0x80*2+0x40+26) = (($drive) << 6) | 1
end

if ($bits>1)
# Setup PC25 - pmux 7
set *(unsigned char *)(0x41008000+0x80*2+0x30+25/2) &= ~0xf0
set *(unsigned char *)(0x41008000+0x80*2+0x30+25/2) |= 0x70
set *(unsigned char *)(0x41008000+0x80*2+0x40+25) = (($drive) << 6) | 1

# Setup PC24 - pmux 7
set *(unsigned char *)(0x41008000+0x80*2+0x30+24/2) &= ~0x0f
set *(unsigned char *)(0x41008000+0x80*2+0x30+24/2) |= 0x07
set *(unsigned char *)(0x41008000+0x80*2+0x40+24) = (($drive) << 6) | 1
end

# Set number of bits in DBGMCU_CR
set *0xE0042004 &= ~(3<<6)

if ($bits<3)
set *0xE0042004 |= ((($bits+1)<<6) | (1<<5))
else
set *0xE0042004 |= ((3<<6) | (1<<5))
end

# Enable Trace TRCENA (DCB DEMCR)
set *($CDBBASE+0xC)=(1<<24)

# Finally start the trace output
_doTRACE

#set language auto
end
document enableSAMD5XTRACE
enableSAMD5XTRACE <Width> <Drive>: Enable TRACE on SAM5x pins
<Width> : Number of bits wide (1,2 or 4 only)
<Drive> : Drive strength (0=normal, 1=strong)
end
# ====================================================================
define dwtPOSTCNT
#set language c
Expand Down
Loading