Skip to content

Commit d04d549

Browse files
committed
update - see revision.md
1 parent 3374d85 commit d04d549

File tree

7 files changed

+100
-42
lines changed

7 files changed

+100
-42
lines changed

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
ulptool v2.4.0
1+
ulptool v2.4.1
22
==================
3-
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.
3+
Now Arduino can program the ULP coprocessor for your esp32 projects. The guide below assumes you installed the esp32 core with the preferred method using the board manager.
44

5-
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.
5+
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 series of recipes for building the ULP assembly files by using the '.s' extension which Arduino will let you create. Take note, the extension is a lower case **s**. In tring to keep the ulp build process the same as the esp-idf framework only a few small modifications are needed to the esp32 Arduino installation.
66

7-
New experimental c compiler (lcc) for the ulp implemented by Jason Fuller included now. Currently only Mac and Linux have been built but hopefully we will have Windows soon. There are many limitations and those can found at his github page here: https://github.com/jasonful/lcc
7+
A new experimental c compiler (lcc) for the ulp implemented by Jason Fuller is included now. Currently only Mac and Linux have been built but hopefully I'll have Windows soon:) There are many limitations and those can found at his github page here: https://github.com/jasonful/lcc
88
Examples can be found in the ulp_examples/ulpcc folder.
99

10+
Note - platform.local.txt version does not follow ulptool version.
11+
1012
Manual Setup Steps:
11-
============
13+
==================
1214
1. Download the latest release of this repository and unpack-> https://github.com/duff2013/ulptool/releases/latest
1315
delete the release version number so the folder is just called 'ulptool'
1416

@@ -22,19 +24,19 @@ delete the release version number so the folder is just called 'ulptool'
2224

2325
Typically (Linux) -> ~/.arduino15/packages/esp32
2426

