For v1.28 I've already started porting machine_pin.c and machine_cpu.c files into P2LLVM based MicroPython and have had some success compiling them in. Still working on the SDCard which has changed a bit since 1.13, along with VFS stuff. There is a useful machine_sdcard.c file in the ESP32 ports folder which I'm using as a template to try to enable the SDCard using this newer interface scheme. This variant uses ESP32 HW controllers and supports having multiple bus "slots" as different SPI buses but I'm customizing it for the P2 IO. For the P2 I want to provide 3 slots and also enable the optional power and card detect pins on more advanced setups if I can get that far. Something like this:
slot 0 - first SD card interface using fixed P58-P61 pins (SPI mode) - based on existing bit bang IO code from 1.13
slot 1 - second SD card interface on other pins (SPI mode), enable optional power control/card detection, same bit bang IO code as above on different pins
slot 2 - third SD card interface on other pins (1,4 bit SD mode) using a future more capable driver (eg. something based on @evanh work) with both power control and card detection. This requires C code not SPIN2, but can use some inline PASM2, maybe not fully in Fcache though. Or alternatively some mailbox based driver to to talk to another COG. The SD card work being done by Stephen Moraco looks good, but we don't really need another FAT32 interface, just raw block transfers would suffice as MicroPython already does the high level stuff in its own VFS layers. Also that is SPIN2 based and needs to be C/C++ unless we bundle it as a blob run on another COG. Memory management is then an issue.
In MP there are also VFS filesystem interfaces to Flash chips now (vfs_rom.c) and drivers to access the flash including Winbond 128Mbit devices we typically use with P2's. So a lot of the work is done.
It'd be good if I could try to co-ordinate the flash and SD card slot 0 use so they don't break each other. I know this is still limited/confusing so not sure how well it can work. Probably far better if you have boot flash to just put the SD card on a different interface.
Comments
For v1.28 I've already started porting machine_pin.c and machine_cpu.c files into P2LLVM based MicroPython and have had some success compiling them in. Still working on the SDCard which has changed a bit since 1.13, along with VFS stuff. There is a useful machine_sdcard.c file in the ESP32 ports folder which I'm using as a template to try to enable the SDCard using this newer interface scheme. This variant uses ESP32 HW controllers and supports having multiple bus "slots" as different SPI buses but I'm customizing it for the P2 IO. For the P2 I want to provide 3 slots and also enable the optional power and card detect pins on more advanced setups if I can get that far. Something like this:
slot 0 - first SD card interface using fixed P58-P61 pins (SPI mode) - based on existing bit bang IO code from 1.13
slot 1 - second SD card interface on other pins (SPI mode), enable optional power control/card detection, same bit bang IO code as above on different pins
slot 2 - third SD card interface on other pins (1,4 bit SD mode) using a future more capable driver (eg. something based on @evanh work) with both power control and card detection. This requires C code not SPIN2, but can use some inline PASM2, maybe not fully in Fcache though. Or alternatively some mailbox based driver to to talk to another COG. The SD card work being done by Stephen Moraco looks good, but we don't really need another FAT32 interface, just raw block transfers would suffice as MicroPython already does the high level stuff in its own VFS layers. Also that is SPIN2 based and needs to be C/C++ unless we bundle it as a blob run on another COG. Memory management is then an issue.
In MP there are also VFS filesystem interfaces to Flash chips now (vfs_rom.c) and drivers to access the flash including Winbond 128Mbit devices we typically use with P2's. So a lot of the work is done.
It'd be good if I could try to co-ordinate the flash and SD card slot 0 use so they don't break each other. I know this is still limited/confusing so not sure how well it can work. Probably far better if you have boot flash to just put the SD card on a different interface.