2020-11-02 03:28 AM
Hi,
I'm having some issues with setting up the IDE for dual-debugging so I can access both the M7 and M4 core in the same IDE.
I'm using STLink V3Set for debugging and GDB (I could not get the OCD setup working at all).
I have tried going through the steps in AN5361, but judging by the pictures and references in the document, it is not actually done or tested on CubeIDE, but SW4STM32. Is this true?
The CM7 part works as expected, once I try to start the CM4 part, I get the error for STLink device not detected or could not start GDB server.
I have set enough gap in the port numbers that this should suffice.
Has anyone gotten this to work on CubeIDE or are we out of luck with the tools?
Best regards,
2020-11-02 04:37 AM
To give some more insight to my question, I know implemented the debug configurations step by step as per the application note.
I do manage to (on occasion) get the two core into debug mode simultaneously while they both wait at their starting breakpoints in the beginning of main.
I then set the CM7 to run mode (no breakpoints in the code).
And, if I set CM4 into run mode, I get a SIGTRAP:Trace/breakpoint trap at location 0xa05f0000
This only happens if I set CM4 to run mode, if I step through the code untile the startup semaphore has been handled (CM7 releases a semaphore to signal CM4 "ready to start"), I do not get the error. But my for example my ADCs do not work, I can't get them to calibrate properly without HAL-errors.
Here is the startup of the code
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
/*HW semaphore Clock enable*/
__HAL_RCC_HSEM_CLK_ENABLE();
/* Activate HSEM notification for Cortex-M4*/
HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
/*
Domain D2 goes to STOP mode (Cortex-M4 in deep-sleep) waiting for Cortex-M7 to
perform system initialization (system clock config, external memory configuration.. )
*/
HAL_PWREx_ClearPendingEvent();
HAL_PWREx_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFE, PWR_D2_DOMAIN);
/* Clear HSEM flag */
__HAL_HSEM_CLEAR_FLAG(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
/* USER CODE END Boot_Mode_Sequence_1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
So, if I step the code until line 25, everything is fine (no SIGTRAP), but it seems my peripheral clocks are "off" or wonky. If I set the code to run from the beginning, I end up int SIGTRAP.
Any ideas?
This is CubeMX generated code that I hope has been tested and I'm just missing something.
2020-11-02 05:52 AM
And some more food for thought if anyone has any ideas.
I have setup a small example using ADC1, I'm trying to calibrate it on the CM4 and use it on the CM4.
The code looks as follows:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
/*HW semaphore Clock enable*/
__HAL_RCC_HSEM_CLK_ENABLE();
/* Activate HSEM notification for Cortex-M4*/
HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
/*
Domain D2 goes to STOP mode (Cortex-M4 in deep-sleep) waiting for Cortex-M7 to
perform system initialization (system clock config, external memory configuration.. )
*/
HAL_PWREx_ClearPendingEvent();
HAL_PWREx_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFE, PWR_D2_DOMAIN);
/* Clear HSEM flag */
__HAL_HSEM_CLEAR_FLAG(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
/* USER CODE END Boot_Mode_Sequence_1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C2_SMBUS_Init();
MX_SPI2_Init();
MX_SPI5_Init();
MX_TIM1_Init();
MX_TIM4_Init();
MX_TIM5_Init();
MX_TIM12_Init();
MX_TIM15_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_ADC3_Init();
MX_DAC1_Init();
MX_TIM17_Init();
/* USER CODE BEGIN 2 */
configureTca6507();
if(HAL_ADCEx_Calibration_Start(&hadc2, ADC_CALIB_OFFSET, ADC_DIFFERENTIAL_ENDED) != HAL_OK) {
Error_Handler();
}
if(HAL_ADC_Start(&hadc2) != HAL_OK) {
Error_Handler();
}
if(HAL_ADC_PollForConversion(&hadc2, 1000) != HAL_OK) {
Error_Handler();
}
uint32_t measuredValue = 0;
measuredValue = HAL_ADC_GetValue(&hadc2);
while(measuredValue != 0x0000) {
HAL_GPIO_TogglePin(DigitalDebugLedOut02_GPIO_Port, DigitalDebugLedOut02_Pin);
HAL_Delay(500);
}
This code works if I just set it to run without debugging, or if I'm debugging CM7. But if I'm connected to CM4 and I step through the first part (around line 7), I will get to the calibration part and that will fail, I have now had the calibration on the background in debug mode for a few minutes. And it is still running the calibration function.
It's like the clock is running real slow or something like that, when calibrating.
My debug registers look like this:
CM4:CM7:These should be OK, right? The clocks should be running as normal.
I have now had the calibration running in the background for couple of more minutes, and it is still running, without hitting any timeouts or anything.
I tried pausing the run mode manually (breakpoints don't seem to work anymore in this mode) and it is stuck in this mode:
while (LL_ADC_IsCalibrationOnGoing(hadc->Instance) != 0UL)
{
wait_loop_index++;
if (wait_loop_index >= ADC_CALIBRATION_TIMEOUT)
{
/* Update ADC state machine to error */
ADC_STATE_CLR_SET(hadc->State,
HAL_ADC_STATE_BUSY_INTERNAL,
HAL_ADC_STATE_ERROR_INTERNAL);
/* Process unlocked */
__HAL_UNLOCK(hadc);
return HAL_ERROR;
}
}
More specifically on line 1 of this. If I set a breakpoint here, it does not break when it hits the while-call, I have to manually stop and I'm on that line or inside the call in the while condition.
Any thoughts?