These are chat archives for esp8266/Arduino

7th
May 2015
linagee
@linagee
May 07 2015 01:23
I think the CH340 is either really sensitive to the type of USB cable you use, or a had a really bad USB cable. (no enumeration with a CH340 I had until I plugged it straight into the computer with no ~3 ft USB cable.)
onkelfunny
@onkelfunny
May 07 2015 06:03
i found another issue with the esptool-ck: after the file is uploaded, the FLASH_DOWNLOAD_DONE will be only send if i use the "-vv" mode. without -vv i have to restart the module by the hand. is this a bug or a feature? if it is a bug, i will try to fix them this evening
Ivan Grokhotkov
@igrr
May 07 2015 06:10
that would be a bug
onkelfunny
@onkelfunny
May 07 2015 06:10
ok, i try to fix it
Ivan Grokhotkov
@igrr
May 07 2015 06:11
I'll pull your changes and will also take a look
onkelfunny
@onkelfunny
May 07 2015 06:11
thx
Ivan Grokhotkov
@igrr
May 07 2015 06:11
I don't have a ch340 though, so will test with an FTDI and cp2103
onkelfunny
@onkelfunny
May 07 2015 06:15
ok. i tested it with ch340 and FTDI... but this all is new for me and im not 100% sure ;)
Ivan Grokhotkov
@igrr
May 07 2015 07:13
@onkelfunny re FLASH_DOWNLOAD_DONE:
here is the relevant part of main.c
    if (espcomm_file_uploaded())
    {
        espcomm_start_app(0);
    }