25-
4. Move the **ulptool** folder you downloaded and unpacked to the tools folder here -> **.../esp32/tools/**.
27+
4. Move the **ulptool** folder you downloaded and unpacked to the tools folder here -> **... /esp32/tools/ulptool/**.
2628

2729
5. Copy the 'platform.local.txt' file to **... /esp32/hardware/esp32/1.0.0/**. Remember **1.0.0** has to match your esp32 core version.
2830

29-
6. In the **ulptool** release you downloaded, move or copy the **... /esp32/tools/ulptool/src/ulp_examples** folder to where Arduino saves your sketches.
31+
6. In the **ulptool** folder, move or copy the **... /ulptool/src/ulp_examples** folder to where Arduino saves your sketches.
3032

31-
7. Move **esp32ulp-elf-binutils** folder you downloaded and unpacked to -> **... /esp32/tools/ulptool/src/**.
33+
7. Move **esp32ulp-elf-binutils** folder you downloaded and unpacked to -> **... /esp32/tools/ulptool/src/esp32ulp-elf-binutils/**.
3234

33-
Thats it, you now have all the files in place, lets look at very simple example to get you compiling ulp assembly code!
35+
That's it, you now have all the files in place, lets look at very simple example to get you compiling ulp assembly code!
3436

35-
Example:
36-
========
37-
Open a blank Arduino sketch and copy and paste the code below into the that sketch.
37+
Assembly Example:
38+
-----------------
39+
Open a blank Arduino sketch and copy and paste the code below into that sketch.
3840
```
3941
#include "esp32/ulp.h"// Must have this!!!
4042
@@ -73,7 +75,7 @@ static void init_run_ulp(uint32_t usec) {
7375
}
7476
```
7577

76-
Create a new tab named <b>ulp.s</b>, take notice that the extension is a lower case 's'. Copy the code below into that ulp assembly file tab.
78+
Create a new tab named <b>ulp.s</b>, take notice that the extension is a lower case **s**. Copy the code below into the ulp assembly file you just created.
7779
```
7880
/* Define variables, which go into .bss section (zero-initialized data) */
7981
.bss
@@ -93,7 +95,7 @@ entry:
9395
halt
9496
```
9597

96-
Create a new tab named <b>ulp_main.h</b>. This header allows your sketch to see global variables whose memory is allocated in your ulp assembly file. This memory is in the SLOW RTC section. Copy the code below into that header file. As with the esp-idf you have to add 'ulp_' to the front of the variable name. Unlike esp-idf the name of this header is always this name.
98+
Create a new tab named <b>ulp_main.h</b>. This header allows your sketch to see global variables whose memory is allocated in your ulp assembly file. This memory is from the SLOW RTC section. Copy the code below into the header file. As with the esp-idf you have to add 'ulp_' to the front of the variable name. Unlike esp-idf the name of this header is always **ulp_main.h**.
9799
```
98100
/*
99101
Put your ULP globals here you want visibility
@@ -106,9 +108,9 @@ extern uint32_t ulp_entry;
106108
extern uint32_t ulp_count;
107109
```
108110

109-
Compile and run and you should see the variable 'ulp_count' increment every 100 msecs.
111+
Upload the code then open your serial monitor, you should see the variable 'ulp_count' increment every 100 msecs.
110112

111-
ULPCC Examples:
113+
ULPCC Example:
112114
---------------
113115
Open a blank Arduino sketch and copy and paste the code below into the that sketch. This is basically the same as the example above but written in c:)
114116
```
@@ -167,7 +169,7 @@ void entry() {
167169
#endif // do not add code after here
168170
```
169171

170-
Create a new tab named <b>ulp_main.h</b>. This header allows your sketch to see global variables whose memory is allocated in your ulp c file. This memory is in the SLOW RTC section. Copy the code below into that header file. As with the esp-idf you have to add 'ulp_' to the front of the variable name. Unlike esp-idf the name of this header is always this name.
172+
Create a new tab named <b>ulp_main.h</b>. This header allows your sketch to see global variables whose memory is allocated in your ulp assembly file. This memory is from the SLOW RTC section. Copy the code below into the header file. As with the esp-idf you have to add 'ulp_' to the front of the variable name. Unlike esp-idf the name of this header is always **ulp_main.h**.
171173
```
172174
/*
173175
Put your ULP globals here you want visibility
@@ -181,11 +183,11 @@ extern uint32_t ulp_entry;
181183
extern uint32_t ulp_counter;
182184
```
183185

184-
Compile and run and you should see the variable 'ulp_counter' increment every 100 msecs.
186+
Upload the code then open your serial monitor, you should see the variable 'ulp_counter' increment every 100 msecs.
185187

186188
Under the Hood:
187189
===============
188-
All the magic happens in the python script called esp32ulp_build_recipe.py. This along with espressif's esp32ulp_mapgen.py in which both are located in the ulp directory from this repository.
190+
All the magic happens in the python script called esp32ulp_build_recipe.py along with espressif's esp32ulp_mapgen.py script.
189191

190192
Limitations:
191193
============

revisions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
><b>Updated (8/20/19 v2.4.1)</b><br>
2+
* Added lcc copyright file.<br>
3+
* Fix grammar and spelling of README.md.<br>
4+
* Fix lcc examples.<br>
5+
16
><b>Updated (7/14/19 v2.4.0)</b><br>
27
* Added support for ulpcc c compiler :)<br>
38
* Cleaned up code.<br>

src/esp32ulp_build_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1717
# DEALINGS IN THE SOFTWARE.
1818

19-
# version 2.4.0
19+
# version 2.4.1
2020
import os
2121
import re
2222
import sys

src/ulp_examples/ulpcc/ulpcc_adc/adc.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/*
2-
* do not add code above here all
3-
* ulp c code must be between this
4-
* ifdef.
5-
*/
6-
#ifdef _ULPCC_
1+
#ifdef _ULPCC_ // do not add code above this line
72
// must include ulpcc helper functions
83
#include <ulp_c.h>
94
#include "common.h"
@@ -15,18 +10,20 @@
1510
unsigned threshold;
1611
/*
1712
* esp32 main processor can reach this variable.
18-
* It is used to signal that a result is ready.
13+
* It is used to signal that a result is ready
14+
* and when the main processor read the value.
1915
*/
2016
unsigned mutex = 0;
2117

