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

Fix panics for UART #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ impl From<esp_reset_reason_t> for ResetReason {
esp_reset_reason_t_ESP_RST_PANIC => Self::Panic,
esp_reset_reason_t_ESP_RST_INT_WDT => Self::InterruptWatchdog,
esp_reset_reason_t_ESP_RST_POWERON => Self::PowerOn,
esp_reset_reason_t_ESP_RST_UNKNOWN => Self::Unknown,
esp_reset_reason_t_ESP_RST_BROWNOUT => Self::Brownout,
esp_reset_reason_t_ESP_RST_TASK_WDT => Self::TaskWatchdog,
esp_reset_reason_t_ESP_RST_DEEPSLEEP => Self::DeepSleep,
_ => unreachable!(),
_ => Self::Unknown,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't mind altering it so that Self::Unknown becomes a catch all.

But: you are not fixing the root cause why it panicked in the first place, isn't it?

  • It didn't panic because of esp_reset_reason_t_ESP_RST_UNKNOWN because we have that branch
  • It panicked because of something else

So... how about we map this something else (whatever it is) in the match statement? I mean in addition to the change you introduce here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I'll look at the reset reason code and add it to the enum. @ivmarkov Did you mean this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes.

}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1899,15 +1899,15 @@ fn new_common<UART: Uart>(
uart_driver_install(
UART::port(),
if rx.is_some() {
config.rx_fifo_size as _
config.rx_fifo_size
} else {
0
},
UART_FIFO_SIZE * 2
ivmarkov marked this conversation as resolved.
Show resolved Hide resolved
} as _,
if tx.is_some() {
config.tx_fifo_size as _
config.tx_fifo_size
} else {
0
},
UART_FIFO_SIZE * 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

However.... why do we need this? Are you having problems with TX as well, or are you doing it "just in case"? IMO this is not necessary, because the TX assert is slightly different: https://github.com/espressif/esp-idf/blob/a322e6bdad4b6675d4597fb2722eea2851ba88cb/components/driver/uart/uart.c#L1589

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Cancel changes

} as _,
config.queue_size as _,
queue.map(|q| q as *mut _).unwrap_or(ptr::null_mut()),
InterruptType::to_native(config.intr_flags) as i32,
Expand Down
Loading