this shouldn't depend on -vv argument
also regarding additional serialport_send_C0();
i've checked the esptool.py source
Ivan Grokhotkov
@igrr
May 07 2015 07:18
and it seems to me that sending two C0's at the end of packet is not what esptool.py does... so I'm trying to understand why this change improves things with CH340...
onkelfunny
@onkelfunny
May 07 2015 07:35
maybe this is a timing problem. i will try a delay before sending the second C0.
Ivan Grokhotkov
@igrr
May 07 2015 07:47
yeah, I think the issue is with the drain() which follows
with a -vvv option
arrgh, gitter app is loosing my messages
a was saying, can you please paste the error log you get with the original version and ch340, and -vvv option?
onkelfunny
@onkelfunny
May 07 2015 07:55
i'm currently not at home. i will try this at evening
Ivan Grokhotkov
@igrr
May 07 2015 07:55
sure, thanks
ficeto
@ficeto
May 07 2015 09:53
I'm really glad that the new wifi lib fixed that ACK issue with large files
question now is why do I only get 100 kbps speed
when all debug is disabled
SD clock is at 4Mbps
Ivan Grokhotkov
@igrr
May 07 2015 09:56
max speed will be (tx block size)/(tcp round-trip time)
ficeto
@ficeto
May 07 2015 09:56
block is at max, can't make the connection better :)
and I'm sure I've gotten faster upload speeds
in magnitude of Mbps
can't be as fast as serial... seems way too slow
Ivan Grokhotkov
@igrr
May 07 2015 09:58
perhaps it is worth having more than one MTU in flight at a time
why are we sending just one MTU by the way?
ficeto
@ficeto
May 07 2015 09:58
what do you mean by 1 MTU?
Ivan Grokhotkov
@igrr
May 07 2015 09:59
1 packet of 1450 bytes
ficeto
@ficeto
May 07 2015 09:59
how can I send more?
i mean , i'm sending packet after mpacket
1460 bytes of data
Ivan Grokhotkov
@igrr
May 07 2015 10:00
let me check if lwip is configured with support for packet fragmentation
sec
#define IP_FRAG 0
nope, it doesn't...
ficeto
@ficeto
May 07 2015 10:02
so I have no better way
Ivan Grokhotkov
@igrr
May 07 2015 10:03
but #define MEMP_NUM_TCP_SEG 16
so while we can not send fragmented packets, we can split them ourselves
ficeto
@ficeto
May 07 2015 10:04
and it's exactly what I do
Ivan Grokhotkov
@igrr
May 07 2015 10:04
this needs some support in ClientContext
ficeto
@ficeto
May 07 2015 10:05
I read 1460 bytes from the SD and write that to the client
Ivan Grokhotkov
@igrr
May 07 2015 10:05
no, not exactly — since you use WiFiClient::write, it will block until ACK is received for a packet
what i mean is to send multiple packets at once, and then wait for all the ACKs
ficeto
@ficeto
May 07 2015 10:05
you think I can send packets without waiting?
and will this be a good idea?
not sure that is how TCP is meant to work
Ivan Grokhotkov
@igrr
May 07 2015 10:06
you can not do this with WiFiClient API, as it is blocking
ficeto
@ficeto
May 07 2015 10:06
And that is how it should be
Ivan Grokhotkov
@igrr
May 07 2015 10:07
but at the lower level I can call tcp_write multiple times
ficeto
@ficeto
May 07 2015 10:07
because if an ACK is not received, the packet is retransmitted
if you send another.. the buffer will have the bnew packet
so retransmission will not work
and data will get lost
especially on WiFi
I do not think that that is the issue
something is maybe slowing down
seems too close to UART speed
I have a 5db antenna and I'm not far from the router
the client is connected to the router over Gb ethernet
Ivan Grokhotkov
@igrr
May 07 2015 10:10
i think if you measure the round-trip time with wireshark and divide the buffer size by roundtrip time, you will get the speed almost exactly
like 1.5k / 10ms = 150k/s
can you try one thing?
in ClientContext, add tcp_output( _pcb ); in the write method
at line 172
this may save a few ms on each write operation
ficeto
@ficeto
May 07 2015 10:21
here is the timing
PCK 221511 0
ACK 221560 49
PCK 345988 124477
ACK 346025 124510
11680 bits for 0.124510 seconds = 93807.7263 bps
it takes forever to send the next packet
will try what you said
Ivan Grokhotkov
@igrr
May 07 2015 10:23
what are those numbers again?
microseconds?
ficeto
@ficeto
May 07 2015 10:23
yes
0.the number seconds
second column is just starting from 0
Ivan Grokhotkov
@igrr
May 07 2015 10:24
so it takes around 120ms between the ack and next packet being sent...
ficeto
@ficeto
May 07 2015 10:24
yes
Ivan Grokhotkov
@igrr
May 07 2015 10:24
we need to log micros() output somewhere to debug this on the sketch side
perhaps context switching takes too much time
ficeto
@ficeto
May 07 2015 10:25
you mean the time it takes to read from the SD
will log now
Ivan Grokhotkov
@igrr
May 07 2015 10:26
extern "C" uint32_t esp_micros_at_task_start();
you can add this declaration to your sketch and print the output of this function as well
before and after client.write()
ficeto
@ficeto
May 07 2015 10:27
ok
gives precisely that period
T:125023
T:124910
T:125010
T:124990
T:125094
T:124934
T:124881
T:125297
T:126172
T:123592
T:124914
T:125079
T:124923
T:128993
T:121175
T:124824
T:125084
ficeto
@ficeto
May 07 2015 10:36
adding that line made things much different
900Kbps
Ivan Grokhotkov
@igrr
May 07 2015 10:44
i think that should be good enough for a $5 thingy
Ivan Grokhotkov
@igrr
May 07 2015 10:52
(gone looking for an SD card socket breakout)
can't wait to try it
ficeto
@ficeto
May 07 2015 10:52
that is great for a 5$ thingy
now a proper API export and JS apps,here we go :)
if you have a SD to MicroSD adapter, a few wires and soldering iron, you are set
SD it at 3.3V so no external components are needed
you do not even need SS pin for it :) just tie it to ground
onkelfunny
@onkelfunny
May 07 2015 11:00
@ficeto can you make a wire diagram for the MicroSD adapter and the ESP-01?
ficeto
@ficeto
May 07 2015 11:01
does the ESP-01 have GPIOs 12-14 broken out?
onkelfunny
@onkelfunny
May 07 2015 11:03
do i need this GPIOs? i have some ESP-12 with full gpios
ficeto
@ficeto
May 07 2015 11:03
yes
SD card runs on SPI
I will test a software SPI with it, but that is not there yet
I have a pretty nice SSPI lib already, but need to adjust the SD library for it
I'm really eager to try SDcard boot as well
onkelfunny
@onkelfunny
May 07 2015 11:08
i will try to solder some extra pins to the esp-01 like this: http://esp8266.ru/tag/esp-01/
in my current project i need 4 gpios ... hope i have luck :)
ficeto
@ficeto
May 07 2015 11:08
seems my card is really slow, so speed might be actually higher than what I get
Ivan Grokhotkov
@igrr
May 07 2015 11:14
@ficeto did you use any pull up resistors on the SD card interface?
ficeto
@ficeto
May 07 2015 11:14
no
Ivan Grokhotkov
@igrr
May 07 2015 11:14
like this?
ficeto
@ficeto
May 07 2015 11:15
I did not use pullups and tied SS to ground
5 wires total
surely you can use any pin for SS
but since i have nothing else on the SPI, I did not bother
Ivan Grokhotkov
@igrr
May 07 2015 12:44
still doesn't work very well:
[igrokhotkov@igrokhot-mbp /tmp]$ wget http://192.168.222.166/1.jpg
--2015-05-07 15:42:10--  http://192.168.222.166/1.jpg
Connecting to 192.168.222.166:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 974468 (952K) [image/jpeg]
Saving to:1.jpg’

