2023-04-29 05:53 AM
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
2023-04-29 11:40 AM
You may find the answer in Application Note AN4989, section 7.4.
Hope that helps?
Good luck and regards
/Peter
2023-04-29 12:29 PM
VCP UART and Pins? SWD PB3 SWO pin? Correct core frequency and HSE_VALUE? 25 MHz not 8 MHz
2023-04-30 03:01 AM
2023-04-30 03:03 AM
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 ?
2023-04-30 05:44 AM
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.
2023-04-30 06:07 AM
2023-04-30 09:14 AM
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...)