sp1 board def - #11261
Conversation
…ng, removed unused include from nordic/supervisor/port.c
|
The latest commit brings back it uses |
…ort for 16 bit magic, disable CIRCUITPY_SDCARD_USB on SP-1
|
The latest commit fixes the compile error from a missing It also brings in the |
|
I've done a successful basic test of this branch the SP-1 device now. Initial flash, REPL, LEDs, buttons, a faders are all working as expected. Have not tested audio or emmc with this branch on SP-1 yet. There will need to be some reconciliation between this branch and the emmcio module branch once one or the other is merged. Both this branch and the current emmcio module PR branch have been intentionally separated so as not to rely on each other. But there is still some code needed for using both together. The original PR has code inside of emmcio that is responsible for feeding the watchdog. That needs to come back but it needs to be in a branch where both exist. I'll pick up testing tomorrow with locally merged branches and try out audio and emmc. |
tannewt
left a comment
There was a problem hiding this comment.
Looking better! Thanks for working on this. One Q about bitbanging I2C and another about the peripherals dir.
| // codecs off mid-signal: the CS42L42 loses its clock and the TAS2505's class-D | ||
| // driver loses its reset with whatever was on the output still on it. | ||
| // | ||
| // Bit-banged rather than driven through TWIM. |
There was a problem hiding this comment.
Why not use common_hal_busio_i2c here?
There was a problem hiding this comment.
Neither caller can own a bus object.
reset_board() is called twice from main.c. The one at main.c:1082 runs before the first start_mp(). main() reaches it at line 1082, and start_mp() first runs inside run_safemode_py/run_boot_py at 1110/1113. No GC heap, no nlr handler. common_hal_busio_i2c_construct() raises on three paths (raise_ValueError_invalid_pins(), "All I2C peripherals are in use", mp_raise_OSError(MP_EIO)), so its error path there is a fault or a safe-mode boot instead of a muted codec.
The other, main.c:417, runs before stop_mp(). Nordic's reset_port() (ports/nordic/supervisor/port.c:200) doesn't touch I2C at all, and a user-made busio.I2C is only deinited by finalisers in stop_mp(), which is two lines later. So at that instant the pins can still belong to a live, enabled TWIM.
board_power_off_prepare() runs from board_background_task() → power_off_tick(), arbitrarily deep inside user code with the codec drivers' bus constructed and possibly locked mid-transfer. It's also a point of no return (USB down, then SYSTEM_OFF), so it has to work from safe mode and after a VM crash.
There was a problem hiding this comment.
The object itself can be statically allocated and then used. The raising paths shouldn't trigger because you know the pins are valid and it isn't in use. It should be possible.
There was a problem hiding this comment.
There is also bitbangio which can be used too.
There was a problem hiding this comment.
changed to busio_i2c in the latest commit.
I think it is fine to use board_background_task because it does a flush before power off. I bet you can check that /CIRCUITPY is mounted and not power off until after. |
…d tasks out of peripherals nvm.c to the callsites instead.
The latest commits guard the flush to prevent it from trying when filesystem isn't present, and defer the power off trigger during filesystem format. |
tannewt
left a comment
There was a problem hiding this comment.
Let's get the I2C by hand out of here and then it should be good to go.
I tried to contain it as much as possible to the board specific folder.
board_early_init()is a new addition that I tried to avoid, but I think is necessary. The bootloader on this device reads buttons using the SAADC and leaves it enabled. My understanding is that this would cause problems before board_init() is run so a new hook needed to be introduced that is earlier thanboard_init().Feeding the watchdog during a first boot before it starts to format the flash filesystem is important as well. Formatting takes long enough that the dog would bite during if it were not first fed until board_init().
This branch is currently untested on hardware. Submitting it now as a draft to open it up for feedback. I am working next on making a local merged branch that includes this board def along with the changes from the other separated PRs to get a build to validate the functionality on hardware.