1.jpg                                        6%[====>                                                                                    ]  58.46K  18.2KB/s   in 3.2s   

2015-05-07 15:42:14 (18.2 KB/s) - Connection closed at byte 59860. Retrying.

--2015-05-07 15:42:15--  (try: 2)  http://192.168.222.166/1.jpg
Connecting to 192.168.222.166:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 974468 (952K) [image/jpeg]
Saving to:1.jpg’

1.jpg                                       20%[================>                                                                        ] 191.05K  26.3KB/s   in 7.1s   

2015-05-07 15:42:27 (26.9 KB/s) - Connection closed at byte 195640. Retrying.

--2015-05-07 15:42:29--  (try: 3)  http://192.168.222.166/1.jpg
Connecting to 192.168.222.166:80... failed: Connection refused.
[igrokhotkov@igrokhot-mbp /tmp]$ wget http://192.168.222.166/1.jpg
--2015-05-07 15:42:34--  http://192.168.222.166/1.jpg
Connecting to 192.168.222.166:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 974468 (952K) [image/jpeg]
Saving to:1.jpg.11.jpg.1                                      7%[=====>                                                                                   ]  71.29K  14.1KB/s   in 5.1s   

2015-05-07 15:42:41 (14.1 KB/s) - Connection closed at byte 73000. Retrying.
ficeto
@ficeto
May 07 2015 12:45
you have debugs and whatnot? did you pull the latest git? with that line in ClientContext?
speed seem slow
Ivan Grokhotkov
@igrr
May 07 2015 12:46
yes latest version. i do have looong wires between the esp and the sd card though
well, 15cm
ficeto
@ficeto
May 07 2015 12:47
should not be that bad
ficeto@Hristos-Mac-mini-2 ~/Desktop/ESP8266/Arduino/build $ wget http://esp8266sd.local/oled.jpg
--2015-05-07 15:46:14--  http://esp8266sd.local/oled.jpg
Преобразувам esp8266sd.local (esp8266sd.local)... 192.168.254.173, 192.168.254.173
Connecting to esp8266sd.local (esp8266sd.local)|192.168.254.173|:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 808277 (789K) [image/jpeg]
Saving to: ‘oled.jpg’

100%[===============================================================================================================================================================================================>] 808 277      116KB/s   in 6,5s   

2015-05-07 15:46:26 (121 KB/s) - ‘oled.jpg’ saved [808277/808277]
Ivan Grokhotkov
@igrr
May 07 2015 12:48
in setup method it should be while (WiFi.status() != WL_CONNECTED && ++i < 20) delay(500); instead of while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500); by the way:)
i'll fix it along with some refactoring...
ficeto
@ficeto
May 07 2015 12:48
why?
let me think :D
yeah..
or should check for == 21
Ivan Grokhotkov
@igrr
May 07 2015 12:49
right :)
ficeto
@ficeto
May 07 2015 12:49
note my speed
121KB
Ivan Grokhotkov
@igrr
May 07 2015 12:53
:sent 1460
:ww
:wr
:rch 1131, 61
:sent 1460
:ww
:wr
:sent 1460
:ww
:wr
:sent 1460
:ww
:wr
:sent 1460
:ww
:wr
:rch 1192, 369
LmacRxBlk:1
LmacRxBlk:1
:er -8
:ww
:wr !_pcb
:wr !_pcb
:wr !_pcb
:wr !_pcb
:wr !_pcb
:wr !_pcb
i think this is the same issue you have observed
ficeto
@ficeto
May 07 2015 12:55
yes
but all I have done is rebuid the Arduino.app with the latest everything and the problem and speed issues are gone
exact sketch I'm running:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <SPI.h>
#include <SD.h>

