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.
@Rayman said:
@rogloh Fixed up LLVM with your files and downloaded Micropython.
It's been a moment since compiled Micropython, and that was with RISCVP2...
Do you have any tips on doing this?
LOL, it's a bit of messing about setting up tool paths etc and I'm not going to be able to hold your hand for all of that. But to get started you could try using the zipfile contents "p2-mp-minimal.zip" I posted in this post above https://forums.parallax.com/discussion/comment/1572778/#Comment_1572778
and reading what I posted on it (partial snippet reproduced below), that should get your going. You will also want those fixes for the P2LLVM toolchain so it doesn't crash with CORDIC stuff etc.
Attached is a p2-mp-minimal.zip file containing source files to apply over the files in the "minimal" ports folder in the MicroPython project tree. Or better yet you can copy these into a newly created native "p2" ports folder. Type "make run" in that folder after that with a P2 plugged in and LLVM & loadp2 tool locations setup appropriately in the Makefile.
@Rayman said:
Ok I’ll try it. I looked at that zip earlier and didn’t look like enough files there to be enough…
It's only enough for a proof-of-concept minimal build to load and run. But it won't do much as it doesn't have any special P2 pin IO or COG stuff included. I'm working on the porting of those components from our older v1.13 builds into a v1.28 build of MP. I've already done the machine_pin and machine_cpu files which compile (but are barely tested). Currently I'm trying to rewrite the SD card stuff by retargeting some ESP32 SD card framework to allow both SD and SPI interfaces to control the card. Eventually I hope to get @evanh SD code in this to get some faster SD card transfer vs the bitbang SPI. His code is already in C plus has some inline PASM2. Mostly seems like it will map over but I need to figure out an Fcache solution with P2LLVM which inherently doesn't support that right now, however I expect should be possible to include some initial loader code in the read/write routines that need to run in Fcache so that the streamer can be used, assuming this inline code addressing can be made to run at COG location 0. May need a bit of tweaking for that and add a few extra P2 instructions to P2LLVM which C doesn't yet require...
@Rayman said:
@rogloh Ok, I'm seeing now that your files are a patch to the "minimal" port, so it needs to compile a lot of files...
Attempting to compile in Windows, but looking pretty futile...
I sort of wonder if Windows can even compile MicroPython given it uses Makefiles. Without "make" present it'd be tricky. @Tubular and I actually spoke about this yesterday and he's going to ask the local MP guys here at their meetup this upcoming week about that. Perhaps they need to install the GNU make utility for this.
@Rayman said:
@rogloh Ok, I'm seeing now that your files are a patch to the "minimal" port, so it needs to compile a lot of files...
Attempting to compile in Windows, but looking pretty futile...
I sort of wonder if Windows can even compile MicroPython given it uses Makefiles. Without "make" present it'd be tricky. @Tubular and I actually spoke about this yesterday and he's going to ask the local MP guys here at their meetup this upcoming week about that. Perhaps they need to install the GNU make utility for this.
To install make on Windows, open a command line or terminal window and enter:
Did install some kind of make and that helped. Also installed some things like mkdir because works different. But the build still doesn’t work and it’s too many levels deep to figure out…
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.
@rogloh Fixed up LLVM with your files and downloaded Micropython.
It's been a moment since compiled Micropython, and that was with RISCVP2...
Do you have any tips on doing this?
LOL, it's a bit of messing about setting up tool paths etc and I'm not going to be able to hold your hand for all of that. But to get started you could try using the zipfile contents "p2-mp-minimal.zip" I posted in this post above
https://forums.parallax.com/discussion/comment/1572778/#Comment_1572778
and reading what I posted on it (partial snippet reproduced below), that should get your going. You will also want those fixes for the P2LLVM toolchain so it doesn't crash with CORDIC stuff etc.
Ok I’ll try it. I looked at that zip earlier and didn’t look like enough files there to be enough…
It's only enough for a proof-of-concept minimal build to load and run. But it won't do much as it doesn't have any special P2 pin IO or COG stuff included. I'm working on the porting of those components from our older v1.13 builds into a v1.28 build of MP. I've already done the machine_pin and machine_cpu files which compile (but are barely tested). Currently I'm trying to rewrite the SD card stuff by retargeting some ESP32 SD card framework to allow both SD and SPI interfaces to control the card. Eventually I hope to get @evanh SD code in this to get some faster SD card transfer vs the bitbang SPI. His code is already in C plus has some inline PASM2. Mostly seems like it will map over but I need to figure out an Fcache solution with P2LLVM which inherently doesn't support that right now, however I expect should be possible to include some initial loader code in the read/write routines that need to run in Fcache so that the streamer can be used, assuming this inline code addressing can be made to run at COG location 0. May need a bit of tweaking for that and add a few extra P2 instructions to P2LLVM which C doesn't yet require...
@rogloh Ok, I'm seeing now that your files are a patch to the "minimal" port, so it needs to compile a lot of files...
Attempting to compile in Windows, but looking pretty futile...
Maybe I should try to twist the Windows port into a P2 port, but not sure that would work either...
I sort of wonder if Windows can even compile MicroPython given it uses Makefiles. Without "make" present it'd be tricky. @Tubular and I actually spoke about this yesterday and he's going to ask the local MP guys here at their meetup this upcoming week about that. Perhaps they need to install the GNU make utility for this.
To install make on Windows, open a command line or terminal window and enter:
winget install ezwinports.makeRoss.
Did install some kind of make and that helped. Also installed some things like mkdir because works different. But the build still doesn’t work and it’s too many levels deep to figure out…