These are chat archives for esp8266/Arduino

2nd
May 2015
Markus
@Links2004
May 02 2015 12:58
onewire is broken #159 :(
ficeto
@ficeto
May 02 2015 13:09
looks like the exception address is inside the SPI.Transfer ?
Markus
@Links2004
May 02 2015 13:11
do you need the dump from 402428dc?
ficeto
@ficeto
May 02 2015 13:11
stupid me... anyway, I'll ask like this
why is the OneWire class calling the SPI class?
Markus
@Links2004
May 02 2015 13:11
i think this comes from code optimization

uint8_t OneWire::reset(void)
{
    IO_REG_TYPE mask = bitmask;
    volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
    uint8_t r;
    uint8_t retries = 125;

    noInterrupts();
    DIRECT_MODE_INPUT(reg, mask);
    interrupts();
    // wait until the wire is high... just in case
    do {
        if (--retries == 0) return 0;
        delayMicroseconds(2);
    } while ( !DIRECT_READ(reg, mask));

    noInterrupts();
    DIRECT_WRITE_LOW(reg, mask);
    DIRECT_MODE_OUTPUT(reg, mask);    // drive output low
    interrupts();
    delayMicroseconds(480);
    noInterrupts();
    DIRECT_MODE_INPUT(reg, mask);    // allow it to float
    delayMicroseconds(70);
    r = !DIRECT_READ(reg, mask);
    interrupts();
    delayMicroseconds(410);
    return r;
}
this is the funciton
strange 402428c4 do not exist in the dump only 402428c5 and 402428c6

40242884 <_ZN8SPIClass8transferEh>:
40242884:    fffd51            l32r    a5, 40242878 <_ZN8SPIClass15setClockDividerEj+0xc>
40242887:    fffd41            l32r    a4, 4024287c <_ZN8SPIClass15setClockDividerEj+0x10>
4024288a:    743030            extui    a3, a3, 0, 8
4024288d:    0020c0            memw
40242890:    0568          l32i.n    a6, a5, 0
40242892:    052d          mov.n    a2, a5
40242894:    f58647            bany    a6, a4, 4024288d <_ZN8SPIClass8transferEh+0x9>
40242897:    fffa51            l32r    a5, 40242880 <_ZN8SPIClass15setClockDividerEj+0x14>
4024289a:    0020c0            memw
4024289d:    0539          s32i.n    a3, a5, 0
4024289f:    0020c0            memw
402428a2:    0238          l32i.n    a3, a2, 0
402428a4:    203340            or    a3, a3, a4
402428a7:    0020c0            memw
402428aa:    0239          s32i.n    a3, a2, 0
402428ac:    0020c0            memw
402428af:    0238          l32i.n    a3, a2, 0
402428b1:    f78347            bany    a3, a4, 402428ac <_ZN8SPIClass8transferEh+0x28>
402428b4:    0020c0            memw
402428b7:    0528          l32i.n    a2, a5, 0
402428b9:    742020            extui    a2, a2, 0, 8
402428bc:    f00d          ret.n
402428be:    740000            extui    a0, a0, 0, 8
402428c1:    0f              .byte 0xf
402428c2:    804000            add    a4, a0, a0
402428c5:    0f              .byte 0xf
402428c6:    124000            excw

402428c8 <_ZN7OneWire5resetEv>:
402428c8:    f0c112            addi    a1, a1, -16
402428cb:    21c9          s32i.n    a12, a1, 8
402428cd:    11d9          s32i.n    a13, a1, 4
402428cf:    02c8          l32i.n    a12, a2, 0
402428d1:    12d8          l32i.n    a13, a2, 4
402428d3:    3109          s32i.n    a0, a1, 12
402428d5:    01e9          s32i.n    a14, a1, 0
402428d7:    fffa01            l32r    a0, 402428c0 <_ZN8SPIClass8transferEh+0x3c>
402428da:    0000c0            callx0    a0
402428dd:    0020c0            memw
402428e0:    056dc2            s32i    a12, a13, 20
402428e3:    fff801            l32r    a0, 402428c4 <_ZN8SPIClass8transferEh+0x40>
402428e6:    0000c0            callx0    a0
402428e9:    7da0e2            movi    a14, 125
402428ec:    ee0b          addi.n    a14, a14, -1
402428ee:    74e0e0            extui    a14, a14, 0, 8
402428f1:    058e16            beqz    a14, 4024294d <_ZN7OneWire5resetEv+0x85>
402428f4:    02a022            movi    a2, 2
402428f7:    fdda05            call0    40240698 <delayMicroseconds>
402428fa:    0020c0            memw
402428fd:    062d22            l32i    a2, a13, 24
40242900:    e802c7            bnone    a2, a12, 402428ec <_ZN7OneWire5resetEv+0x24>
40242903:    ffef01            l32r    a0, 402428c0 <_ZN8SPIClass8transferEh+0x3c>
40242906:    0000c0            callx0    a0
40242909:    0020c0            memw
4024290c:    2dc9          s32i.n    a12, a13, 8
4024290e:    0020c0            memw
40242911:    4dc9          s32i.n    a12, a13, 16
40242913:    ffec01            l32r    a0, 402428c4 <_ZN8SPIClass8transferEh+0x40>
40242916:    0000c0            callx0    a0
40242919:    e0a122            movi    a2, 0x1e0
4024291c:    fdd785            call0    40240698 <delayMicroseconds>
4024291f:    ffe801            l32r    a0, 402428c0 <_ZN8SPIClass8transferEh+0x3c>
40242922:    0000c0            callx0    a0
40242925:    624c          movi.n    a2, 70
40242927:    0020c0            memw
4024292a:    5dc9          s32i.n    a12, a13, 20
4024292c:    fdd685            call0    40240698 <delayMicroseconds>
4024292f:    0020c0            memw
40242932:    6d28          l32i.n    a2, a13, 24
40242934:    0e0c          movi.n    a14, 0
40242936:    10c2c0            and    a12, a2, a12
40242939:    120c          movi.n    a2, 1
4024293b:    83e2c0            moveqz    a14, a2, a12
4024293e:    ffe101            l32r    a0, 402428c4 <_ZN8SPIClass8transferEh+0x40>
40242941:    0000c0            callx0    a0
40242944:    9aa122            movi    a2, 0x19a
40242947:    74e0e0            extui    a14, a14, 0, 8
4024294a:    fdd4c5            call0    40240698 <delayMicroseconds>
4024294d:    3108          l32i.n    a0, a1, 12
4024294f:    0e2d          mov.n    a2, a14
40242951:    21c8          l32i.n    a12, a1, 8
40242953:    11d8          l32i.n    a13, a1, 4
40242955:    01e8          l32i.n    a14, a1, 0
40242957:    10c112            addi    a1, a1, 16
4024295a:    f00d          ret.n
ficeto
@ficeto
May 02 2015 13:16
c2 is 24 bit instruction from what I can see
this c5 is next
Markus
@Links2004
May 02 2015 13:17
ok my asm is to bad to read this
ficeto
@ficeto
May 02 2015 13:18
from your previous dump it looks like it breaks rather too early
i'll rewrite this with the new API when I'm back tomorrow, even though nothing was changed in anything related
and see if it's of any difference
Markus
@Links2004
May 02 2015 13:20
i have recompiled during the two dumps
ficeto
@ficeto
May 02 2015 13:20
can you try and see where it breaks in that method actually
looks like before the while loop
and I wander what is this:
Markus
@Links2004
May 02 2015 13:21
i try to remove all DIRECT_MODE stuff but same result
ficeto
@ficeto
May 02 2015 13:21
volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
also I have not looked at the interrupts() and noInterrupts() methods
Markus
@Links2004
May 02 2015 13:24
looks like copy the ptr for my but why?