#define WWW_BUF_SIZE 1460

const char* ssid = "nbis-test";
const char* password = "1234567890";
const char* hostname = "esp8266sd";

MDNSResponder mdns;
ESP8266WebServer server(80);

static bool hasSD = false;

bool loadFromSdCard(String path){
  String dataType = "text/plain";
  if(path.endsWith("/")) path += "index.htm";

  if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
  else if(path.endsWith(".htm")) dataType = "text/html";
  else if(path.endsWith(".css")) dataType = "text/css";
  else if(path.endsWith(".js")) dataType = "application/javascript";
  else if(path.endsWith(".png")) dataType = "image/png";
  else if(path.endsWith(".gif")) dataType = "image/gif";
  else if(path.endsWith(".jpg")) dataType = "image/jpeg";
  else if(path.endsWith(".ico")) dataType = "image/x-icon";
  else if(path.endsWith(".xml")) dataType = "text/xml";
  else if(path.endsWith(".pdf")) dataType = "application/pdf";
  else if(path.endsWith(".zip")) dataType = "application/zip";

  File dataFile = SD.open(path.c_str());
  if(dataFile.isDirectory()){
    path += "/index.htm";
    dataType = "text/html";
    dataFile = SD.open(path.c_str());
  }
  if (dataFile) {
    WiFiClient client = server.client();
    String head = "HTTP/1.1 200 OK\r\nContent-Type: ";
    head += dataType;
    head += "\r\nContent-Length: ";
    head += dataFile.size();
    head += "\r\n\r\n";
    client.print(head);

    uint8_t obuf[WWW_BUF_SIZE];

    while (dataFile.available() > WWW_BUF_SIZE){
      dataFile.read(obuf, WWW_BUF_SIZE);
      client.write(obuf, WWW_BUF_SIZE);
    }
    uint16_t leftLen = dataFile.available();
    dataFile.read(obuf, leftLen);
    client.write(obuf, leftLen);

    dataFile.close();
    return true;
  }
  return false;
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  //try to load the file from the card
  if(hasSD){
    if(loadFromSdCard(server.uri())) return;
  } else {
    message = "SDCARD Not Detected\n\n";
  }

  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " NAME:"+server.argName(i) + "\n VALUE:" + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  Serial1.print(message);
}

void setup(void){
  Serial1.begin(115200);
  Serial1.setDebugOutput(true);
  WiFi.begin(ssid, password);
  Serial1.print("\nConnecting to ");
  Serial1.println(ssid);

  // Wait for connection
  uint8_t i = 0;
  while (WiFi.status() != WL_CONNECTED && i++ < 20) {//wait 10 seconds
    delay(500);
  }
  if(i == 20){
    Serial1.print("Could not connect to");
    Serial1.println(ssid);
    while(1) delay(500);
  }
  Serial1.print("Connected! IP address: ");
  Serial1.println(WiFi.localIP());

  if (mdns.begin(hostname, WiFi.localIP())) {
    Serial1.println("MDNS responder started");
    Serial1.print("You can now connect to http://");
    Serial1.print(hostname);
    Serial1.println(".local");
  }

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial1.println("HTTP server started");

  if (SD.begin(SS)){
     Serial1.println("SD Card initialized.");
     hasSD = true;
  }
}

