Nice. Just ran "...\libraries\NativeEthernet\examples\UdpNtpClien t\UdpNtpClient.ino" and it works! { with my Beta T-4.1 and OSH type PJRC magjack - using a 30cm/12" ribbon }
And it builds from editor with TSET CMDLine batch calling Arduino build without any issue.
I printed the IP and I can ping it! For some reason Sometimes I have to repower the Teensy after upload? It hits setup() and prints - but nothing after with code edit below. Is that from interrupting a packet in process or something? Reset the ethernet chip in setup()? This showed before adding teensyMAC(mac);
Code:
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Ethernet connect ... \n");
teensyMAC(mac);
if (Ethernet.begin(mac) != 0) {
IPAddress myIP = Ethernet.localIP();
Serial.printf( "IP Address %u.%u.%u.%u\n", myIP[0], myIP[1], myIP[2], myIP[3] );
}
else { // start Ethernet and UDP
Serial.println("\nFailed to configure Ethernet using DHCP");
I see it has a hardcoded MAC - need to find Teensy MAC. >> https://forum.pjrc.com/threads/57595...l=1#post221833
That code - called as above : teensyMAC(mac);
Uses this function with an #ifdef edited to compile from link:
Code:
void teensyMAC(uint8_t *mac) {
static char teensyMac[23];
#if defined(HW_OCOTP_MAC1) && defined(HW_OCOTP_MAC0)
Serial.println("using HW_OCOTP_MAC* - see https://forum.pjrc.com/threads/57595-Serial-amp-MAC-Address-Teensy-4-0");
for(uint8_t by=0; by<2; by++) mac[by]=(HW_OCOTP_MAC1 >> ((1-by)*8)) & 0xFF;
for(uint8_t by=0; by<4; by++) mac[by+2]=(HW_OCOTP_MAC0 >> ((3-by)*8)) & 0xFF;
#define MAC_OK
#else
mac[0] = 0x04;
mac[1] = 0xE9;
mac[2] = 0xE5;
uint32_t SN=0;
__disable_irq();
#if defined(HAS_KINETIS_FLASH_FTFA) || defined(HAS_KINETIS_FLASH_FTFL)
Serial.println("using FTFL_FSTAT_FTFA - vis teensyID.h - see https://github.com/sstaub/TeensyID/blob/master/TeensyID.h");
FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
FTFL_FCCOB0 = 0x41;
FTFL_FCCOB1 = 15;
FTFL_FSTAT = FTFL_FSTAT_CCIF;
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
SN = *(uint32_t *)&FTFL_FCCOB7;
#define MAC_OK
#elif defined(HAS_KINETIS_FLASH_FTFE)
Serial.println("using FTFL_FSTAT_FTFE - vis teensyID.h - see https://github.com/sstaub/TeensyID/blob/master/TeensyID.h");
kinetis_hsrun_disable();
FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
*(uint32_t *)&FTFL_FCCOB3 = 0x41070000;
FTFL_FSTAT = FTFL_FSTAT_CCIF;
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
SN = *(uint32_t *)&FTFL_FCCOBB;
kinetis_hsrun_enable();
#define MAC_OK
#endif
__enable_irq();
for(uint8_t by=0; by<3; by++) mac[by+3]=(SN >> ((2-by)*8)) & 0xFF;
#endif
#ifdef MAC_OK
sprintf(teensyMac, "MAC: %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
Serial.println(teensyMac);
#else
Serial.println("ERROR: could not get MAC");
#endif
}
An idea of code size now 71KB - might consider moving some startup or rare code as run from FLASHMEM?:
Code:
FlexRAM section ITCM+DTCM = 512 KB
Config : aaaaaabf
ITCM : 71024 B (72.25% of 96 KB)
DTCM : 25280 B ( 5.93% of 416 KB)
Available for Stack: 400704
OCRAM: 512KB
DMAMEM: 110784 B (21.13% of 512 KB)
Available for Heap: 413504 B (78.87% of 512 KB)
Flash: 83344 B ( 1.03% of 7936 KB)