These are chat archives for esp8266/Arduino

24th
May 2015
Michael Miller
@Makuna
May 24 2015 02:02
@igrr We have one more timer available, I need to clean it up but I confirmed at least on my esp7 that Compare0 is not being used and does work.
I suspect that the other two extensa timers Compare1 and Compare2 were "fused" (what is the term for programming a PSOC hardware?) for esp8266 to be the FRC and RTC timers.
Michael Miller
@Makuna
May 24 2015 02:07
@igrr Is the ets_sys.h file something that you copy in or can it be "modified" without pain?
chad cormier roussel
@chadouming
May 24 2015 02:58
@ficeto are you there ?
chad cormier roussel
@chadouming
May 24 2015 03:20
When you'll see this, your solution lead me to
In file included from C:\Users\chad\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/ESP8266WiFi.h:32:0,
from C:\Users\chad\Documents\Arduino\libraries\mysql_connector\mysql.h:39,
from C:\Users\chad\Documents\Arduino\libraries\mysql_connector\mysql.cpp:29:
C:\Users\chad\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = unsigned char; size_t = unsigned int]':
C:\Users\chad\Documents\Arduino\libraries\mysql_connector\mysql.cpp:355:35: required from here
C:\Users\chad\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/WiFiClient.h:109:36: error: request for member 'available' in 'source', which is of non-class type 'unsigned char
'
size_t left = source.available();
^
C:\Users\chad\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src/WiFiClient.h:113:5: error: request for member 'read' in 'source', which is of non-class type 'unsigned char*'
source.read(buffer.get(), will_send);
^
Error compiling.
chad cormier roussel
@chadouming
May 24 2015 03:31
nvm, nothing a (byte*) cast couldn't fix
and it is a hell more faster now
it only fail to connect three time now :D
ficeto
@ficeto
May 24 2015 03:37
:D
one of those moments you love to get just 3 disconnects
have you tried with local mysql?
chad cormier roussel
@chadouming
May 24 2015 03:38
nope
ficeto
@ficeto
May 24 2015 03:38
if that fixes the reconnect issue, then it's clearly something in the VPS
not that such situations should not be handled... :D
but i think your code is sound
good night from me :) it's 6:40 am here
time to go :D
chad cormier roussel
@chadouming
May 24 2015 03:42
good night, it's only 23:40 here
I think the problem is not network wise tho. It seems like it take a certain number of packet rather than a number of time.
chad cormier roussel
@chadouming
May 24 2015 03:58
every time, it tried to connect 3 times slowly, then 2 times fast.
chad cormier roussel
@chadouming
May 24 2015 04:03
nvm, it's just faster, still fail a lot xD
Ivan Grokhotkov
@igrr
May 24 2015 07:24
@Makuna you can modify ets_sys.h, usually when I update the SDK I review the diffs manually
chad cormier roussel
@chadouming
May 24 2015 18:03
ok, so i've installed MariaDB instead of mysql and connection is almost instant (Still fail some time). I will clean up the libs, make a good example then i think it will be ready for merging :D
holy shuit
doing some sed command works here
xD
ficeto
@ficeto
May 24 2015 18:03
yey! Great stuff!
is the Maria also on the VPS?
chad cormier roussel
@chadouming
May 24 2015 18:14
Yup
So it might be a lot faster on local network
ficeto
@ficeto
May 24 2015 18:14
yeah not just that
on a stand alone machine
where you have 100% processing time maybe...
why would it fail to connect otherwise?
i'll give it a go when you push your changes :)
have some local mysqls
and some remote ones
chad cormier roussel
@chadouming
May 24 2015 18:22
well, this machine as 100% of it's virtual core for that xD
ficeto
@ficeto
May 24 2015 18:23
your tcpdump showed no response from the mysql server
you took the dump on the server side correct?
chad cormier roussel
@chadouming
May 24 2015 18:24
yes
ficeto
@ficeto
May 24 2015 18:24
then that means that the packets get to the machine
i imagine if you get here and there a disconnect or two that it might be caused by reconnect actually
chad cormier roussel
@chadouming
May 24 2015 18:27
you think old connection is still alive when i try to connect again ?
ficeto
@ficeto
May 24 2015 18:27
might be, like you had one in the dump last night
you had a few unsccessful attempts, then reconnect, then more unsuccess, then you connected again
chad cormier roussel
@chadouming
May 24 2015 18:29
that would me the mysql server would have a bigger than 5 minutes timeout, since i cut the connection client wise and go to sleep for 5 minutes after the insert in the DB
ficeto
@ficeto
May 24 2015 18:30
so you just left it running?
chad cormier roussel
@chadouming
May 24 2015 18:30
yup
ficeto
@ficeto
May 24 2015 18:31
could the server have keep-alive on?
or some other option that could be doing it?
chad cormier roussel
@chadouming
May 24 2015 18:32
looks like this
ficeto
@ficeto
May 24 2015 18:34
that's like just once without fail
can you plase take another dump?
chad cormier roussel
@chadouming
May 24 2015 18:34
yup
ficeto
@ficeto
May 24 2015 18:34
i want to see if they negotiate the disconnect properly
chad cormier roussel
@chadouming
May 24 2015 18:34
but it's 2 fail every time instead of 41
slight upgrade
ficeto
@ficeto
May 24 2015 18:35
those could be reconnects
chad cormier roussel
@chadouming
May 24 2015 18:36
ran the program twice
ficeto
@ficeto
May 24 2015 18:41
you are not responding to the closing requests
wait to sleep untill that is done
chad cormier roussel
@chadouming
May 24 2015 18:42
hmm, maybe the connector sends the wrong closing packet ?
ficeto
@ficeto
May 24 2015 18:42
no.. it just does not respond to the server fin packets
it might already be sleeping
chad cormier roussel
@chadouming
May 24 2015 18:43
gimme 20 seconds
i'm uploading with delay after the disconnect
ficeto
@ficeto
May 24 2015 18:43
no rush :)
chad cormier roussel
@chadouming
May 24 2015 18:47
hmm, added delay between the connect, query, disconnect and sleep
seems to have changed nothing but i'll get you are tcpdump
ficeto
@ficeto
May 24 2015 18:48
what is your delay between reconnect attempts?
chad cormier roussel
@chadouming
May 24 2015 18:48
1 second
ficeto
@ficeto
May 24 2015 18:49
i actually see syn packets going out every 400ms
chad cormier roussel
@chadouming
May 24 2015 18:50
hmm, it was actually 10ms
i think i changed it yesterday as a test
changed it back to 1 sec and getting a tcpdumpp
ficeto
@ficeto
May 24 2015 18:53
look at this...
14:49:52.685119 IP (tos 0x0, ttl 248, id 6, offset 0, flags [none], proto TCP (6), length 44)
modemcable095.187-172.144.mc.videotron.ca.4097 > vps39145.vps.ovh.ca.mysql: Flags [S], cksum 0x12eb (correct), seq 6545, win 5840, options [mss 1460], length 0
14:49:52.992649 IP (tos 0x0, ttl 57, id 9163, offset 0, flags [DF], proto TCP (6), length 45)
modemcable095.187-172.144.mc.videotron.ca.49825 > vps39145.vps.ovh.ca.mysql: Flags [P.], cksum 0xeae6 (correct), seq 1264929211:1264929216, ack 663285949, win 255, length 5
300ms between the packets
the above packet is a new SYN packet for opening a new socket
chad cormier roussel
@chadouming
May 24 2015 18:55
do{
connected = client.connect(server, port);
if(!connected)
Serial.println("Failed :(");
delay(1000);
i++;
}while(!connected && i <= MAX_CONNECT_ATTEMPTS);
that is the function
ficeto
@ficeto
May 24 2015 18:55
the second packet comes from totaly different port
chad cormier roussel
@chadouming
May 24 2015 18:55
god dammit
i have heidiSQL open -_-
ficeto
@ficeto
May 24 2015 18:55
and is actually a duplicate data packet
chad cormier roussel
@chadouming
May 24 2015 18:55
let me get new packet
ficeto
@ficeto
May 24 2015 18:55
:D
ok you got me scared there
chad cormier roussel
@chadouming
May 24 2015 18:58
ficeto
@ficeto
May 24 2015 19:02
oh... i so think i busted the problem....
do me a favor, and do in the same sketch one after another two queries
chad cormier roussel
@chadouming
May 24 2015 19:03
don't keep me holding
hmm, ok
ficeto
@ficeto
May 24 2015 19:03
connect-query-disconnect, wait 2 sec do the same, then sleep
and take a dump
chad cormier roussel
@chadouming
May 24 2015 19:07
hmm
....Connected to wifi!
Connected to DataBase!
Failed :(
Failed :(
Failed :(
Failed :(
Failed :(
Connected to server version 5.5.5-10.1.4-MariaDB-1~sid-wsrep
Disconnected.
Connected to server version 5.5.5-10.1.4-MariaDB-1~sid-wsrep
Disconnected.
INSERT INTO tempLogging.logs VALUES (NULL, 10187771, 17.70, 3326, 30.90, NULL)
Yay!
Time to sleep : 300
ficeto
@ficeto
May 24 2015 19:07
so the secnd has no problem right?
chad cormier roussel
@chadouming
May 24 2015 19:07
yup
ficeto
@ficeto
May 24 2015 19:08
let me look quick on the bin
dump i mean
after it wakes up there will be one more disconnect than before, and that will grow with each reset
test it
chad cormier roussel
@chadouming
May 24 2015 19:09
hmm, need to have 2 tries per program run ?
ficeto
@ficeto
May 24 2015 19:09
no
chad cormier roussel
@chadouming
May 24 2015 19:10
ok
ficeto
@ficeto
May 24 2015 19:10
just test what I asked, sleep less
chad cormier roussel
@chadouming
May 24 2015 19:10
yeah
ficeto
@ficeto
May 24 2015 19:10
every second connection should have no problems
but after wakeup there should be one more fail every time
chad cormier roussel
@chadouming
May 24 2015 19:11
uploading
20 secs of sleep instead of 5 mins
ficeto
@ficeto
May 24 2015 19:11
great
chad cormier roussel
@chadouming
May 24 2015 19:13
seems to have 5 fails every time
ficeto
@ficeto
May 24 2015 19:14
can you dump two on a row
chad cormier roussel
@chadouming
May 24 2015 19:14
same thing but with 2 on a row ?
ficeto
@ficeto
May 24 2015 19:15
well now you left two connect-query-disconnects there correct?
chad cormier roussel
@chadouming
May 24 2015 19:15
nope
ficeto
@ficeto
May 24 2015 19:15
that was the test
two on a row, then seep less then again
if it's just one, will always answer at the same disconnects
chad cormier roussel
@chadouming
May 24 2015 19:18
ok, so now it's: connect -> send query -> disconnect -> wait -> connect -> query -> disconnect -> sleep
ficeto
@ficeto
May 24 2015 19:18
yes
this is an lwip/linux tcp problem
you can not connect untill you get to port 4102
and you always start at port 4097
chad cormier roussel
@chadouming
May 24 2015 19:21
hmm, mysql is port 3306
ficeto
@ficeto
May 24 2015 19:21
i thought the once you raise the port with the second connect it will also require higher port next time
has nothing to do with mysql
chad cormier roussel
@chadouming
May 24 2015 19:21
ah
ficeto
@ficeto
May 24 2015 19:22
i had this issue on my stack
chad cormier roussel
@chadouming
May 24 2015 19:22
so, it's not my fault ? xD
ficeto
@ficeto
May 24 2015 19:22
no
i can tell you how it can be fixed though
chad cormier roussel
@chadouming
May 24 2015 19:22
well, don't keep me waiting
ficeto
@ficeto
May 24 2015 19:23
and @iggr should be able to say how it can be further implemented in the current stack
the point is at boot the starting port (there is such counter in the stack) to have the highest 6 bits at random
but since we are on a MCU, there is no source for randomness
and that usually never helps
what I did is to ask ntp for the time
then use that as seed for the random
and set the port,s highest 6 bits to that
this way every time my actual sketch requests connect it starts from different high number
this needs to actually be in the stack, but can not tell you how and where and i'm not sure we have access
chad cormier roussel
@chadouming
May 24 2015 19:28
can't i just set the port manually ?
ficeto
@ficeto
May 24 2015 19:29
that is what you need to find how to do
then implement what I did
Ivan Grokhotkov
@igrr
May 24 2015 19:29
that was igrr not iggr, so i missed the mention :)
sec
ficeto
@ficeto
May 24 2015 19:29
sorry :D
fat fingers..
Ivan Grokhotkov
@igrr
May 24 2015 19:30
lucky us, since SDK 1.1.0 we've got a source of randomness
comes from ADC
well, kinda randomness
chad cormier roussel
@chadouming
May 24 2015 19:31
well, it's probably more random that not random at all xD
ficeto
@ficeto
May 24 2015 19:31
the most random is what i did
read it somewhere
i was fucked because of those static port numbers
Ivan Grokhotkov
@igrr
May 24 2015 19:31
we've got an NTP client sample sketch included
ficeto
@ficeto
May 24 2015 19:31
how to set that though?
Ivan Grokhotkov
@igrr
May 24 2015 19:31
so we need an API to set source TCP port?
or is that UDP?
chad cormier roussel
@chadouming
May 24 2015 19:32
tcp
ficeto
@ficeto
May 24 2015 19:32
not the source tcp port for the client
Ivan Grokhotkov
@igrr
May 24 2015 19:32
k
ficeto
@ficeto
May 24 2015 19:32
in the tcp stack there is a variable that increments with each client
that is what needs to be set
and set once, then it increments
Ivan Grokhotkov
@igrr
May 24 2015 19:33
#define TCP_LOCAL_PORT_RANGE_START        0xc000
#define TCP_LOCAL_PORT_RANGE_END          0xffff
and
/* last local TCP port */
static u16_t tcp_port = TCP_LOCAL_PORT_RANGE_START;
ficeto
@ficeto
May 24 2015 19:33
crap :(
we can write to that tcp_port right?
0xc000 is 42000... he start from 4097 every time
chad cormier roussel
@chadouming
May 24 2015 19:40
hmm, might be worthy of a 1000$ from espressif if you actually find the bug
ficeto
@ficeto
May 24 2015 19:42
what do you mean find it :)
i just told you what it is :D
my stack thing was also based on lwip
but thought it's take care of
chad cormier roussel
@chadouming
May 24 2015 19:43
yeah, but where does it really come. What's the basic problem
or is it in binary ?
ficeto
@ficeto
May 24 2015 19:43
the basic problem is that it always starts from the same port
so every client connect will be in the same order
and servers do not like that
especially if there is a connection hangin there
and they don't like it because that is how the tcp stack is written there
it's not really a bug
Ivan Grokhotkov
@igrr
May 24 2015 19:45
we can't change this "last port number" variable within lwip, but i can add a way to set port on the WiFiClient
ficeto
@ficeto
May 24 2015 19:45
as there isn't a really random seed
Ivan Grokhotkov
@igrr
May 24 2015 19:45
client.setLocalPort(port)
which you will have to call before calling connect
ficeto
@ficeto
May 24 2015 19:46
@igrr sure... but that has to be done every time
Ivan Grokhotkov
@igrr
May 24 2015 19:46
of course you will have to manage the port numbers yourself
ficeto
@ficeto
May 24 2015 19:46
while it should be done once on boot
Ivan Grokhotkov
@igrr
May 24 2015 19:47
well if we had an lwip version which we could modify and compile ourselves then I would have added a method to set this default port number
unfortunately the open-source lwip is lagging behind, it doesn't work with latest changes from espressif
so i can't change anything there
oh well, i can... change one object and do some ar/objcopy to patch the binary from esressif...
@chadouming will client.setLocalPort(port) API work for you?
chad cormier roussel
@chadouming
May 24 2015 19:49
ofvc
ofc*
Ivan Grokhotkov
@igrr
May 24 2015 19:49
k
will push in an hour
once im home
chad cormier roussel
@chadouming
May 24 2015 19:54
would be nice to have an automated solution, but I'll take anything that works :D
ficeto
@ficeto
May 24 2015 19:55
@igrr maybe do it in ClientContext where you open new client connection and expose a lib method to set the upper 4 bits
6 bits to stay clear from 1024
so once set, every next client will be with correct port
setting it to every client separately is not a good idea
they should be incrementing
Ivan Grokhotkov
@igrr
May 24 2015 20:01
OK, thats also possible
we can have some static function which will set the starting port
ficeto
@ficeto
May 24 2015 20:02
but that is only for when you initiate the connection
Ivan Grokhotkov
@igrr
May 24 2015 20:02
sure
ficeto
@ficeto
May 24 2015 20:02
incomming clients have the server port
Ivan Grokhotkov
@igrr
May 24 2015 20:02
when you bind, you specify a port anyway
ficeto
@ficeto
May 24 2015 20:02
the local port?
or the remote port?
Ivan Grokhotkov
@igrr
May 24 2015 20:03
local
ficeto
@ficeto
May 24 2015 20:04
int ICACHE_FLASH_ATTR  WiFiClient::connect(const char* host, uint16_t port) 
{
    IPAddress remote_addr;
    if (WiFi.hostByName(host, remote_addr))
    {
        return connect(remote_addr, port);
    }
    return 0;
}

int ICACHE_FLASH_ATTR  WiFiClient::connect(IPAddress ip, uint16_t port) 
{
    if (_client)
        stop();

    tcp_pcb* pcb = tcp_new();
    if (!pcb)
        return 0;

    ip_addr_t addr;
    addr.addr = ip;
    tcp_arg(pcb, this);
    tcp_err(pcb, &WiFiClient::_s_err);
    tcp_connect(pcb, &addr, port, reinterpret_cast<tcp_connected_fn>(&WiFiClient::_s_connected));

    esp_yield();
    if (_client)
        return 1;

    //  if tcp_error was called, pcb has already been destroyed.
    // tcp_abort(pcb);
    return 0;
}
here is where it should be
Ivan Grokhotkov
@igrr
May 24 2015 20:04
yes I've just added it there :)
ficeto
@ficeto
May 24 2015 20:04
i do not see it specified
the local port i mean
Ivan Grokhotkov
@igrr
May 24 2015 20:06
currently it's zero by default (set in tcp_new)
when you call tcp_connect, it will check the value of local_port
if it's zero, tcp_new_port will be called to generate a port number
same with tcp_bind (for server PCBs)
the difference is that for server PCBs we normally specify the port ourselves
and for clients we didn't
ficeto
@ficeto
May 24 2015 20:08
what tcp_new_port does is get the last used port and add 1
Ivan Grokhotkov
@igrr
May 24 2015 20:09
yep
actually, not last used
last generated
ficeto
@ficeto
May 24 2015 20:10
well it gets a number form the variable that holds the value
and that variable is initialized with the number 0x1000 in his and should be ours too
then on each call just increments that var and returns it
Ivan Grokhotkov
@igrr
May 24 2015 20:16
esp8266/Arduino@00604f3
chad cormier roussel
@chadouming
May 24 2015 20:17
should i start at 6 or 4102 ?
ficeto
@ficeto
May 24 2015 20:21
you should start at 4096 | (random(16) << 12)
chad cormier roussel
@chadouming
May 24 2015 20:21
simple enough, will try that
ficeto
@ficeto
May 24 2015 20:21
but before that your random seed needs to be initialized with something random
else will give the same number every time
so get the ntp example
Ivan Grokhotkov
@igrr
May 24 2015 20:23
there are two new APIs in the current SDK
unsigned long os_random(void);
int os_get_random(unsigned char *buf, size_t len);
ficeto
@ficeto
May 24 2015 20:23
no seed setting though
Ivan Grokhotkov
@igrr
May 24 2015 20:24
it's seeded from ADC
chad cormier roussel
@chadouming
May 24 2015 20:24
it's set on ADC
ficeto
@ficeto
May 24 2015 20:24
sucks
chad cormier roussel
@chadouming
May 24 2015 20:24
which, if floating, should return a random value
Ivan Grokhotkov
@igrr
May 24 2015 20:24
unfortunately they don't specify what is the range of the random values returned
this API is not in their SDK doc...
ficeto
@ficeto
May 24 2015 20:26
randomSeed(time);
do we have randomSeed()?
yup in wmath
srand(seed)
i imagine this will alter the system's random generator as well??
Ivan Grokhotkov
@igrr
May 24 2015 20:31
pro tip: update your library to the new format
with src subfolder and library properties file
(check the layout of ESP8266WiFi library or ESP8266WebServer library)
chad cormier roussel
@chadouming
May 24 2015 20:32
done xDF
ficeto
@ficeto
May 24 2015 20:34
also MySQL.cpp and h instead of all lower case
Ivan Grokhotkov
@igrr
May 24 2015 20:35
was about to write the same thing :)
yeah, Arduino libraries have names starting in upper case
ficeto
@ficeto
May 24 2015 20:35
why did you name it Connector?
not that it's not :D
chad cormier roussel
@chadouming
May 24 2015 20:36
i ported this library, not created it
ficeto
@ficeto
May 24 2015 20:36
oh ok
chad cormier roussel
@chadouming
May 24 2015 20:36
it's how it was named
Ivan Grokhotkov
@igrr
May 24 2015 20:36
it under the terms of the GNU General Public License as published by
eww
not that I was planning to use it for anything commercial..
ficeto
@ficeto
May 24 2015 20:38
i hate licenses...
if it's out there, it out there
chad cormier roussel
@chadouming
May 24 2015 20:41
it works, ain't that the important thing %
?*
ficeto
@ficeto
May 24 2015 20:44
sure it is
chad cormier roussel
@chadouming
May 24 2015 20:45
and, can i build the latest version for windows on linux %
?*
Ivan Grokhotkov
@igrr
May 24 2015 20:46
latest version of Arduino?
chad cormier roussel
@chadouming
May 24 2015 20:46
yeah
Ivan Grokhotkov
@igrr
May 24 2015 20:46
git clone, cd build, ant dist
or ant run
oh misread your question
i don't think you can build on one platform for another
chad cormier roussel
@chadouming
May 24 2015 20:49
Sad
I'll wait for next board manager release then
Ivan Grokhotkov
@igrr
May 24 2015 20:49
i'm going to set it up so that it will build a new release on each commit
this will be like "development branch"
the json will have different url
chad cormier roussel
@chadouming
May 24 2015 20:50
That will be awesome
Markus
@Links2004
May 24 2015 21:12
has some one get the new SDK version running the latest git now compiles but at startup i always get Fatal exception (0)
Ivan Grokhotkov
@igrr
May 24 2015 21:18
hmm, i was just running a sketch...
let me clean everything and try again
Markus
@Links2004
May 24 2015 21:20
ok error is here:
Fatal exception (0):  
epc1=0x401077ec
Disassembly of section .UserEnter.text:

401077e8 <call_user_start-0x4>:
401077e8:    100000            and    a0, a0, a0
401077eb:    ff2140            excw

401077ec <call_user_start>:
401077ec:    ffff21            l32r    a2, 401077e8 <_etext>
401077ef:    13e720            wsr.vecbase    a2
401077f2:    faa805            call0    40102274 <call_user_start_local>
chad cormier roussel
@chadouming
May 24 2015 21:22
I had problem too
Serial kept pushing BS
Ivan Grokhotkov
@igrr
May 24 2015 21:24
right
got it
fixing...
Ivan Grokhotkov
@igrr
May 24 2015 21:34
done esp8266/Arduino@9214799
overlooked this when i was copying SDK files
Markus
@Links2004
May 24 2015 21:35
k will try, getting one ExceptionVector also sounds nice.
chad cormier roussel
@chadouming
May 24 2015 21:41
Hmm, can't we set the seed for randomness to be the chip id ? I know it's not really random, but it will at least be unique and different for each device ?
Markus
@Links2004
May 24 2015 21:42
still Fatal exception (0):
but this time 0x40226220
ficeto
@ficeto
May 24 2015 21:42
that is not the point @chadouming
has to be unique every time
or as unique as it can be
Markus
@Links2004
May 24 2015 21:43
40225e88 <user_uart_wait_tx_fifo_empty>:
40225e88:    e0c112            addi    a1, a1, -32
40225e8b:    21d9          s32i.n    a13, a1, 8
40225e8d:    41f9          s32i.n    a15, a1, 16
40225e8f:    0109          s32i.n    a0, a1, 0
40225e91:    11c9          s32i.n    a12, a1, 4
40225e93:    31e9          s32i.n    a14, a1, 12
40225e95:    02cd          mov.n    a12, a2
40225e97:    03ed          mov.n    a14, a3
40225e99:    a85d01            l32r    a0, 40210010 <_irom0_text_start+0x10>
40225e9c:    0000c0            callx0    a0
40225e9f:    02dd          mov.n    a13, a2
40225ea1:    fff8f1            l32r    a15, 40225e84 <wdt_init+0x80>
40225ea4:    f57501            l32r    a0, 40223478 <xPortGetFreeHeapSize+0x50>
40225ea7:    d1ffc0            mul16s    a15, a15, a12
40225eaa:    ff0a          add.n    a15, a15, a0
40225eac:    ade0c1            l32r    a12, 4021162c <_ZN10arduinoVNC20read_from_rfb_serverEiPcj+0xa0>
40225eaf:    0020c0            memw
40225eb2:    872f02            l32i    a0, a15, 0x21c
40225eb5:    140c07            bnone    a12, a0, 40225ecd <user_uart_wait_tx_fifo_empty+0x45>
40225eb8:    a85601            l32r    a0, 40210010 <_irom0_text_start+0x10>
40225ebb:    0000c0            callx0    a0
40225ebe:    c002d0            sub    a0, a2, a13
40225ec1:    083e07            bltu    a14, a0, 40225ecd <user_uart_wait_tx_fifo_empty+0x45>
40225ec4:    0020c0            memw
40225ec7:    872f32            l32i    a3, a15, 0x21c
40225eca:    ea83c7            bany    a3, a12, 40225eb8 <user_uart_wait_tx_fifo_empty+0x30>
40225ecd:    11c8          l32i.n    a12, a1, 4
40225ecf:    21d8          l32i.n    a13, a1, 8
40225ed1:    31e8          l32i.n    a14, a1, 12
40225ed3:    41f8          l32i.n    a15, a1, 16
40225ed5:    0108          l32i.n    a0, a1, 0
40225ed7:    20c112            addi    a1, a1, 32
40225eda:    f00d          ret.n
.................
40226217:    0108          l32i.n    a0, a1, 0
40226219:    10c112            addi    a1, a1, 16
4022621c:    f00d          ret.n
4022621e:    610000            excw
40226221:    41f785            call0    4026819c <_flash_code_end+0x20a74>
40226224:    0cf783            excw
40226227:    b46705            call0    401da898 <_lit4_end+0xd2f38>
4022622a:    445207            bbc    a2, a0, 40226272 <ic_enable_interface+0x12>
4022622d:    441b00            extui    a1, a0, 11, 5
40226230:    f79467            bne    a4, a6, 4022622b <user_uart_wait_tx_fifo_empty+0x3a3>
40226233:    f00d          ret.n
40226235:    000000            ill
40226238:    fec7f0            excw
4022623b:    3f              .byte 0x3f
chad cormier roussel
@chadouming
May 24 2015 21:43
technically, if it's unique every time it's not really random, no ?
ficeto
@ficeto
May 24 2015 21:45
it doe not neceserry need to be random
just different enough
but since you are in an MCU
Markus
@Links2004
May 24 2015 21:45
the new sdk has to new compiler options will try -ffunction-sections -fdata-sections
ficeto
@ficeto
May 24 2015 21:45
the moment you execute it will always have the same value
alon24
@alon24
May 24 2015 21:46
I have this code for rotary encoder, I know it worked before I did the latest board manager update, the thing is, that If I go into the loop:: if statement and give the lastEncoderValue == encoderValue command, the output (serial print) is not the correct number, only -1,-2,-3 not the correct numbers

//From bildr article: http://bildr.org/2012/08/rotary-encoder-arduino/

//these pins can not be changed 2/3 are special pins
int encoderPin1 = 12;
int encoderPin2 = 13;
int encoderSwitchPin = 4; //push button switch

volatile int lastEncoded = 0;
volatile long encoderValue = 0;

long lastencoderValue = 0;

int lastMSB = 0;
int lastLSB = 0;

void setup() {
  Serial.begin (115200);

  pinMode(encoderPin1, INPUT); 
  pinMode(encoderPin2, INPUT);

  pinMode(encoderSwitchPin, INPUT);


  digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
  digitalWrite(encoderPin2, HIGH); //turn pullup resistor on

  digitalWrite(encoderSwitchPin, HIGH); //turn pullup resistor on


  //call updateEncoder() when any high/low changed seen
  //on interrupt 0 (pin 2), or interrupt 1 (pin 3) 
  attachInterrupt(encoderPin1, updateEncoder, CHANGE); 
  attachInterrupt(encoderPin2, updateEncoder, CHANGE);

}

void loop(){ 
  //Do stuff here
  if(digitalRead(encoderSwitchPin)){
    //button is not being pushed
  }else{
    //button is being pushed
  }

 if (lastencoderValue != encoderValue) {

  Serial.println();
  lastencoderValue= encoderValue;
 }

//  delay(1000); //just here to slow down the output, and show it will work  even during a delay
}


void updateEncoder(){
  int MSB = digitalRead(encoderPin1); //MSB = most significant bit
  int LSB = digitalRead(encoderPin2); //LSB = least significant bit

  int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number
  int sum  = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

  if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;
  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --;

  lastEncoded = encoded; //store this value for next time
}
linagee
@linagee
May 24 2015 21:46
Just got my environment up and running with the new way using Board Manager. Great job to whoever got that working!
alon24
@alon24
May 24 2015 21:47
can any one tell me why lastencoderValue= encoderValue; messes with the encoderValue?
ficeto
@ficeto
May 24 2015 21:47
first of all
pinModes need to be INPUT_PULLUP
do not write to the pins, just read them
alon24
@alon24
May 24 2015 21:50
sorry Serial.println(); should of course be Serial.println(encoderValue);
Ivan Grokhotkov
@igrr
May 24 2015 21:50
@Links2004 i'm not getting this exception, seems to depend on the sketch
alon24
@alon24
May 24 2015 21:51
@ficeto -thanks, that did the trick
Markus
@Links2004
May 24 2015 21:51
@igrr it was working before the update, will try a clean one.
Ivan Grokhotkov
@igrr
May 24 2015 21:51
@linagee you are welcome!
alon24
@alon24
May 24 2015 21:52
this is a difference than the arduino regular code, becasue there on my arduino nano, this works
but this works here now, so I am NOT complaing at all
ficeto
@ficeto
May 24 2015 21:52
AVR has different GPIO register layout
Markus
@Links2004
May 24 2015 22:04
#include <Arduino.h>

void setup() {
}

void loop() {
}
and still the same exception
Ivan Grokhotkov
@igrr
May 24 2015 22:09
when i try this sketch I get no output
with this one, i get what is expected:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.setDebugOutput(true);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("test");
  delay(300);
}
Serial1 works as well...
alon24
@alon24
May 24 2015 22:12
@igrr is the ssd1306 code in the latest board manager?
Markus
@Links2004
May 24 2015 22:12
ok found a way to stop it but what they have changed....
my flash where running on 80Mhz on the old SDK now i get the exaction with this setting.
if i go down to 40Mhz its running fine. if i use the old SDK 80Mhz working well.
the chip itself is an W25Q32 and can handle it.
Ivan Grokhotkov
@igrr
May 24 2015 22:13
there have been some changes to the SPI part in the latest SDK
alon24
@alon24
May 24 2015 22:14
and what do i do if I have the old non functioning code (the oneI tried to fix with the help of the good people here (and failed))
Ivan Grokhotkov
@igrr
May 24 2015 22:15
no ssd1306 is not packaged
where do i get the version which work with ESPs?
alon24
@alon24
May 24 2015 22:15
it was in the chat, trying to find
Ivan Grokhotkov
@igrr
May 24 2015 22:19
ficeto/Adafruit_SSD1306@fef5856
this one i think
alon24
@alon24
May 24 2015 22:19
u beat me to it but yes
can this be pushed to board manager (I have not tested it, and in the chat someone said that he was not able to connect to wifi when using it)
Ivan Grokhotkov
@igrr
May 24 2015 22:30
@Links2004 i wonder what's the point using -ffunction-sections and -fdata-sections without -Wl,--gc-sections...
Not that it changes the output size though
Markus
@Links2004
May 24 2015 22:36
i port this setting from the original make files
orginal:
CCFLAGS +=             \
    -g            \
    -O2            \
    -Wpointer-arith        \
    -Wundef            \
    -Werror            \
    -Wl,-EL            \
    -fno-inline-functions    \
    -nostdlib       \
    -mlongcalls    \
    -mtext-section-literals \
    -ffunction-sections \
    -fdata-sections
Ivan Grokhotkov
@igrr
May 24 2015 22:37
yeah, i mean — why did espressif include those options? without -Wl,--gc-sections they don't actually do anything
except the elf file is larger
alon24
@alon24
May 24 2015 22:38
i tried to run it, using the code from the git (ficeto) - it did not work
Markus
@Links2004
May 24 2015 22:38
yes gcc manual says:
-ffunction-sections
-fdata-sections
Place each function or data item into its own section in the output file if the
target supports arbitrary sections. The name of the function or the name of
the data item determines the section’s name in the output file.
Use these options on systems where the linker can perform optimizations to
improve locality of reference in the instruction space. Most systems using the
ELF object format and SPARC processors running Solaris 2 have linkers with
such optimizations. AIX may have these optimizations in the future.
Only use these options when there are significant benefits from doing so. When
you specify these options, the assembler and linker will create larger object and
executable files and will also be slower. You will not be able to use gprof on all
systems if you specify this option and you may have problems with debugging
if you specify both this option and ‘-g’.
will remove them again.