I'm back Chris,
The bootloader ended up being ok. The TCPSocket_HelloWorld demo program works. So what could be different?
I looked at main.cpp of TCPSocket_HelloWorld and saw a couple of things that were different.
1. EthernetInterface eth; is called inside of int main() {...} instead at the top where the hardware declarations are made.
2. I use a lot of serial communications to the Host PC, since I have a CLI user interface. So I use Serial or RawSerial. This is where I found an issue. In the HelloWorld example, I added 4 lines:
#include "mbed.h"
#include "EthernetInterface.h"
RawSerial pc(USBTX, USBRX); //<<added line
int main() {
pc.baud(230400); //<<added line
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
printf("IP Address-a is %s\n", eth.getIPAddress());
printf("IP Address-b is %s\n", eth.getIPAddress()); //<<added line
printf("IP Address-c is %s\n", eth.getIPAddress()); //<<added line
TCPSocketConnection sock;
sock.connect("mbed.org", 80);
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[300];
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
buffer[ret] = '\0';
printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
eth.disconnect();
while(1) {}
}
So far so good. The IP Address gets printed out 3 times and serial runs at 230400 baud
Now, if I change any or all of the printf statements to pc.printf, nothing works. The K64F is hung.
#include "mbed.h"
#include "EthernetInterface.h"
RawSerial pc(USBTX, USBRX); //<<added line
int main() {
pc.baud(230400); //<<added line
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
printf("IP Address-a is %s\n", eth.getIPAddress());
pc.printf("IP Address-b is %s\n", eth.getIPAddress()); //<<added line and changed to pc.printf
printf("IP Address-c is %s\n", eth.getIPAddress()); //<<added line
TCPSocketConnection sock;
sock.connect("mbed.org", 80);
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[300];
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
buffer[ret] = '\0';
printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
eth.disconnect();
while(1) {}
}
Only made one additional change, and now it is dead. It doesn't matter which printf statement you change, it is frozen. It also doesn't matter whether you are using Serial or RawSerial.
There is a major conflict with the K64F, EthernetInterface and Serial. This all works on the mbed1768
...kevin
Can anyone please confirm for me that the recently updated EthernetInterface library works on the FRDM-K64F platform?
I am presently struggling to get the TCPSocket_Helloworld example application to run. It hangs when init() is called.
Thanks, Cameron