void loop(void){
  mdns.update();
  server.handleClient();
}
Ivan Grokhotkov
@igrr
May 07 2015 12:58
same here. perhaps I should try to do erase_flash, eh? it solves mysterious issues sometimes :)
ficeto
@ficeto
May 07 2015 12:58
:D
give it a go
Ivan Grokhotkov
@igrr
May 07 2015 13:01
no dice
ficeto
@ficeto
May 07 2015 13:17
something must be different for you to get such low speed
that is the speed I was getting before the change in ClientContext
have not had the issue sinse
we need to rewrite the argument parsing for POST requests
Ivan Grokhotkov
@igrr
May 07 2015 13:19
the low speed doesn't bother me as much as resets
ficeto
@ficeto
May 07 2015 13:19
and actually add the rest of the methods as well (PATCH, PUT...)
yes, but resets went away after the speed increased
make sure you have the line 172 edit in your app reources
my SD Card is more than 10 years old
it's actually a MiniSD with adapter from Dell PDA I had long time ago
I'm on the slow side
Ivan Grokhotkov
@igrr
May 07 2015 13:22
ah, just as i thought...
ficeto
@ficeto
May 07 2015 13:23
?
Ivan Grokhotkov
@igrr
May 07 2015 13:23
it's the UDP is interfering
when i disable mdns the problem goes away
ficeto
@ficeto
May 07 2015 13:23
but I have mDNS enabled and I'm loading through it
wget http://esp8266sd.local/oled.jpg
Ivan Grokhotkov
@igrr
May 07 2015 13:24
yes this is obviously an issue that doesn't always happen, and depends on network, sd card, and other factors which affect timing
so it might happen for me and not happen for you
but now i understand why UDP causes problems
ficeto
@ficeto
May 07 2015 13:25
I would not think that using Espressif's new mDNS api will be of any help
Ivan Grokhotkov
@igrr
May 07 2015 13:26
and I know why this happens for me and not for you: i'm on a very busy network with tons of mDNS packets flying around
ficeto
@ficeto
May 07 2015 13:26
you think? :)
what is that network
it's quite complicated here as well
Ivan Grokhotkov
@igrr
May 07 2015 13:27
our work LAN, many Apple devices and other stuff that shouts DNS-SD all over the place
so it doesn't take much to fill up the RX buffers with UDP packets while we are in server.handle()
and mDNS doesn't have the chance to receive these packets until we get into mdns handler
so it's a catch 22
let me think a bit
perhaps I need to let mDNS work async, directly through lwip
ficeto
@ficeto
May 07 2015 13:29
any chance we skip server.handle and mdns.update?
Ivan Grokhotkov
@igrr
May 07 2015 13:29
skip?
ficeto
@ficeto
May 07 2015 13:29
i have not looked at your network source, but if you have interrupt vector, maybe we can use that and not call from the loop?
Ivan Grokhotkov
@igrr
May 07 2015 13:30
no, that won't work — we rely on context switching for network blocking IO
and context switching only happens for the main task
not for the interrupts
ficeto
@ficeto
May 07 2015 13:31
I have a stack i wrote for AVR that does not use interrupts like this, but handles the important packets in it's RX loop
like DNS, DHCP, IGMP and ICMP
Ivan Grokhotkov
@igrr
May 07 2015 13:32
in our case that basically means "rewrite mDNS to work over lwip async API"
ficeto
@ficeto
May 07 2015 13:32
doing so let's me handle any incomming packet
yes
that is what it means
Ivan Grokhotkov
@igrr
May 07 2015 13:32
sure, I can do that
at least we now know why is this issue happening :)
good to learn something)
ficeto
@ficeto
May 07 2015 13:33
good that your network is so clogged
Ivan Grokhotkov
@igrr
May 07 2015 13:33
yep
i didn't get this issue at home
ficeto
@ficeto
May 07 2015 13:33
I'm in a multi-VLAN environment here
have a 10G optica cable coming in
and some servers buzzing
Ivan Grokhotkov
@igrr
May 07 2015 13:34
meh
i just ran wget 50 times in a loop
ficeto
@ficeto
May 07 2015 13:35
and?
Ivan Grokhotkov
@igrr
May 07 2015 13:35
and it failed 1 time...
ficeto
@ficeto
May 07 2015 13:35
:D:D:D
Ivan Grokhotkov
@igrr
May 07 2015 13:35
but
without LrxMacBlk stuff this time
just
:sent 1460

:tww

:twr

:ter -8

:tww

:twr !_pcb
someone decided to close the connection
btw
ficeto
@ficeto
May 07 2015 13:36
tcpdump can tell
Ivan Grokhotkov
@igrr
May 07 2015 13:36
when you call client.write() you need to check the return value
ficeto
@ficeto
May 07 2015 13:36
what does it return?
Ivan Grokhotkov
@igrr
May 07 2015 13:36
and if it is less than the requested size, bail out of the handler
it returns the number of bytes actually transfered
ficeto
@ficeto
May 07 2015 13:37
cool
Ivan Grokhotkov
@igrr
May 07 2015 13:37
otherwise we get into an infinite loop because _pcb == 0
and get killed by the watchdog
ficeto
@ficeto
May 07 2015 13:37
had this happen to me
Ivan Grokhotkov
@igrr
May 07 2015 13:38
:sent 1460

