Skip to content

iprintln!() fails to print after printing certain amount of data #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JOE1994 opened this issue Jun 12, 2020 · 4 comments
Open

iprintln!() fails to print after printing certain amount of data #229

JOE1994 opened this issue Jun 12, 2020 · 4 comments

Comments

@JOE1994
Copy link
Contributor

JOE1994 commented Jun 12, 2020

Hello 🦀, when running the program below that repeatedly calls iprintln!(), it always stops printing at the same point in code, not finishing the printing tasks. It should print "Hello World ~" 77 times in a loop, but the program always stops printing in the middle of 26th invocation of iprintln!().

#[entry]
fn main() -> ! {
    if let (Some(dp), Some(mut cp)) = (
        stm32::Peripherals::take(),
        cortex_m::peripheral::Peripherals::take(),
    ) {
        // Set up the system clock. We want to run at 168MHz for this one.
        let rcc = dp.RCC.constrain();
        let clocks = rcc.cfgr.sysclk(168.mhz()).freeze();
        let mut itm = cp.ITM;
        for i in 0..77 {
            iprintln!(&mut itm.stim[0], "Hello World for the {}-th time", i);            
        }

        loop {
            continue;
        }
    }

    // Failed to access peripherals..
    panic!();
}

logs from ITM are stored locally in itm.txt, and the log is always the same as below
(no matter how many times I try running).

Hello World for the 0-th time
Hello World for the 1-th time
Hello World for the 2-th time
Hello World for the 3-th time
Hello World for the 4-th time
Hello World for the 5-th time
Hello World for the 6-th time
Hello World for the 7-th time
Hello World for the 8-th time
Hello World for the 9-th time
Hello World for the 10-th time
Hello World for the 11-th time
Hello World for the 12-th time
Hello World for the 13-th time
Hello World for the 14-th time
Hello World for the 15-th time
Hello World for the 16-th time
Hello World for the 17-th time
Hello World for the 18-th time
Hello World for the 19-th time
Hello World for the 20-th time
Hello World for the 21-th time
Hello World for the 22-th time
Hello World for the 23-th time
Hello World for the 24-th time
Hello World

Is there a maximum limit of data that iprintln! can send in total?
If not, I guess this should be considered a bug..

Metadata

  • I used stm32f407g-disc1 board to run this program.
  • rustc --version --verbose
rustc 1.46.0-nightly (feb3536eb 2020-06-09)
binary: rustc
commit-hash: feb3536eba10c2e4585d066629598f03d5ddc7c6
commit-date: 2020-06-09
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
@JOE1994 JOE1994 changed the title iprintln!() halts printing after printing certain amount of data iprintln!() fails to print after printing certain amount of data Jun 12, 2020
@bcantrill
Copy link

How are you consuming ITM? For whatever it's worth, your example works for me with an ITM consumer that we have purpose built that consumes ITM via the TPIU; are you using the STLink/V2 on the Discovery and then OpenOCD? And is your program stopping, or is the ITM data being dropped?

@JOE1994
Copy link
Contributor Author

JOE1994 commented Jun 12, 2020

How are you consuming ITM? For whatever it's worth, your example works for me with an ITM consumer that we have purpose built that consumes ITM via the TPIU; are you using the STLink/V2 on the Discovery and then OpenOCD? And is your program stopping, or is the ITM data being dropped?

Thank you so much for testing the example on your side! 😸
I am using STLink/V2-1 on the Discovery and with OpenOCD.
The program runs to completion and reaches the infinite loop at the end,
and only the ITM data is dropped 😿

(Using gdb-multiarch),
I tried executing the code instruction-by-instruction using the n command
to see if doing that could make the program successfully run all invocations of iprintln!()..
But pressing n just once simply executes the program all the way to the end..

(gdb) n

Breakpoint 4, main () at src/main.rs:20
20      #[entry]
(gdb) n
(gdb) ^C
Program received signal SIGINT, Interrupt.
stim_practice::__cortex_m_rt_main () at src/main.rs:37
37              loop {
(gdb) 

@JOE1994
Copy link
Contributor Author

JOE1994 commented Jul 5, 2020

Update:
I tested the above example program on another board(Nucleo-429ZI), and it also exhibits the same behavior 😿

So far I've tested two devices and they both exhibit the same behavior. Both belong to the STM32F4 series.

  • stm32f407g-disc1
  • Nucleo-F429ZI

At the moment, I'm not sure what's causing this. (guess: issue with OpenOCD?)

@jonas-schievink
Copy link
Contributor

Maybe try with probe-rs' ITM support?

adamgreig pushed a commit that referenced this issue Jan 12, 2022
229: Fixed changed compile-fail messages r=jonas-schievink a=korken89

Fixed the errors now present in `compile-fail` tests.

Co-authored-by: Emil Fresk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants