Description
Good evening !
I'm starting to use rust+cortex-m on STM32, and I'm planning to mix existing C code (using STM32CubeIDE, CMSIS and freeRTOS) and Rust code (as a static library).
In my early experiments, I have trouble with ITM support, which seems incompatible with Cube IDE (or at least the SWV ITM Data console)
itm::write_all(), which is used by write_str() and iprintln!, will send 32bits words on ITM (thus 4 chars per word).
This is not compatible with ST CubeIDE ITM display, and CMSIS Core Peripheral Access Layer
E.g in core_cm4.h: (Drivers/CMSIS/, (provided by ARM I think))
__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
{
if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */
{
while (ITM->PORT[0U].u32 == 0UL)
{
__NOP();
}
ITM->PORT[0U].u8 = (uint8_t)ch;
}
return (ch);
}
thus a single byte is sent at a time (wasting 75% bandwidth with ascii)
With Rust/Cortex-m:
itm::write_all(itm(), "DEF".as_bytes());
itm::write_all(itm(), "DEF".as_bytes());
itm::write_all(itm(), "DEF".as_bytes());
itm::write_all(itm(), "\n".as_bytes());
And this will display "D䙅D䙅D䙅" in cube IDE
Trace log shows
hence the D (68), while EF becomes 0x4645 and is displayed as U+4645 character (as if it was utf-32)
IMHO, a mode that complies/mimic with CMSIS lib should be provided (and probably should be default)