cancel
Showing results for 
Search instead for 
Did you mean: 

Troubles getting started STM32H7B3I-DK

bojankoce
Associate II

Hello, guys.

I recently bought STM32H7B3I-DK and started playing with it. There are a few questions/issues I have:

1) It seems that the board is recognized by the host PC only when it is directly connected to the PC's USB port. If I connect it through USB hub, the board is not visible and, consequently, not accessible. Do you have any idea why is that?

2) I would like to perform printf style debugging of the code from STM32CubeIDE tool. I enabled SWV in Debug settings, opened SWV ITM Data Console, enabled port 0 and started trace. However, no printf messages are printed on the cosole. I am not sure how to set ITM block active. Would this be enough for transferring printf message to ITM block FIFO?

#define DEMCR        			*((volatile uint32_t*) 0xE000EDFCU )
 
/* ITM register addresses */
#define ITM_STIMULUS_PORT0   	*((volatile uint32_t*) 0xE0000000 )
#define ITM_TRACE_EN          	*((volatile uint32_t*) 0xE0000E00 )
 
void ITM_SendChar(uint8_t ch)
{
	//Enable TRCENA
	DEMCR |= ( 1 << 24);
 
	//enable stimulus port 0
	ITM_TRACE_EN |= ( 1 << 0);
 
	// read FIFO status in bit [0]:
	while(!(ITM_STIMULUS_PORT0 & 1));
 
	//Write to ITM stimulus port0
	ITM_STIMULUS_PORT0 = ch;
}

3) Where can I find source codes for the examples you provided in the form of .hex/.bat files?

Thanks in advance for your time and efforts.

Looking forward to reading from you.

Sincerely,

Bojan.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Bojan,

That is probably sign of that USB3.0 hub can't communicate HS with the STLink3 (and STLink3 does not implement full functionality in FS, and ST said clearly they won't fix this, I'm not going to look up that thread). Not all USB3 hubs are up to the task, there's too much crap out there.

You've tried using several cables I presume.

Jan

View solution in original post

9 REPLIES 9

 > If I connect it through USB hub, the board is not visible and, consequently, not accessible. Do you have any idea why is that?

Is it a High-Speed hub?

You likely have STLinkV3 on that board and that does not support Full Speed USB.

JW

bojankoce
Associate II

Hello, Jan.

Yes, the hub I have is USB3.0 hub.

Is there any update of STLinkV3 I need to implement in order to be able to use the board through the hub?

> USB3.0 hub

That paradoxically may make things worse. Is there anything else connected to that hub, and to other USB3 ports on the PC which may go to the same root hub?

Is this a Windows PC? Do you "see" the STLink in the Device Manager if you connect it through the hub (compare to situation when it's connected directly)? Can you see a different hub, possibly a USB2 one?

JW

bojankoce
Associate II

Hi @Community member​ .

Even if I have only DK board is connected on USB3.0 hub I have a problem to see the board. I am running Windows 10 here. When connected through USB3.0 hub, the board is seen as USB Composite Device.

When I connect the board directly to PC USB port or through USB2.0 hub (just gave it a try), the board is normally seen through STMicroelectronics STLink Virtual COM Port.

It seems that USB3.0 hub is causing the trouble. Is there any way (workaround) for that?

Sincerely,

Bojan.

Hi Bojan,

That is probably sign of that USB3.0 hub can't communicate HS with the STLink3 (and STLink3 does not implement full functionality in FS, and ST said clearly they won't fix this, I'm not going to look up that thread). Not all USB3 hubs are up to the task, there's too much crap out there.

You've tried using several cables I presume.

Jan

bojankoce
Associate II

OK, @Community member​ , thank you very much for your efforts! It is now clear what is going on.

Will not bother anymore with this thread because I have the way to continue playing with the DK.

Cheers,

Bojan.

We did not discuss your 2nd question so if it's still pertinent please repost it in a new thread.

JW

bojankoce
Associate II

Yes, indeed, you did not address questions 2 and 3. I am still interested to find out the answers.

would you mind to address those questions here?

Thanks in advance!

Bojan.

Nikita91
Lead II

To initialize SWO a use this function:

void swoInit (uint32_t portMask, uint32_t cpuCoreFreqHz, uint32_t baudrate)
{
	gpioPinDesc_t		pb3Desc ;
 
	uint32_t SWOPrescaler = (cpuCoreFreqHz / baudrate) - 1 ; // divider value
 
	// Enable debug clocks
	DBGMCU->CR = 0x00700000 ;	// D3DBGCKEN D1DBGCKEN TRACECLKEN
 
	// SWO->LAR unlock
	*((uint32_t *)(SWO_BASE + 0xFB0)) = 0xC5ACCE55 ; // SWO_LAR
 
	// SWO divider setting, SWO->CODR = PRESCALER[12:0]
	*((__IO uint32_t *)(SWO_BASE + 0x010)) = SWOPrescaler ; // SWO_CODR
 
	// SWO set the protocol, SWO->SPPR = PPROT[1:0] = NRZ
	*((__IO uint32_t *)(SWO_BASE + 0x0F0)) = 0x00000002 ; // SWO_SPPR
 
	// UNLOCK FUNNEL, SWTF->LAR unlock
	*((__IO uint32_t *)(SWTF_BASE + 0xFB0)) = 0xC5ACCE55 ; // SWTF_LAR
 
	// Enable ITM input of SWO trace funnel. SWTF->CTRL bit 0 ENSO = Enable
	*((__IO uint32_t *)(SWTF_BASE + 0x000)) |= 1 ; // SWFT_CTRL
 
 
	// Configure ITM
	ITM->LAR	= 0xC5ACCE55 ;							// ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC
	ITM->TCR	= 0x00010001 ;							// ITM Trace Control Register
	ITM->TPR	= ITM_TPR_PRIVMASK_Msk ;				// ITM Trace Privilege Register. All stimulus ports
	ITM->TER	= portMask ;							// ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port.
 
 
	// RCC_AHB4ENR enable GPIOB clock
	RCC->AHB4ENR |= RCC_AHB4ENR_GPIOBEN ;
 
	// Configure SWO output pin PB3
	pb3Desc.port 	= 'B';
	pb3Desc.pin 	= 3 ;
	pb3Desc.af		= 0 ;
	pb3Desc.flags 	= AA_GPIO_MODE_ALTERNATE | AA_GPIO_SPEED_HIGH | AA_GPIO_PUSH_PULL ;
	gpioConfigurePin (& pb3Desc) ;
 
	// ITM/SWO works only if enabled from debugger.
	// If ITM stimulus 0 is not free, don't try to send data to SWO
	if (ITM->PORT [0].u8 == 1)
	{
		bItmAvailable = 1 ;
	}
}

And to transmit a char:

void swoPutChar (char value)
{
	aaIrqStatus_t	intState ;
 
	if (bItmAvailable != 0)
	{
		while (1)
		{
			intState = bspSaveAndDisableIrq () ;
			if (ITM->PORT [0].u8 == 1)
			{
				ITM->PORT[0].u8 = (uint8_t) value ;
				bspRestoreIrq (intState) ;
				break ;
			}
			bspRestoreIrq (intState) ;
		}
	}
}