duff2013 / ulptool

Program the esp32 ULP coprocessor in Arduino
278 stars 69 forks source link

ULPCC example in README.md broken #50

Closed drandreas closed 4 years ago

drandreas commented 4 years ago

The README.md contains the following snippet:

/*
 * do not add code above here all
 * ulp c code must be between this
 * ifdef.
 */
#ifdef _ULPCC_
// must include ulpcc helper functions
#include <ulp_c.h>

// global variable that the main processor can see
unsigned counter = 0;

// all ulpcc programs have have this function
void entry() {
  // increment counter
  counter++;
}
#endif // do not add code after here

However gen_assembly expects a clean file:

        for file in c_files:
            with open(file, "rb") as f:
                top = f.readline().strip()
                bottom = f.readlines()[-1].strip()
                if top == "#ifdef _ULPCC_":
                    if bottom == "#endif":
                        ulpcc_files.append(file)

Therefore the documentation disables/breaks the compilation of ulp_counter.c.

Everything else works flawlessly on MacOS Catalina 👍 .

duff2013 commented 4 years ago

Thanks! just fixed it.

drandreas commented 4 years ago

Thank you for the prompt response. Sadly the fix addresses only the "it has to be the first and last line" issue.

I suggest the following new code instead of https://github.com/duff2013/ulptool/blob/21e08961dd37bd58a5f0ef47707bbc2a5c7ff589/src/esp32ulp_build_recipe.py#L300 https://github.com/duff2013/ulptool/blob/21e08961dd37bd58a5f0ef47707bbc2a5c7ff589/src/esp32ulp_build_recipe.py#L301

 if top.startswith("#ifdef _ULPCC_"):
       if bottom.startswith("#endif"):
duff2013 commented 4 years ago

Ok I see that looks good do you want to do pull request?