From 529d816a39e9b42b72c7684ffd917cc7e15925b4 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Sat, 26 Sep 2020 13:37:40 -0700 Subject: [PATCH] px4_fmu-v6x:Support ETM Hardware Trace --- boards/px4/fmu-v6x/src/board_config.h | 42 ++- platforms/nuttx/Debug/FMUv6_Trace.pex | Bin 0 -> 2036 bytes .../nuttx/Debug/jtrace_debug_ozone.jdebug | 328 ++++++++++++++++++ 3 files changed, 364 insertions(+), 6 deletions(-) create mode 100644 platforms/nuttx/Debug/FMUv6_Trace.pex create mode 100644 platforms/nuttx/Debug/jtrace_debug_ozone.jdebug diff --git a/boards/px4/fmu-v6x/src/board_config.h b/boards/px4/fmu-v6x/src/board_config.h index 17d23e42f9..c398a2da61 100644 --- a/boards/px4/fmu-v6x/src/board_config.h +++ b/boards/px4/fmu-v6x/src/board_config.h @@ -47,12 +47,15 @@ #include #include + #include /**************************************************************************************************** * Definitions ****************************************************************************************************/ +#undef TRACE_PINS + /* PX4IO connection configuration */ #define BOARD_USES_PX4IO_VERSION 2 @@ -83,10 +86,9 @@ * TRACED0 PE3 - nLED_RED - Trace Connector Pin 3 * TRACED1 PE4 - nLED_GREEN - Trace Connector Pin 5 * TRACED2 PE5 - nLED_BLUE - Trace Connector Pin 7 - * TRACED3 PC12 - UART5_TX_TELEM2 - Trace Connector Pin 8 + * TRACED3 PE6 - nARMED - Trace Connector Pin 8 */ -#undef TRACE_PINS /* LEDs are driven with push open drain to support Anode to 5V or 3.3V or used as TRACE0-2 */ @@ -100,9 +102,23 @@ # define BOARD_ARMED_STATE_LED LED_BLUE #else -# if defined(CONFIG_STM32H7_UART5) && (GPIO_UART5_TX == GPIO_UART5_TX_3) -# error Need to disable CONFIG_STM32H7_UART5 for Trace 3 (Retarget to CAN2 if need be) -# endif + +# define GPIO_TRACECLK1 (GPIO_TRACECLK |GPIO_PULLUP|GPIO_SPEED_100MHz|GPIO_PUSHPULL) //(GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN2) +# define GPIO_TRACED0 (GPIO_TRACED0_2|GPIO_PULLUP|GPIO_SPEED_100MHz|GPIO_PUSHPULL) //(GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN3) +# define GPIO_TRACED1 (GPIO_TRACED1_2|GPIO_PULLUP|GPIO_SPEED_100MHz|GPIO_PUSHPULL) //(GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN4) +# define GPIO_TRACED2 (GPIO_TRACED2_2|GPIO_PULLUP|GPIO_SPEED_100MHz|GPIO_PUSHPULL) //(GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN5) +# define GPIO_TRACED3 (GPIO_TRACED3_2|GPIO_PULLUP|GPIO_SPEED_100MHz|GPIO_PUSHPULL) //(GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN6) +//#define GPIO_TRACESWO //(GPIO_ALT|GPIO_AF0|GPIO_PORTB|GPIO_PIN3) + +# undef BOARD_HAS_CONTROL_STATUS_LEDS +# undef BOARD_OVERLOAD_LED +# undef BOARD_ARMED_STATE_LED + +# define GPIO_nLED_RED GPIO_TRACED0 +# define GPIO_nLED_GREEN GPIO_TRACED1 +# define GPIO_nLED_BLUE GPIO_TRACED2 +# define GPIO_nARMED GPIO_TRACED3 +# define GPIO_nARMED_INIT GPIO_TRACED3 #endif @@ -230,10 +246,12 @@ * The GPIO will be set as input while not armed HW will have external HW Pull UP. * While armed it shall be configured at a GPIO OUT set LOW */ +#if !defined(TRACE_PINS) #define GPIO_nARMED_INIT /* PE6 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN6) #define GPIO_nARMED /* PE6 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN6) - #define BOARD_INDICATE_ARMED_STATE(on_armed) px4_arch_configgpio((on_armed) ? GPIO_nARMED : GPIO_nARMED_INIT) +#endif + /* PWM */ @@ -417,7 +435,19 @@ #define BOARD_HAS_ON_RESET 1 +#if defined(TRACE_PINS) +#define GPIO_TRACE \ + GPIO_TRACECLK1, \ + GPIO_TRACED0, \ + GPIO_TRACED1, \ + GPIO_TRACED2, \ + GPIO_TRACED3 +#else +#define GPIO_TRACE (GPIO_OUTPUT|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN2) +#endif + #define PX4_GPIO_INIT_LIST { \ + GPIO_TRACE, \ PX4_ADC_GPIO, \ GPIO_HW_VER_REV_DRIVE, \ GPIO_CAN1_TX, \ diff --git a/platforms/nuttx/Debug/FMUv6_Trace.pex b/platforms/nuttx/Debug/FMUv6_Trace.pex new file mode 100644 index 0000000000000000000000000000000000000000..c045d3f4983e2609a3c0b642d9068c6fc03776f8 GIT binary patch literal 2036 zcmb7^-)qxQ6vt2NYy!LJ)sEnU4|i5d6@_f8Fp5IgF40QLip|7_F^O$j;z~M_JQSbi z%b@>7eJTC{{sX@3&Htgk^i>7%#fN&*w6)7jybD}%e%#N={hk|6t^9Hm5&&NSAc;%I z6@G@8moRuAHA@j>3Npjb^-Qm-7y+w-7_2yU?2t+o$2#^3 z>|bc^9+dZ9DD}$IXZmZbSFY=7$#Bh`X47F$nA}rjS>2LlnWr4Mmf&sRAF4ohTRZjg|Px5fvt(DJH|RH z$m99wJg0(I{7PH&LqdWHKJODm+@XX7aTVi4G|&$iO$>O#$!C{%pPBO_C$HW5`+c98 z^K8MNPR~ES5k9{J{+{{%b9%QU^kSS#Zw$|+H-^`i`W2}c`FOoq`1oU;j?H+fcJqYP# z5qdGsr8kD>(i_8b=|%p3di%4e-z_>(NK*^*tH+5sC( Mj1=^LuHr=g18CLC@Bjb+ literal 0 HcmV?d00001 diff --git a/platforms/nuttx/Debug/jtrace_debug_ozone.jdebug b/platforms/nuttx/Debug/jtrace_debug_ozone.jdebug new file mode 100644 index 0000000000..6e4b4efce5 --- /dev/null +++ b/platforms/nuttx/Debug/jtrace_debug_ozone.jdebug @@ -0,0 +1,328 @@ +/********************************************************************* +* (c) SEGGER Microcontroller GmbH * +* The Embedded Experts * +* www.segger.com * +********************************************************************** + +File : jtrace_debug_ozone.jdebug +Created : 26 Oct 2020 14:30 +Ozone Version : V3.20e +*/ + +/********************************************************************* +* +* OnProjectLoad +* +* Function description +* Project load routine. Required. +* +********************************************************************** +*/ +void OnProjectLoad (void) { + // + // Dialog-generated settings + // + Project.SetTraceSource ("Trace Pins"); + Project.SetDevice ("STM32H753II"); + Project.SetHostIF ("USB", ""); + Project.SetTargetIF ("SWD"); + Project.SetTIFSpeed ("4 MHz"); + Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M7F.svd"); + Project.AddSvdFile ("$(InstallDir)/Config/Peripherals/ARMv7M.svd"); + // + // User settings + // + Edit.Preference (PREF_TIMESTAMP_FORMAT, TIMESTAMP_FORMAT_INST_CNT); + Edit.SysVar (VAR_TRACE_TIMESTAMPS_ENABLED, 0); + Edit.SysVar (VAR_TRACE_CORE_CLOCK, 480000000); +} + +/********************************************************************* +* +* OnStartupComplete +* +* Function description +* Called when program execution has reached/passed +* the startup completion point. Optional. +* +********************************************************************** +*/ +//void OnStartupComplete (void) { +//} + +/********************************************************************* +* +* TargetReset +* +* Function description +* Replaces the default target device reset routine. Optional. +* +* Notes +* This example demonstrates the usage when +* debugging a RAM program on a Cortex-M target device +* +********************************************************************** +*/ +//void TargetReset (void) { +// +// unsigned int SP; +// unsigned int PC; +// unsigned int VectorTableAddr; +// +// VectorTableAddr = Program.GetBaseAddr(); +// +// if (VectorTableAddr != 0xFFFFFFFF) { +// SP = Target.ReadU32(VectorTableAddr); +// Target.SetReg("SP", SP); +// } else { +// Util.Log("Project file error: failed to get program base"); +// } +// +// PC = Elf.GetEntryPointPC(); +// +// if (PC != 0xFFFFFFFF) { +// Target.SetReg("PC", PC); +// } else if (VectorTableAddr != 0xFFFFFFFF) { +// PC = Target.ReadU32(VectorTableAddr + 4); +// Target.SetReg("PC", PC); +//} + +/********************************************************************* +* +* BeforeTargetReset +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void BeforeTargetReset (void) { +//} + +/********************************************************************* +* +* AfterTargetReset +* +* Function description +* Event handler routine. Optional. +* - Sets the PC register to program reset value. +* - Sets the SP register to program reset value on Cortex-M. +* +********************************************************************** +*/ +void AfterTargetReset (void) { + unsigned int SP; + unsigned int PC; + unsigned int VectorTableAddr; + + VectorTableAddr = Elf.GetBaseAddr(); + + if (VectorTableAddr == 0xFFFFFFFF) { + Util.Log("Project file error: failed to get program base"); + } else { + SP = Target.ReadU32(VectorTableAddr); + Target.SetReg("SP", SP); + + PC = Target.ReadU32(VectorTableAddr + 4); + Target.SetReg("PC", PC); + } +} +/********************************************************************* +* +* DebugStart +* +* Function description +* Replaces the default debug session startup routine. Optional. +* +********************************************************************** +*/ +//void DebugStart (void) { +//} + +/********************************************************************* +* +* TargetConnect +* +* Function description +* Replaces the default target IF connection routine. Optional. +* +********************************************************************** +*/ +//void TargetConnect (void) { +//} + +/********************************************************************* +* +* BeforeTargetConnect +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +void BeforeTargetConnect (void) { + Project.SetJLinkScript("FMUv6_Trace.pex"); +} + +/********************************************************************* +* +* AfterTargetConnect +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void AfterTargetConnect (void) { +//} + +/********************************************************************* +* +* TargetDownload +* +* Function description +* Replaces the default program download routine. Optional. +* +********************************************************************** +*/ +//void TargetDownload (void) { +//} + +/********************************************************************* +* +* BeforeTargetDownload +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void BeforeTargetDownload (void) { +//} + +/********************************************************************* +* +* AfterTargetDownload +* +* Function description +* Event handler routine. Optional. +* - Sets the PC register to program reset value. +* - Sets the SP register to program reset value on Cortex-M. +* +********************************************************************** +*/ +void AfterTargetDownload (void) { + unsigned int SP; + unsigned int PC; + unsigned int VectorTableAddr; + + VectorTableAddr = Elf.GetBaseAddr(); + Util.Log("___"); + if (VectorTableAddr == 0xFFFFFFFF) { + Util.Log("Project file error: failed to get program base"); + } else { + SP = Target.ReadU32(VectorTableAddr); + Target.SetReg("SP", SP); + + PC = Target.ReadU32(VectorTableAddr + 4); + Target.SetReg("PC", PC); + } +} + +/********************************************************************* +* +* BeforeTargetDisconnect +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void BeforeTargetDisconnect (void) { +//} + +/********************************************************************* +* +* AfterTargetDisconnect +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void AfterTargetDisconnect (void) { +//} + +/********************************************************************* +* +* AfterTargetHalt +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void AfterTargetHalt (void) { +//} + +/********************************************************************* +* +* BeforeTargetResume +* +* Function description +* Event handler routine. Optional. +* +********************************************************************** +*/ +//void BeforeTargetResume (void) { +//} + +/********************************************************************* +* +* OnSnapshotLoad +* +* Function description +* Called upon loading a snapshot. Optional. +* +* Additional information +* This function is used to restore the target state in cases +* where values cannot simply be written to the target. +* Typical use: GPIO clock needs to be enabled, before +* GPIO is configured. +* +********************************************************************** +*/ +//void OnSnapshotLoad (void) { +//} + +/********************************************************************* +* +* OnSnapshotSave +* +* Function description +* Called upon saving a snapshot. Optional. +* +* Additional information +* This function is usually used to save values of the target +* state which can either not be trivially read, +* or need to be restored in a specific way or order. +* Typically use: Memory Mapped Registers, +* such as PLL and GPIO configuration. +* +********************************************************************** +*/ +//void OnSnapshotSave (void) { +//} + +/********************************************************************* +* +* OnError +* +* Function description +* Called when an error ocurred. Optional. +* +********************************************************************** +*/ +//void OnError (const char* sErrorMsg) { +//} +