ULP global variables

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Tue Oct 10, 2017 9:16 pm

.macro I2C_delay
wait 10 // 38 // minimal 4.7us
.endm

.macro read_SCL // Return current level of SCL line, 0 or 1
READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S + 9, 1) // RTC_GPIO_9 == GPIO_32
.endm

.macro read_SDA // Return current level of SDA line, 0 or 1
READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S + 8, 1) // RTC_GPIO_8 == GPIO_33
.endm

.macro set_SCL // Do not drive SCL (set pin high-impedance)
WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TC_REG, RTC_GPIO_ENABLE_W1TC_S + 9, 1, 1)
.endm

.macro clear_SCL // Actively drive SCL signal low
// Output mode
WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TS_REG, RTC_GPIO_ENABLE_W1TS_S + 9, 1, 1)
.endm

.macro set_SDA // Do not drive SDA (set pin high-impedance)
WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TC_REG, RTC_GPIO_ENABLE_W1TC_S + 8, 1, 1)
.endm

.macro clear_SDA // Actively drive SDA signal low
// Output mode
WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TS_REG, RTC_GPIO_ENABLE_W1TS_S + 8, 1, 1)
.endm
In i2c.s, I found some macros, but anyone wont use label

tomtor
Posts: 22
Joined: Thu May 11, 2017 6:15 am

Re: ULP global variables

Postby tomtor » Wed Oct 11, 2017 6:08 am

urbanze wrote: I'm trying to create local numeric variables (to be able to use in macros), but all the methods I've tried from various sites do not compile!

I have already tried declaring local labels for macros:

\1:
&1:
$ 1:
LOCAL 1:

etc. With this, I would use jump 1b to go to label "1" before the jump.

None worked. How can I define these "dynamic labels" for use in macros? I need to call the macro several times.
If I use symbolic labels (like: "abc:"), assembler says: "label already defined".


Reference with dynamic labels:
https://sourceware.org/binutils/docs-2. ... mbol-Names
Yes, that is an issue (bug) with the ULP assembler, labels like 1b and 1f do not work.

I plan to look at it in the assembler sources, because GAS should be able to handle these labels.

Note that it is in general better to use real functions instead of macros, because macros generate a lot of code (when you call them several times) and code size is limited for the ULP.

tomtor
Posts: 22
Joined: Thu May 11, 2017 6:15 am

Re: ULP global variables

Postby tomtor » Wed Oct 11, 2017 2:58 pm

tomtor wrote: Yes, that is an issue (bug) with the ULP assembler, labels like 1b and 1f do not work.

I plan to look at it in the assembler sources, because GAS should be able to handle these labels.

Note that it is in general better to use real functions instead of macros, because macros generate a lot of code (when you call them several times) and code size is limited for the ULP.
Work around:

Code: Select all

	nop
	.set target,1f
	jump target
	nop
1:
	nop
Note that the NOPs are not part of the work around ;)

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Wed Oct 11, 2017 10:48 pm

Why assembly of ulp is "raw"?

Whats the version/name of this assembly? I would like to study it, but not find any name/version, most similar (I think) is GNU assembly, but various mnemonics not exist or not work...

tomtor
Posts: 22
Joined: Thu May 11, 2017 6:15 am

Re: ULP global variables

Postby tomtor » Thu Oct 12, 2017 7:02 am

urbanze wrote:Why assembly of ulp is "raw"?

Whats the version/name of this assembly? I would like to study it, but not find any name/version, most similar (I think) is GNU assembly, but various mnemonics not exist or not work...
https://github.com/espressif/binutils-esp32ulp

tomtor
Posts: 22
Joined: Thu May 11, 2017 6:15 am

Re: ULP global variables

Postby tomtor » Fri Oct 13, 2017 2:29 pm

tomtor wrote:
tomtor wrote: Yes, that is an issue (bug) with the ULP assembler, labels like 1b and 1f do not work.

I plan to look at it in the assembler sources, because GAS should be able to handle these labels.
This should fix it:

https://github.com/espressif/binutils-esp32ulp/pull/5

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Fri Oct 13, 2017 3:37 pm

tomtor wrote:
tomtor wrote:
tomtor wrote: Yes, that is an issue (bug) with the ULP assembler, labels like 1b and 1f do not work.

I plan to look at it in the assembler sources, because GAS should be able to handle these labels.
This should fix it:

https://github.com/espressif/binutils-esp32ulp/pull/5
This question is kind of strange, but how can I add this edited file to binutils? For the installation, I used the files "ready": (https://github.com/espressif/binutils-e ... #downloads), and installed directly in the folder. But now that you have edited a different file, I have tried to follow the binutils README.

I tried to do this:

1-) I downloaded the binutils.
2-) I edited the old file for your new one.
2-) I opened the mingw32 and went to the binutils folder.
3-) Commands used: make, make install.
4-) I tested the label:

.macro delay
stage_rst
1: stage_inc 1
wait 64000
jumps 1b, 125, lt
.endm

and continued presenting the error. I'm pretty sure that the installation was incorrect, unless the update does not work.

Can you take a step-by-step or indicate some better way to do this update?

tomtor
Posts: 22
Joined: Thu May 11, 2017 6:15 am

Re: ULP global variables

Postby tomtor » Fri Oct 13, 2017 4:48 pm

urbanze wrote:
tomtor wrote:
tomtor wrote:
This should fix it:

https://github.com/espressif/binutils-esp32ulp/pull/5
This question is kind of strange, but how can I add this edited file to binutils? For the installation, I used the files "ready": (https://github.com/espressif/binutils-e ... #downloads), and installed directly in the folder. But now that you have edited a different file, I have tried to follow the binutils README.

I tried to do this:

1-) I downloaded the binutils.
2-) I edited the old file for your new one.
2-) I opened the mingw32 and went to the binutils folder.
3-) Commands used: make, make install.
4-) I tested the label:

.macro delay
stage_rst
1: stage_inc 1
wait 64000
jumps 1b, 125, lt
.endm

and continued presenting the error. I'm pretty sure that the installation was incorrect, unless the update does not work.

Can you take a step-by-step or indicate some better way to do this update?
See viewtopic.php?f=2&t=3228

You must specify an target when building or you will get an x86 toolchain. Probably you will find new toolchain binairies in your installation directory without the esp32 prefix.

Note that using jumps within macros did not work for me (unrelated to bf local labels). No errors but non working code. Not sure why....

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Fri Oct 13, 2017 7:50 pm

tomtor wrote:
urbanze wrote:
This question is kind of strange, but how can I add this edited file to binutils? For the installation, I used the files "ready": (https://github.com/espressif/binutils-e ... #downloads), and installed directly in the folder. But now that you have edited a different file, I have tried to follow the binutils README.

I tried to do this:

1-) I downloaded the binutils.
2-) I edited the old file for your new one.
2-) I opened the mingw32 and went to the binutils folder.
3-) Commands used: make, make install.
4-) I tested the label:

.macro delay
stage_rst
1: stage_inc 1
wait 64000
jumps 1b, 125, lt
.endm

and continued presenting the error. I'm pretty sure that the installation was incorrect, unless the update does not work.

Can you take a step-by-step or indicate some better way to do this update?
See viewtopic.php?f=2&t=3228

You must specify an target when building or you will get an x86 toolchain. Probably you will find new toolchain binairies in your installation directory without the esp32 prefix.

Note that using jumps within macros did not work for me (unrelated to bf local labels). No errors but non working code. Not sure why....
Ok, I tried your post from link, and ming show some problems, however, i tried to make flash and got error, obvious.

Image list of errors:

https://imgur.com/a/TBCqm

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: ULP global variables

Postby urbanze » Sun Oct 15, 2017 4:51 pm

@tomtor

Just errors. What can I do??? :evil: :(

MAKE error: https://i.imgur.com/Ha1jH4V.jpg
Image


MAKE INSTALL error: https://i.imgur.com/zttSpvM.jpg
Image

Who is online

Users browsing this forum: Baidu [Spider] and 84 guests