├── README ├── src ├── validate.h ├── tftp.c ├── main.h ├── debug.h ├── validate.c ├── tftp.h ├── net.h ├── debug.c ├── .project ├── main.c ├── net.c ├── Makefile ├── Readme.txt ├── w5100_reg.h └── .cproject ├── .hgignore ├── .hgtags └── package ├── hardware └── arduino-tftpboot │ ├── boards.txt │ └── bootloaders │ └── arduino-tftpboot │ └── arduino-tftpboot-bootloader-m328.hex └── libraries └── ArduinoTFTP └── examples ├── BlinkUploadTest └── BlinkUploadTest.ino ├── WriteNetworkSettings └── WriteNetworkSettings.ino ├── WebServerWithSettings └── WebServerWithSettings.ino └── WebServerWithReset └── WebServerWithReset.ino /README: -------------------------------------------------------------------------------- 1 | A nicely packaged TFTP bootloader. 2 | 3 | -------------------------------------------------------------------------------- /src/validate.h: -------------------------------------------------------------------------------- 1 | uint8_t validImage(uint8_t *base); 2 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | # use glob syntax. 2 | syntax: glob 3 | 4 | *.o 5 | -------------------------------------------------------------------------------- /src/tftp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freetronics/arduino-tftpboot/HEAD/src/tftp.c -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | 525aad5c3a399e7e649ed83519795f3109073b08 ARDUINO-TFTPBOOT-BETA-001 2 | 953ad867ed9368a7c891644197a34737f0c35ec7 ARDUINO-TFTPBOOT-BETA-002 3 | eeefafbd213bc80b09ebbad30a83d0920eb393c7 ARDUINO-TFTPBOOT-BETA-003 4 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | //Offset of LED PIN in port (PORTB pin 1 for Arduino Eth) 4 | #define LED_PIN 1 5 | 6 | void updateLed(); 7 | uint8_t timedOut(); 8 | void ResetTick(); 9 | -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define DEBUG 5 | 6 | #ifdef DEBUG 7 | #define TRACE(msg) trace(msg) 8 | void trace(char* msg); 9 | void tracenum(uint16_t num); 10 | #else 11 | #define TRACE(msg) trace(msg) 12 | void trace(char* msg); 13 | void tracenum(uint16_t num); 14 | #endif 15 | void debugInit(); 16 | -------------------------------------------------------------------------------- /src/validate.c: -------------------------------------------------------------------------------- 1 | /* Validate first sector is a genuine image */ 2 | #include 3 | 4 | uint8_t validImage(uint8_t *base) { 5 | /* Check that a jump table is present in the first flash sector */ 6 | uint8_t i; 7 | for (i=0; i<0x34; i+=4) { 8 | // For each vector, check it is of the form: 9 | // 0x0C 0x94 0xWX 0xYZ ; JMP 0xWXYZ 10 | // 11 | if (base[i] != 0x0C) return 0; 12 | if (base[i+1] != 0x94) return 0; 13 | } 14 | return 1; 15 | } 16 | -------------------------------------------------------------------------------- /src/tftp.h: -------------------------------------------------------------------------------- 1 | // TFTP Opcode values from RFC 1350 2 | // 3 | #define TFTP_OPCODE_RRQ 1 4 | #define TFTP_OPCODE_WRQ 2 5 | #define TFTP_OPCODE_DATA 3 6 | #define TFTP_OPCODE_ACK 4 7 | #define TFTP_OPCODE_ERROR 5 8 | 9 | // TFTP Error codes from RFC 1350 10 | // 11 | #define TFTP_ERROR_UNDEF 0 12 | #define TFTP_ERROR_NOT_FOUND 1 13 | #define TFTP_ERROR_ACCESS 2 14 | #define TFTP_ERROR_FULL 3 15 | #define TFTP_ERROR_ILLEGAL_OP 4 16 | #define TFTP_ERROR_UNKNOWN_XFER 4 17 | #define TFTP_ERROR_EXISTS 6 18 | #define TFTP_ERROR_NO_SUCH_USER 7 19 | 20 | 21 | #define TFTP_PORT 69 22 | 23 | void tftpInit(); 24 | uint8_t tftpPoll(); 25 | -------------------------------------------------------------------------------- /package/hardware/arduino-tftpboot/boards.txt: -------------------------------------------------------------------------------- 1 | arduino-tftpboot.name = TFTP Bootloader ATmega328 (No Upload) 2 | 3 | arduino-tftpboot.build.mcu = atmega328p 4 | arduino-tftpboot.build.f_cpu = 16000000L 5 | arduino-tftpboot.build.core = arduino:arduino 6 | arduino-tftpboot.build.variant = arduino:standard 7 | 8 | arduino-tftpboot.upload.maximum_size = 28672 9 | 10 | arduino-tftpboot.bootloader.low_fuses=0xFF 11 | arduino-tftpboot.bootloader.high_fuses=0xD0 12 | arduino-tftpboot.bootloader.extended_fuses=0x05 13 | arduino-tftpboot.bootloader.path=arduino-tftpboot 14 | arduino-tftpboot.bootloader.file=arduino-tftpboot-bootloader-m328.hex 15 | #arduino-tftpboot.bootloader.unlock_bits=0x3F 16 | #arduino-tftpboot.bootloader.lock_bits=0x0F 17 | 18 | -------------------------------------------------------------------------------- /package/libraries/ArduinoTFTP/examples/BlinkUploadTest/BlinkUploadTest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | This example code is in the public domain. 6 | */ 7 | 8 | // Pin 13 has an LED connected on most Arduino boards, 9 | // but pin 13 is also used by the network chip so we need to use 10 | // another pin to which we will attach an LED: 11 | int led = 9; 12 | 13 | // the setup routine runs once when you press reset: 14 | void setup() { 15 | // initialize the digital pin as an output. 16 | pinMode(led, OUTPUT); 17 | } 18 | 19 | // the loop routine runs over and over again forever: 20 | void loop() { 21 | digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 22 | delay(1000); // wait for a second 23 | digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 24 | delay(1000); // wait for a second 25 | } 26 | -------------------------------------------------------------------------------- /src/net.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | //Offset of pin INSIDE PORTB!! (not absolute) 5 | #define SCK_PIN 5 //PB5 6 | #define MISO_PIN 4 //PB4 7 | #define MOSI_PIN 3 //PB3 8 | #define SS_PIN 2 //PB2 9 | 10 | #define EEPROM_SIG_1 ((uint8_t*)0) 11 | #define EEPROM_SIG_2 ((uint8_t*)1) 12 | #define EEPROM_IMG_STAT ((uint8_t*)2) 13 | #define EEPROM_DATA ((uint8_t*)3) 14 | #define EEPROM_SIG_1_VALUE (0x55) 15 | #define EEPROM_SIG_2_VALUE (0xAA) 16 | #define EEPROM_IMG_OK_VALUE (0xBB) 17 | #define EEPROM_IMG_BAD_VALUE (0xFF) 18 | 19 | #define EEPROM_GATEWAY ((uint8_t*)2) 20 | #define EEPROM_MAC ((uint8_t*)6) 21 | #define EEPROM_IP ((uint8_t*)12) 22 | 23 | 24 | void netWriteReg(uint16_t address, uint8_t value); 25 | uint8_t netReadReg(uint16_t address); 26 | uint16_t netReadWord(uint16_t address); 27 | void netWriteWord(uint16_t address, uint16_t value); 28 | 29 | void netInit(); 30 | 31 | #define SS_LOW() PORTB &= ~_BV(SS_PIN) 32 | #define SS_HIGH() PORTB |= _BV(SS_PIN) 33 | 34 | #define SPI_WRITE (0xF0) 35 | #define SPI_READ (0x0F) 36 | -------------------------------------------------------------------------------- /src/debug.c: -------------------------------------------------------------------------------- 1 | /* Name: debug.c 2 | * Author: . 3 | * Copyright: Arduino 4 | * License: GPL http://www.gnu.org/licenses/gpl-2.0.html 5 | * Project: eboot 6 | * Function: Utility routines for bootloader debugging 7 | * Version: 0.1 tftp / flashing functional 8 | */ 9 | 10 | #include "debug.h" 11 | 12 | #ifdef DEBUG 13 | void debugInit() { 14 | UCSR0A = 0x22; 15 | UCSR0B = 0x08; 16 | UBRR0 = 16; // 115k2 baud 8N1 17 | DDRD = 0x92; 18 | } 19 | void trace(char* msg) { 20 | uint8_t c; 21 | while ((c = *msg++)) { 22 | UDR0 = c; 23 | while (!(UCSR0A & _BV(UDRE0))); 24 | } 25 | 26 | } 27 | void putchar(uint8_t c) { 28 | UDR0=c; 29 | while(!(UCSR0A & _BV(UDRE0))); 30 | } 31 | void puthex(uint8_t c) { 32 | c &= 0xf; 33 | if (c>9) c+=7; 34 | UDR0=c+'0'; 35 | while(!(UCSR0A & _BV(UDRE0))); 36 | } 37 | void tracenum(uint16_t num) { 38 | putchar('0'); 39 | putchar('x'); 40 | puthex(num>>12); 41 | puthex(num>>8); 42 | puthex(num>>4); 43 | puthex(num); 44 | } 45 | #else 46 | void debugInit() { 47 | ; 48 | } 49 | void trace(char* msg) { 50 | ; 51 | } 52 | void tracenum(uint16_t num) { 53 | ; 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /package/libraries/ArduinoTFTP/examples/WriteNetworkSettings/WriteNetworkSettings.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | WriteNetworkSettings 4 | 5 | This sketch writes a set of network configuration settings to EEPROM 6 | in such a way that both the `arduino-tftpboot` bootloader & a sketch 7 | can read them back later and share the same settings. 8 | 9 | As commented below these are the settings available for modification: 10 | 11 | * Gateway IP address 12 | * Subnet mask 13 | * MAC address 14 | * Arduino device IP address 15 | 16 | Once the settings have been written to EEPROM, an LED on pin 9 17 | (if connected) will flash rapdily. 18 | 19 | 20 | The default settings used by the bootloader: 21 | 22 | 192,168,1,254, // Gateway IP address 23 | 255,255,255,0, // Subnet mask 24 | 0x12,0x34,0x45,0x78,0x9A,0xBC, // MAC address 25 | 192,168,1,1, // Arduino device IP address 26 | 27 | 28 | Settings suitable for link-local use: 29 | 30 | 169,254,1,1, // Gateway IP address 31 | 255,255,0,0, // Subnet mask 32 | 0x12,0x34,0x45,0x78,0x9A,0xBC, // MAC address 33 | 169,254,254,169, // Arduino device IP address 34 | 35 | */ 36 | 37 | #include 38 | 39 | // TODO: Allow settings to be specified as individual variables. 40 | // TODO: Wrap this all in a library. 41 | 42 | uint8_t NetworkSettings[] = { 43 | 0x55, 0xAA, // Signature 44 | 0xFF, // Image Status (bad) 45 | 46 | // EEPROM block starts here 47 | 10,1,1,1, // Gateway IP address 48 | 255,0,0,0, // Subnet mask 49 | 0x12,0x34,0x45,0x78,0x9A,0xBC, // MAC address 50 | 10,1,1,20, // Arduino device IP address 51 | // EEPROM block ends here 52 | }; 53 | 54 | 55 | void setup() { 56 | for (int address = 0; address < sizeof(NetworkSettings)/sizeof(uint8_t); address++) { 57 | EEPROM.write(address, NetworkSettings[address]); 58 | } 59 | 60 | pinMode(9, OUTPUT); 61 | } 62 | 63 | 64 | void loop() { 65 | // Blink an LED on pin 9 rapidly if present 66 | // to indicate the settings have been stored in EEPROM. 67 | digitalWrite(9, HIGH); 68 | delay(100); 69 | digitalWrite(9, LOW); 70 | delay(100); 71 | } 72 | -------------------------------------------------------------------------------- /src/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TFTP BootLoader 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?name? 14 | 15 | 16 | 17 | org.eclipse.cdt.make.core.append_environment 18 | true 19 | 20 | 21 | org.eclipse.cdt.make.core.autoBuildTarget 22 | clean all 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | make 31 | 32 | 33 | org.eclipse.cdt.make.core.buildLocation 34 | C:\Users\dperotto\Desktop\Arduino\Eclipse\Workspaces\TFTPBootLoader 35 | 36 | 37 | org.eclipse.cdt.make.core.cleanBuildTarget 38 | clean 39 | 40 | 41 | org.eclipse.cdt.make.core.contents 42 | org.eclipse.cdt.make.core.activeConfigSettings 43 | 44 | 45 | org.eclipse.cdt.make.core.enableAutoBuild 46 | false 47 | 48 | 49 | org.eclipse.cdt.make.core.enableCleanBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.enableFullBuild 54 | true 55 | 56 | 57 | org.eclipse.cdt.make.core.fullBuildTarget 58 | clean all 59 | 60 | 61 | org.eclipse.cdt.make.core.stopOnError 62 | true 63 | 64 | 65 | org.eclipse.cdt.make.core.useDefaultBuildCmd 66 | true 67 | 68 | 69 | 70 | 71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 72 | full,incremental, 73 | 74 | 75 | 76 | 77 | 78 | org.eclipse.cdt.core.cnature 79 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 80 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 81 | de.innot.avreclipse.core.avrnature 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* Name: main.c 2 | * Author: Denis PEROTTO, from work published by Arduino 3 | * Copyright: Arduino 4 | * License: GPL http://www.gnu.org/licenses/gpl-2.0.html 5 | * Project: eboot 6 | * Function: Bootloader core 7 | * Version: 0.2 tftp functional on 328P 8 | */ 9 | 10 | 11 | #include "main.h" 12 | #include "net.h" 13 | #include "tftp.h" 14 | #include 15 | #include "debug.h" 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | 22 | uint16_t lastTimer1; 23 | uint16_t tick = 0; 24 | 25 | 26 | #define TIMEOUT 19 //(5 seconds) 27 | #define VERSION "0.2" 28 | int main(void) __attribute__ ((naked)) __attribute__ ((section (".init9"))); 29 | 30 | 31 | // Function 32 | void (*app_start)(void) = 0x0000; 33 | 34 | void updateLed() { 35 | 36 | //config of timer1 37 | uint16_t nextTimer1 = TCNT1; 38 | 39 | 40 | 41 | //if timer has started a new cycle increment tick count 42 | if (nextTimer1 < lastTimer1){ 43 | tick++; 44 | if(PORTB & _BV(LED_PIN)){ 45 | PORTB &= ~_BV(LED_PIN); //turn off LED 46 | } 47 | else{ 48 | PORTB |= _BV(LED_PIN); //_BV(LED_PIN)= byte with LED_PIN set, turns up LED 49 | } 50 | } 51 | 52 | 53 | //Store timer value for next call of updateled 54 | lastTimer1 = nextTimer1; 55 | 56 | } 57 | 58 | uint8_t timedOut() { 59 | 60 | //Called from TFTP poll 61 | if (pgm_read_word(0x0000) == 0xFFFF){ 62 | // Never timeout if there is no code in Flash or if flash is corrupted 63 | return 0; 64 | } 65 | if (tick > TIMEOUT){ 66 | return 1; 67 | } 68 | return 0; 69 | } 70 | void ResetTick(){ 71 | tick=0; 72 | } 73 | 74 | int main(void) { 75 | 76 | MCUSR = 0; 77 | wdt_disable(); 78 | 79 | debugInit(); 80 | _delay_ms(250); //be sure that W5100 has started (ATM starts in 65ms, W5100 150-200ms) 81 | // Set up outputs to communicate with W5100 chip 82 | DDRB = _BV(LED_PIN) | _BV(SCK_PIN) | _BV(MOSI_PIN) | _BV(SS_PIN); //set pins as output 83 | PORTB = _BV(SCK_PIN) | _BV(MISO_PIN) | _BV(MOSI_PIN) | _BV(SS_PIN); //set pins UP 84 | 85 | /* 86 | Prescaler=0, ClkIO Period = 62,5ns 87 | 88 | TCCR1B values: 89 | 0x01 -> ClkIO/1 -> 62,5ns period, 4ms max 90 | 0x02 -> ClkIO/8 -> 500ns period, 32ms max 91 | 0X03 -> ClkIO/64 -> 4us period, 256ms max 92 | 0x04 -> ClkIO/256 -> 16us period, 1024ms max 93 | 0x05 -> ClkIO/1024 -> 64us period, 4096ms max 94 | */ 95 | 96 | TCCR1B = 0x03; 97 | SPSR = (1< 14 | #include "debug.h" 15 | #include "w5100_reg.h" 16 | 17 | #define REGISTER_BLOCK_SIZE 28 18 | //#define REGISTER_BLOCK_SIZE UINT8_C(28) 19 | //SIG1(0x55), SIG2(0XAA), GWIP0, GWIP1, GWIP2, GWIP3, MASK0, MASK1, MASK2, MASK3, MAC0, MAC1, MAC2, MAC3, MAC4, MAC5, IP0, IP1, IP2, IP3 20 | uint8_t registerBuffer[REGISTER_BLOCK_SIZE] = { 21 | 0x80, // MR Mode - reset device 22 | 23 | // EEPROM block starts here 24 | 192,168,1,254, // GWR Gateway IP Address Register 25 | 255,255,255,0, // SUBR Subnet Mask Register 26 | 0x12,0x34,0x45,0x78,0x9A,0xBC, // SHAR Source Hardware Address Register 27 | 192,168,1,1, // SIPR Source IP Address Register 28 | // EEPROM block ends here 29 | 30 | 0,0, // Reserved locations 31 | 0, // IR Interrupt Register 32 | 0, // IMR Interrupt Mask Register 33 | 0x07,0xd0, // RTR Retry Time-value Register 34 | 0x80, // RCR Retry Count Register 35 | 0x55, // RMSR Rx Memory Size Register, 2K per socket 36 | 0x55 // TMSR Tx Memory Size Register, 2K per socket 37 | }; 38 | 39 | void netWriteReg(uint16_t address, uint8_t value) { 40 | 41 | /*trace("NetWriteReg:"); 42 | tracenum(address); 43 | putchar(','); 44 | tracenum(value); 45 | trace("\r\n"); 46 | */ 47 | //Send uint8_t to Eth controler 48 | SPCR = _BV(SPE) | _BV(MSTR); //Set SPI as master 49 | SS_LOW(); 50 | SPDR = SPI_WRITE; while(!(SPSR & _BV(SPIF))); 51 | SPDR = address >> 8; while(!(SPSR & _BV(SPIF))); 52 | SPDR = address & 0xff; while(!(SPSR & _BV(SPIF))); 53 | SPDR = value; while(!(SPSR & _BV(SPIF))); 54 | SS_HIGH(); 55 | SPCR = 0; //turn off SPI 56 | } 57 | 58 | uint8_t netReadReg(uint16_t address) { 59 | //Read uint8_t from Eth controler 60 | uint8_t returnValue; 61 | SPCR = _BV(SPE) | _BV(MSTR); 62 | SS_LOW(); 63 | SPDR = SPI_READ; while(!(SPSR & _BV(SPIF))); 64 | SPDR = address >> 8; while(!(SPSR & _BV(SPIF))); 65 | SPDR = address & 0xff; while(!(SPSR & _BV(SPIF))); 66 | SPDR = 0; while(!(SPSR & _BV(SPIF))); 67 | SS_HIGH(); 68 | returnValue = SPDR; 69 | SPCR = 0; 70 | return returnValue; 71 | } 72 | uint16_t netReadWord(uint16_t address) { 73 | //Read uint16_t from Eth controler 74 | return (netReadReg(address++)<<8) | netReadReg(address); 75 | } 76 | void netWriteWord(uint16_t address, uint16_t value) { 77 | //Write uint16_t to Eth controler 78 | netWriteReg(address++, value >> 8); 79 | netWriteReg(address, value & 0xff); 80 | } 81 | 82 | void netInit() { 83 | //Init Wiznet Chip 84 | // Set up SPI 85 | 86 | // Pull in altered presets if available from AVR EEPROM (if signature bytes are set) 87 | if ((eeprom_read_byte(EEPROM_SIG_1) == EEPROM_SIG_1_VALUE) && (eeprom_read_byte(EEPROM_SIG_2) == EEPROM_SIG_2_VALUE)) { 88 | uint8_t i=0; 89 | trace("Using EEPROM settings\r\n"); 90 | for (;i<18; i++) registerBuffer[i+1] = eeprom_read_byte(EEPROM_DATA+i); //copy eeprom to registerBuffer, starting at adress 2 91 | } 92 | else { 93 | trace("Using Default Settings\r\n"); 94 | ; 95 | } 96 | 97 | // Configure Wiznet chip 98 | uint8_t i=0; 99 | for (i=0; i 19 | #include 20 | 21 | #include 22 | 23 | // Enter a MAC address for your controller below--it must match the one the bootloader uses. 24 | byte mac[] = {0x12,0x34,0x45,0x78,0x9A,0xBC}; 25 | 26 | // The IP address will be read from EEPROM or be set to a value default in `configureNetwork()`. 27 | IPAddress ip; 28 | 29 | // Initialize the Ethernet server library 30 | // with the IP address and port you want to use 31 | // (port 80 is default for HTTP): 32 | EthernetServer server(80); 33 | 34 | void configureNetwork() { 35 | // Reads IP address from EEPROM as stored by `WriteNetworkSettings` sketch. 36 | 37 | #define EEPROM_SIG_1_VALUE 0x55 38 | #define EEPROM_SIG_2_VALUE 0xAA 39 | 40 | #define EEPROM_SIG_1_OFFSET 0 41 | #define EEPROM_SIG_2_OFFSET 1 42 | 43 | #define EEPROM_GATEWAY_OFFSET 3 44 | #define EEPROM_MASK_OFFSET 7 45 | #define EEPROM_MAC_OFFSET 11 46 | #define EEPROM_IP_OFFSET 17 47 | 48 | if ((EEPROM.read(EEPROM_SIG_1_OFFSET) == EEPROM_SIG_1_VALUE) 49 | && (EEPROM.read(EEPROM_SIG_2_OFFSET) == EEPROM_SIG_2_VALUE)) { 50 | ip = IPAddress(EEPROM.read(EEPROM_IP_OFFSET), 51 | EEPROM.read(EEPROM_IP_OFFSET+1), 52 | EEPROM.read(EEPROM_IP_OFFSET+2), 53 | EEPROM.read(EEPROM_IP_OFFSET+3)); 54 | } else { 55 | ip = IPAddress(192,168,1,1); 56 | }; 57 | 58 | // TODO: Handle MAC, mask & gateway also. 59 | } 60 | 61 | void setup() { 62 | // Open serial communications and wait for port to open: 63 | Serial.begin(9600); 64 | while (!Serial) { 65 | ; // wait for serial port to connect. Needed for Leonardo only 66 | } 67 | 68 | configureNetwork(); 69 | 70 | // start the Ethernet connection and the server: 71 | Ethernet.begin(mac, ip); 72 | server.begin(); 73 | Serial.print("server is at "); 74 | Serial.println(Ethernet.localIP()); 75 | } 76 | 77 | 78 | void loop() { 79 | // listen for incoming clients 80 | EthernetClient client = server.available(); 81 | if (client) { 82 | Serial.println("new client"); 83 | // an http request ends with a blank line 84 | boolean currentLineIsBlank = true; 85 | while (client.connected()) { 86 | if (client.available()) { 87 | char c = client.read(); 88 | Serial.write(c); 89 | // if you've gotten to the end of the line (received a newline 90 | // character) and the line is blank, the http request has ended, 91 | // so you can send a reply 92 | if (c == '\n' && currentLineIsBlank) { 93 | // send a standard http response header 94 | client.println("HTTP/1.1 200 OK"); 95 | client.println("Content-Type: text/html"); 96 | client.println("Connnection: close"); 97 | client.println(); 98 | client.println(""); 99 | client.println(""); 100 | // add a meta refresh tag, so the browser pulls again every 5 seconds: 101 | client.println(""); 102 | // output the value of each analog input pin 103 | for (int analogChannel = 0; analogChannel < 6; analogChannel++) { 104 | int sensorReading = analogRead(analogChannel); 105 | client.print("analog input "); 106 | client.print(analogChannel); 107 | client.print(" is "); 108 | client.print(sensorReading); 109 | client.println("
"); 110 | } 111 | client.println(""); 112 | break; 113 | } 114 | if (c == '\n') { 115 | // you're starting a new line 116 | currentLineIsBlank = true; 117 | } 118 | else if (c != '\r') { 119 | // you've gotten a character on the current line 120 | currentLineIsBlank = false; 121 | } 122 | } 123 | } 124 | // give the web browser time to receive the data 125 | delay(1); 126 | // close the connection: 127 | client.stop(); 128 | Serial.println("client disonnected"); 129 | } 130 | } 131 | 132 | -------------------------------------------------------------------------------- /package/libraries/ArduinoTFTP/examples/WebServerWithReset/WebServerWithReset.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Web Server 3 | 4 | A simple web server that shows the value of the analog input pins. 5 | using an Arduino Wiznet Ethernet shield. 6 | 7 | Circuit: 8 | * Ethernet shield attached to pins 10, 11, 12, 13 9 | * Analog inputs attached to pins A0 through A5 (optional) 10 | 11 | created 18 Dec 2009 12 | by David A. Mellis 13 | modified 9 Apr 2012 14 | by Tom Igoe 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | 26 | // Enter a MAC address for your controller below--it must match the one the bootloader uses. 27 | byte mac[] = {0x12,0x34,0x45,0x78,0x9A,0xBC}; 28 | 29 | // The IP address will be read from EEPROM or be set to a value default in `configureNetwork()`. 30 | IPAddress ip; 31 | 32 | // Initialize the Ethernet server library 33 | // with the IP address and port you want to use 34 | // (port 80 is default for HTTP): 35 | EthernetServer server(80); 36 | 37 | // Connections to this port will cause a reset to the bootloader 38 | // so a sketch can be uploaded. 39 | EthernetServer reset_server(81); 40 | 41 | 42 | void configureNetwork() { 43 | // Reads IP address from EEPROM as stored by `WriteNetworkSettings` sketch. 44 | 45 | #define EEPROM_SIG_1_VALUE 0x55 46 | #define EEPROM_SIG_2_VALUE 0xAA 47 | 48 | #define EEPROM_SIG_1_OFFSET 0 49 | #define EEPROM_SIG_2_OFFSET 1 50 | 51 | #define EEPROM_GATEWAY_OFFSET 3 52 | #define EEPROM_MASK_OFFSET 7 53 | #define EEPROM_MAC_OFFSET 11 54 | #define EEPROM_IP_OFFSET 17 55 | 56 | if ((EEPROM.read(EEPROM_SIG_1_OFFSET) == EEPROM_SIG_1_VALUE) 57 | && (EEPROM.read(EEPROM_SIG_2_OFFSET) == EEPROM_SIG_2_VALUE)) { 58 | ip = IPAddress(EEPROM.read(EEPROM_IP_OFFSET), 59 | EEPROM.read(EEPROM_IP_OFFSET+1), 60 | EEPROM.read(EEPROM_IP_OFFSET+2), 61 | EEPROM.read(EEPROM_IP_OFFSET+3)); 62 | } else { 63 | ip = IPAddress(192,168,1,1); 64 | }; 65 | 66 | // TODO: Handle MAC, mask & gateway also. 67 | } 68 | 69 | void setup() { 70 | // Open serial communications and wait for port to open: 71 | Serial.begin(9600); 72 | while (!Serial) { 73 | ; // wait for serial port to connect. Needed for Leonardo only 74 | } 75 | 76 | configureNetwork(); 77 | 78 | // start the Ethernet connection and the server: 79 | Ethernet.begin(mac, ip); 80 | server.begin(); 81 | Serial.print("server is at "); 82 | Serial.println(Ethernet.localIP()); 83 | } 84 | 85 | 86 | void loop() { 87 | 88 | // Check for a connection that indicates we should reset to the bootloader 89 | // so another sketch can be uploaded. 90 | // Note: This approach means that if the sketch hangs later in the loop then any connection 91 | // attempt will not be detected so reset will not occur. So, don't hang. :) 92 | EthernetClient reset_client = reset_server.available(); // Unfortunately requires a byte sent. 93 | 94 | if (reset_client) { 95 | reset_client.stop(); 96 | 97 | wdt_disable(); 98 | wdt_enable(WDTO_2S); 99 | while (1); 100 | } 101 | 102 | 103 | // listen for incoming clients 104 | EthernetClient client = server.available(); 105 | if (client) { 106 | Serial.println("new client"); 107 | // an http request ends with a blank line 108 | boolean currentLineIsBlank = true; 109 | while (client.connected()) { 110 | if (client.available()) { 111 | char c = client.read(); 112 | Serial.write(c); 113 | // if you've gotten to the end of the line (received a newline 114 | // character) and the line is blank, the http request has ended, 115 | // so you can send a reply 116 | if (c == '\n' && currentLineIsBlank) { 117 | // send a standard http response header 118 | client.println("HTTP/1.1 200 OK"); 119 | client.println("Content-Type: text/html"); 120 | client.println("Connnection: close"); 121 | client.println(); 122 | client.println(""); 123 | client.println(""); 124 | client.print("Reset me @ http://"); 127 | client.print(Ethernet.localIP()); 128 | client.print(":81

