-
Notifications
You must be signed in to change notification settings - Fork 25
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
C-preprocessor-like macros? #19
Comments
the official assembler toolchain has also these macros (in soc_ulp.h):
|
Yes, I think we need a replacement for these. A few implementation options off the top of my head:
I think 1) will be too heavy-weight. There are even existing C preprocessors implemented in Python that could be used but they are all complex and memory intensive. Suspect it'll be very hard to work within the memory constraints of a microcontroller. 2 could work. Perhaps makes sense to explicitly call it before
The attractive part of 3 is that it could make the code quite elegant. But the commands would be specific to py-esp32-ulp and it could be misleading to users; it wouldn't be clear how they mapped to ULP instructions. Worth noting that 1 & 2 have a huge benefit of being compatible with existing ULP code. I think I'm leaning toward option 2... |
I'm also a little confused with the implementation of the Espressif macros. It appears like the address passed in to the macro should be a 32bit address but by the time the macro is expanded the value is offset and divided by 4:
Expands with (from soc_ulp.h):
to:
It just looks...wrong. Your compatibility test takes the raw Am I missing something? |
The compat test were just written to use all opcodes with some (more or less random) parameters. It could well be that some params do not make sense at all. And all it tests right now is that the official assembler output is same as the py-esp32-ulp output (not that the code makes sense or works). |
I think option 1) is out of question due to the reasons you already mentioned. Option 2) [good compatibility] and 3) [ease of implementation] seem to be good options. |
As a potential user, option 2 looks the best to me, though I have to admit to currently knowing very little about these macros, except for the fact that I need to use them in my ULP code to read and write pins. It's a shame this project is so quiet because I'm sure that there are many ESP32 users who need the simplicity of MicroPython for a load of complex stuff but still need the ease of just including a snippet of ULP code in their project to save on battery power. If there is anything I can do to help advance this issue, please let me know, though I fear I won't be much use except for testing. |
Yeah, not many contributors here (not even me right now). Maybe it needs more advertisement in the esp32 community. Advancing this stuff == making a pull request. |
OK, so Matty wrote the code for the ULP WAKE instruction in MicroPython, so that's a big improvement to ULP use imho because MP can be restarted based on an ULP algorithm. I (and others) have tested it and it works with py-esp32-ulp. Hurrah. 🥳 I think the difficulty of performing IO etc. without the macros will have put off many of the potential users of ULP code in MP, so I am going to look to see if I can understand what's involved in adding them, but as Matty will tell you, I didn't get very far with trying to work out the code for the WAKE instruction so don't hold your breath! 😸 Thanks again for making such a great tool. I think when the macros work, there might be a possibility of getting Andreas Spiess to create a feature video on py-esp32-ulp, especially if I can furnish him with some working examples and that is likely to generate a lot more interest. |
Fixed by #43. |
Moved the "assembler macros" discussion to #40.
Below, let's discuss about C-preprocessor-like macros.
The text was updated successfully, but these errors were encountered: