cancel
Showing results for 
Search instead for 
Did you mean: 

semihosting in stm32f746disco

mBosc.11
Associate II

Hi everyone,

 i want to ask a question about semihosting printing messages in console. I've been using it for some time and it works well. I use it on boards designed by me with various micros and with the ST-LINK/V2 emulator, no problem. I happened to have to use the STM32F746G-DISCO evaluation card, this card already has the emulator integrated on the card... in this case I couldn't get the semihosting to work with console messages. What's different ? Can anyone tell me if he managed to make it work and how?

Thanks

7 REPLIES 7
Peter BENSCH
ST Employee

You may find the answer in Application Note AN4989, section 7.4.

Hope that helps?

Good luck and regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

VCP UART and Pins? SWD PB3 SWO pin? Correct core frequency and HSE_VALUE? 25 MHz not 8 MHz​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mBosc.11
Associate II

mBosc.11
Associate II

thanks for the answer, and the documentation, I checked and did exactly as described, since in other tabs it works.

I found out where the problem is... this micro is an M7 and it has the i cache and the dcache, if I disable these the semihosting works...

But unfortunately I need them because I use ethenet and LWIP, I configured the regions for ethernet (which works). But I don't know what I have to do for semihosting.

can you help me ?

Can only help if you explain method and show related code. Not clear why cache would be a specific issue.

DTCM shouldn't be an issue, not sure how USART would be either.​

Perhaps need to use memory fencing instructions or cache ByAddr maintenance. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mBosc.11
Associate II
 
Pavel A.
Evangelist III

Confirmed here, with STM32F767 on custom board similar to Discovery-STM32746G.

When D-Cache is NOT enabled, semihosting prints and file opens work well.

After D-Cache enabled, printf prints garbage, opening a file fails.

#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
extern void initialise_monitor_handles(void);
 
void test_semihosting(void)
{
  initialise_monitor_handles();
  //SCB_EnableDCache(); //<<< if this is commented, semihosting works
  SCB_EnableICache();
  __DSB();
 
  printf("Test semihosting! read big file from host\n");
  char const* fname =  "F:/test/test.bin";
 
  int fd = open(fname, O_RDONLY|O_BINARY);
  if (fd <= 0) {
	  printf("Error open file!\n");
	  return;
  }
......................

 My program runs in RAM, if this matters (and there's another OpenOCD related bug...)