Replies: 3 comments 21 replies
-
I see how that reset behavior could be nifty. However, I also agree that this isn't the responsibility of the logger, particularly when the logger could be used across different i.MX RT processors. imxrt-log is helpful when we need quick debug logging. ("Quick" tries to be both "easier to integrate" and also "lower overhead.") Once we start needing to do other things with the peripherals besides sending out text, it's time to consider something custom for our systems. In light of #130, I've been thinking about ways to simplify imxrt-log. My goal would be to make it easier for others to build logging policies themselves. Instead of baking this into imxrt-log, maybe we could figure out a different, Teensy 4-specific logging / USB extensions that could support this reset behavior? |
Beta Was this translation helpful? Give feedback.
-
I have a similar problem, with the difference that I am on Windows and the Hence I started implementing the route of the hard reset, the so called rebootor. Although I had the idea to combine the two; as I use UART for logging instead of USB, my USB port is currently unused, so I could implement a self-rebootor on it that reboots itself instead of a different chip. So far, this is working great: https://github.com/Finomnis/teensy4-selfrebootor It can be programmed via Note that I got a teensy micromod - I didn't port the reboot code for teensy4.0 yet, which is a little bit more complicated according the the teensyduino repository. Now there's one problem that I do need help with, and maybe @mciantyre has an idea: The rebootor only reacts to the message from The error is consistent with the I did capture the entire communication on Saleae with USB 1.1 Full-Speed, but my knowledge of USB isn't deep enough to decypher what's going on. I attached the Saleae log, maybe someone else understands what's going on? |
Beta Was this translation helpful? Give feedback.
-
I now finished the This allows the device to be reprogrammed hands-off. Its only requirement is that nothing else uses the USB Port. Here's a minimal example of a system that can get re-programmed via #[rtic::app(device = teensy4_bsp)]
mod app {
use teensy4_bsp::hal::usbd::{BusAdapter, EndpointMemory, EndpointState};
use usb_device::bus::UsbBusAllocator;
static EP_MEMORY: EndpointMemory<1024> = EndpointMemory::new();
static EP_STATE: EndpointState<4> = EndpointState::new();
#[local]
struct Local {
rebootor: teensy4_selfrebootor::Rebootor<'static>,
}
#[shared]
struct Shared {}
#[init(local = [bus: Option<UsbBusAllocator<BusAdapter>> = None])]
fn init(cx: init::Context) -> (Shared, Local) {
let teensy4_bsp::board::Resources { usb, .. } = teensy4_bsp::board::t40(cx.device);
let usb_bus = cx.local.bus.insert(UsbBusAllocator::new(BusAdapter::new(
usb, &EP_MEMORY, &EP_STATE,
)));
let rebootor = teensy4_selfrebootor::Rebootor::new(usb_bus);
(Shared {}, Local { rebootor })
}
#[task(binds = USB_OTG1, priority = 5, local = [rebootor])]
fn usb1(ctx: usb1::Context) {
ctx.local.rebootor.poll();
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi,
I think (at least in my opinion), it would be good to be able to use the soft reset capability that Teensyduino has. I did read Teensyduino code and it seems they are using CDC data_rate field magic value of 0x86 to mark a soft reset. I am no rust developer, but I was able to hack some example.
Would it be bad for imxrt-log to have a feature to enable this? I know its not technically responsibility of a logger, but .. this is where we are allocating the CDC device, so its the easiest place to put.
Please see my quick and dirty PoC: imxrt-rs/imxrt-hal@main...psobiech:imxrt-hal:main#diff-b73d632826be6b8fa8004b25a1e6d97b3680a564f1eea19785f9d9998c7c6e77R112
Usage is as follows:
teensy_loader_cli -vs --mcu=TEENSY41 main.hex
We would need to change PID/VID (I dont know about the consequences of that, or rationale why they are different), otherwise teensy_loader_cli will not pick up our device, but with the above I can flash teensyduino / teensy4-bsp w/o any problems, flashing from Arduino IDE also works even if I have teensy4-bsp flashed.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions