Skip to content

Document the need for "cp.DCB.enable_trace();" or include the ame action in defmt_itm::enable(cp.ITM); #941

Open
@RobertGauld

Description

@RobertGauld

Hi appologies if it is infact documented but I just missed it.
(and yes there are many reasons I spent time making this work rather than dumping information out one of the unused UARTS on the chip - I've come to love using defmt since coming accross it).

Side story

I had simple code for a thingy implemented and working on a bluepill (an STM32F103), essentially a blinking LED with each state change output to a UART and defmt-itm. When my custom designed PCBs using an STM32f105RC arrived, and the relvant changes to hal fetaures in my Cargo.toml made my code worked fine when a debugger had been attached since power on but failed if the board was powered on and a programmer not attached. After spending a few days ruling out hardware my attention turned to where in the software things wre going wrong, despite having the line "defmt_itm::enable(cp.ITM);" whenever I used the trace! or info! macros things failed. This led me to investigate whether it was a bug in one of the defmt crates, or an error of understanding on my part.

Solution found

Having implemented the same simple thingy in ST's CubeIDE and comparing it's generated setup code I investigated how registers are set. It appears that the STM32f105 (and presumably others) requires the use of the following code, please can this be documented (better) or the setting of the registers that it does done in defmt_itm's enable method. I guess this could be considered low priority since this issue is hopefully findable by anyone else who runs into this annoyance.

    let mut cp = cortex_m::Peripherals::take().unwrap();
    cp.DCB.enable_trace();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions