Page 2 of 3

Re: esp32 ulp programming

Posted: Thu Mar 15, 2018 3:34 pm
by duffster
tele_player wrote:If you’re on a linux or other Unix-like system, you can write a shell script to wrap bin/esp32ulp-elf-nm and handle the redirection into a file.
I'm trying to make a python wrapper for the ulp code, thanks, this gave me the idea to use python.
ESP_igrr wrote:Since Arduino for esp32 already depends on Python, this might be an option for you:
https://github.com/ThomasWaldmann/py-esp32-ulp
(still WIP but simple programs can already be compiled).
I was going the python route when I saw your message so thanks for sharing that with me, it helps a lot. I'm not going to do are the parsing of the actual assembly code in python but will use it to wrap up all the shell commands that build and link the ulp code. One thing I did just find out is Arduino ide doesn't handle .s extension to files so I have to find a way to tell if the code is written for the ulp or the xtensa processors in .S files. Also I would eventually like to have this work on (MAC OS, WINDOWS, LINUX) but can I expect them to all have python installed?

Re: esp32 ulp programming

Posted: Thu Mar 22, 2018 11:58 pm
by duffster
Just a follow-up to this thread, I am successfully loading the ulp binary blob into the final elf and running a test sketch using the ulp to increment a global variable. Looks like I can use .s extension for ulp assembly and .S for xtensa assembly and have a python script do the heavy lifting of creating an ulp binary blob to embed into larger elf. I'm trying my hardest to keep the functionality of how you write code for the ulp the same as you would do with esp-idf environment, but there are few snags I need to figure out.

First being on how Arduino compiles code makes it difficult for the sketch to see any global variables defined in the assembly because the Arduino ide doesn't have a platform.txt hook before Arduino detects libraries. The way esp-idf does it is it creates a header file that gives your c, c++ code an externed variables that links to the assembly global variables. What happens is Arduino detects all the libraries and sketch ino files before I can compile the ulp code and create that header file. What works is to have the user create that header file manually in the ide and define the externed global variables that they want to access in their sketch. This is the only way I can think of so far, not to bad though I think?

I am in the process of moving but once I get chance I'll post a how-to for MacOS and possibly linux and upload the files to my github account.

Re: esp32 ulp programming

Posted: Wed Mar 28, 2018 4:58 pm
by duffster
I got the files uploaded to github with a little how-to as the readme. If anyone tries this out let me know any problems you have with compiling a project here or in the github repository.

Re: esp32 ulp programming

Posted: Fri Apr 13, 2018 3:06 pm
by duffster
I have recently added support for multiple ulp assembly files and hopefully window and linux support but those need to be tested by someone that has those OS's.

Re: esp32 ulp programming

Posted: Fri Jun 08, 2018 11:34 pm
by timpur
Hey, sorry random question, just wondering if anyone knows why Programming the ULP using macros became legacy. I was kinda thinking it was an easy and effective way with out the need of additional build tools.

Trying to program the ULP using ESP32 Arduino and cant figure out the "proper" way yet, but macros work for now ....

Re: esp32 ulp programming

Posted: Sat Jun 09, 2018 12:28 pm
by ESP_igrr
We're not planning to remove ULP macros, but examples will be written using ULP binutils support. Also some instructions might be missing from the ULP macros header file.

FYI there's also a ULP assembler written in Python for micropython project. It might be easier to integrate into Arduino.

Re: esp32 ulp programming

Posted: Sun Jun 10, 2018 5:30 pm
by duffster
timpur wrote: Hey, sorry random question, just wondering if anyone knows why Programming the ULP using macros became legacy. I was kinda thinking it was an easy and effective way with out the need of additional build tools.

Trying to program the ULP using ESP32 Arduino and cant figure out the "proper" way yet, but macros work for now ....
I think once you try to program a more complicated program you will find the MACROS quite limiting and difficult to use. Look at the ulp assembly examples and imagine trying that with the MACROS.
ESP_igrr wrote: FYI there's also a ULP assembler written in Python for micropython project. It might be easier to integrate into Arduino.
Wouldn't this require using micro-python instead of Arduino? How would that help if someone wants to use Arduino? Also as far as I have seen the micro-python ULP support is currently only for simple programs and it is stated they try to compile code similar to binutils AS but not exactly. This is awesome for micropython but not sure how that helps with someone wanting to use Arduino. This is why I created this fix for Arduino ulp assembly programing. I wish it could be done easier to install and welcome any ideas people have to make it better. Maybe you guys could integrate it into the forthcoming Arduino esp32 install?

Re: esp32 ulp programming

Posted: Mon Jun 11, 2018 4:47 am
by ESP_igrr
Wouldn't this require using micro-python instead of Arduino?
If it doesn't yet run under CPython, i think it would not be too hard to make it run there. Most of the implementation seems to be pretty standard python3, as far as i can tell.
Sorry that I didn't add a link in my previous comment: https://github.com/ThomasWaldmann/py-esp32-ulp

Re: esp32 ulp programming

Posted: Mon Jun 11, 2018 5:48 pm
by duffster
ESP_igrr wrote: If it doesn't yet run under CPython, i think it would not be too hard to make it run there. Most of the implementation seems to be pretty standard python3, as far as i can tell.
Sorry that I didn't add a link in my previous comment: https://github.com/ThomasWaldmann/py-esp32-ulp
From what I read, CPython is just the python Interpreter written in C, it doesn't compile C code from python scripts, though I guess there is Cython. How would CPython integrate into a Arduino environment? Not trying to argue with you but I really don't see how this would be any easier or would even work without some major changes to the Arduino IDE using esp32? For example, even if you do get the ulp binary blob from Waldman's python script you still have to combine it with the users compiled code and link it all together, that would still require changing how esp32 Arduino recipes compile users code. I do admit that Thomas Waldmans micro python ulp implementation is a much higher feet of innovation than mine but its geared for micro python not Arduino.

Re: esp32 ulp programming

Posted: Tue Jun 12, 2018 10:17 pm
by timpur
Yes, i think your right, it does become complex and confusing quick using macros, but for now the only way i can find that works easy with arduino. Might create an issue on the arduino thread about this.

Thanks guys :)