how to recieve input from PC keyboard on target in a debug session
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:27 AM
Hi,
With Keil uVision I could type to a console and reicieve that on target with SER_GetChar ().
I implemented SER_GetChar () but the code below does not go to case 'a'.
switch ( SER_GetChar() )
{
case 'a' :
dbg_print ( "Pressed 'a'\n" );
break;
default :
break;
}
What am I doing wrong ?
Any idea how to recieve input from PC keyboard on target in a debug session, to replicate uVision's functionality ?
Thank you
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:35 AM
@ferro wrote:With Keil uVision I could type to a console and receive that on target with SER_GetChar ().
You've posted this in the STM32CubeIDE section - does this mean that you're now trying to get the same thing working in CubeIDE?
You'll need to show your implementation of SER_GetChar() - see the Posting Tips for how to post source code:
Is it receiving anything at all ?
What board are you using, and how is it connected to the PC?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:36 AM - edited ‎2024-10-15 4:42 AM
https://www.youtube.com/watch?v=JWOV4j5fCS4
https://www.youtube.com/playlist?list=PLnMKNibPkDnFCosVVv98U5dCulE6T3Iy8
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:49 AM
@Andrew Neil, thanks for prompt reply. I use CubeIDE 1.16.1, custom board and STLink v3.
extern volatile int32_t ITM_RxBuffer;
volatile int32_t ITM_RxBuffer = ITM_RXBUFFER_EMPTY;
int SER_GetChar (void)
{
return ITM_ReceiveChar();
}
Breakpoint at Line 2687 is never reached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:51 AM
Hello @ferro ,
AFAIK, you need to retarget the "get char" to the ITM:
volatile int32_t ITM_RxBuffer=ITM_RXBUFFER_EMPTY;
int __io_getchar(void)
{
return ITM_ReceiveChar();
}
Inspired from this thread:
https://community.st.com/t5/stm32-mcus-products/itm-receivechar-void-gives-undefined/td-p/538168
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:54 AM - edited ‎2024-10-15 4:58 AM
Right, so you're using the Instrumentation Trace Macrocell (ITM):
https://www.youtube.com/watch?v=-X8tndfqTu8
https://wiki.st.com/stm32mcu/wiki/Category:STM32CubeIDE
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 4:59 AM - edited ‎2024-10-15 5:00 AM
@ferro wrote:
This means that you didn't receive any character as the buffer is empty according to the if condition.
Also, look at this article. It may help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 5:41 AM
Thanks @mÆŽALLEm , so far no success with your __io_getchar().
https://community.st.com/t5/stm32-mcus/how-to-use-semihosting-with-stm32cubeide-and-stm32/ta-p/49742
Thanks, might try that next.
I remembered ITM settings in uVision - is something similar in Cube ? Is ITM in Cube set for semihosting internally ?
Clearly it is a black magic to me. I checked what ITM is - part of Cortex M debuging suite. So, is not this supported by STLink ? There is GBD, STLink, some code on target, Cube. Anything else in the chain ? Cannot be Cube in control of this chain so that console printf/read is woking smoothly ? Very confusing.
@Andrew Neilthanks for the links, will take some time to get through them.
"Right, so you're using the Instrumentation Trace Macrocell (ITM):"
As I said, I have no clue what I am doing. Just trying to copy what is working (ITM) on my other project (Cortex M3, Ulink, uVision, clang) where someone else got it working. It does not need to be ITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 6:04 AM
See this video, especially at @1:12 for ITM configuration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-15 6:07 AM
@ferro wrote:It does not need to be ITM
A common(er?) alternative would be to use a UART instead - that was the focus of my 2nd reply.
A complex system designed from scratch never works and cannot be patched up to make it work.
