Giter Site home page Giter Site logo

Comments (6)

feuerrot avatar feuerrot commented on August 29, 2024

Uhm, I just saw that I have a wrong JUMPS argument. If I want to loop until the stage counter reaches 122, I have to use LT instead of EQ. But it also works quite well using EQ, so there might be a bug in the silicon?

from binutils-esp32ulp.

feuerrot avatar feuerrot commented on August 29, 2024

According to the listing file the first and the last instruction in the inserted macro are different from the non-macro version.

  33                    toggle:
  34 0014 0105601C              WRITE_RTC_REG(RTC_GPIO_OUT_W1TS_REG, RTC_GPIO_OUT_DATA_W1TS_S + 10, 1, 1)
  35 0018 00004074              STAGE_RST
  36                    
  37 001c FFFF0040      0:      WAIT    65535 # maximum according to TRM 29.4.10 - ca. 8.1ms
  38 0020 10000074              STAGE_INC       1
  39                    
  40 0024 7A000585              JUMPS   0b, 122, EQ # ~999.4ms + 122*4 cycles
  41 0028 0205601C              WRITE_RTC_REG(RTC_GPIO_OUT_W1TC_REG, RTC_GPIO_OUT_DATA_W1TC_S + 10, 1, 1)
  42                    
  43 002c 00000274              WAIT_SEC
  43      FFFF0040 
  43      10000074 
  43      7A000184 
  44                    
  45 003c 14000080              jump toggle

The 00004074 of STAGE_RST becomes 00000274, the 7A000585 of JUMPS becomes 7A000184.

from binutils-esp32ulp.

8785benjamin avatar 8785benjamin commented on August 29, 2024

Nobody from ESP32 to help sorting this issue out ?

Well, there are many bugs when using macros. Jumps, jumpr, jump, ... even REG_RD/WR. Binary code is incorrect .
I have written a quick ULP disassmbler to check the final bin file and I can confirm the the opcodes are sometimes incorrect when dealing with addresses. Quite puzzling is that it happens randomly and from a certain point, my .S file is assembled incorrectly (but only some instructions).
So unfortunately the assembler is not reliable at all.

Example (from my disassembler), from address 0x0314 code is incorrect and addresses are replaced by 0:
...
00bb 02ec 1a500502 REG_WR (RTCIO_BASE+0008)(102)[20:20]=1
00bc 02f0 72800ff1 MOVE R1 = ff
00bd 02f4 72800c12 MOVE R2 = c1
00be 02f8 7220001f SUB R3 = R3 - 1
00bf 02fc 6800000e ST MEM[R3+0] = R2
00c0 0300 80000208 JUMP 0208 (0082)
00c1 0304 1a500501 REG_WR (RTCIO_BASE+0004)(101)[20:20]=1
00c2 0308 d000000e LD R2 = MEM[R3+0]
00c3 030c 7200001f ADD R3 = R3 + 1
00c4 0310 80200002 JUMP R2
00c5 0314 1a501730 REG_WR (RTC_I2C_BASE+00c0)(330)[20:20]=5 <= INCORRECT
00c6 0318 72800001 MOVE R1 = 0
00c7 031c 72000035 ADD R1 = R1 + 3
00c8 0320 72800001 MOVE R1 = 0
00c9 0324 6800000d ST MEM[R3+0] = R1
00ca 0328 7220001f SUB R3 = R3 - 1
00cb 032c 80000000 JUMP 0000 (0000) <= INCORRECT
00cc 0330 72800ff1 MOVE R1 = ff
00cd 0334 72800001 MOVE R1 = 0
00ce 0338 6800000d ST MEM[R3+0] = R1
00cf 033c 7220001f SUB R3 = R3 - 1
00d0 0340 80000000 JUMP 0000 (0000) <= INCORRECT

from binutils-esp32ulp.

8785benjamin avatar 8785benjamin commented on August 29, 2024

@feuerrot:

I suggest you try with my new version of gas which generates a correct code (see my post : Relocation information not generated correctly ; you will need to remake the binutils but should not bet a problem).
I have tried to compile and the .lst is correct (and the .elf too).

Side remarks on your code:
I don't understand why in your loop, you put jumps xx, EQ
This is probably not what you want to do because it will never jump (if jumps only if the condition is true). You shall use LT instead as you want to jump until the counter equals 122, ie. jump as long as the counter is less than 122

It's not a good idea to put a label in the macro. The assembler will tell you that you are redefining the label if you use your macro more than once. You can use a local label like bar@ which tells the assembler to increment @ each time your macro is used, so that labels are kept unique, or you can also consider defining a symbol with the current address since the assembler accepts symbol redefinitions : .set bar, (.)

from binutils-esp32ulp.

feuerrot avatar feuerrot commented on August 29, 2024

@8785benjamin
Regarding the code:
See #8 (comment) - I'm not sure why, but this also works if I use EQ instead of LT. I already changed my code to use LT.

Regarding the label:
GAS supports Local Labels which I'm using in this example.

from binutils-esp32ulp.

8785benjamin avatar 8785benjamin commented on August 29, 2024

Strange that LT doesn't work, I'm using it and it works quite well for me. Most likely the same bug, you should try with my fix.

from binutils-esp32ulp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.