:tww

:twr

:sent 1460

:tww

:twr

:sent 1460

:tww

:twr

:sent 1460

:tww

:twr

:ter -8

:tww

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb

:twr !_pcb
it's this loop:
    while (dataFile.available() > WWW_BUF_SIZE){
      dataFile.read(obuf, WWW_BUF_SIZE);
      client.write(obuf, WWW_BUF_SIZE);
    }
has to be
    while (dataFile.available() > WWW_BUF_SIZE){
      dataFile.read(obuf, WWW_BUF_SIZE);
      if (client.write(obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE) {
        dataFile.close();
        return false;
      }
    }
ficeto
@ficeto
May 07 2015 13:43
yup :) was editing it as you were posting
should not return false
false will let the 404 handle run
and client is gone
Ivan Grokhotkov
@igrr
May 07 2015 13:43
ok
right
tried this with F_CPU=160MHz, speed almost the same
ficeto
@ficeto
May 07 2015 13:46
yeah... btw I'm running on 160MHz and fastest upload speed
so I try to be as cruel as I can
Ivan Grokhotkov
@igrr
May 07 2015 13:47
does it get hot?)
ficeto
@ficeto
May 07 2015 13:47
nah
but mine is encosed
Ivan Grokhotkov
@igrr
May 07 2015 13:49
will add a convenience method to WiFiWebServer:
send(Stream&, size)
so that users don't have to write this reading-writing loop in the sketch
so they will just have client.send(dataFile, dataFile.size());
ficeto
@ficeto
May 07 2015 13:50
or just dataFile
Ivan Grokhotkov
@igrr
May 07 2015 13:51
you can't derive size from Stream alone
ficeto
@ficeto
May 07 2015 13:51
the rest can be gotten from the name
Ivan Grokhotkov
@igrr
May 07 2015 13:51
and .size() is a method of File class
and we are not guaranteed that user will have SD.h included in the sketch
so may fail to compile
(if you aren't aware, SD library will not be included into the build by the IDE if it is not included from the main sketch file)
ficeto
@ficeto
May 07 2015 13:52
yeah I know
just did not think of client.send(dataFile, dataFile.size()); as client.send(&Stream, len);
ficeto
@ficeto
May 07 2015 13:57
running 100 downloads, one got caught by the check
127KB/s every time
will search for faster SD not larger than 4GB
ficeto
@ficeto
May 07 2015 14:22
my old card performs more stable than newer 8GB microSD
speed is constant with the old while jumping up and down with the new
trying a 222MB iso download :) failed at max 5% on the new card
9% on the old
ficeto
@ficeto
May 07 2015 14:38
yeah...no mDNS i'm up to 43% and going strong
ficeto
@ficeto
May 07 2015 14:56
ficeto@Hristos-Mac-mini-2 ~/Desktop/ESP8266/Arduino/build $ wget http://192.168.254.173/image.iso
--2015-05-07 17:25:34--  http://192.168.254.173/image.iso
Connecting to 192.168.254.173:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 232783872 (222M) [text/plain]
Saving to: ‘image.iso.1’

100%[===============================================================================================================================================================================================>] 232 783 872  127KB/s   in 29m 45s

2015-05-07 17:55:19 (127 KB/s) - ‘image.iso.1’ saved [232783872/232783872]
Ivan Grokhotkov
@igrr
May 07 2015 14:57
nice
onkelfunny
@onkelfunny
May 07 2015 16:00
@iggr here is my output from esptool-ck with -vvv (without the second C0)
esptool v0.4.3 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to ck
    setting baudrate from 115200 to 115200
    setting port from /dev/tty.usbserial to /dev/tty.wchusbserial1410
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    stat /var/folders/_n/sy8p0xjs0dlffvp139xmn9qm0000gn/T/build5591577188314539311.tmp/clock.cpp_00000.bin success
opening port /dev/tty.wchusbserial1410 at 115200
    tcgetattr
    tcsetattr
    serial open
