Skip to content

Commit

Permalink
update - see revision.md
Browse files Browse the repository at this point in the history
  • Loading branch information
duff2013 committed Feb 16, 2019
1 parent 6105971 commit 1910421
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 996 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ulptool v2.2.0
ulptool v2.3.0
==================
This guide explains how to setup Arduino to use ULP coprocessor assembly files for your esp32 projects. This guide assumes you installed the esp32 core with the preferred method of the board manager.

Typically in Arduino you can compile assembly files using the '.S' extension. Using the ESP32 Arduino core framework these files would correspond to the Xtensa processors whose toolchain is incompatible with the ULP coprocessor. Luckily, Arduino provides a fairly easy albeit not that flexible build framework using series of recipes. This guide extends those esp32 recipes for building the ULP assembly files. We will use the '.s' extensions for ULP assembly files which Arduino will let you create. Remember thats a lower case 's'. I tried to keep the ulp build process the same as the esp-if framework with only a few small modifications the user needs to do in order to compile in Arduino.

Manual Setup Steps:
============
1. Download the latest release of this repository and unpack-> 'ulptool'. https://github.com/duff2013/ulptool/releases/latest
1. Download the latest release of this repository and unpack-> https://github.com/duff2013/ulptool/releases/latest
delete the release version number so the folder is just called 'ulptool'

2. Download and unpack the latest pre-compiled binutils-esp32ulp toolchain for Mac/Linux/Windows: https://github.com/espressif/binutils-esp32ulp/releases/latest
Expand All @@ -33,9 +33,13 @@ Example:
========
Open a blank Arduino sketch and copy and paste the code below into the that sketch.
```
#include "esp32/ulp.h"
#include "esp32/ulp.h"// Must have this!!!
// include ulp header you will create
#include "ulp_main.h"
#include "ulp_main.h"// Must have this!!!
// Custom binary loader
#include "ulptool.h"// Must have this!!!
// Unlike the esp-idf always use these binary blob names
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
Expand All @@ -59,7 +63,8 @@ static void init_run_ulp(uint32_t usec) {
// initialize ulp variable
ulp_count = 0;
ulp_set_wakeup_period(0, usec);
esp_err_t err = ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
// use this binary loader instead
esp_err_t err = ulptool_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
// ulp coprocessor will run on its own now
err = ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t));
}
Expand Down Expand Up @@ -108,6 +113,6 @@ Limitations:
============
While almost a complete solution to programing the ULP coprocessor in assembly, there are currently a few limitations. Once I fix these, I'll remove them from this list.

1. Not tested with Windows or Linux yet.
1. Not tested with Linux yet.
2. Errors can be non-informative.
3. Changing the ulp memory size is not working fully yet.
3. Have to use the custom binary loader function now. (ulptool_load_binary)
10 changes: 8 additions & 2 deletions platform.local.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=2.1.0
version=2.3.0

## paths
compiler.ulp.path={runtime.tools.ulptool.path}/esp32ulp-elf-binutils/bin/
Expand All @@ -13,5 +13,11 @@ compiler.s.cmd=python "{tools.ulptool.path}{tools.ulptool.cmd}"
## ulp_main.ld file address
compiler.c.elf.extra_flags="-L{build.path}/sketch/" -T ulp_main.ld "{build.path}/sketch/ulp_main.bin.bin.o"

## Compile s (ulp) files
## add ulptool.h to g++
compiler.cpp.extra_flags="-I{tools.ulptool.path}/include/ulptool"

## compile '.s' (ulp) files
recipe.hooks.core.postbuild.01.pattern={compiler.s.cmd} {compiler.cpreprocessor.flags} -b {build.path} -p {runtime.platform.path} -u {compiler.ulp.path} -x {compiler.path} -t {tools.ulptool.path} --DF_CPU={build.f_cpu} --DARDUINO={runtime.ide.version} --DARDUINO_={build.board} --DARDUINO_ARCH_={build.arch} --DARDUINO_BOARD="{build.board}" --DARDUINO_VARIANT="{build.variant}"

## run esp32.ld linker script through c preprocessor
#recipe.hooks.core.postbuild.02.pattern="{compiler.path}{compiler.c.elf.cmd}" -E -P -C -xc -o "{compiler.sdk.path}/ld/esp32_out.ld" "-I{compiler.sdk.path}/include/config" "{compiler.sdk.path}/ld/esp32.ld"
6 changes: 6 additions & 0 deletions revisions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
><b>Updated (2/15/19 v2.3.0)</b><br>
* Fixed flash memory allocation.<br>
* Add custom binary load function("ulptool_load_binary").<br>
* Use python to run the esp32.ld thru the c preprocessor creating an updated esp32_out.ld<br>
* Print ulp memory usage in stdout now.<br>
><b>Updated (2/8/19 v2.2.0)</b><br>
* Fixed compiling of non ulp projects.<br>
* Changed example file name from README.ino to ulp_README.ino.<br>
Expand Down
Loading

0 comments on commit 1910421

Please sign in to comment.