|
|
|
@ -11,10 +11,10 @@
|
|
|
|
* TODO:
|
|
|
|
* TODO:
|
|
|
|
* OK(v1.1) 1. Print-out received file from TFTP to serial console (small file < 512 bytes OK).
|
|
|
|
* OK(v1.1) 1. Print-out received file from TFTP to serial console (small file < 512 bytes OK).
|
|
|
|
* OK(v1.2) 2. Print-out received file from TFTP to serial console (multi-packet files > 512 bytes).
|
|
|
|
* OK(v1.2) 2. Print-out received file from TFTP to serial console (multi-packet files > 512 bytes).
|
|
|
|
* OK(v1.3) 3. Write-in data to SD-card file "readme_txt" and another patterns.
|
|
|
|
* OK(v1.3) 3. Write-in data to SD-card file "test.txt" and another patterns.
|
|
|
|
* 4. Print out "readme.txt" contents head (from SD-Card ) in a serial terminal.
|
|
|
|
* OK(v1.4) 4. Print out "test.txt" contents head (from SD-Card ) in a serial terminal.
|
|
|
|
* 5. Add handlers for CHK_RAM_LEAKAGE && CHK_UPTIME.
|
|
|
|
* 5. Add handlers for CHK_RAM_LEAKAGE && CHK_UPTIME.
|
|
|
|
* 6. Clear the code from the loopback sockets
|
|
|
|
* 6.?? Clear the code from the loopback sockets (Is it really need to do?)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Remark:
|
|
|
|
* Remark:
|
|
|
|
* Checked with PC tftp-server (WIN7) - tftpd64.exe
|
|
|
|
* Checked with PC tftp-server (WIN7) - tftpd64.exe
|
|
|
|
@ -63,7 +63,7 @@ volatile unsigned long _millis; // for millis tick !! Overflow every ~49.7 days
|
|
|
|
//*********Program metrics
|
|
|
|
//*********Program metrics
|
|
|
|
const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции
|
|
|
|
const char compile_date[] PROGMEM = __DATE__; // Mmm dd yyyy - Дата компиляции
|
|
|
|
const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции
|
|
|
|
const char compile_time[] PROGMEM = __TIME__; // hh:mm:ss - Время компиляции
|
|
|
|
const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.3 Static IP TFTP Client && FATFS SDCARD WIZNET_5500 ETHERNET 27/03/2019\r\n"; // Program name
|
|
|
|
const char str_prog_name[] PROGMEM = "\r\nAtMega1284p v1.4 Static IP TFTP Client && FATFS SDCARD WIZNET_5500 ETHERNET 28/03/2019\r\n"; // Program name
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__AVR_ATmega128__)
|
|
|
|
#if defined(__AVR_ATmega128__)
|
|
|
|
const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128
|
|
|
|
const char PROGMEM str_mcu[] = "ATmega128"; //CPU is m128
|
|
|
|
@ -373,7 +373,7 @@ void fatfs_head_file(const char * fn)
|
|
|
|
_buf[br] = 0x0;
|
|
|
|
_buf[br] = 0x0;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
_buf[127] = 0x0;
|
|
|
|
_buf[127] = 0x0;
|
|
|
|
PRINTF ("OK\r\n");
|
|
|
|
PRINTF("OK\r\n");
|
|
|
|
PRINTF("text contents reading %u bytes:\r\n", br);
|
|
|
|
PRINTF("text contents reading %u bytes:\r\n", br);
|
|
|
|
PRINTF("%s", _buf);
|
|
|
|
PRINTF("%s", _buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -391,6 +391,7 @@ void fatfs_head_file(const char * fn)
|
|
|
|
PRINTF ("ERROR opening file <%s> ", fn);
|
|
|
|
PRINTF ("ERROR opening file <%s> ", fn);
|
|
|
|
put_rc(f_err_code);
|
|
|
|
put_rc(f_err_code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRINTF("\r\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fatfs_init(void)
|
|
|
|
void fatfs_init(void)
|
|
|
|
@ -520,7 +521,7 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
//FAT_FS init and quick test(root directory list && print out head index.htm)
|
|
|
|
//FAT_FS init and quick test(root directory list && print out head index.htm)
|
|
|
|
fatfs_init();
|
|
|
|
fatfs_init();
|
|
|
|
fatfs_head_file("index.htm");
|
|
|
|
//fatfs_head_file("index.htm");
|
|
|
|
|
|
|
|
|
|
|
|
//Wizchip WIZ5500 Ethernet initialize
|
|
|
|
//Wizchip WIZ5500 Ethernet initialize
|
|
|
|
IO_LIBRARY_Init(); //After that ping must working
|
|
|
|
IO_LIBRARY_Init(); //After that ping must working
|
|
|
|
@ -557,10 +558,10 @@ int main()
|
|
|
|
printf("\r\n########## SW1 was pressed.\r\n");
|
|
|
|
printf("\r\n########## SW1 was pressed.\r\n");
|
|
|
|
memset(tftp_filename, 0x0, TFTP_FILE_NAME_SIZE);
|
|
|
|
memset(tftp_filename, 0x0, TFTP_FILE_NAME_SIZE);
|
|
|
|
//!!Don't forget about 8.3 file name rule!!
|
|
|
|
//!!Don't forget about 8.3 file name rule!!
|
|
|
|
//strncpy(tftp_filename, "test.txt", TFTP_FILE_NAME_SIZE);
|
|
|
|
strncpy(tftp_filename, "test.txt", TFTP_FILE_NAME_SIZE);
|
|
|
|
strncpy(tftp_filename, "README.md", TFTP_FILE_NAME_SIZE);
|
|
|
|
//strncpy(tftp_filename, "README.md", TFTP_FILE_NAME_SIZE);
|
|
|
|
//strncpy(tftp_filename, "tftpd32.ini", TFTP_FILE_NAME_SIZE);
|
|
|
|
//strncpy(tftp_filename, "tftpd32.ini", TFTP_FILE_NAME_SIZE);
|
|
|
|
//strncpy(tftp_filename, "ff_lfn.c", TFTP_FILE_NAME_SIZE);
|
|
|
|
//strncpy(tftp_filename, "ff_lfn.txt", TFTP_FILE_NAME_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
tftp_server = ((uint32_t)tftp_destip[0] << 24) | ((uint32_t)tftp_destip[1] << 16) | ((uint32_t)tftp_destip[2] << 8) | ((uint32_t)tftp_destip[3]);
|
|
|
|
tftp_server = ((uint32_t)tftp_destip[0] << 24) | ((uint32_t)tftp_destip[1] << 16) | ((uint32_t)tftp_destip[2] << 8) | ((uint32_t)tftp_destip[3]);
|
|
|
|
|
|
|
|
|
|
|
|
@ -582,6 +583,10 @@ int main()
|
|
|
|
if(_ret == TFTP_SUCCESS)
|
|
|
|
if(_ret == TFTP_SUCCESS)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PRINTF("\r\n++TFTP transfer complete:[%u] SUCCESS, received %lu bytes\r\n", _ret, get_tftp_received_size());
|
|
|
|
PRINTF("\r\n++TFTP transfer complete:[%u] SUCCESS, received %lu bytes\r\n", _ret, get_tftp_received_size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Print-out head received file
|
|
|
|
|
|
|
|
fatfs_head_file(tftp_filename);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(_ret == TFTP_FAIL)
|
|
|
|
else if(_ret == TFTP_FAIL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|