opening bootloader
resetting board
trying to connect
    setting character timeout 0
    done
    setting character timeout 1
    done
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
        espcomm_send_command: didn't receive command response
trying to connect
    setting character timeout 0
    done
    setting character timeout 1
    done
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_send_command: receiving 2 bytes of data
        espcomm_send_command: received 2 bytes: 
        0x00 
        0x00 
        espcomm_send_command: response 0x20120707
    espcomm_open
Uploading 34000 bytes from /var/folders/_n/sy8p0xjs0dlffvp139xmn9qm0000gn/T/build5591577188314539311.tmp/clock.cpp_00000.bin to flash at 0x00000000
    erasing flash
    size: 0084d0 address: 000000
    first_sector_index: 0
    total_sector_count: 9
    head_sector_count: 9
    adjusted_sector_count: 5
    adjusted_size: 005000
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    setting timeout 10000
    setting character timeout 100
    done
    setting timeout 1
    setting character timeout 1
    done
warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
closing bootloader
onkelfunny
@onkelfunny
May 07 2015 16:06
i add a espcomm_delay_ms(5); before serialport_send_C0 and everything works good
Ivan Grokhotkov
@igrr
May 07 2015 16:07
what if you add it before drain()?
onkelfunny
@onkelfunny
May 07 2015 16:07
works as well
i try to fix the problem with the espcomm_start_app function and make a pull-request if you like
Ivan Grokhotkov
@igrr
May 07 2015 16:10
can you add some debug output to espcomm_start_app function and see if it is executed at all?
onkelfunny
@onkelfunny
May 07 2015 16:11
no it is not executed... the var file_uploaded is 0 ... i think this is a timing problem as well
Ivan Grokhotkov
@igrr
May 07 2015 16:12
yes, might be...
Markus
@Links2004
May 07 2015 16:32
SPI.beginTransaction is broken. looks like settings._clock need to be translated to the register settings, will fix it.
Ivan Grokhotkov
@igrr
May 07 2015 16:39
@ficeto rewrote mDNS so it is now fully async
no need for mdns.update() in the main loop now :)
ficeto
@ficeto
May 07 2015 16:51
great! I'm onto proper POST/GET extraction
onkelfunny
@onkelfunny
May 07 2015 16:51