uint8_t OneWire::reset(void)
{
    IO_REG_TYPE mask = bitmask;
    //volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
    uint8_t r;
    uint8_t retries = 125;

    noInterrupts();
    DIRECT_MODE_INPUT(baseReg, mask);
    interrupts();
.....
has the same error
ficeto
@ficeto
May 02 2015 13:28
where is that library? I seem to not be able to find it?
is it for all or just esp8266
ficeto
@ficeto
May 02 2015 13:29
can you comment all interrupts/noInterrupts things?
Markus
@Links2004
May 02 2015 13:29
i try
same result
i disable the code optimization may we get better obj dumps
ficeto
@ficeto
May 02 2015 13:32
#elif defined(ARDUINO_ARCH_ESP8266)
#define PIN_TO_BASEREG(pin)             (portOutputRegister(digitalPinToPort(pin)))
#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
#define IO_REG_TYPE uint32_t
#define IO_REG_ASM
#define DIRECT_READ(base, mask)         (((*(base+6)) & (mask)) ? 1 : 0)    //GPIO_IN_ADDRESS
#define DIRECT_MODE_INPUT(base, mask)   ((*(base+5)) = (mask))              //GPIO_ENABLE_W1TC_ADDRESS
#define DIRECT_MODE_OUTPUT(base, mask)  ((*(base+4)) = (mask))              //GPIO_ENABLE_W1TS_ADDRESS
#define DIRECT_WRITE_LOW(base, mask)    ((*(base+2)) = (mask))              //GPIO_OUT_W1TC_ADDRESS
#define DIRECT_WRITE_HIGH(base, mask)   ((*(base+1)) = (mask))              //GPIO_OUT_W1TS_ADDRESS
this is kinda funky lookin
not really sure what isgoing on there
any warnings on build?
do you have build and upload debugging enabled in the Arduino IDE?
Markus
@Links2004
May 02 2015 13:33
i have -Wall yes
only Wreorder and Wsign-compare like always
error in 0x40243653

4024362c <_ZN7OneWire5resetEv>:
4024362c:    d0c112            addi    a1, a1, -48
4024362f:    b109          s32i.n    a0, a1, 44
40243631:    a1f9          s32i.n    a15, a1, 40
40243633:    01fd          mov.n    a15, a1
40243635:    4f29          s32i.n    a2, a15, 16
40243637:    4f28          l32i.n    a2, a15, 16
40243639:    0228          l32i.n    a2, a2, 0
4024363b:    1f29          s32i.n    a2, a15, 4
4024363d:    4f28          l32i.n    a2, a15, 16
4024363f:    1228          l32i.n    a2, a2, 4
40243641:    2f29          s32i.n    a2, a15, 8
40243643:    7da022            movi    a2, 125
40243646:    004f22            s8i    a2, a15, 0
40243649:    2f28          l32i.n    a2, a15, 8
4024364b:    14c222            addi    a2, a2, 20
4024364e:    1f38          l32i.n    a3, a15, 4
40243650:    0020c0            memw
40243653:    0239          s32i.n    a3, a2, 0
40243655:    000f22            l8ui    a2, a15, 0
40243658:    220b          addi.n    a2, a2, -1
4024365a:    004f22            s8i    a2, a15, 0
4024365d:    000f42            l8ui    a4, a15, 0
40243660:    130c          movi.n    a3, 1
40243662:    020c          movi.n    a2, 0
40243664:    832340            moveqz    a2, a3, a4
40243667:    742020            extui    a2, a2, 0, 8
4024366a:    328c          beqz.n    a2, 40243671 <_ZN7OneWire5resetEv+0x45>
4024366c:    020c          movi.n    a2, 0
4024366e:    001d46            j    402436e7 <_ZN7OneWire5resetEv+0xbb>
40243671:    220c          movi.n    a2, 2
40243673:    fd0cc5            call0    40240740 <delayMicroseconds>
40243676:    2f28          l32i.n    a2, a15, 8
40243678:    18c222            addi    a2, a2, 24
4024367b:    0020c0            memw
4024367e:    0238          l32i.n    a3, a2, 0
40243680:    1f28          l32i.n    a2, a15, 4
40243682:    104320            and    a4, a3, a2
40243685:    130c          movi.n    a3, 1
40243687:    020c          movi.n    a2, 0
40243689:    832340            moveqz    a2, a3, a4
4024368c:    742020            extui    a2, a2, 0, 8
4024368f:    fc2256            bnez    a2, 40243655 <_ZN7OneWire5resetEv+0x29>
40243692:    2f28          l32i.n    a2, a15, 8
40243694:    228b          addi.n    a2, a2, 8
40243696:    1f38          l32i.n    a3, a15, 4
40243698:    0020c0            memw
4024369b:    0239          s32i.n    a3, a2, 0
4024369d:    2f28          l32i.n    a2, a15, 8
4024369f:    10c222            addi    a2, a2, 16
402436a2:    1f38          l32i.n    a3, a15, 4
402436a4:    0020c0            memw
402436a7:    0239          s32i.n    a3, a2, 0
402436a9:    e0a122            movi    a2, 0x1e0
402436ac:    fd0905            call0    40240740 <delayMicroseconds>
402436af:    2f28          l32i.n    a2, a15, 8
402436b1:    14c222            addi    a2, a2, 20
402436b4:    1f38          l32i.n    a3, a15, 4
402436b6:    0020c0            memw
402436b9:    0239          s32i.n    a3, a2, 0
402436bb:    624c          movi.n    a2, 70
402436bd:    fd0805            call0    40240740 <delayMicroseconds>
402436c0:    2f28          l32i.n    a2, a15, 8
402436c2:    18c222            addi    a2, a2, 24
402436c5:    0020c0            memw
402436c8:    0238          l32i.n    a3, a2, 0
402436ca:    1f28          l32i.n    a2, a15, 4
402436cc:    104320            and    a4, a3, a2
402436cf:    01a032            movi    a3, 1
402436d2:    00a022            movi    a2, 0
402436d5:    832340            moveqz    a2, a3, a4
402436d8:    742020            extui    a2, a2, 0, 8
402436db:    0c4f22            s8i    a2, a15, 12
402436de:    9aa122            movi    a2, 0x19a
402436e1:    fd05c5            call0    40240740 <delayMicroseconds>
402436e4:    0c0f22            l8ui    a2, a15, 12
402436e7:    0f1d          mov.n    a1, a15
402436e9:    b108          l32i.n    a0, a1, 44
402436eb:    a1f8          l32i.n    a15, a1, 40
402436ed:    30c112            addi    a1, a1, 48
402436f0:    f00d          ret.n
402436f2:    740000            extui    a0, a0, 0, 8
402436f5:    0f              .byte 0xf
402436f6:    804000            add    a4, a0, a0
402436f9:    0f              .byte 0xf
402436fa:    124000            excw
ficeto
@ficeto
May 02 2015 13:36
breaks at the same place
Markus
@Links2004
May 02 2015 13:37
yes but the SPI stuff is gone ;)
ficeto
@ficeto
May 02 2015 13:39
ok, we have changed this:

