Skip to content
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

feat(allwinner-d1): panic handling improvements #116

Merged
merged 4 commits into from
Jul 1, 2023
Merged

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented Jul 1, 2023

This branch contains two commits:

  • feat(allwinner-d1): disable IRQs in panic

    This commit changes the panic handler for the D1 to disable
    interrupts, and adds a flag for tracking double panics. If we panic
    inside the panic handler, we now just die immediately instead of
    trying to print something.

  • feat(crowtty): try to decode loose utf8

    This commit changes crowtty to attempt to decode any output that isn't
    in a SerMux frame as UTF-8 text. This lets us get panic output without
    having to do fancy COBS encoding in the panic handler. It also lets us
    see other stuff, like xfel's bootloader output.

    For example:
    image

hawkw added 2 commits July 1, 2023 08:40
This commit changes crowtty to attempt to decode any output that isn't
in a SerMux frame as text. This lets us get panic output and other
stuff, like `xfel`'s bootloader output.

![image](https://github.com/tosc-rs/mnemos/assets/2796466/6e818932-c97d-4261-8aef-6b92e70e3341)
@hawkw hawkw requested a review from jamesmunns July 1, 2023 16:35
@hawkw hawkw self-assigned this Jul 1, 2023
@netlify
Copy link

netlify bot commented Jul 1, 2023

Deploy Preview for merry-scone-cc7a60 ready!

Name Link
🔨 Latest commit 5231001
🔍 Latest deploy log https://app.netlify.com/sites/merry-scone-cc7a60/deploys/64a0579f4cefe60008702858
😎 Deploy Preview https://deploy-preview-116--merry-scone-cc7a60.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hawkw hawkw marked this pull request as ready for review July 1, 2023 16:35

fn die() -> ! {
loop {
core::sync::atomic::fence(Ordering::SeqCst);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge deal, but you could wfi loop here instead to not heat the CPU (it'll probably just never wake)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good call

}

// TODO(eliza): abort any in-flight DMAs.

// Ugly but works
let mut uart: Uart = unsafe { core::mem::transmute(()) };

write!(&mut uart, "\r\n").ok();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want a null BEFORE as well, to force the end of the previous frame.

Additionally, you also probably want to either busy wait until the DMAC transfer is complete, or hard-stop any DMAC transfers that are ongoing, before manually driving the panic, otherwise I dunno how pushing bytes into the fifo while the DMAC is also doing it would go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i left a TODO about killing DMAC transfers. i intend to do that in a follow-up but will have to read the data sheet first.

Copy link
Contributor

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits are TIOLI, and feel free to defer any of the nice to haves for later PRs if you want to merge now.

@hawkw hawkw merged commit 3e51138 into main Jul 1, 2023
10 checks passed
@hawkw hawkw deleted the eliza/dont-panic branch July 1, 2023 16:56
@hawkw hawkw added this to the beepberry computer v0.1 milestone Jul 10, 2023
@jamesmunns jamesmunns added platform: D1 Specific to the Allwinner D1 hardware platform area: kernel Related to the cross-platform kernel labels Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: kernel Related to the cross-platform kernel platform: D1 Specific to the Allwinner D1 hardware platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants