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

Remove IRQ enable / disable in EEPROM module #6

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

mciantyre
Copy link
Contributor

@mciantyre mciantyre commented Feb 1, 2023

__enable_irq() would be written in Rust as

unsafe { cortex_m::interrupt::enable() }

This call is unsafe for good reason: it could break critical sections that runtimes like RTIC are expected to control. A resulting race condition would be particularly gnarly to track down.

The __disable_irq() would be safe, but we should generally let Rust code -- specifically, the owner of the Eeprom object -- manage interrupts if they need.

I want to emphasize that, when it was originally prototyped, I did not review this C code for suitability in teensy4-bsp. Furthermore, I did not review this code for suitability in the Aqueduct system. My scope was to integrate the C code, and I'm assuming that Aqueduct is comfortable with the license associated with this C code.

`__enable_irq()` would be written in Rust as

    unsafe { cortex_m::interrupt::enable() }

This call is `unsafe` for good reason: it could break critical sections
that runtimes like RTIC are expected to control. A resulting race
condition would be particularly gnarly to track down.

The `__disable_irq()` would be safe, but we should generally let Rust
code -- specifically, the owner of the `Eeprom` object -- manage
interrupts if they need.

I want to emphasize that, when it was originally prototyped, I did not
review this C code for suitability in teensy4-bsp. Furthermore, I did
not review this code for suitability in the Aqueduct system. My scope
was to integrate the C code, and I'm assuming that Aqueduct is
comfortable with the license associated with this C code.
@dstric-aqueduct
Copy link
Collaborator

I want to emphasize that, when it was originally prototyped, I did not review this C code for suitability in teensy4-bsp. Furthermore, I did not review this code for suitability in the Aqueduct system. My scope was to integrate the C code, and I'm assuming that Aqueduct is comfortable with the license associated with this C code.

For posterity's sake, here's the license from the eeprom.c file:

/* Teensyduino Core Library
 * http://www.pjrc.com/teensy/
 * Copyright (c) 2019 PJRC.COM, LLC.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * 1. The above copyright notice and this permission notice shall be 
 * included in all copies or substantial portions of the Software.
 *
 * 2. If the Software is incorporated into a build system that allows 
 * selection among a list of target devices, then similar target
 * devices manufactured by PJRC.COM must be included in the list of
 * target devices and selectable in the same manner.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

I don't see anything concerning here other than it should be added to the licenses directory before we make anything public.

I'm going to pull this PR code and go through the persistence check on the 4.1 MFPP device - assuming that looks good we'll merge in. Have you run this through the EEPROM example?

Good catch...

@mciantyre
Copy link
Contributor Author

mciantyre commented Feb 1, 2023

Have you run this through the EEPROM example?

I tested on a Teensy 4.0, following the tests discussed here. EEPROM persistence still worked as described by the Teensy 4.0 row.

@dstric-aqueduct
Copy link
Collaborator

Have you run this through the EEPROM example?

I tested on a Teensy 4.0, following the tests discussed here. EEPROM persistence still worked as described by the Teensy 4.0 row.

Cool...just ran through setting the config values via the UI after flashing as the MFPP. Data persists after power cycling. Let's merge this in.

@dstric-aqueduct dstric-aqueduct merged commit 4371e19 into main Feb 1, 2023
@mciantyre mciantyre deleted the eeprom-no-irqs branch February 1, 2023 19:41
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

Successfully merging this pull request may close these issues.

2 participants