uint32_t digitalPinToPort(uint32_t pin) {
    return 0;
}

uint32_t digitalPinToBitMask(uint32_t pin) {
    return 1 << pin;
}

volatile uint32_t* portOutputRegister(uint32_t port) {
    return (volatile uint32_t*)GPO;
}

volatile uint32_t* portInputRegister(uint32_t port) {
    return (volatile uint32_t*)GPI;
}

volatile uint32_t* portModeRegister(uint32_t port) {
    return (volatile uint32_t*)GPE;
}
those should be turned into defines I believe
that should help
this is in wiring_digital
Markus
@Links2004
May 02 2015 13:41
ok i try
ficeto
@ficeto
May 02 2015 13:42
try this in OneWire.h
#define PIN_TO_BASEREG(pin)             GPO
#define PIN_TO_BITMASK(pin)             (1 << pin)
then this should also be changed I think
Markus
@Links2004
May 02 2015 13:45
#define PIN_TO_BASEREG(pin)             (volatile uint32_t*) GPO
or i get compiler error
ficeto
@ficeto
May 02 2015 13:46
#define DIRECT_READ(base, mask)         ((GPI & (mask)) ? 1 : 0)    //GPIO_IN_ADDRESS
#define DIRECT_MODE_INPUT(base, mask)   (GPE &= ~(mask))              //GPIO_ENABLE_W1TC_ADDRESS
#define DIRECT_MODE_OUTPUT(base, mask)  (GPE |= (mask))              //GPIO_ENABLE_W1TS_ADDRESS
#define DIRECT_WRITE_LOW(base, mask)    (GPOC = (mask))              //GPIO_OUT_W1TC_ADDRESS
#define DIRECT_WRITE_HIGH(base, mask)   (GPOS = (mask))              //GPIO_OUT_W1TS_ADDRESS
oops
something like that
Markus
@Links2004
May 02 2015 13:50
#define DIRECT_READ(base, mask)         ((GPI & (mask)) ? 1 : 0)   //GPIO_IN_ADDRESS
#define DIRECT_MODE_INPUT(base, mask)   (GPO &= (mask))            //GPIO_ENABLE_W1TC_ADDRESS
#define DIRECT_MODE_OUTPUT(base, mask)  (GPO = (mask))             //GPIO_ENABLE_W1TS_ADDRESS
#define DIRECT_WRITE_LOW(base, mask)    ((*(base+2)) = (mask))     //GPIO_OUT_W1TC_ADDRESS
#define DIRECT_WRITE_HIGH(base, mask)   ((*(base+1)) = (mask))     //GPIO_OUT_W1TS_ADDRESS
but then i get in the statup code
Fatal exception (28):  
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00007ff0, depc=0x00000000
ficeto
@ficeto
May 02 2015 13:50
I edited it
chack it again
hit enter too early :)
Markus
@Links2004
May 02 2015 13:50
ok retry
working !
ficeto
@ficeto
May 02 2015 13:51
:)
Markus
@Links2004
May 02 2015 13:52
thx, will commit it and also do
#define digitalPinToPort(pin) 0
#define digitalPinToBitMask(pin) (1UL << (pin))
#define portOutputRegister(port) ((volatile uint32_t*) GPO)
#define portInputRegister(port) ((volatile uint32_t*) GPI)
#define portModeRegister(port) ((volatile uint32_t*) GPE)
ficeto
@ficeto
May 02 2015 13:52
great!
I'm heading out
will be back tomorrow
Markus
@Links2004
May 02 2015 13:53
ok thx for the help
ficeto
@ficeto
May 02 2015 13:53
no probs :)