rust-embedded / cortex-m-semihosting

Semihosting for ARM Cortex-M processors
Apache License 2.0
40 stars 19 forks source link

add hprint macros #27

Closed japaric closed 5 years ago

japaric commented 5 years ago

which are useful when using QEMU

the implementation uses unsafe static mut variables instead of safe static + interrupt::Mutex to continue supporting Rust 1.30. Mutex's const constructor requires 1.31; moving to it would be a breaking change.

this PR also prepares a new release

thejpster commented 5 years ago

It's unfortunate that the write has to be performed with interrupts disabled. This is OK for now, but I'd be interested in a version that did most of the work outside of the critical section and perhaps stored a raw pointer in at AtomicUsize instead.

japaric commented 5 years ago

bors r+

It's unfortunate that the write has to be performed with interrupts disabled.

What's the motivation for moving the formatting outside the critical section? Each write syscall will halt the microcontroller for tens, if not for a hundred plus, milliseconds. While the microcontroller is halted no interrupt will be processed, the cycle counter will not move forward and some timers will not advance (depending on the contents of the DBG registers). On its own the write syscall is worse than disabling interrupts. I don't see a good reason to make the implementation more complex since any potential benefit is negligible when compared to the cost of the write syscall.

bors[bot] commented 5 years ago

Build succeeded

thejpster commented 5 years ago

It's unfortunate that the write has to be performed with interrupts disabled.

Each write syscall will halt the microcontroller for tens, if not for a hundred plus, milliseconds.

Ouch. Ok, given that I agree my suggestion makes no sense. I had no idea it was so slow!

therealprof commented 5 years ago

@thejpster It is, the real slowdown depends on the the debugger speed, too. It's somewhere between "barely acceptable" with expensive debuggers down to horror-show with a standard ST-Link. Some even say semihosting is the worst possible form of communicating with the host...