2218
// # of samples
2319
unsigned sample_counter = 0;
24-
/*
25-
* ulp registers are only 32 bits but
26-
* can only hold 16 bits of data so we
27-
* use sum_hi and sum_lo to hold 32 bits
20+
/*
21+
* ulp registers are 32 bits but can
22+
* only hold 16 bits of data. We use
23+
* sum_hi (upper 16-bits) and sum_lo
24+
* (lower 16-bits) to hold 32 bits
2825
* of data. The averaged data is computed
29-
* from sum_hi and sum_lo.
26+
* from this proto 32-bit number.
3027
*/
3128
unsigned sum_lo = 0;
3229
unsigned sum_hi = 0;
@@ -36,7 +33,7 @@ void entry() {
3633
unsigned tmp = 0, i = 0;
3734
sum_hi = 0;
3835
sum_lo = 0;
39-
// # of adc samples set by the adc_oversampling_factor in common.h
36+
// avg routine
4037
for (i = 0; i < adc_oversampling_factor; i++) {
4138
// get adc reading
4239
tmp = adc(0, adc_channel + 1);

src/ulp_examples/ulpcc/ulpcc_adc/ulpcc_adc.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ void loop() {
3131
adc_oversampling_factor,
3232
ulp_adc_avg_result & 0xffff
3333
);
34-
//Serial.printf("%i\n", ulp_result & 0xffff);
3534
Serial.flush();
3635
// tell ulp we are done reading result
3736
ulp_mutex = false;
@@ -46,8 +45,8 @@ static void init_run_ulp(uint32_t usec) {
4645
//rtc_gpio_hold_en(GPIO_NUM_15);
4746
ulp_set_wakeup_period(0, usec);
4847
esp_err_t err = ulptool_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
49-
// all shared ulp variables have to inialize after ulptool_load_binary for the ulp to see it.
50-
// Set the high threshold you want the ulp to trigger a main processor wakeup
48+
// all shared ulp variables have to be intialized after ulptool_load_binary for the ulp to see it.
49+
// Set the high threshold reading you want the ulp to trigger a main processor wakeup.
5150
ulp_threshold = 0x20;
5251
err = ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t));
5352
if (err) Serial.println("Error Starting ULP Coprocessor");

src/ulp_examples/ulpcc/ulpcc_counter/ulp_counter.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/*
2-
* do not add code above here all
3-
* ulp c code must be between this
4-
* ifdef.
5-
*/
6-
#ifdef _ULPCC_
1+
#ifdef _ULPCC_ // do not add code above this line
72
// must include ulpcc helper functions
83
#include <ulp_c.h>
94

src/ulpcc/CPYRIGHT

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
The authors of this software are Christopher W. Fraser and
2+
David R. Hanson.
3+
4+
Copyright (c) 1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002
5+
by AT&T, Christopher W. Fraser, and David R. Hanson. All Rights Reserved.
6+
7+
Permission to use, copy, modify, and distribute this software for any
8+
purpose, subject to the provisions described below, without fee is
9+
hereby granted, provided that this entire notice is included in all
10+
copies of any software that is or includes a copy or modification of
11+
this software and in all copies of the supporting documentation for
12+
such software.
13+
14+
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
15+
WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
16+
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
17+
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
18+
19+
lcc is not public-domain software, shareware, and it is not protected
20+
by a `copyleft' agreement, like the code from the Free Software
21+
Foundation.
22+
23+
lcc is available free for your personal research and instructional use
24+
under the `fair use' provisions of the copyright law. You may, however,
25+
redistribute lcc in whole or in part provided you acknowledge its
26+
source and include this CPYRIGHT file. You may, for example, include
27+
the distribution in a CDROM of free software, provided you charge only
28+
for the media, or mirror the distribution files at your site.
29+
30+
You may not sell lcc or any product derived from it in which it is a
31+
significant part of the value of the product. Using the lcc front end
32+
to build a C syntax checker is an example of this kind of product.
33+
34+
You may use parts of lcc in products as long as you charge for only
35+
those components that are entirely your own and you acknowledge the use
36+
of lcc clearly in all product documentation and distribution media. You
37+
must state clearly that your product uses or is based on parts of lcc
38+
and that lcc is available free of charge. You must also request that
39+
bug reports on your product be reported to you. Using the lcc front
40+
end to build a C compiler for the Motorola 88000 chip and charging for
41+
and distributing only the 88000 code generator is an example of this
42+
kind of product.
43+
44+
Using parts of lcc in other products is more problematic. For example,
45+
using parts of lcc in a C++ compiler could save substantial time and
46+
effort and therefore contribute significantly to the profitability of
47+
the product. This kind of use, or any use where others stand to make a
48+
profit from what is primarily our work, requires a license agreement
49+
with Addison-Wesley. Per-copy and unlimited use licenses are
50+
available; for more information, contact
51+
52+
Kim Boedigheimer
53+
Addison Wesley
54+
75 Arlington St., Suite 300
55+
Boston, MA 02116
56+
617/848-6559 kim.boedigheimer@pearsoned.com
57+
-----
58+
Chris Fraser / cwf@aya.yale.edu
59+
David Hanson / drh@drhanson.net
60+
$Revision$ $Date$

0 commit comments

Comments
 (0)