ok ... i found the issue :) i have a breadboard cable interruption :(

with espcomm_delay_ms(5); before the drain(); everything works fine

ficeto
@ficeto
May 07 2015 16:52
wanna have an on-board file editor.manager for the SD
Ivan Grokhotkov
@igrr
May 07 2015 16:52
like a console running on Arduino?
damn I forgot to check why HardwareSerial doesn't read
ficeto
@ficeto
May 07 2015 16:54
like a proper REST communication
at the moment only plaintext POSTs are supported
and only GET and POST are supported
things like that
so I can not upload or post a form
and then if it's post, the get arguments are not read
then once rest is ON, it's easy toexport an APIto JS
so small web apps that talk to the ESP can be written in JavaScript
Ivan Grokhotkov
@igrr
May 07 2015 16:57
why of course you can post a form
ficeto
@ficeto
May 07 2015 16:57
no you can not
forms use bondary
and that is something you do not even check for
content of actual form is not the same as plaintext post
Header Name: Content-Type : multipart/form-data; boundary=----WebKitFormBoundaryMJPM9B09uOmxnQYw
then each item has content type
have to check if it's a file
the file probably will be multy-packet
Ivan Grokhotkov
@igrr
May 07 2015 16:59
just make sure your form uses application/x-www-form-urlencoded
if you are not going to handle files, you're good
ficeto
@ficeto
May 07 2015 16:59
i do not even have a form
even posting a plaintext file is a problem
you separate on '&'
and if it's in the file....
this way any post can be handled
and onFileUpload() can be added
Ivan Grokhotkov
@igrr
May 07 2015 17:02
mm okay, i agree. my remark was just to "so I can not upload or post a form" — you can post a form, just not a form which contains files :)
I even had a sample sketch with a form somewhere...
ficeto
@ficeto
May 07 2015 17:02
yes but since there is a large storage available now.. :)
Ivan Grokhotkov
@igrr
May 07 2015 17:03
sure, go ahead :)
ficeto
@ficeto
May 07 2015 17:03
I was thinking maybe to have an option for lua interpreter and have a CGI for lua files in future...
like NodeMCU but better
Markus
@Links2004
May 07 2015 18:51
ok SPI is now working #199 but the way of setting CPOL is not known for the ESP8266
onkelfunny
@onkelfunny
May 07 2015 19:36
is it useful to set the BLOCKSIZE_FLASH to a higher value?
Test:
BLOCKSIZE_FLASH = 0x0400 => Upload-Time: 27 Seconds
BLOCKSIZE_FLASH = 0x0800 => Upload-Time: 25 Seconds
BLOCKSIZE_FLASH = 0x1800 => Upload-Time: 22 Seconds
Ivan Grokhotkov
@igrr
May 07 2015 20:18
@Links2004 regarding your changes...
Markus
@Links2004
May 07 2015 20:18
yes?
Ivan Grokhotkov
@igrr
May 07 2015 20:18
i think SPISettings.clock is a clock divider, not frequency
so when you do setFrequency(settings._clock); it doesn't make sense to me
with AVR Arduinos you pass a clock divider macro into SPISettings
like SPI_CLOCK_DIV1M
so my suggestion is to keep the behaviour compatible
Markus
@Links2004
May 07 2015 20:21
i have 2 libarys that add a freqency there no define (ESP8266 get fatal error in ths cases)
arduino says only "speed: the speed of the communication" http://www.arduino.cc/en/Reference/SPISettings
Ivan Grokhotkov
@igrr
May 07 2015 20:23
if the libraries do it, then okay, i trust they are correct:)
Markus
@Links2004
May 07 2015 20:24
i think so.
the defines are manly for the setClockDivider function
ficeto
@ficeto
May 07 2015 20:26
the other issue is that calculation is not that easy
I have to see where I had the function for it and maybe implement that instead of hardcoded values
Ivan Grokhotkov
@igrr
May 07 2015 20:27
also the last change makes SD card slow:
#ifdef ESP8266
#include "SPI.h"
uint32_t const SPI_FULL_SPEED = SPI_CLOCK_DIV2;
uint32_t const SPI_HALF_SPEED = SPI_CLOCK_DIV4;
uint32_t const SPI_QUARTER_SPEED = SPI_CLOCK_DIV8;
#else
Markus
@Links2004
May 07 2015 20:27
yes i have a basic idee how it is working but i miss the meaning of to parts of the register (N , H, L)
ficeto
@ficeto
May 07 2015 20:28
that is not that slow
it's compatible
it runs at 2Mbps or 4Mbps
so its a freqency for the SPISettings
ficeto
@ficeto
May 07 2015 20:30
I actually calcuated those values in php
:D it's my calculator
Markus
@Links2004
May 07 2015 20:31
ok why the 0x000fffc0 for 16Mhz is so different from all other?
that's regarding N, H, L
Markus
@Links2004
May 07 2015 20:33
with this info i can get rip of the static table :)
ficeto
@ficeto
May 07 2015 20:44
do not be in such hurry
at least comment them out
I did not come out with this numbers out of my ass
I did spend quite some time exploring the wen and the docs to figure them out
when I said that I used php, it was because I did many crosschecks and whatnot I can not remember unfortunatelly
and there seem to be nothing left
Markus
@Links2004
May 07 2015 20:47
i noticed that this value has a big different and want to know the reason for it. I dont want to say there is a mistake.
ficeto
@ficeto
May 07 2015 20:47
i can't remember.... :( had to do with something
there are many values that can actually clock to the same frequency
Markus
@Links2004
May 07 2015 20:48
no problem.
ficeto
@ficeto
May 07 2015 20:48
so there was something involved
Markus
@Links2004
May 07 2015 20:49
my idee is to do the calculation from freqency to register value in a function direct on the ESP8266.
ficeto
@ficeto
May 07 2015 20:54
so looking again at the registers and my values
it seems that the point was to get the lowest H and L values (not 0) and such devider that clocks to the required frequency
switching the D was somehow different for the hardware or something...
 SPI clock = CPU clock / 10 / 4
HIGHT level = (CPU clock / 10 / 2) ^ -1,
LOW level = (CPU clock / 10 / 2) ^ -1
Markus
@Links2004
May 07 2015 22:50
Links2004/Arduino@c8510ed working. now its time for some sleep.