Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


Printf via SWV doesn't print anything

Hello,

I am currently using a STM32F103RB on a Nucleo board using STM32 Workbench add-on on Eclipse.
I want to test if my ADC function works properly by using a simple “printf” but this doesn’t work...
Actually, I’m using SWV on ST-LINK and printf does not display anything.
However, I’ve tried to use “ITM_SendChar” and “ITM_SendString”; this works but displays weird characters, which don’t correspond to what I want in ASCII table. (e.g “Hello world!!\r\n” is: “˜ÅÜÜß@çßâÜÄA”

Do you have any suggestion ?

Thank you in advance,

Julien.

Hello,

to do the printf I used semihosting from https://github.com/justyn/semihosting-cortexm-uosQuestion
I did minor modifications because the compiler complains but it works fine.
In my code I have
trace_printf(“>>>>> AmbientT: %3.3f°C AmbientP: %4.1fhPa\n”, oMeasure_AmbientTemperature.m_lTemperature/1000.0F,oMeasure_AmbientPressure.m_lPressure/100.0F );
In the openocd console:
>>>>> AmbientT: 27.114°C AmbientP: 1025.4hPa
My configuration is STM32f429I-DISCO openstm321.1.0 and eCos as RTOS

Hello,

I’ve fixed my bug !
Actually, in “system_stm32f10x.c”, I uncommented “#define PLL_SOURCE_HSE” instead of “#define PLL_SOURCE_HSI” and now ITM_SendChar works properly (“printf()” still doesn’t work however).

Have a good day.

Hi Julien,

Could you please describe, how you implemented the ITM? What are the files you included? What are the functions that you used? and what softwared did you view the output in? was in the console of openOCD or ST utility? Could you please describe. That would be a lot helpful.

Thank you

Rosh


Tunisia

Hello All,

Using ITM is pretty simple.

My usage:
in syscalls.c, add #include “stm32f4xx.h” (depends on your device) & (you should include CMSIS folder)
and modify the _write function :

int _write(int file, char *ptr, int len)
{
	int DataIdx;

	for (DataIdx = 0; DataIdx < len; DataIdx++)
	{
	   ITM_SendChar( *ptr++ );
	}

	return len;
}


After that, you can use printf to output message via printf.

To visualize the ITM output, you can use ST-Link Utility (menu : ST-LINK > Printf via SWO Viewer)

Best Regards,
Tarek

I have added the syscalls.c(into the source location, where main.c is)...My source configuration is 72MHz (system clock), I have included CMSIS workspace in my directory... Changed the write routine... Still doesn’t work... Code compiles, but doesn’t work...

I am running a GPIO example, not RTOS. Will this method mentioned by you still work?

In addition, I have couple more question. how adding syscalls.c and changing the _write() function changes the implementaion of printf? how the syscall.c changes the implementation in ?

I really need get printf or ITMSend recieve working as ap. I am using stm32f3 Discovery. How to determine the clock frequency and port number so that we can see in STLInk? Please advice.

Thanks in advance :-)

Tunisia

>> I have added the syscalls.c(into the source location, where main.c is)...My source configuration is 72MHz (system clock), I have included CMSIS workspace in my directory... Changed the write routine... Still doesn’t work... Code compiles, but doesn’t work...
⇒ You need to solder the ‘Solder Bridge’ SB10 (SWO)

>> I am running a GPIO example, not RTOS. Will this method mentioned by you still work?
⇒ YES

>> In addition, I have couple more question. how adding syscalls.c and changing the _write() function changes the implementaion of printf? how the syscall.c changes the implementation in ?
⇒ Simply because printf send the string characters one by one using the _write routine (avoid using -specs=nosys.specs in linker miscellaneous flags)

>> I really need get printf or ITMSend recieve working as ap. I am using stm32f3 Discovery. How to determine the clock frequency and port number so that we can see in STLInk? Please advice.
⇒ as your cpu frequency is 72MHz, then use 72000000 as System clock and Stimulus port 0

Thanks a lot Tarek,

That was really helpful. I soldered and make the change to the linker script and YES! it is working fine.

Now I read a lot about semihosting. What is the difference between the ITM and semihosting. Could you point me in the right direction by explaining or giving me the links of resources?

Is semihosting possible in System WorkBench? or Is there any available methodology presently available where we can see the output in openOCD terminal?

By the way, this should get me going. Thanks a lot :-)

Rosh

Tunisia

>> That was really helpful. I soldered and make the change to the linker script and YES! it is working fine.
Good to hear that

>> Now I read a lot about semihosting. What is the difference between the ITM and semihosting. Could you point me in the right direction by explaining or giving me the links of resources?
Check these links : SemihostingQuestion, ITMQuestion

>> Is semihosting possible in System WorkBench? or Is there any available methodology presently available where we can see the output in openOCD terminal?
Yes, it is possible
In Debug configuration > Startup Tab , add this :

monitor arm semihosting enable

and in Project, Properties, C/C++ Build, Settings, MCU GCC Linker, Miscellaneous, Linker flags,

-specs=nosys.specs -specs=nano.specs -specs=rdimon.specs -lc -lrdimon

since you have used rdimon.specs, you don’t need to use syscalls.c
And finally in your code, you have only to call the initialize_monitor_handles in the begin of the main routine

#include <stdio.h>
#include <stdlib.h>
# ….

extern void initialise_monitor_handles(void);

int main(void) {
  initialise_monitor_handles();

  printf("Hello !\n");

  HAL_Init();
  SystemClock_Config();

  puts("Check your openocd console.\n");
  printf("This works too\n");
  //……………
}


Hi Tarek,

After following your suggestion, the printf using semihosting is also worked. But some how I felt like ITM via ST LINK Utility SWV is more robust than open ocd. Because, in my program, I had to do print some values, light some LEDs and read accelerometer and gyroscope vals... When I am printing, I found out than in open OCD, which uses semihosting, it require more time. and I may miss some LED. But ITM via stlink seems okay...

Thanks alot Tarek. You really help a lot.

Have nice day!

Rosh

@ tarek bouchkati

since in filesystem of my Windows 7 working station I have two (identical) copies of syscalls.c

1.
C:\Users\zaffing\Downloads\eclipse\plugins\com.st.microxplorer.rcp_4.16.0.201607131424\db\plugins\projectmanager\src\syscalls.c

2.
C:\Users\zaffing\Downloads\eclipse\plugins\fr.ac6.mcu.firmware_1.10.0.201607251855\resources\builtin\syscalls.c

I would like to ask:

“Do You suggest to modify one of those and recompile the project?”

“Which one?”(Ok I can try each of them)

“Is it possible to cover _write definition in syscalls.c with a redefined int _write(int file, char *ptr, int len) body somewhere else?”

“Can You (or anybody) explain more or rephrase the soldiering thing on ‘Solder Bridge’ SB10 (SWO) ? Is it something specific of a particular board? Which board? And what about other boards?”

Thank You.

Giangiacomo

United States
What if you dont have a syscalls.c

France

Hi Rosh,

The performance difference comes from the way semihosting works: while printing on ITM is done just by writing in a few registers, like writing on an UART (which is the way it works when writing through the STLink-V2-1 provided serail over USB link), semihosting generates an SWI instructioon with a predefined code, that is intercepted by OpenOCD (stopping the CPU execution) which has to read CPU registers (through the JTAG/SWD interface) then restart CPU execution.

Due to the stop/read/start sequence of debug interaction, semihosting is thus inherently slower than writing on a few registers without debug interaction.

Bernard (Ac6)

Thank you Bernad. It does make sense now.

:-)

Rosh


Thank you Bernad. It does make sense now.

:-)

Rosh