"); 129 | // add a meta refresh tag, so the browser pulls again every 5 seconds: 130 | client.println(""); 131 | // output the value of each analog input pin 132 | for (int analogChannel = 0; analogChannel < 6; analogChannel++) { 133 | int sensorReading = analogRead(analogChannel); 134 | client.print("analog input "); 135 | client.print(analogChannel); 136 | client.print(" is "); 137 | client.print(sensorReading); 138 | client.println("
"); 139 | } 140 | client.println(""); 141 | break; 142 | } 143 | if (c == '\n') { 144 | // you're starting a new line 145 | currentLineIsBlank = true; 146 | } 147 | else if (c != '\r') { 148 | // you've gotten a character on the current line 149 | currentLineIsBlank = false; 150 | } 151 | } 152 | } 153 | // give the web browser time to receive the data 154 | delay(1); 155 | // close the connection: 156 | client.stop(); 157 | Serial.println("client disonnected"); 158 | } 159 | } 160 | 161 | -------------------------------------------------------------------------------- /src/Readme.txt: -------------------------------------------------------------------------------- 1 | Name: Readme.txt 2 | Author: Denis PEROTTO, from work published by Arduino 3 | Copyright: Denis PEROTTO 4 | License: GPL http://www.gnu.org/licenses/gpl-2.0.html 5 | Project: TFTP Bootloader 6 | Function: Project documentation 7 | Contact : denis dot perotto at gmail dot com 8 | Compilator : gcc version 4.3.3 (WinAVR 20100110) 9 | Version: 0.2 tftp functional on 328P 10 | ------------------------------------------------- 11 | Ethernet bootloader for the ATmega328P / W5100 12 | Tested on Arduino Ethernet 13 | ------------------------------------------------- 14 | 15 | How it works 16 | ------------ 17 | This bootloader starts a TFTP server on default UDP Port 69, and listens for about 5 seconds at startup. During this time the user can upload 18 | a new firmware using any TFTP client software. 19 | 20 | It manages interrupted file transfers even if a power failure succeed. 21 | 22 | Size 23 | ---- 24 | At this time the bootloader's size is about 1500 words (3000 Bytes). Fuses have to be configured in order to declare a 2Kwords booloader. 25 | Therefore the user code must not exceed 28672 Bytes. 26 | 27 | EEPROM Usage 28 | ------------- 29 | Bytes 0 to 20 are reserved for the TFTP Bootloader, please read "Settings stored in flash" below 30 | 31 | Flashing bootloader: 32 | -------------------- 33 | Connect a TinyUSB programmer and "make install". 34 | 35 | Configuring your network: 36 | ------------------------- 37 | The bootloader default address is 192.168.1.1. 38 | Configure your computer network card to a static address of 192.168.1.x with a subnet of 255.255.255.0. 39 | By default, the bootloader assumes an internet gateway is at address 192.168.1.254. 40 | 41 | Converting firmware to the right format: 42 | ---------------------------------------- 43 | The bootloader accepts raw binary images, starting at address 0x0000. 44 | These can be generated using avr-objcopy, part of WinAVR / AVR-GCC, using the "-O binary" option. 45 | Example: avr-objcopy -j .text -j .data -O binary [firmware].elf [firmware].bin 46 | 47 | Uploading firmware manually: 48 | ---------------------------- 49 | 1) Check the target board is powered, and connected to the computer ethernet. 50 | 2) Verify the computer network settings: Static IP of 192.168.1.x, Subnet of 255.255.255.0. 51 | 3) Push reset button to start the bootloader. The LED will blink rapidly. 52 | 4) In a console window (Windows): tftp -i 192.168.1.1 put [firmware].bin 53 | 6) The board will be reprogrammed and reboot. 54 | 55 | Flash codes: 56 | ------------ 57 | Rapid blinking: Ethernet bootloader is wainting for a connection. 58 | 59 | Timing 60 | ------ 61 | -Timeout at startup is set to 5 seconds approximately 62 | -Timeout will never occur if there is no firmware in user flash space 63 | -Timeout (also 5 seconds) will occur if a download has been started and no response is sent by the client, and TFTP server will restart and wait for a new attempt 64 | -Timeout will never occur after an hardware reset if there has been an interrupted transfer before (we suppose the image in flash to be incomplete) 65 | 66 | 67 | IP Addressing: 68 | -------------- 69 | 70 | This TFTP bootloader does not implement a DHCP client at this time. As it has been thought to be as tiny, reliable and autonomous as possible 71 | only static addressing is supported. 72 | 73 | DHCP boot with TFTP server address recovery in specific DHCP Option could be an option in order to have a diskless station like behaviour, but 74 | once again this bootloader has been thought to be rock-solid and automatic flashing of firmware at startup is a dangerous option. 75 | 76 | Settings stored in flash: 77 | ---------------------------------- 78 | 79 | In order to provide the possibility to configure the Ethernet settings used by the TFTP Bootloader 80 | and the user application, the following settings can be stored in the MCU flash. 81 | 82 | These are intended to be shared between the TFTP Bootloader and the client App. This will avoid any inconsistencies 83 | and ARP resolution problems during the initialisation process that would succeed if different MAC addresses are 84 | used for example. 85 | 86 | 0:SIG1(0x55), 1:SIG2(0XAA) --> Signature, if present Bootloader will use the following settings for configuring the Ethernet Chip 87 | 2:IMAGE STATUS : 0xFF: BAD or never uploaded, 0xBB: IMAGE OK 88 | 3:GWIP0, 4:GWIP1, 5:GWIP2, 6:GWIP3 --> Gateway IP address (Default 192.168.1.254) 89 | 7:MASK0, 8:MASK1, 9:MASK2, 10:MASK3 --> Mask (Default 255.255.255.0) 90 | 11:MAC0, 12:MAC1, 13:MAC2, 14:MAC3, 15:MAC4, 16:MAC5 --> MAC Address (Default 12:34:45:78:9A:BC) 91 | 17:IP0, 18:IP1, 19:IP2, 20:IP3 --> IP Address (Default 192.168.1.1) 92 | 93 | The consistency of these settings have to be garanteed by the client application. 94 | 95 | Errors handled during TFTP transfer: 96 | --------------- 97 | The following error codes and error strings can be reported to the TFTP client software: 98 | 99 | - "Opcode?", Code 1, TFTP Opcode sent by client is not supported 100 | - "Flash Full", Code 3, Flash size exceeded 101 | - "Invalid Image", Code 5, Firmware sent by client don't start with 0x0C 0x94 0xWX 0xYZ (JMP 0xWXYZ) 102 | - "Error", Code 0, Unknown error 103 | 104 | Debugging 105 | --------- 106 | Debugging can be enabled at time of compilation in debug.h, uncomment the following line, save and compile: 107 | 108 | //#define DEBUG 109 | 110 | should be replaced by : 111 | 112 | #define DEBUG 113 | 114 | Debug will be outputted to the serial port of the Arduino board at 115200 bps speed. 115 | 116 | Version history 117 | --------------- 118 | 0.1 (xx/xx/xxxx): First internal release. Supports uploads on tftp. (Arduino unachieved published release) 119 | 0.2 (07/12/2011): Reviewed by Denis PEROTTO, comments added, additionnal error codes added and code cleaned 120 | 121 | Todo List 122 | --------------- 123 | - Return to Ethernet default settings when putting one pin HIGH during startup 124 | - Enable TFTP debugging by setting a value in flash in the client application 125 | - Add syslog functionnality in addition to serial debugging 126 | - Add possibility to configure the timeout of the TFTP bootloader by setting a value in flash in the client application 127 | -------------------------------------------------------------------------------- /src/w5100_reg.h: -------------------------------------------------------------------------------- 1 | //Mode 2 | #define REG_MR 0x000 3 | 4 | //GW Addr 5 | #define REG_GAR0 0x001 6 | #define REG_GAR1 0x002 7 | #define REG_GAR2 0x003 8 | #define REG_GAR3 0x004 9 | 10 | //Mask 11 | #define REG_SUBR0 0x005 12 | #define REG_SUBR1 0x006 13 | #define REG_SUBR2 0x007 14 | #define REG_SUBR3 0x008 15 | 16 | //Mac Address (Source Hardware Address) 17 | #define REG_SHAR0 0x009 18 | #define REG_SHAR1 0x00A 19 | #define REG_SHAR2 0x00B 20 | #define REG_SHAR3 0x00C 21 | #define REG_SHAR4 0x00D 22 | #define REG_SHAR5 0x00E 23 | 24 | //IP Address (Source Ip Address) 25 | #define REG_SIPR0 0x00F 26 | #define REG_SIPR1 0x010 27 | #define REG_SIPR2 0x011 28 | #define REG_SIPR3 0x012 29 | 30 | //Interrupt 31 | #define REG_IR 0x015 32 | 33 | //Interrupt Mask 34 | #define REG_IMR 0x016 35 | 36 | //Retry Time 37 | #define REG_RTR0 0x017 38 | #define REG_RTR1 0x018 39 | 40 | //Retry Count 41 | #define REG_RCR 0x019 42 | 43 | //RX Memory Size 44 | #define REG_RMSR 0x01A 45 | 46 | //TX Memory Size 47 | #define REG_TMSR 0x01B 48 | 49 | //PPPoE Auth 50 | #define REG_PATR0 0x01C 51 | #define REG_PATR1 0x01D 52 | 53 | //PPP LCP Request Timer 54 | #define REG_PTIMER 0x028 55 | 56 | //PPP LCP Magic Number 57 | #define REG_PMAGIC 0x029 58 | 59 | //Unreachable IP Address 60 | #define REG_UIPR0 0x02A 61 | #define REG_UIPR1 0x02B 62 | #define REG_UIPR2 0x02C 63 | #define REG_UIPR3 0x02D 64 | 65 | //Unreachable Port 66 | #define REG_UPORT0 0x02E 67 | #define REG_UPORT1 0x02F 68 | 69 | //Socket 0 addresses 70 | 71 | //Mode 72 | #define REG_S0_MR 0x400 73 | 74 | //Command 75 | #define REG_S0_CR 0x401 76 | 77 | //Interrupt 78 | #define REG_S0_IR 0x402 79 | 80 | //Status 81 | #define REG_S0_SR 0x403 82 | 83 | //Source Port 84 | #define REG_S0_PORT0 0x404 85 | #define REG_S0_PORT1 0x405 86 | 87 | //Destination Hardware Address 88 | #define REG_S0_DHAR0 0x406 89 | #define REG_S0_DHAR1 0x407 90 | #define REG_S0_DHAR2 0x408 91 | #define REG_S0_DHAR3 0x409 92 | #define REG_S0_DHAR4 0x40A 93 | #define REG_S0_DHAR5 0x40B 94 | 95 | //Destination IP Address 96 | #define REG_S0_DIPR0 0x40C 97 | #define REG_S0_DIPR1 0x40D 98 | #define REG_S0_DIPR2 0x40E 99 | #define REG_S0_DIPR3 0x40F 100 | 101 | //Destination Port 102 | #define REG_S0_DPORT0 0x410 103 | #define REG_S0_DPORT1 0x411 104 | 105 | //Maximum Segment Size 106 | #define REG_S0_MSSR0 0x412 107 | #define REG_S0_MSSR1 0x413 108 | 109 | //Protocol in Raw Mode 110 | #define REG_S0_PROTO 0x414 111 | 112 | //TOS 113 | #define REG_S0_TOS 0x415 114 | 115 | //TTL 116 | #define REG_S0_TTL 0x416 117 | 118 | //TX Free Size 119 | #define REG_S0_TX_FSR0 0x420 120 | #define REG_S0_TX_FSR1 0x421 121 | 122 | //TX Read Pointer 123 | #define REG_S0_TX_RD0 0x422 124 | #define REG_S0_TX_RD1 0x423 125 | 126 | //TX Write Pointer 127 | #define REG_S0_TX_WR0 0x424 128 | #define REG_S0_TX_WR1 0x425 129 | 130 | //RX Received Size 131 | #define REG_S0_RX_RSR0 0x426 132 | #define REG_S0_RX_RSR1 0x427 133 | 134 | //RX Read Pointer 135 | #define REG_S0_RX_RD0 0x428 136 | #define REG_S0_RX_RD1 0x429 137 | 138 | //Socket 1 addresses 139 | #define REG_S1_MR 0x500 140 | #define REG_S1_CR 0x501 141 | #define REG_S1_IR 0x502 142 | #define REG_S1_SR 0x503 143 | #define REG_S1_PORT0 0x504 144 | #define REG_S1_PORT1 0x505 145 | #define REG_S1_DHAR0 0x506 146 | #define REG_S1_DHAR1 0x507 147 | #define REG_S1_DHAR2 0x508 148 | #define REG_S1_DHAR3 0x509 149 | #define REG_S1_DHAR4 0x50A 150 | #define REG_S1_DHAR5 0x50B 151 | #define REG_S1_DIPR0 0x50C 152 | #define REG_S1_DIPR1 0x50D 153 | #define REG_S1_DIPR2 0x50E 154 | #define REG_S1_DIPR3 0x50F 155 | #define REG_S1_DPORT0 0x510 156 | #define REG_S1_DPORT1 0x511 157 | #define REG_S1_MSSR0 0x512 158 | #define REG_S1_MSSR1 0x513 159 | #define REG_S1_PROTO 0x514 160 | #define REG_S1_TOS 0x515 161 | #define REG_S1_TTL 0x516 162 | #define REG_S1_TX_FSR0 0x520 163 | #define REG_S1_TX_FSR1 0x521 164 | #define REG_S1_TX_RD0 0x522 165 | #define REG_S1_TX_RD1 0x523 166 | #define REG_S1_TX_WR0 0x524 167 | #define REG_S1_TX_WR1 0x525 168 | #define REG_S1_RX_RSR0 0x526 169 | #define REG_S1_RX_RSR1 0x527 170 | #define REG_S1_RX_RD0 0x528 171 | #define REG_S1_RX_RD1 0x529 172 | 173 | //Socket 2 addresses 174 | #define REG_S2_MR 0x600 175 | #define REG_S2_CR 0x601 176 | #define REG_S2_IR 0x602 177 | #define REG_S2_SR 0x603 178 | #define REG_S2_PORT0 0x604 179 | #define REG_S2_PORT1 0x605 180 | #define REG_S2_DHAR0 0x606 181 | #define REG_S2_DHAR1 0x607 182 | #define REG_S2_DHAR2 0x608 183 | #define REG_S2_DHAR3 0x609 184 | #define REG_S2_DHAR4 0x60A 185 | #define REG_S2_DHAR5 0x60B 186 | #define REG_S2_DIPR0 0x60C 187 | #define REG_S2_DIPR1 0x60D 188 | #define REG_S2_DIPR2 0x60E 189 | #define REG_S2_DIPR3 0x60F 190 | #define REG_S2_DPORT0 0x610 191 | #define REG_S2_DPORT1 0x611 192 | #define REG_S2_MSSR0 0x612 193 | #define REG_S2_MSSR1 0x613 194 | #define REG_S2_PROTO 0x614 195 | #define REG_S2_TOS 0x615 196 | #define REG_S2_TTL 0x616 197 | #define REG_S2_TX_FSR0 0x620 198 | #define REG_S2_TX_FSR1 0x621 199 | #define REG_S2_TX_RD0 0x622 200 | #define REG_S2_TX_RD1 0x623 201 | #define REG_S2_TX_WR0 0x624 202 | #define REG_S2_TX_WR1 0x625 203 | #define REG_S2_RX_RSR0 0x626 204 | #define REG_S2_RX_RSR1 0x627 205 | #define REG_S2_RX_RD0 0x628 206 | #define REG_S2_RX_RD1 0x629 207 | 208 | //Socket 3 addresses 209 | #define REG_S3_MR 0x700 210 | #define REG_S3_CR 0x701 211 | #define REG_S3_IR 0x702 212 | #define REG_S3_SR 0x703 213 | #define REG_S3_PORT0 0x704 214 | #define REG_S3_PORT1 0x705 215 | #define REG_S3_DHAR0 0x706 216 | #define REG_S3_DHAR1 0x707 217 | #define REG_S3_DHAR2 0x708 218 | #define REG_S3_DHAR3 0x709 219 | #define REG_S3_DHAR4 0x70A 220 | #define REG_S3_DHAR5 0x70B 221 | #define REG_S3_DIPR0 0x70C 222 | #define REG_S3_DIPR1 0x70D 223 | #define REG_S3_DIPR2 0x70E 224 | #define REG_S3_DIPR3 0x70F 225 | #define REG_S3_DPORT0 0x710 226 | #define REG_S3_DPORT1 0x711 227 | #define REG_S3_MSSR0 0x712 228 | #define REG_S3_MSSR1 0x713 229 | #define REG_S3_PROTO 0x714 230 | #define REG_S3_TOS 0x715 231 | #define REG_S3_TTL 0x716 232 | #define REG_S3_TX_FSR0 0x720 233 | #define REG_S3_TX_FSR1 0x721 234 | #define REG_S3_TX_RD0 0x722 235 | #define REG_S3_TX_RD1 0x723 236 | #define REG_S3_TX_WR0 0x724 237 | #define REG_S3_TX_WR1 0x725 238 | #define REG_S3_RX_RSR0 0x726 239 | #define REG_S3_RX_RSR1 0x727 240 | #define REG_S3_RX_RD0 0x728 241 | #define REG_S3_RX_RD1 0x729 242 | #define S0_TX_START 0x4000 243 | #define S0_TX_END 0x4800 244 | #define S1_TX_START 0x4800 245 | #define S1_TX_END 0x5000 246 | #define S2_TX_START 0x5000 247 | #define S2_TX_END 0x5800 248 | #define S3_TX_START 0x5800 249 | #define S3_TX_END 0x6000 250 | #define S0_RX_START 0x6000 251 | #define S0_RX_END 0x6800 252 | #define S1_RX_START 0x6800 253 | #define S1_RX_END 0x7000 254 | #define S2_RX_START 0x7000 255 | #define S2_RX_END 0x7800 256 | #define S3_RX_START 0x7800 257 | #define S3_RX_END 0x8000 258 | 259 | 260 | #define MR_CLOSED 0x00 261 | #define MR_TCP 0x01 262 | #define MR_UDP 0x02 263 | #define MR_IPRAW 0x03 264 | #define MR_MACRAW 0x04 265 | #define MR_PPPOE 0x05 266 | 267 | /*Sn_CR (Socket n Command Register) [R/W] [0x0401, 0x0501, 0x0601, 0x0701] [0x00] 268 | This register is utilized for socket n initialization, close, connection establishment, 269 | termination, data transmission and command receipt. After performing the commands, 270 | the register value will be automatically cleared to 0x00.*/ 271 | 272 | #define CR_OPEN 0x01 273 | #define CR_LISTEN 0x02 274 | #define CR_CONNECT 0x04 275 | #define CR_DISCON 0x08 276 | #define CR_CLOSE 0x10 277 | #define CR_SEND 0x20 278 | #define CR_SEND_MAC 0x21 279 | #define CR_SEND_KEEP 0x22 280 | #define CR_RECV 0x40 281 | 282 | /*Sn_SR (Socket n Status Register) [R] [0x0403, 0x0503, 0x0603, 0x0703] [0x00] 283 | This register has the status value of socket n. 284 | The main status is shown in the below diagram*/ 285 | 286 | #define SOCK_CLOSED 0x00 287 | #define SOCK_ARP1 0x11 288 | #define SOCK_INIT 0x13 289 | #define SOCK_LISTEN 0x14 290 | #define SOCK_SYNSENT 0x15 291 | #define SOCK_SYNRECV 0x16 292 | #define SOCK_ESTABLISHED 0x17 293 | #define SOCK_FIN_WAIT 0x18 294 | #define SOCK_CLOSING 0x1A 295 | #define SOCK_TIME_WAIT 0x1B 296 | #define SOCK_CLOSE_WAIT 0x1C 297 | #define SOCK_LAST_ACK 0x1D 298 | #define SOCK_ARP2 0x21 299 | #define SOCK_UDP 0x22 300 | #define SOCK_ARP3 0x31 301 | #define SOCK_IPRAW 0x32 302 | #define SOCK_MACRAW 0x42 303 | #define SOCK_PPPOE 0x5F 304 | -------------------------------------------------------------------------------- /package/hardware/arduino-tftpboot/bootloaders/arduino-tftpboot/arduino-tftpboot-bootloader-m328.hex: -------------------------------------------------------------------------------- 1 | :107000004FC00000A7C00000A5C00000A3C0000042 2 | :10701000A1C000009FC000009DC000009BC00000F8 3 | :1070200099C0000097C0000095C0000093C0000008 4 | :1070300091C000008FC000008DC000008BC0000018 5 | :1070400089C0000087C0000085C0000083C0000028 6 | :1070500081C000007FC000007DC000007BC0000038 7 | :1070600079C0000077C00000000500044F70636F16 8 | :1070700064653F0000050003466C61736820467537 9 | :107080006C6C00000500004572726F720000050014 10 | :1070900000496E76616C696420696D616765000006 11 | :1070A00011241FBECFEFD8E0DEBFCDBF14E0A0E0BB 12 | :1070B000B1E0E0EEF9E702C005900D92AA31B10708 13 | :1070C000D9F714E0AAE1B4E001C01D92A332B107E0 14 | :1070D000E1F701D083C414BE88E10FB6F894809321 15 | :1070E0006000109260000FBE10D484EC99E020E99B 16 | :1070F00031E0F9013197F1F70197D9F78EE284B9C0 17 | :107100008CE385B983E08093810081E08DBD80E0D0 18 | :1071100091E00AD481E391E007D485E391E004D4BF 19 | :10712000ACD085E491E000D485E591E0FDD3D3D0E7 20 | :1071300084E691E0F9D377D3882311F00CD0FBCF0C 21 | :1071400085E791E0F1D3E0911C04F0911D040995CD 22 | :1071500080E090E055CF20918400309185008091AF 23 | :107160002104909122042817390770F480911A04A1 24 | :1071700090911B04019690931B0480931A04299B01 25 | :1071800002C0299801C0299A309322042093210437 26 | :107190000895E0E0F0E0859194918F5F9F4F11F4A6 27 | :1071A00020E008C020E080911A0490911B044497CD 28 | :1071B00008F021E0822F089510921B0410921A0407 29 | :1071C00008959C0180E58CBD2A9880EF8EBD0DB49A 30 | :1071D00007FEFDCF832F99278EBD0DB407FEFDCF8F 31 | :1071E0002EBD0DB407FEFDCF6EBD0DB407FEFDCF65 32 | :1071F0002A9A1CBC08959C0180E58CBD2A988FE0DA 33 | :107200008EBD0DB407FEFDCF832F99278EBD0DB423 34 | :1072100007FEFDCF2EBD0DB407FEFDCF1EBC0DB485 35 | :1072200007FEFDCF2A9A8EB51CBC0895EF92FF92FF 36 | :107230000F931F938C01DFDFE82EC8010196DBDF7F 37 | :10724000FF24FE2CEE2490E08E299F291F910F91A0 38 | :10725000FF90EF900895EF92FF920F931F938C0190 39 | :107260007B01672F7727ADDFC80101966E2DA9DF5F 40 | :107270001F910F91FF90EF900895CF93DF9380E0DF 41 | :1072800090E096D38535A9F481E090E091D38A3AD5 42 | :1072900081F486E891E048D3C3E0D0E0CE0188D302 43 | :1072A000FE01EB54FE4F80832196C531D105B1F725 44 | :1072B00003C08EE991E038D3C0E0D0E0FE01E9548C 45 | :1072C000FE4FCE0160817DDF2196CC31D105B1F733 46 | :1072D000DF91CF91089584E097E065E470E0BBDF33 47 | :1072E00080E097E062E06DDF81E097E061E069DFD8 48 | :1072F00083E097E080DF823221F081E097E060E177 49 | :1073000060DF83E097E077DF823229F70895DF922C 50 | :10731000EF92FF920F931F93DF93CF93CDB7DEB71A 51 | :10732000C456D040DEBFCDBF8C0184E297E07EDF43 52 | :107330007C0103301105A9F10430110538F4013046 53 | :10734000110529F10230110539F435C00430110559 54 | :10735000A9F10530110589F0CE01019663E870E7C7 55 | :107360004AE050E01CD35AE0D52EC7018050984A1D 56 | :107370007E010894E11CF11C3BC0CE0101966DE832 57 | :1073800070E742E150E00BD342E1D42EEECFCE01C4 58 | :10739000019668E670E74CE050E001D33CE0D32E64 59 | :1073A000E4CFCE01019664E770E74FE050E0F7D2FA 60 | :1073B0002FE0D22EDACF83ED91E0B6D28AEE91E0C3 61 | :1073C000B3D280911E0490911F04CDD284EF91E03E 62 | :1073D000ABD2198284E08A8320911E0430911F046D 63 | :1073E000832F99278B832C8384E0D82EBECFC801AE 64 | :1073F0008C010F5F1F4FF7016081E3DEF0E6003084 65 | :107400001F0711F400E018E50894E11CF11CDA9460 66 | :1074100071F70050184584E297E0B8011CDF81E065 67 | :1074200097E060E2CEDE81E097E0E5DE8823D9F7E1 68 | :1074300087EF91E079D2CC59DF4FDEBFCDBFCF913E 69 | :10744000DF911F910F91FF90EF90DF9008956F9261 70 | :107450007F928F929F92AF92BF92CF92DF92EF92E4 71 | :10746000FF920F931F93DF93CF93CDB7DEB7C05139 72 | :10747000D240DEBFCDBF8C0187E092E055D284E4DC 73 | :1074800092E052D28DE592E04FD2C8016CD28EE6E6 74 | :1074900092E04AD20050184019F487E792E044D2B3 75 | :1074A00088E297E0C3DE4C0181E0881688E0980608 76 | :1074B00010F4640111C085E892E036D286EA92E0C9 77 | :1074C00033D2C40150D284EF91E02ED27FEFC72E89 78 | :1074D00077E0D72EC820D92086EA92E025D2C601CF 79 | :1074E0008050984840D266E0E62E68E7F62EEC0C15 80 | :1074F000FD1CC70180DE082FC601895F97487BDE2F 81 | :10750000A82EBB24E8E0F0E0AE0EBF1E10E0102F66 82 | :107510000027A00EB11E84EF91E006D284EB92E02A 83 | :1075200003D2C70120D284EF91E0FED185EC92E036 84 | :10753000FBD144EF642E4FEF742E6A0C7B1CC30109 85 | :1075400012D284EF91E0F0D175010894E11CF11C96 86 | :107550008E010F5F1F4F15C0C601805098484BDE4B 87 | :10756000F80180830894C11CD11CF0E0CF16F8E02C 88 | :10757000DF0611F4CC24DD240F5F1F4F0894E108CF 89 | :10758000F108E114F10441F787ED92E0CDD18501D6 90 | :10759000080D191DC801E7D184EF91E0C5D188E23B 91 | :1075A00097E0B80158DE81E097E060E40ADE81E010 92 | :1075B00097E021DE8823D9F789EE92E0B5D186E203 93 | :1075C00097E034DED0D184EF91E0AED17E01089413 94 | :1075D000E11CF11C0CE017E0C801F70161917F018B 95 | :1075E000F0DD0F5F1F4FF7E002311F07A9F7898514 96 | :1075F00090E0182F00278A85080F111D8B8590E0D9 97 | :10760000D82ECC248C85C80ED11C86EF92E08CD16C 98 | :10761000C601A9D184EF91E087D187E093E084D1BE 99 | :10762000C801A1D184EF91E07FD10330110509F4A5 100 | :107630005AC00430110520F40230110549F40FC07E 101 | :107640000430110509F4D5C00530110509F4D4C082 102 | :10765000C80189D18FE093E067D181E0D1C083E296 103 | :1076600093E062D181E097E060E4ABDD81E097E0F8 104 | :1076700060E1A7DD80E097E062E0A3DD81E097E0D4 105 | :1076800061E09FDD6E8170E0609570958D8190E086 106 | :10769000982F8827682B792B84E097E0DCDD83E046 107 | :1076A00097E0A9DD823221F081E097E060E189DD99 108 | :1076B00083E097E0A0DD8232E9F683E393E034D102 109 | :1076C0008E8125E5822790E02D8130E0322F222720 110 | :1076D000822B932B48D184EF91E026D110921F0486 111 | :1076E00010921E047FC0D0921F04C0921E04760127 112 | :1076F0000894E108F108FE2CEE24FF0C84E493E0EA 113 | :1077000013D180911E0490911F042DD184EF91E03C 114 | :107710000BD1C5018E0D9F1D8150904728F08EE53D 115 | :1077200093E002D183E06CC08FE693E0FDD0C70107 116 | :107730001AD184EF91E0F8D0850102C00F5F1F4F8E 117 | :10774000C8018F779070892BC9F7E114F10459F0C3 118 | :10775000DE011D9640E050E0CC24C394F3E0DF2E20 119 | :1077600075E061E137C0CE010D96BFD0882381F767 120 | :107770008AE893E0D9D085E043C011968C911197A7 121 | :1077800090E0982F88272C9130E0822B932BF701E3 122 | :107790000C01C0925700E89511244E5F5F4FCA015B 123 | :1077A0008F779070892B89F4EE57F040D092570074 124 | :1077B000E89507B600FCFDCF70935700E89507B633 125 | :1077C00000FCFDCF60935700E895129682E090E0B0 126 | :1077D000E80EF91E4017510780F290E0691692E01A 127 | :1077E000790610F082E00CC08BE993E09DD084E034 128 | :1077F00007C08FEA93E002C085EB93E095D080E06C 129 | :10780000C05FDD4FDEBFCDBFCF91DF911F910F91E4 130 | :10781000FF90EF90DF90CF90BF90AF909F908F90B0 131 | :107820007F906F9008951F9386E297E0FFDC0097AA 132 | :1078300021F10DDE182F90E06ADD81E080932004B5 133 | :1078400082E090E06FEFBCD0B7DC1430B1F481E09F 134 | :1078500097E060E1B6DC82E090E06BEBB1D08DEBBD 135 | :1078600093E062D082E090E0A3D090E07CD084EFFF 136 | :1078700091E05AD086EC93E032C08BDC8823E9F0AB 137 | :10788000809120048823C9F081E097E060E199DCD1 138 | :1078900086ED93E049D08EEE93E046D0109220041E 139 | :1078A00007B600FCFDCFF999FECFE0E0F0E083E001 140 | :1078B00080935700E8950FDD15C06BDC882391F0AD 141 | :1078C00080912004882371F482E090E071D08B3B9A 142 | :1078D00049F481E097E060E174DC8FE094E024D02B 143 | :1078E00080E001C081E01F910895FC0190E080815B 144 | :1078F0008C3049F48181843931F49C5F349694331F 145 | :10790000B1F781E0089580E0089582E28093C0009D 146 | :1079100088E08093C10080E190E09093C50080935F 147 | :10792000C40082E98AB90895FC0106C08093C600AC 148 | :107930008091C00085FFFCCF81918823B9F708951D 149 | :107940008093C6008091C00085FFFCCF08958F70A2 150 | :107950008A3008F0895F805D8093C6008091C00006 151 | :1079600085FFFCCF08950F931F938C0180E3E8DF20 152 | :1079700088E7E6DFC801892F992782958F70E7DFB6 153 | :10798000812F9927E4DFC80124E0969587952A95F1 154 | :10799000E1F7DDDF802FDBDF1F910F910895FB0101 155 | :1079A000DC0102C005900D9241505040D8F7089577 156 | :1079B000F999FECF92BD81BDF89A992780B50895B7 157 | :1079C000262FF999FECF1FBA92BD81BD20BD0FB6FB 158 | :1079D000F894FA9AF99A0FBE01960895F894FFCF99 159 | :1079E0000D0A5446545020426F6F746C6F61646589 160 | :1079F0007220666F722041726475696E6F204574E3 161 | :107A00006865726E65742C2056657273696F6E209E 162 | :107A100000302E32000D0A4E657420696E69742E96 163 | :107A20002E2E0D0A004E657420696E697420646FF5 164 | :107A30006E650D0A005446545020496E69742E2E0E 165 | :107A40002E0D0A005446545020496E697420646F0C 166 | :107A50006E650D0A0053746172742075736572202F 167 | :107A60006170700D0A005573696E6720454550526C 168 | :107A70004F4D2073657474696E67730D0A005573FA 169 | :107A8000696E672044656661756C74205365747413 170 | :107A9000696E67730D0A0080C0A801FEFFFFFF003A 171 | :107AA000123445789ABCC0A801010000000007D03C 172 | :107AB00080555553656E642041434B20284E6F74AA 173 | :107AC0002046696E616C290D0A0053656E64204181 174 | :107AD000434B20000D0A00526573706F6E73652072 175 | :107AE00073656E740D0A002D2D2D2D2D2D2D2D2D30 176 | :107AF0002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DB6 177 | :107B00002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DA5 178 | :107B10002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D95 179 | :107B20002D0D0A005374617274696E672050726F74 180 | :107B3000636573735061636B65740D0A004461740F 181 | :107B40006120696E206275666665723A2000206267 182 | :107B5000797465730D0A004F564552464C4F5721B4 183 | :107B600021210D0A004170706C79696E67206D6F7C 184 | :107B700064756C6F20746F2072656164506F696EFC 185 | :107B80007465720D0A005265616420506F696E74ED 186 | :107B900065723A004164647265737320666F722087 187 | :107BA0006C656E3A0054465450205061636B6574A6 188 | :107BB0002053697A653A004E6577205265616420EA 189 | :107BC000506F696E7465723A006279746573746F90 190 | :107BD000726561643A005468697320697320626C4D 191 | :107BE0006F636B206EB0004F70636F64653D00691A 192 | :107BF0007320696E76616C6964206F70636F646571 193 | :107C00000D0A005772697465207265717565737429 194 | :107C10000D0A004368616E67656420746F20706FA1 195 | :107C20007274200057726974696E672044617461D0 196 | :107C300020666F7220626C6F636B206EB000466CC2 197 | :107C40006173682069732066756C6C210D0A00579A 198 | :107C5000726974696E6720646174612066726F6D09 199 | :107C600020616464726573732000496E76616C698B 200 | :107C70006420496D616765210D0A00466C61736877 201 | :107C800020697320636F6D706C6574650D0A004127 202 | :107C9000636B0D0A004572726F720D0A00696D67A1 203 | :107CA0005F73746174005446545020436F6D706C60 204 | :107CB0006574650D0A00446F776E6C6F61642069AE 205 | :107CC0006E746572727570746564210D0A00526578 206 | :107CD0002D696E697469616C6973696E67205446B9 207 | :107CE0005450207365727665722E2E2E0D0A005444 208 | :0A7CF000696D656F7574210D0A00BF 209 | :040000030000700089 210 | :00000001FF 211 | -------------------------------------------------------------------------------- /src/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | --------------------------------------------------------------------------------