Browse Source

add iap folder

balbekova 8 năm trước cách đây
mục cha
commit
5767c39298
47 tập tin đã thay đổi với 6924 bổ sung0 xóa
  1. 76 0
      iap/Makefile
  2. 104 0
      iap/Modules/Console/config.h
  3. 680 0
      iap/Modules/Console/microrl.c
  4. 118 0
      iap/Modules/Console/microrl.h
  5. 137 0
      iap/Modules/Console/port_microrl.c
  6. 38 0
      iap/Modules/Console/port_microrl.h
  7. 579 0
      iap/Modules/Ethernet/fsdata.c
  8. 65 0
      iap/Modules/Ethernet/fsdata.h
  9. 686 0
      iap/Modules/Ethernet/httpserver.c
  10. 69 0
      iap/Modules/Ethernet/httpserver.h
  11. 230 0
      iap/Modules/Ethernet/lwipopts.h
  12. BIN
      iap/Modules/Ethernet/makefsdata.exe
  13. 240 0
      iap/Modules/Ethernet/netconf.c
  14. 69 0
      iap/Modules/Ethernet/netconf.h
  15. 56 0
      iap/Modules/crc.c
  16. 35 0
      iap/Modules/crc.h
  17. 138 0
      iap/Modules/flash_if.c
  18. 44 0
      iap/Modules/flash_if.h
  19. 48 0
      iap/Modules/gpio_io.c
  20. 31 0
      iap/Modules/gpio_io.h
  21. 136 0
      iap/Modules/led.c
  22. 85 0
      iap/Modules/led.h
  23. 264 0
      iap/Modules/settings_api.c
  24. 205 0
      iap/Modules/settings_api.h
  25. 256 0
      iap/Modules/systick.c
  26. 81 0
      iap/Modules/systick.h
  27. 86 0
      iap/Modules/usart.c
  28. 36 0
      iap/Modules/usart.h
  29. 77 0
      iap/Modules/wdg.c
  30. 36 0
      iap/Modules/wdg.h
  31. 269 0
      iap/User/main.c
  32. 85 0
      iap/User/main.h
  33. 176 0
      iap/User/stm32f4xx_it.c
  34. 60 0
      iap/User/stm32f4xx_it.h
  35. 399 0
      iap/lwip/port/STM32F4x7/FreeRTOS/ethernetif.c
  36. 12 0
      iap/lwip/port/STM32F4x7/FreeRTOS/ethernetif.h
  37. 586 0
      iap/lwip/port/STM32F4x7/FreeRTOS/sys_arch.c
  38. 311 0
      iap/lwip/port/STM32F4x7/Standalone/ethernetif.c
  39. 11 0
      iap/lwip/port/STM32F4x7/Standalone/ethernetif.h
  40. 1 0
      iap/lwip/port/STM32F4x7/arch/bpstruct.h
  41. 93 0
      iap/lwip/port/STM32F4x7/arch/cc.h
  42. 37 0
      iap/lwip/port/STM32F4x7/arch/cpu.h
  43. 1 0
      iap/lwip/port/STM32F4x7/arch/epstruct.h
  44. 44 0
      iap/lwip/port/STM32F4x7/arch/init.h
  45. 38 0
      iap/lwip/port/STM32F4x7/arch/lib.h
  46. 40 0
      iap/lwip/port/STM32F4x7/arch/perf.h
  47. 56 0
      iap/lwip/port/STM32F4x7/arch/sys_arch.h

+ 76 - 0
iap/Makefile

@@ -0,0 +1,76 @@
+TARGET = iap
+
+INCLUDES = -I../stm32/stm32f4xx_spl/inc 
+INCLUDES += -I../stm32/system
+INCLUDES += -I../config
+
+#----
+INCLUDES += -I.
+INCLUDES += -I../thirdparty/lwip/src/include
+INCLUDES += -I../thirdparty/lwip/src/include/netif
+INCLUDES += -I../thirdparty/lwip/src/include/lwip
+INCLUDES += -I../thirdparty/lwip/src/include/ipv4
+INCLUDES += -Ilwip/port/STM32F4x7
+INCLUDES += -Ilwip/port/STM32F4x7/Standalone
+INCLUDES += -Ilwip/port/STM32F4x7/arch
+INCLUDES += -IModules
+INCLUDES += -IModules/Ethernet
+INCLUDES += -IModules/Console
+INCLUDES += -I../stm32/stm32f4x7_ethernet
+INCLUDES += -IUser
+INCLUDES += -I../thirdparty/TinyStdio
+#----
+
+CSRC = $(wildcard *.c ../stm32/system/*.c)
+CSRC += $(wildcard ../stm32/stm32f4xx_spl/src/*.c)
+
+#----
+CSRC += $(wildcard ../thirdparty/lwip/src/*.c)
+CSRC += $(wildcard ../thirdparty/lwip/src/api/*.c)
+CSRC += $(wildcard ../thirdparty/lwip/src/core/*.c)
+CSRC += $(wildcard ../thirdparty/lwip/src/core/ipv4/*.c)
+CSRC += $(wildcard ../thirdparty/lwip/src/netif/*.c)
+CSRC += $(wildcard lwip/port/STM32F4x7/Standalone/*.c)
+CSRC += $(wildcard Modules/*.c)
+CSRC += $(wildcard Modules/Ethernet/httpserver.c)
+CSRC += $(wildcard Modules/Ethernet/netconf.c)
+CSRC += $(wildcard ../stm32/stm32f4x7_ethernet/*.c)
+CSRC += $(wildcard User/*.c)
+CSRC += $(wildcard ../thirdparty/TinyStdio/*.c)
+
+#---
+
+CSRC += $(wildcard ../stm32/system/syscalls/syscalls.c)
+
+CFLAGS = -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -DPRINTF_CUSTOM
+CFLAGS += -DHARDWARE_$(shell echo $(HARDWARE) | tr a-z A-Z)
+
+ifeq ($(SWOTRACE), 1)
+	CFLAGS += -DSWOTRACE
+endif
+
+ifeq ($(MAC),)
+	#Print default MAC
+	MAC = $(shell awk '/\#define DEVICE_MAC/{print $$3}' ./Modules/settings_api.h )
+else
+    #Set device MAC
+	CFLAGS += -DDEVICE_MAC='"$(MAC)"'
+endif
+
+
+	LDSCRIPT := ../projects/gcc/stm32_flash.ld
+	
+	ASMSRC = ../projects/gcc/startup_stm32f4xx.s
+
+
+BUILDDIR = ../build/iap/$(TARGET)
+
+-include ../Makefile.inc.stm32
+
+prebuild:
+	@grep -wl --include *.h --include *.c "DEVICE_MAC" ./ -R | xargs touch
+	@grep -wl --include *.h --include *.c "SWOTRACE" ./ ../shared -R | xargs touch
+	
+postbuild:
+	@echo "Device MAC address: $(MAC)"
+

+ 104 - 0
iap/Modules/Console/config.h

@@ -0,0 +1,104 @@
+/**
+Microrl library config files
+Autor: Eugene Samoylov aka Helius (ghelius@gmail.com)
+*/
+#ifndef _MICRORL_CONFIG_H_
+#define _MICRORL_CONFIG_H_
+
+#define MICRORL_LIB_VER "1.5.1"
+
+/*********** CONFIG SECTION **************/
+/*
+Command line length, define cmdline buffer size. Set max number of chars + 1,
+because last byte of buffer need to contain '\0' - NULL terminator, and 
+not use for storing inputed char.
+If user input chars more then it parametrs-1, chars not added to command line.*/
+#define _COMMAND_LINE_LEN (1+100)									// for 32 chars
+
+/*
+Command token number, define max token it command line, if number of token 
+typed in command line exceed this value, then prints message about it and
+command line not to be parced and 'execute' callback will not calls.
+Token is word separate by white space, for example 3 token line:
+"IRin> set mode test" */
+#define _COMMAND_TOKEN_NMB 8
+
+/*
+Define you prompt string here. You can use colors escape code, for highlight you prompt,
+for example this prompt will green color (if you terminal supports color)*/
+#define _PROMPT_DEFAULT "\033[32mIBPn >\033[0m "	// green color
+//#define _PROMPT_DEFAULT "\033[32mIRin >\033[0m "	// green color
+//#define _PROMPT_DEFAULT "IRin > "
+
+/*
+Define prompt text (without ESC sequence, only text) prompt length, it needs because if you use
+ESC sequence, it's not possible detect only text length*/
+#define _PROMPT_LEN       7
+
+/*Define it, if you wanna use completion functional, also set completion callback in you code,
+now if user press TAB calls 'copmlitetion' callback. If you no need it, you can just set 
+NULL to callback ptr and do not use it, but for memory saving tune, 
+if you are not going to use it - disable this define.*/
+#define _USE_COMPLETE
+
+/*Define it, if you wanna use history. It s work's like bash history, and
+set stored value to cmdline, if UP and DOWN key pressed. Using history add
+memory consuming, depends from _RING_HISTORY_LEN parametr */
+#define _USE_HISTORY
+
+/*
+History ring buffer length, define static buffer size.
+For saving memory, each entered cmdline store to history in ring buffer,
+so we can not say, how many line we can store, it depends from cmdline len,
+but memory using more effective. We not prefer dinamic memory allocation for
+small and embedded devices. Overhead is 2 char on each saved line*/
+#define _RING_HISTORY_LEN 64
+
+/*
+Enable Handling terminal ESC sequence. If disabling, then cursor arrow, HOME, END will not work,
+use Ctrl+A(B,F,P,N,A,E,H,K,U,C) see README, but decrease code memory.*/
+#define _USE_ESC_SEQ
+
+/*
+Use snprintf from you standard complier library, but it gives some overhead.
+If not defined, use my own u16int_to_str variant, it's save about 800 byte of code size
+on AVR (avr-gcc build).
+Try to build with and without, and compare total code size for tune library.
+*/
+#define _USE_LIBC_STDIO
+
+/*
+Enable 'interrupt signal' callback, if user press Ctrl+C */
+#define _USE_CTLR_C
+
+/*
+Print prompt at 'microrl_init', if enable, prompt will print at startup, 
+otherwise first prompt will print after first press Enter in terminal
+NOTE!: Enable it, if you call 'microrl_init' after your communication subsystem 
+already initialize and ready to print message */
+#undef _ENABLE_INIT_PROMPT
+
+/*
+New line symbol */
+#define _ENDL_CR
+
+#if defined(_ENDL_CR)
+#define ENDL "\r"
+#elif defined(_ENDL_CRLF)
+#define ENDL "\r\n"
+#elif defined(_ENDL_LF)
+#define ENDL "\n"
+#elif defined(_ENDL_LFCR)
+#define ENDL "\n\r"
+#else
+#error "You must define new line symbol."
+#endif
+
+/********** END CONFIG SECTION ************/
+
+
+#if _RING_HISTORY_LEN > 256
+#error "This history implementation (ring buffer with 1 byte iterator) allow 256 byte buffer size maximum"
+#endif
+
+#endif

+ 680 - 0
iap/Modules/Console/microrl.c

@@ -0,0 +1,680 @@
+/**
+Author: Samoylov Eugene aka Helius (ghelius@gmail.com)
+BUGS and TODO:
+-- add echo_off feature
+-- rewrite history for use more than 256 byte buffer
+*/
+
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include "microrl.h"
+#ifdef _USE_LIBC_STDIO
+#include <stdio.h>
+#endif
+
+//#define DBG(...) fprintf(stderr, "\033[33m");fprintf(stderr,__VA_ARGS__);fprintf(stderr,"\033[0m");
+
+char * prompt_default = _PROMPT_DEFAULT;
+
+#ifdef _USE_HISTORY
+
+#ifdef _HISTORY_DEBUG
+//*****************************************************************************
+// print buffer content on screen
+static void print_hist (ring_history_t * pThis)
+{
+	printf ("\n");
+	for (int i = 0; i < _RING_HISTORY_LEN; i++) {
+		if (i == pThis->begin)
+			printf ("b");
+		else 
+			printf (" ");
+	}
+	printf ("\n");
+	for (int i = 0; i < _RING_HISTORY_LEN; i++) {
+		if (isalpha(pThis->ring_buf[i]))
+			printf ("%c", pThis->ring_buf[i]);
+		else 
+			printf ("%d", pThis->ring_buf[i]);
+	}
+	printf ("\n");
+	for (int i = 0; i < _RING_HISTORY_LEN; i++) {
+		if (i == pThis->end)
+			printf ("e");
+		else 
+			printf (" ");
+	}
+	printf ("\n");
+}
+#endif
+
+//*****************************************************************************
+// remove older message from ring buffer
+static void hist_erase_older (ring_history_t * pThis)
+{
+	int new_pos = pThis->begin + pThis->ring_buf [pThis->begin] + 1;
+	if (new_pos >= _RING_HISTORY_LEN)
+		new_pos = new_pos - _RING_HISTORY_LEN;
+	
+	pThis->begin = new_pos;
+}
+
+//*****************************************************************************
+// check space for new line, remove older while not space
+static int hist_is_space_for_new (ring_history_t * pThis, int len)
+{
+	if (pThis->ring_buf [pThis->begin] == 0)
+		return true;
+	if (pThis->end >= pThis->begin) {
+		if (_RING_HISTORY_LEN - pThis->end + pThis->begin - 1 > len)
+			return true;
+	}	else {
+		if (pThis->begin - pThis->end - 1> len)
+			return true;
+	}
+	return false;
+}
+
+//*****************************************************************************
+// put line to ring buffer
+static void hist_save_line (ring_history_t * pThis, char * line, int len)
+{
+	if (len > _RING_HISTORY_LEN - 2)
+		return;
+	while (!hist_is_space_for_new (pThis, len)) {
+		hist_erase_older (pThis);
+	}
+	// if it's first line
+	if (pThis->ring_buf [pThis->begin] == 0) 
+		pThis->ring_buf [pThis->begin] = len;
+	
+	// store line
+	if (len < _RING_HISTORY_LEN-pThis->end-1)
+		memcpy (pThis->ring_buf + pThis->end + 1, line, len);
+	else {
+		int part_len = _RING_HISTORY_LEN-pThis->end-1;
+		memcpy (pThis->ring_buf + pThis->end + 1, line, part_len);
+		memcpy (pThis->ring_buf, line + part_len, len - part_len);
+	}
+	pThis->ring_buf [pThis->end] = len;
+	pThis->end = pThis->end + len + 1;
+	if (pThis->end >= _RING_HISTORY_LEN)
+		pThis->end -= _RING_HISTORY_LEN;
+	pThis->ring_buf [pThis->end] = 0;
+	pThis->cur = 0;
+#ifdef _HISTORY_DEBUG
+	print_hist (pThis);
+#endif
+}
+
+//*****************************************************************************
+// copy saved line to 'line' and return size of line
+static int hist_restore_line (ring_history_t * pThis, char * line, int dir)
+{
+	int cnt = 0;
+	// count history record	
+	int header = pThis->begin;
+	while (pThis->ring_buf [header] != 0) {
+		header += pThis->ring_buf [header] + 1;
+		if (header >= _RING_HISTORY_LEN)
+			header -= _RING_HISTORY_LEN; 
+		cnt++;
+	}
+
+	if (dir == _HIST_UP) {
+		if (cnt >= pThis->cur) {
+			int header = pThis->begin;
+			int j = 0;
+			// found record for 'pThis->cur' index
+			while ((pThis->ring_buf [header] != 0) && (cnt - j -1 != pThis->cur)) {
+				header += pThis->ring_buf [header] + 1;
+				if (header >= _RING_HISTORY_LEN)
+					header -= _RING_HISTORY_LEN;
+				j++;
+			}
+			if (pThis->ring_buf[header]) {
+					pThis->cur++;
+				// obtain saved line
+				if (pThis->ring_buf [header] + header < _RING_HISTORY_LEN) {
+					memset (line, 0, _COMMAND_LINE_LEN);
+					memcpy (line, pThis->ring_buf + header + 1, pThis->ring_buf[header]);
+				} else {
+					int part0 = _RING_HISTORY_LEN - header - 1;
+					memset (line, 0, _COMMAND_LINE_LEN);
+					memcpy (line, pThis->ring_buf + header + 1, part0);
+					memcpy (line + part0, pThis->ring_buf, pThis->ring_buf[header] - part0);
+				}
+				return pThis->ring_buf[header];
+			}
+		}
+	} else {
+		if (pThis->cur > 0) {
+				pThis->cur--;
+			int header = pThis->begin;
+			int j = 0;
+
+			while ((pThis->ring_buf [header] != 0) && (cnt - j != pThis->cur)) {
+				header += pThis->ring_buf [header] + 1;
+				if (header >= _RING_HISTORY_LEN)
+					header -= _RING_HISTORY_LEN;
+				j++;
+			}
+			if (pThis->ring_buf [header] + header < _RING_HISTORY_LEN) {
+				memcpy (line, pThis->ring_buf + header + 1, pThis->ring_buf[header]);
+			} else {
+				int part0 = _RING_HISTORY_LEN - header - 1;
+				memcpy (line, pThis->ring_buf + header + 1, part0);
+				memcpy (line + part0, pThis->ring_buf, pThis->ring_buf[header] - part0);
+			}
+			return pThis->ring_buf[header];
+		} else {
+			/* empty line */
+			return 0;
+		}
+	}
+	return -1;
+}
+#endif
+
+
+
+
+
+
+
+
+//*****************************************************************************
+// split cmdline to tkn array and return nmb of token
+static int split (microrl_t * pThis, int limit, char const ** tkn_arr)
+{
+	int i = 0;
+	int ind = 0;
+	while (1) {
+		// go to the first whitespace (zerro for us)
+		while ((pThis->cmdline [ind] == '\0') && (ind < limit)) {
+			ind++;
+		}
+		if (!(ind < limit)) return i;
+		tkn_arr[i++] = pThis->cmdline + ind;
+		if (i >= _COMMAND_TOKEN_NMB) {
+			return -1;
+		}
+		// go to the first NOT whitespace (not zerro for us)
+		while ((pThis->cmdline [ind] != '\0') && (ind < limit)) {
+			ind++;
+		}
+		if (!(ind < limit)) return i;
+	}
+	return i;
+}
+
+
+//*****************************************************************************
+inline static void print_prompt (microrl_t * pThis)
+{
+	pThis->print (pThis->prompt_str);
+}
+
+//*****************************************************************************
+inline static void terminal_backspace (microrl_t * pThis)
+{
+		pThis->print ("\033[D \033[D");
+}
+
+//*****************************************************************************
+inline static void terminal_newline (microrl_t * pThis)
+{
+	pThis->print (ENDL);
+}
+
+#ifndef _USE_LIBC_STDIO
+//*****************************************************************************
+// convert 16 bit value to string
+// 0 value not supported!!! just make empty string
+// Returns pointer to a buffer tail
+static char *u16bit_to_str (unsigned int nmb, char * buf)
+{
+	char tmp_str [6] = {0,};
+	int i = 0, j;
+	if (nmb <= 0xFFFF) {
+		while (nmb > 0) {
+			tmp_str[i++] = (nmb % 10) + '0';
+			nmb /=10;
+		}
+		for (j = 0; j < i; ++j)
+			*(buf++) = tmp_str [i-j-1];
+	}
+	*buf = '\0';
+	return buf;
+}
+#endif
+
+
+//*****************************************************************************
+// set cursor at position from begin cmdline (after prompt) + offset
+static void terminal_move_cursor (microrl_t * pThis, int offset)
+{
+	char str[16] = {0,};
+#ifdef _USE_LIBC_STDIO 
+	if (offset > 0) {
+		snprintf (str, 16, "\033[%dC", offset);
+	} else if (offset < 0) {
+		snprintf (str, 16, "\033[%dD", -(offset));
+	}
+#else 
+	char *endstr;
+	strcpy (str, "\033[");
+	if (offset > 0) {
+		endstr = u16bit_to_str (offset, str+2);
+		strcpy (endstr, "C");
+	} else if (offset < 0) {
+		endstr = u16bit_to_str (-(offset), str+2);
+		strcpy (endstr, "D");
+	} else
+		return;
+#endif	
+	pThis->print (str);
+}
+
+//*****************************************************************************
+static void terminal_reset_cursor (microrl_t * pThis)
+{
+	char str[16];
+#ifdef _USE_LIBC_STDIO
+	snprintf (str, 16, "\033[%dD\033[%dC", \
+						_COMMAND_LINE_LEN + _PROMPT_LEN + 2, _PROMPT_LEN);
+
+#else
+	char *endstr;
+	strcpy (str, "\033[");
+	endstr = u16bit_to_str ( _COMMAND_LINE_LEN + _PROMPT_LEN + 2,str+2);
+	strcpy (endstr, "D\033["); endstr += 3;
+	endstr = u16bit_to_str (_PROMPT_LEN, endstr);
+	strcpy (endstr, "C");
+#endif
+	pThis->print (str);
+}
+
+//*****************************************************************************
+// print cmdline to screen, replace '\0' to wihitespace 
+static void terminal_print_line (microrl_t * pThis, int pos, int cursor)
+{
+	pThis->print ("\033[K");    // delete all from cursor to end
+
+	char nch [] = {0,0};
+	int i;
+	for (i = pos; i < pThis->cmdlen; i++) {
+		nch [0] = pThis->cmdline [i];
+		if (nch[0] == '\0')
+			nch[0] = ' ';
+		pThis->print (nch);
+	}
+	
+	terminal_reset_cursor (pThis);
+	terminal_move_cursor (pThis, cursor);
+}
+
+//*****************************************************************************
+void microrl_init (microrl_t * pThis, void (*print) (const char *)) 
+{
+	memset(pThis->cmdline, 0, _COMMAND_LINE_LEN);
+#ifdef _USE_HISTORY
+	memset(pThis->ring_hist.ring_buf, 0, _RING_HISTORY_LEN);
+	pThis->ring_hist.begin = 0;
+	pThis->ring_hist.end = 0;
+	pThis->ring_hist.cur = 0;
+#endif
+	pThis->cmdlen =0;
+	pThis->cursor = 0;
+	pThis->execute = NULL;
+	pThis->get_completion = NULL;
+#ifdef _USE_CTLR_C
+	pThis->sigint = NULL;
+#endif
+	pThis->prompt_str = prompt_default;
+	pThis->print = print;
+#ifdef _ENABLE_INIT_PROMPT
+	print_prompt (pThis);
+#endif
+}
+
+//*****************************************************************************
+void microrl_set_complete_callback (microrl_t * pThis, char ** (*get_completion)(int, const char* const*))
+{
+	pThis->get_completion = get_completion;
+}
+
+//*****************************************************************************
+void microrl_set_execute_callback (microrl_t * pThis, int (*execute)(int, const char* const*))
+{
+	pThis->execute = execute;
+}
+#ifdef _USE_CTLR_C
+//*****************************************************************************
+void microrl_set_sigint_callback (microrl_t * pThis, void (*sigintf)(void))
+{
+	pThis->sigint = sigintf;
+}
+#endif
+
+#ifdef _USE_ESC_SEQ
+static void hist_search (microrl_t * pThis, int dir)
+{
+	int len = hist_restore_line (&pThis->ring_hist, pThis->cmdline, dir);
+	if (len >= 0) {
+		pThis->cursor = pThis->cmdlen = len;
+		terminal_reset_cursor (pThis);
+		terminal_print_line (pThis, 0, pThis->cursor);
+	}
+}
+
+//*****************************************************************************
+// handling escape sequences
+static int escape_process (microrl_t * pThis, char ch)
+{
+	if (ch == '[') {
+		pThis->escape_seq = _ESC_BRACKET;
+		return 0;
+	} else if (pThis->escape_seq == _ESC_BRACKET) {
+		if (ch == 'A') {
+#ifdef _USE_HISTORY
+			hist_search (pThis, _HIST_UP);
+#endif
+			return 1;
+		} else if (ch == 'B') {
+#ifdef _USE_HISTORY
+			hist_search (pThis, _HIST_DOWN);
+#endif
+			return 1;
+		} else if (ch == 'C') {
+			if (pThis->cursor < pThis->cmdlen) {
+				terminal_move_cursor (pThis, 1);
+				pThis->cursor++;
+			}
+			return 1;
+		} else if (ch == 'D') {
+			if (pThis->cursor > 0) {
+				terminal_move_cursor (pThis, -1);
+				pThis->cursor--;
+			}
+			return 1;
+		} else if (ch == '7') {
+			pThis->escape_seq = _ESC_HOME;
+			return 0;
+		} else if (ch == '8') {
+			pThis->escape_seq = _ESC_END;
+			return 0;
+		} 
+	} else if (ch == '~') {
+		if (pThis->escape_seq == _ESC_HOME) {
+			terminal_reset_cursor (pThis);
+			pThis->cursor = 0;
+			return 1;
+		} else if (pThis->escape_seq == _ESC_END) {
+			terminal_move_cursor (pThis, pThis->cmdlen-pThis->cursor);
+			pThis->cursor = pThis->cmdlen;
+			return 1;
+		}
+	}
+
+	/* unknown escape sequence, stop */
+	return 1;
+}
+#endif
+
+//*****************************************************************************
+// insert len char of text at cursor position
+static int microrl_insert_text (microrl_t * pThis, char * text, int len)
+{
+	int i;
+	if (pThis->cmdlen + len < _COMMAND_LINE_LEN) {
+		memmove (pThis->cmdline + pThis->cursor + len,
+						 pThis->cmdline + pThis->cursor,
+						 pThis->cmdlen - pThis->cursor);
+		for (i = 0; i < len; i++) {
+			pThis->cmdline [pThis->cursor + i] = text [i];
+			if (pThis->cmdline [pThis->cursor + i] == ' ') {
+				pThis->cmdline [pThis->cursor + i] = 0;
+			}
+		}
+		pThis->cursor += len;
+		pThis->cmdlen += len;
+		pThis->cmdline [pThis->cmdlen] = '\0';
+		return true;
+	}
+	return false;
+}
+
+//*****************************************************************************
+// remove one char at cursor
+static void microrl_backspace (microrl_t * pThis)
+{
+	if (pThis->cursor > 0) {
+		terminal_backspace (pThis);
+		memmove (pThis->cmdline + pThis->cursor-1,
+						 pThis->cmdline + pThis->cursor,
+						 pThis->cmdlen-pThis->cursor+1);
+		pThis->cursor--;
+		pThis->cmdline [pThis->cmdlen] = '\0';
+		pThis->cmdlen--;
+	}
+}
+
+
+#ifdef _USE_COMPLETE
+
+//*****************************************************************************
+static int common_len (char ** arr)
+{
+	int len = 0;
+	int i = 1;
+	while (1) {
+		while (arr[i]!=NULL) {
+			if ((arr[i][len] != arr[i-1][len]) || 
+					(arr[i][len] == '\0') || 
+					(arr[i-1][len]=='\0')) 
+				return len;
+			len++;
+		}
+		i++;
+	}
+	return 0;
+}
+
+//*****************************************************************************
+static void microrl_get_complite (microrl_t * pThis) 
+{
+	char const * tkn_arr[_COMMAND_TOKEN_NMB];
+	char ** compl_token; 
+	
+	if (pThis->get_completion == NULL) // callback was not set
+		return;
+	
+	int status = split (pThis, pThis->cursor, tkn_arr);
+	if (pThis->cmdline[pThis->cursor-1] == '\0')
+		tkn_arr[status++] = "";
+	compl_token = pThis->get_completion (status, tkn_arr);
+	if (compl_token[0] != NULL) {
+		int i = 0;
+		int len;
+
+		if (compl_token[1] == NULL) {
+			len = strlen (compl_token[0]);
+		} else {
+			len = common_len (compl_token);
+			terminal_newline (pThis);
+			while (compl_token [i] != NULL) {
+				pThis->print (compl_token[i]);
+				pThis->print (" ");
+				i++;
+			}
+			terminal_newline (pThis);
+			print_prompt (pThis);
+		}
+		
+		if (len) {
+			microrl_insert_text (pThis, compl_token[0] + strlen(tkn_arr[status-1]), 
+																	len - strlen(tkn_arr[status-1]));
+			if (compl_token[1] == NULL) 
+				microrl_insert_text (pThis, " ", 1);
+		}
+		terminal_reset_cursor (pThis);
+		terminal_print_line (pThis, 0, pThis->cursor);
+	} 
+}
+#endif
+
+//*****************************************************************************
+void new_line_handler(microrl_t * pThis){
+	char const * tkn_arr [_COMMAND_TOKEN_NMB];
+	int status;
+
+	terminal_newline (pThis);
+#ifdef _USE_HISTORY
+	if (pThis->cmdlen > 0)
+		hist_save_line (&pThis->ring_hist, pThis->cmdline, pThis->cmdlen);
+#endif
+	status = split (pThis, pThis->cmdlen, tkn_arr);
+	if (status == -1){
+		//          pThis->print ("ERROR: Max token amount exseed\n");
+		pThis->print ("ERROR:too many tokens");
+		pThis->print (ENDL);
+	}
+	if ((status > 0) && (pThis->execute != NULL))
+		pThis->execute (status, tkn_arr);
+	print_prompt (pThis);
+	pThis->cmdlen = 0;
+	pThis->cursor = 0;
+	memset(pThis->cmdline, 0, _COMMAND_LINE_LEN);
+#ifdef _USE_HISTORY
+	pThis->ring_hist.cur = 0;
+#endif
+}
+
+//*****************************************************************************
+
+void microrl_insert_char (microrl_t * pThis, int ch)
+{
+#ifdef _USE_ESC_SEQ
+	if (pThis->escape) {
+		if (escape_process(pThis, ch))
+			pThis->escape = 0;
+	} else {
+#endif
+		switch (ch) {
+			//-----------------------------------------------------
+#ifdef _ENDL_CR
+			case KEY_CR:
+				new_line_handler(pThis);
+			break;
+			case KEY_LF:
+			break;
+#elif defined(_ENDL_CRLF)
+			case KEY_CR:
+				pThis->tmpch = KEY_CR;
+			break;
+			case KEY_LF:
+			if (pThis->tmpch == KEY_CR)
+				new_line_handler(pThis);
+			break;
+#elif defined(_ENDL_LFCR)
+			case KEY_LF:
+				pThis->tmpch = KEY_LF;
+			break;
+			case KEY_CR:
+			if (pThis->tmpch == KEY_LF)
+				new_line_handler(pThis);
+			break;
+#else
+			case KEY_CR:
+			break;
+			case KEY_LF:
+				new_line_handler(pThis);
+			break;
+#endif
+			//-----------------------------------------------------
+#ifdef _USE_COMPLETE
+			case KEY_HT:
+				microrl_get_complite (pThis);
+			break;
+#endif
+			//-----------------------------------------------------
+			case KEY_ESC:
+#ifdef _USE_ESC_SEQ
+				pThis->escape = 1;
+#endif
+			break;
+			//-----------------------------------------------------
+			case KEY_NAK: // ^U
+					while (pThis->cursor > 0) {
+					microrl_backspace (pThis);
+				}
+				terminal_print_line (pThis, 0, pThis->cursor);
+			break;
+			//-----------------------------------------------------
+			case KEY_VT:  // ^K
+				pThis->print ("\033[K");
+				pThis->cmdlen = pThis->cursor;
+			break;
+			//-----------------------------------------------------
+			case KEY_ENQ: // ^E
+				terminal_move_cursor (pThis, pThis->cmdlen-pThis->cursor);
+				pThis->cursor = pThis->cmdlen;
+			break;
+			//-----------------------------------------------------
+			case KEY_SOH: // ^A
+				terminal_reset_cursor (pThis);
+				pThis->cursor = 0;
+			break;
+			//-----------------------------------------------------
+			case KEY_ACK: // ^F
+			if (pThis->cursor < pThis->cmdlen) {
+				terminal_move_cursor (pThis, 1);
+				pThis->cursor++;
+			}
+			break;
+			//-----------------------------------------------------
+			case KEY_STX: // ^B
+			if (pThis->cursor) {
+				terminal_move_cursor (pThis, -1);
+				pThis->cursor--;
+			}
+			break;
+			//-----------------------------------------------------
+			case KEY_DLE: //^P
+#ifdef _USE_HISTORY
+			hist_search (pThis, _HIST_UP);
+#endif
+			break;
+			//-----------------------------------------------------
+			case KEY_SO: //^N
+#ifdef _USE_HISTORY
+			hist_search (pThis, _HIST_DOWN);
+#endif
+			break;
+			//-----------------------------------------------------
+			case KEY_DEL: // Backspace
+			case KEY_BS: // ^U
+				microrl_backspace (pThis);
+				terminal_print_line (pThis, pThis->cursor, pThis->cursor);
+			break;
+#ifdef _USE_CTLR_C
+			case KEY_ETX:
+			if (pThis->sigint != NULL)
+				pThis->sigint();
+			break;
+#endif
+			//-----------------------------------------------------
+			default:
+			if (((ch == ' ') && (pThis->cmdlen == 0)) || IS_CONTROL_CHAR(ch))
+				break;
+			if (microrl_insert_text (pThis, (char*)&ch, 1))
+				terminal_print_line (pThis, pThis->cursor-1, pThis->cursor);
+			
+			break;
+		}
+#ifdef _USE_ESC_SEQ
+	}
+#endif
+}

+ 118 - 0
iap/Modules/Console/microrl.h

@@ -0,0 +1,118 @@
+
+#ifndef MICRORL_H_
+#define MICRORL_H_
+
+#include "config.h"
+
+#define true  1
+#define false 0
+
+ /* define the Key codes */
+#define KEY_NUL 0 /**< ^@ Null character */
+#define KEY_SOH 1 /**< ^A Start of heading, = console interrupt */
+#define KEY_STX 2 /**< ^B Start of text, maintenance mode on HP console */
+#define KEY_ETX 3 /**< ^C End of text */
+#define KEY_EOT 4 /**< ^D End of transmission, not the same as ETB */
+#define KEY_ENQ 5 /**< ^E Enquiry, goes with ACK; old HP flow control */
+#define KEY_ACK 6 /**< ^F Acknowledge, clears ENQ logon hand */
+#define KEY_BEL 7 /**< ^G Bell, rings the bell... */
+#define KEY_BS  8 /**< ^H Backspace, works on HP terminals/computers */
+#define KEY_HT  9 /**< ^I Horizontal tab, move to next tab stop */
+#define KEY_LF  10  /**< ^J Line Feed */
+#define KEY_VT  11  /**< ^K Vertical tab */
+#define KEY_FF  12  /**< ^L Form Feed, page eject */
+#define KEY_CR  13  /**< ^M Carriage Return*/
+#define KEY_SO  14  /**< ^N Shift Out, alternate character set */
+#define KEY_SI  15  /**< ^O Shift In, resume defaultn character set */
+#define KEY_DLE 16  /**< ^P Data link escape */
+#define KEY_DC1 17  /**< ^Q XON, with XOFF to pause listings; "okay to send". */
+#define KEY_DC2 18  /**< ^R Device control 2, block-mode flow control */
+#define KEY_DC3 19  /**< ^S XOFF, with XON is TERM=18 flow control */
+#define KEY_DC4 20  /**< ^T Device control 4 */
+#define KEY_NAK 21  /**< ^U Negative acknowledge */
+#define KEY_SYN 22  /**< ^V Synchronous idle */
+#define KEY_ETB 23  /**< ^W End transmission block, not the same as EOT */
+#define KEY_CAN 24  /**< ^X Cancel line, MPE echoes !!! */
+#define KEY_EM  25  /**< ^Y End of medium, Control-Y interrupt */
+#define KEY_SUB 26  /**< ^Z Substitute */
+#define KEY_ESC 27  /**< ^[ Escape, next character is not echoed */
+#define KEY_FS  28  /**< ^\ File separator */
+#define KEY_GS  29  /**< ^] Group separator */
+#define KEY_RS  30  /**< ^^ Record separator, block-mode terminator */
+#define KEY_US  31  /**< ^_ Unit separator */
+
+#define KEY_DEL 127 /**< Delete (not a real control character...) */
+
+#define IS_CONTROL_CHAR(x) ((x)<=31)
+
+// direction of history navigation
+#define _HIST_UP   0
+#define _HIST_DOWN 1
+// esc seq internal codes
+#define _ESC_BRACKET  1
+#define _ESC_HOME     2
+#define _ESC_END      3
+
+#ifdef _USE_HISTORY
+// history struct, contain internal variable
+// history store in static ring buffer for memory saving
+typedef struct {
+	char ring_buf [_RING_HISTORY_LEN];
+	int begin;
+	int end;
+	int cur;
+} ring_history_t;
+#endif
+
+// microrl struct, contain internal library data
+typedef struct {
+#ifdef _USE_ESC_SEQ
+	char escape_seq;
+	char escape;
+#endif
+#if (defined(_ENDL_CRLF) || defined(_ENDL_LFCR))
+	char tmpch;
+#endif
+#ifdef _USE_HISTORY
+	ring_history_t ring_hist;          // history object
+#endif
+	char * prompt_str;                 // pointer to prompt string
+	char cmdline [_COMMAND_LINE_LEN];  // cmdline buffer
+	int cmdlen;                        // last position in command line
+	int cursor;                        // input cursor
+	int (*execute) (int argc, const char * const * argv );            // ptr to 'execute' callback
+	char ** (*get_completion) (int argc, const char * const * argv ); // ptr to 'completion' callback
+	void (*print) (const char *);                                     // ptr to 'print' callback
+#ifdef _USE_CTLR_C
+	void (*sigint) (void);
+#endif
+} microrl_t;
+
+// init internal data, calls once at start up
+void microrl_init (microrl_t * pThis, void (*print)(const char*));
+
+// set echo mode (true/false), using for disabling echo for password input
+// echo mode will enabled after user press Enter.
+void microrl_set_echo (int);
+
+// set pointer to callback complition func, that called when user press 'Tab'
+// callback func description:
+//   param: argc - argument count, argv - pointer array to token string
+//   must return NULL-terminated string, contain complite variant splitted by 'Whitespace'
+//   If complite token found, it's must contain only one token to be complitted
+//   Empty string if complite not found, and multiple string if there are some token
+void microrl_set_complete_callback (microrl_t * pThis, char ** (*get_completion)(int, const char* const*));
+
+// pointer to callback func, that called when user press 'Enter'
+// execute func param: argc - argument count, argv - pointer array to token string
+void microrl_set_execute_callback (microrl_t * pThis, int (*execute)(int, const char* const*));
+
+// set callback for Ctrl+C terminal signal
+#ifdef _USE_CTLR_C
+void microrl_set_sigint_callback (microrl_t * pThis, void (*sigintf)(void));
+#endif
+
+// insert char to cmdline (for example call in usart RX interrupt)
+void microrl_insert_char (microrl_t * pThis, int ch);
+
+#endif

+ 137 - 0
iap/Modules/Console/port_microrl.c

@@ -0,0 +1,137 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  Console
+ * @file    portConsole.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Port functions console lib
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+#include "stm32f4xx.h" 
+#include "port_microrl.h"
+#include "microrl.h"
+#include "config.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+
+#include "dac.h"
+
+microrl_t rl;
+microrl_t *prl = &rl;
+
+/*
+AVR platform specific implementation routines (for Atmega8, rewrite for your MC)
+*/
+#define _AVR_DEMO_VER "1.0"
+
+// definition commands word
+#define _CMD_HELP   "help"
+#define _CMD_CLEAR  "clear"
+#define _CMD_CLR    "clear_port"
+#define _CMD_SET    "set_port"
+
+#define _CMD_DAC_SEND_TEST_VAL  "dac"
+
+// arguments for set/clear
+#define _SCMD_PB  "port_b"
+#define _SCMD_PD  "port_d"
+
+#define _NUM_OF_CMD 5
+#define _NUM_OF_SETCLEAR_SCMD 2
+
+//available  commands
+char * keyworld [] = {
+  _CMD_HELP,
+  _CMD_CLEAR,
+  _CMD_SET,
+  _CMD_CLR,
+  _CMD_DAC_SEND_TEST_VAL};
+
+// 'set/clear' command argements
+char * set_clear_key [] = {_SCMD_PB, _SCMD_PD};
+
+// array for comletion
+char * compl_world [_NUM_OF_CMD + 1];
+
+/**
+  * @brief  
+  * @retval 
+  */
+void MICRORL_Init(void)
+{
+  microrl_init(prl, print);
+  microrl_set_execute_callback (prl, execute);
+  
+}
+
+/**
+  * @brief  Print callback for microrl library
+  * @retval 
+  */
+void print (const char *str)
+{
+  printf(str);
+}
+
+/**
+  * @brief  
+  * @retval 
+  */
+void MICRORL_GetChar(uint8_t ch)
+{
+  microrl_insert_char(prl, ch);
+}
+
+//*****************************************************************************
+// execute callback for microrl library
+// do what you want here, but don't write to argv!!! read only!!
+int execute (int argc, const char * const * argv)
+{
+	int i = 0;
+	// just iterate through argv word and compare it with your commands
+	while (i < argc) {
+		if (strcmp (argv[i], _CMD_HELP) == 0) 
+                {
+ 		  print ("microrl library v");
+		  print (MICRORL_LIB_VER);
+		  print ("\n\r");
+		  print_help ();        // print help
+		} 
+                else if (strcmp (argv[i], _CMD_CLEAR) == 0) 
+                {
+		  print ("\033[2J");    // ESC seq for clear entire screen
+		  print ("\033[H");     // ESC seq for move cursor at left-top corner
+		}  
+                else if (strcmp (argv[i], _CMD_DAC_SEND_TEST_VAL) == 0) 
+                {
+                  uint16_t val;
+                  if (++i < argc)
+                  {
+                    val = atoi (argv[i]);
+                    DAC_SendRawData(val);
+		    return 0;
+                  }  
+		}                
+                else 
+                {
+		  print ("command: '");
+		  print ((char*)argv[i]);
+		  print ("' Not found.\n\r");
+		}
+		i++;
+	}
+	return 0;
+}
+
+void print_help (void)
+{
+	print ("Use TAB key for completion\n\rCommand:\n\r");
+	print ("\tclear               - clear screen\n\r");
+        print ("\tdac                 - send test value\n\r");
+}
+
+/******************************* (C) LiteMesh *********************************/

+ 38 - 0
iap/Modules/Console/port_microrl.h

@@ -0,0 +1,38 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  Console
+ * @file    portConsole.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Port functions console lib
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef PORT_MICRORL_H
+#define PORT_MICRORL_H
+ 
+/**
+  * @brief  
+  */
+void MICRORL_Init(void);
+
+/**
+  * @brief  
+  */
+void MICRORL_GetChar(uint8_t ch);
+
+/**
+  * @brief  Print callback for microrl library
+  */
+void print (const char * str);
+
+int execute (int argc, const char * const * argv);
+
+void print_help (void);
+
+#endif /* #ifndef PORTCONSOLE_H */
+
+/****************************** (C) LiteMesh ***************** end of file ****/

+ 579 - 0
iap/Modules/Ethernet/fsdata.c

@@ -0,0 +1,579 @@
+#include "lwip/def.h"
+#include "fsdata.h"
+
+
+#define file_NULL (struct fsdata_file *) NULL
+
+
+static const unsigned int dummy_align__error_html = 0;
+static const unsigned char data__error_html[] = {
+/* /error.html (12 chars) */
+0x2f,0x65,0x72,0x72,0x6f,0x72,0x2e,0x68,0x74,0x6d,0x6c,0x00,
+
+/* HTTP header */
+/* "HTTP/1.0 200 OK
+" (17 bytes) */
+0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d,
+0x0a,
+/* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)
+" (63 bytes) */
+0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33,
+0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
+0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
+0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
+/* "Content-type: text/html
+
+" (27 bytes) */
+0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
+0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a,
+/* raw file data (850 bytes) */
+0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50,0x45,0x20,0x68,0x74,0x6d,0x6c,0x3e,0x3c,
+0x68,0x74,0x6d,0x6c,0x20,0x6c,0x61,0x6e,0x67,0x3d,0x22,0x22,0x3e,0x3c,0x68,0x65,
+0x61,0x64,0x3e,0x3c,0x6d,0x65,0x74,0x61,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,
+0x3d,0x22,0x75,0x74,0x66,0x2d,0x38,0x22,0x3e,0x3c,0x6d,0x65,0x74,0x61,0x20,0x68,
+0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69,0x76,0x3d,0x22,0x58,0x2d,0x55,0x41,0x2d,
+0x43,0x6f,0x6d,0x70,0x61,0x74,0x69,0x62,0x6c,0x65,0x22,0x20,0x63,0x6f,0x6e,0x74,
+0x65,0x6e,0x74,0x3d,0x22,0x49,0x45,0x3d,0x65,0x64,0x67,0x65,0x22,0x3e,0x3c,0x6d,
+0x65,0x74,0x61,0x20,0x6e,0x61,0x6d,0x65,0x3d,0x22,0x76,0x69,0x65,0x77,0x70,0x6f,
+0x72,0x74,0x22,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x77,0x69,0x64,
+0x74,0x68,0x3d,0x64,0x65,0x76,0x69,0x63,0x65,0x2d,0x77,0x69,0x64,0x74,0x68,0x2c,
+0x69,0x6e,0x69,0x74,0x69,0x61,0x6c,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,
+0x6d,0x61,0x78,0x69,0x6d,0x75,0x6d,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,
+0x75,0x73,0x65,0x72,0x2d,0x73,0x63,0x61,0x6c,0x61,0x62,0x6c,0x65,0x3d,0x30,0x22,
+0x3e,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x74,0x79,0x6c,
+0x65,0x73,0x68,0x65,0x65,0x74,0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x75,0x70,
+0x6c,0x6f,0x61,0x64,0x2e,0x63,0x73,0x73,0x22,0x3e,0x3c,0x74,0x69,0x74,0x6c,0x65,
+0x3e,0xd0,0x9e,0xd1,0x88,0xd0,0xb8,0xd0,0xb1,0xd0,0xba,0xd0,0xb0,0x20,0xd0,0xbe,
+0xd0,0xb1,0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,
+0xd1,0x8f,0x3c,0x2f,0x74,0x69,0x74,0x6c,0x65,0x3e,0x3c,0x2f,0x68,0x65,0x61,0x64,
+0x3e,0x3c,0x62,0x6f,0x64,0x79,0x3e,0x3c,0x6e,0x61,0x76,0x20,0x63,0x6c,0x61,0x73,
+0x73,0x3d,0x22,0x6e,0x61,0x76,0x62,0x61,0x72,0x22,0x3e,0x3c,0x2f,0x6e,0x61,0x76,
+0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x77,0x72,0x61,
+0x70,0x70,0x65,0x72,0x22,0x3e,0x3c,0x68,0x31,0x3e,0xd0,0x9e,0xd0,0xb1,0xd0,0xbd,
+0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,0x20,0xd0,
+0xbf,0xd1,0x80,0xd0,0xbe,0xd1,0x88,0xd0,0xb8,0xd0,0xb2,0xd0,0xba,0xd0,0xb8,0x3c,
+0x2f,0x68,0x31,0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,
+0x75,0x70,0x6c,0x6f,0x61,0x64,0x2d,0x66,0x6f,0x72,0x6d,0x22,0x3e,0x3c,0x64,0x69,
+0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x67,0x75,0x69,0x64,0x65,0x22,0x20,
+0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x74,0x65,0x78,0x74,0x2d,0x61,0x6c,0x69,0x67,
+0x6e,0x3a,0x63,0x65,0x6e,0x74,0x65,0x72,0x22,0x3e,0x3c,0x70,0x20,0x73,0x74,0x79,
+0x6c,0x65,0x3d,0x22,0x63,0x6f,0x6c,0x6f,0x72,0x3a,0x23,0x64,0x39,0x35,0x33,0x34,
+0x66,0x22,0x3e,0x3c,0x62,0x3e,0xd0,0x9f,0xd1,0x80,0xd0,0xb8,0x20,0xd0,0xbe,0xd0,
+0xb1,0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,
+0xb8,0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd0,0xb3,0xd1,0x80,0xd0,0xb0,0xd0,0xbc,
+0xd0,0xbc,0xd0,0xbd,0xd0,0xbe,0xd0,0xb3,0xd0,0xbe,0x20,0xd0,0xbe,0xd0,0xb1,0xd0,
+0xb5,0xd1,0x81,0xd0,0xbf,0xd0,0xb5,0xd1,0x87,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd1,
+0x8f,0x20,0xd0,0xb2,0xd0,0xbe,0xd0,0xb7,0xd0,0xbd,0xd0,0xb8,0xd0,0xba,0xd0,0xbb,
+0xd0,0xb0,0x20,0xd0,0xbe,0xd1,0x88,0xd0,0xb8,0xd0,0xb1,0xd0,0xba,0xd0,0xb0,0x2e,
+0x3c,0x2f,0x62,0x3e,0x3c,0x62,0x72,0x3e,0xd0,0x9f,0xd0,0xbe,0xd0,0xb6,0xd0,0xb0,
+0xd0,0xbb,0xd1,0x83,0xd0,0xb9,0xd1,0x81,0xd1,0x82,0xd0,0xb0,0x2c,0x20,0xd0,0xbf,
+0xd0,0xbe,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd0,0xb1,0xd1,0x83,0xd0,0xb9,0xd1,0x82,
+0xd0,0xb5,0x20,0xd0,0xb5,0xd1,0x89,0xd1,0x91,0x20,0xd1,0x80,0xd0,0xb0,0xd0,0xb7,
+0x20,0xd1,0x87,0xd0,0xb5,0xd1,0x80,0xd0,0xb5,0xd0,0xb7,0x20,0x3c,0x73,0x70,0x61,
+0x6e,0x20,0x69,0x64,0x3d,0x22,0x63,0x6f,0x75,0x6e,0x74,0x2d,0x6e,0x75,0x6d,0x62,
+0x65,0x72,0x22,0x3e,0x35,0x3c,0x2f,0x73,0x70,0x61,0x6e,0x3e,0x20,0xd1,0x81,0xd0,
+0xb5,0xd0,0xba,0xd1,0x83,0xd0,0xbd,0xd0,0xb4,0x3c,0x2f,0x70,0x3e,0x3c,0x2f,0x64,
+0x69,0x76,0x3e,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x3c,0x73,0x63,0x72,0x69,0x70,0x74,
+0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x74,0x65,0x78,0x74,0x2f,0x6a,0x61,0x76,0x61,
+0x73,0x63,0x72,0x69,0x70,0x74,0x22,0x20,0x73,0x72,0x63,0x3d,0x22,0x75,0x70,0x6c,
+0x6f,0x61,0x64,0x2e,0x6a,0x73,0x22,0x3e,0x3c,0x2f,0x73,0x63,0x72,0x69,0x70,0x74,
+0x3e,0x3c,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,0x63,0x6f,0x75,0x6e,0x74,0x64,0x6f,
+0x77,0x6e,0x28,0x29,0x3b,0x3c,0x2f,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,0x3c,0x2f,
+0x64,0x69,0x76,0x3e,0x3c,0x2f,0x62,0x6f,0x64,0x79,0x3e,0x3c,0x2f,0x68,0x74,0x6d,
+0x6c,0x3e,};
+
+static const unsigned int dummy_align__index_html = 1;
+static const unsigned char data__index_html[] = {
+/* /index.html (12 chars) */
+0x2f,0x69,0x6e,0x64,0x65,0x78,0x2e,0x68,0x74,0x6d,0x6c,0x00,
+
+/* HTTP header */
+/* "HTTP/1.0 200 OK
+" (17 bytes) */
+0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d,
+0x0a,
+/* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)
+" (63 bytes) */
+0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33,
+0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
+0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
+0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
+/* "Content-type: text/html
+
+" (27 bytes) */
+0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
+0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a,
+/* raw file data (1711 bytes) */
+0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50,0x45,0x20,0x68,0x74,0x6d,0x6c,0x3e,0x3c,
+0x68,0x74,0x6d,0x6c,0x20,0x6c,0x61,0x6e,0x67,0x3d,0x22,0x22,0x3e,0x3c,0x68,0x65,
+0x61,0x64,0x3e,0x3c,0x6d,0x65,0x74,0x61,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,
+0x3d,0x22,0x75,0x74,0x66,0x2d,0x38,0x22,0x3e,0x3c,0x6d,0x65,0x74,0x61,0x20,0x68,
+0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69,0x76,0x3d,0x22,0x58,0x2d,0x55,0x41,0x2d,
+0x43,0x6f,0x6d,0x70,0x61,0x74,0x69,0x62,0x6c,0x65,0x22,0x20,0x63,0x6f,0x6e,0x74,
+0x65,0x6e,0x74,0x3d,0x22,0x49,0x45,0x3d,0x65,0x64,0x67,0x65,0x22,0x3e,0x3c,0x6d,
+0x65,0x74,0x61,0x20,0x6e,0x61,0x6d,0x65,0x3d,0x22,0x76,0x69,0x65,0x77,0x70,0x6f,
+0x72,0x74,0x22,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x77,0x69,0x64,
+0x74,0x68,0x3d,0x64,0x65,0x76,0x69,0x63,0x65,0x2d,0x77,0x69,0x64,0x74,0x68,0x2c,
+0x69,0x6e,0x69,0x74,0x69,0x61,0x6c,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,
+0x6d,0x61,0x78,0x69,0x6d,0x75,0x6d,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,
+0x75,0x73,0x65,0x72,0x2d,0x73,0x63,0x61,0x6c,0x61,0x62,0x6c,0x65,0x3d,0x30,0x22,
+0x3e,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x74,0x79,0x6c,
+0x65,0x73,0x68,0x65,0x65,0x74,0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x75,0x70,
+0x6c,0x6f,0x61,0x64,0x2e,0x63,0x73,0x73,0x22,0x3e,0x3c,0x74,0x69,0x74,0x6c,0x65,
+0x3e,0xd0,0x9e,0xd0,0xb1,0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,
+0xbd,0xd0,0xb8,0xd0,0xb5,0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd1,0x88,0xd0,0xb8,
+0xd0,0xb2,0xd0,0xba,0xd0,0xb8,0x3c,0x2f,0x74,0x69,0x74,0x6c,0x65,0x3e,0x3c,0x2f,
+0x68,0x65,0x61,0x64,0x3e,0x3c,0x62,0x6f,0x64,0x79,0x3e,0x3c,0x6e,0x61,0x76,0x20,
+0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x6e,0x61,0x76,0x62,0x61,0x72,0x22,0x3e,0x3c,
+0x2f,0x6e,0x61,0x76,0x3e,0x3c,0x64,0x69,0x76,0x20,0x69,0x64,0x3d,0x22,0x63,0x6f,
+0x75,0x6e,0x74,0x2d,0x77,0x72,0x61,0x70,0x22,0x3e,0x3c,0x64,0x69,0x76,0x20,0x69,
+0x64,0x3d,0x22,0x63,0x6f,0x75,0x6e,0x74,0x64,0x6f,0x77,0x6e,0x22,0x3e,0x3c,0x70,
+0x3e,0xd0,0x9a,0xd0,0xbe,0xd0,0xbd,0xd1,0x82,0xd1,0x80,0xd0,0xbe,0xd0,0xbb,0xd0,
+0xbb,0xd0,0xb5,0xd1,0x80,0x20,0xd0,0xb1,0xd1,0x83,0xd0,0xb4,0xd0,0xb5,0xd1,0x82,
+0x20,0xd0,0xbf,0xd0,0xb5,0xd1,0x80,0xd0,0xb5,0xd0,0xb7,0xd0,0xb0,0xd0,0xb3,0xd1,
+0x80,0xd1,0x83,0xd0,0xb6,0xd0,0xb5,0xd0,0xbd,0x20,0xd1,0x87,0xd0,0xb5,0xd1,0x80,
+0xd0,0xb5,0xd0,0xb7,0x20,0x3c,0x73,0x70,0x61,0x6e,0x20,0x69,0x64,0x3d,0x22,0x63,
+0x6f,0x75,0x6e,0x74,0x2d,0x6e,0x75,0x6d,0x62,0x65,0x72,0x22,0x3e,0x35,0x3c,0x2f,
+0x73,0x70,0x61,0x6e,0x3e,0x20,0xd1,0x81,0xd0,0xb5,0xd0,0xba,0xd1,0x83,0xd0,0xbd,
+0xd0,0xb4,0x2e,0x3c,0x2f,0x70,0x3e,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x3c,0x2f,0x64,
+0x69,0x76,0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x77,
+0x72,0x61,0x70,0x70,0x65,0x72,0x22,0x3e,0x3c,0x68,0x31,0x3e,0xd0,0x9e,0xd0,0xb1,
+0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,
+0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd1,0x88,0xd0,0xb8,0xd0,0xb2,0xd0,0xba,0xd0,
+0xb8,0x3c,0x2f,0x68,0x31,0x3e,0x3c,0x66,0x6f,0x72,0x6d,0x20,0x61,0x63,0x74,0x69,
+0x6f,0x6e,0x3d,0x22,0x2f,0x75,0x70,0x6c,0x6f,0x61,0x64,0x2e,0x63,0x67,0x69,0x22,
+0x20,0x6d,0x65,0x74,0x68,0x6f,0x64,0x3d,0x22,0x70,0x6f,0x73,0x74,0x22,0x20,0x65,
+0x6e,0x63,0x74,0x79,0x70,0x65,0x3d,0x22,0x6d,0x75,0x6c,0x74,0x69,0x70,0x61,0x72,
+0x74,0x2f,0x66,0x6f,0x72,0x6d,0x2d,0x64,0x61,0x74,0x61,0x22,0x20,0x6f,0x6e,0x73,
+0x75,0x62,0x6d,0x69,0x74,0x3d,0x22,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x56,0x61,
+0x6c,0x69,0x64,0x61,0x74,0x65,0x28,0x74,0x68,0x69,0x73,0x29,0x22,0x3e,0x3c,0x64,
+0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,0x64,
+0x2d,0x66,0x6f,0x72,0x6d,0x22,0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,
+0x73,0x3d,0x22,0x67,0x75,0x69,0x64,0x65,0x22,0x3e,0x3c,0x70,0x3e,0xd0,0x94,0xd0,
+0xbb,0xd1,0x8f,0x20,0xd0,0xbe,0xd0,0xb1,0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,
+0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd1,0x8f,0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd1,
+0x88,0xd0,0xb8,0xd0,0xb2,0xd0,0xba,0xd0,0xb8,0x20,0xd0,0xbd,0xd0,0xb5,0xd0,0xbe,
+0xd0,0xb1,0xd1,0x85,0xd0,0xbe,0xd0,0xb4,0xd0,0xb8,0xd0,0xbc,0xd0,0xbe,0x3a,0x3c,
+0x2f,0x70,0x3e,0x3c,0x6f,0x6c,0x3e,0x3c,0x6c,0x69,0x3e,0xd0,0xa1,0xd0,0xba,0xd0,
+0xbe,0xd0,0xbf,0xd0,0xb8,0xd1,0x80,0xd0,0xbe,0xd0,0xb2,0xd0,0xb0,0xd1,0x82,0xd1,
+0x8c,0x20,0xd0,0xbd,0xd0,0xb0,0x20,0xd0,0xba,0xd0,0xbe,0xd0,0xbc,0xd0,0xbf,0xd1,
+0x8c,0xd1,0x8e,0xd1,0x82,0xd0,0xb5,0xd1,0x80,0x20,0xd0,0xb8,0xd0,0xbb,0xd0,0xb8,
+0x20,0xd0,0xb2,0xd0,0xbd,0xd0,0xb5,0xd1,0x88,0xd0,0xbd,0xd0,0xb8,0xd0,0xb9,0x20,
+0xd0,0xbd,0xd0,0xbe,0xd1,0x81,0xd0,0xb8,0xd1,0x82,0xd0,0xb5,0xd0,0xbb,0xd1,0x8c,
+0x2c,0x20,0xd1,0x84,0xd0,0xb0,0xd0,0xb9,0xd0,0xbb,0x20,0xd0,0xbf,0xd1,0x80,0xd0,
+0xbe,0xd1,0x88,0xd0,0xb8,0xd0,0xb2,0xd0,0xba,0xd0,0xb8,0x20,0xd1,0x81,0x20,0xd1,
+0x80,0xd0,0xb0,0xd1,0x81,0xd1,0x88,0xd0,0xb8,0xd1,0x80,0xd0,0xb5,0xd0,0xbd,0xd0,
+0xb8,0xd0,0xb5,0xd0,0xbc,0x20,0x2a,0x2e,0x62,0x69,0x6e,0x3c,0x2f,0x6c,0x69,0x3e,
+0x3c,0x6c,0x69,0x3e,0xd0,0xa3,0xd0,0xba,0xd0,0xb0,0xd0,0xb7,0xd0,0xb0,0xd1,0x82,
+0xd1,0x8c,0x20,0xd0,0xbf,0xd1,0x83,0xd1,0x82,0xd1,0x8c,0x20,0xd0,0xba,0x20,0xd1,
+0x84,0xd0,0xb0,0xd0,0xb9,0xd0,0xbb,0xd1,0x83,0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,
+0xd1,0x88,0xd0,0xb8,0xd0,0xb2,0xd0,0xba,0xd0,0xb8,0x3c,0x2f,0x6c,0x69,0x3e,0x3c,
+0x6c,0x69,0x3e,0xd0,0x9d,0xd0,0xb0,0xd0,0xb6,0xd0,0xb0,0xd1,0x82,0xd1,0x8c,0x20,
+0xd0,0xba,0xd0,0xbd,0xd0,0xbe,0xd0,0xbf,0xd0,0xba,0xd1,0x83,0x20,0x22,0xd0,0x97,
+0xd0,0xb0,0xd0,0xb3,0xd1,0x80,0xd1,0x83,0xd0,0xb7,0xd0,0xb8,0xd1,0x82,0xd1,0x8c,
+0x22,0x3c,0x2f,0x6c,0x69,0x3e,0x3c,0x2f,0x6f,0x6c,0x3e,0x3c,0x70,0x3e,0xd0,0x94,
+0xd0,0xbb,0xd1,0x8f,0x20,0xd0,0xb2,0xd0,0xbe,0xd0,0xb7,0xd0,0xb2,0xd1,0x80,0xd0,
+0xb0,0xd1,0x82,0xd0,0xb0,0x20,0xd0,0xb2,0x20,0xd0,0xbe,0xd1,0x81,0xd0,0xbd,0xd0,
+0xbe,0xd0,0xb2,0xd0,0xbd,0xd0,0xbe,0xd0,0xb9,0x20,0xd0,0xb8,0xd0,0xbd,0xd1,0x82,
+0xd0,0xb5,0xd1,0x80,0xd1,0x84,0xd0,0xb5,0xd0,0xb9,0xd1,0x81,0x20,0xd0,0xba,0xd0,
+0xbe,0xd0,0xbd,0xd1,0x82,0xd1,0x80,0xd0,0xbe,0xd0,0xbb,0xd0,0xbb,0xd0,0xb5,0xd1,
+0x80,0xd0,0xb0,0x20,0xd0,0xbd,0xd0,0xb0,0xd0,0xb6,0xd0,0xbc,0xd0,0xb8,0xd1,0x82,
+0xd0,0xb5,0x20,0x22,0xd0,0x9e,0xd1,0x82,0xd0,0xbc,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,
+0xd1,0x82,0xd1,0x8c,0x22,0x3c,0x2f,0x70,0x3e,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x3c,
+0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,
+0x64,0x2d,0x77,0x72,0x61,0x70,0x70,0x65,0x72,0x22,0x3e,0x3c,0x69,0x6e,0x70,0x75,
+0x74,0x20,0x69,0x64,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,0x64,0x46,0x69,0x6c,0x65,
+0x22,0x20,0x70,0x6c,0x61,0x63,0x65,0x68,0x6f,0x6c,0x64,0x65,0x72,0x3d,0x22,0xd0,
+0xa4,0xd0,0xb0,0xd0,0xb9,0xd0,0xbb,0x22,0x20,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,
+0x64,0x3d,0x22,0x64,0x69,0x73,0x61,0x62,0x6c,0x65,0x64,0x22,0x20,0x63,0x6c,0x61,
+0x73,0x73,0x3d,0x22,0x66,0x69,0x6c,0x65,0x2d,0x6e,0x61,0x6d,0x65,0x22,0x3e,0x3c,
+0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x66,0x69,0x6c,0x65,0x55,
+0x70,0x6c,0x6f,0x61,0x64,0x20,0x62,0x74,0x6e,0x20,0x62,0x74,0x6e,0x2d,0x70,0x72,
+0x69,0x6d,0x61,0x72,0x79,0x22,0x3e,0x3c,0x73,0x70,0x61,0x6e,0x3e,0xd0,0x92,0xd1,
+0x8b,0xd0,0xb1,0xd0,0xbe,0xd1,0x80,0x3c,0x2f,0x73,0x70,0x61,0x6e,0x3e,0x20,0x3c,
+0x69,0x6e,0x70,0x75,0x74,0x20,0x69,0x64,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,0x64,
+0x42,0x74,0x6e,0x22,0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x66,0x69,0x6c,0x65,0x22,
+0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,0x64,0x22,0x20,
+0x6e,0x61,0x6d,0x65,0x3d,0x22,0x64,0x61,0x74,0x61,0x66,0x69,0x6c,0x65,0x22,0x3e,
+0x3c,0x2f,0x64,0x69,0x76,0x3e,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x3c,0x2f,0x64,0x69,
+0x76,0x3e,0x3c,0x69,0x6e,0x70,0x75,0x74,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,
+0x62,0x74,0x6e,0x20,0x62,0x74,0x6e,0x2d,0x70,0x72,0x69,0x6d,0x61,0x72,0x79,0x22,
+0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x73,0x75,0x62,0x6d,0x69,0x74,0x22,0x20,0x76,
+0x61,0x6c,0x75,0x65,0x3d,0x22,0xd0,0x97,0xd0,0xb0,0xd0,0xb3,0xd1,0x80,0xd1,0x83,
+0xd0,0xb7,0xd0,0xb8,0xd1,0x82,0xd1,0x8c,0x22,0x3e,0x20,0x3c,0x69,0x6e,0x70,0x75,
+0x74,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x62,0x74,0x6e,0x20,0x62,0x74,0x6e,
+0x2d,0x64,0x61,0x6e,0x67,0x65,0x72,0x22,0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x62,
+0x75,0x74,0x74,0x6f,0x6e,0x22,0x20,0x76,0x61,0x6c,0x75,0x65,0x3d,0x22,0xd0,0x9e,
+0xd1,0x82,0xd0,0xbc,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd1,0x82,0xd1,0x8c,0x22,0x20,
+0x69,0x64,0x3d,0x22,0x67,0x6f,0x62,0x61,0x63,0x6b,0x22,0x3e,0x3c,0x2f,0x66,0x6f,
+0x72,0x6d,0x3e,0x3c,0x73,0x63,0x72,0x69,0x70,0x74,0x20,0x74,0x79,0x70,0x65,0x3d,
+0x22,0x74,0x65,0x78,0x74,0x2f,0x6a,0x61,0x76,0x61,0x73,0x63,0x72,0x69,0x70,0x74,
+0x22,0x20,0x73,0x72,0x63,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,0x64,0x2e,0x6a,0x73,
+0x22,0x3e,0x3c,0x2f,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,0x3c,0x2f,0x64,0x69,0x76,
+0x3e,0x3c,0x2f,0x62,0x6f,0x64,0x79,0x3e,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,};
+
+static const unsigned int dummy_align__success_html = 2;
+static const unsigned char data__success_html[] = {
+/* /success.html (14 chars) */
+0x2f,0x73,0x75,0x63,0x63,0x65,0x73,0x73,0x2e,0x68,0x74,0x6d,0x6c,0x00,0x00,0x00,
+
+/* HTTP header */
+/* "HTTP/1.0 200 OK
+" (17 bytes) */
+0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d,
+0x0a,
+/* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)
+" (63 bytes) */
+0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33,
+0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
+0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
+0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
+/* "Content-type: text/html
+
+" (27 bytes) */
+0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
+0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a,
+/* raw file data (851 bytes) */
+0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50,0x45,0x20,0x68,0x74,0x6d,0x6c,0x3e,0x3c,
+0x68,0x74,0x6d,0x6c,0x20,0x6c,0x61,0x6e,0x67,0x3d,0x22,0x22,0x3e,0x3c,0x68,0x65,
+0x61,0x64,0x3e,0x3c,0x6d,0x65,0x74,0x61,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,
+0x3d,0x22,0x75,0x74,0x66,0x2d,0x38,0x22,0x3e,0x3c,0x6d,0x65,0x74,0x61,0x20,0x68,
+0x74,0x74,0x70,0x2d,0x65,0x71,0x75,0x69,0x76,0x3d,0x22,0x58,0x2d,0x55,0x41,0x2d,
+0x43,0x6f,0x6d,0x70,0x61,0x74,0x69,0x62,0x6c,0x65,0x22,0x20,0x63,0x6f,0x6e,0x74,
+0x65,0x6e,0x74,0x3d,0x22,0x49,0x45,0x3d,0x65,0x64,0x67,0x65,0x22,0x3e,0x3c,0x6d,
+0x65,0x74,0x61,0x20,0x6e,0x61,0x6d,0x65,0x3d,0x22,0x76,0x69,0x65,0x77,0x70,0x6f,
+0x72,0x74,0x22,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x22,0x77,0x69,0x64,
+0x74,0x68,0x3d,0x64,0x65,0x76,0x69,0x63,0x65,0x2d,0x77,0x69,0x64,0x74,0x68,0x2c,
+0x69,0x6e,0x69,0x74,0x69,0x61,0x6c,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,
+0x6d,0x61,0x78,0x69,0x6d,0x75,0x6d,0x2d,0x73,0x63,0x61,0x6c,0x65,0x3d,0x31,0x2c,
+0x75,0x73,0x65,0x72,0x2d,0x73,0x63,0x61,0x6c,0x61,0x62,0x6c,0x65,0x3d,0x30,0x22,
+0x3e,0x3c,0x6c,0x69,0x6e,0x6b,0x20,0x72,0x65,0x6c,0x3d,0x22,0x73,0x74,0x79,0x6c,
+0x65,0x73,0x68,0x65,0x65,0x74,0x22,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x75,0x70,
+0x6c,0x6f,0x61,0x64,0x2e,0x63,0x73,0x73,0x22,0x3e,0x3c,0x74,0x69,0x74,0x6c,0x65,
+0x3e,0xd0,0xa3,0xd1,0x81,0xd0,0xbf,0xd0,0xb5,0xd1,0x88,0xd0,0xbd,0xd0,0xbe,0xd0,
+0xb5,0x20,0xd0,0xbe,0xd0,0xb1,0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,
+0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,0x3c,0x2f,0x74,0x69,0x74,0x6c,0x65,0x3e,0x3c,0x2f,
+0x68,0x65,0x61,0x64,0x3e,0x3c,0x62,0x6f,0x64,0x79,0x3e,0x3c,0x6e,0x61,0x76,0x20,
+0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x6e,0x61,0x76,0x62,0x61,0x72,0x22,0x3e,0x3c,
+0x2f,0x6e,0x61,0x76,0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,
+0x22,0x77,0x72,0x61,0x70,0x70,0x65,0x72,0x22,0x3e,0x3c,0x68,0x31,0x3e,0xd0,0x9e,
+0xd0,0xb1,0xd0,0xbd,0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,
+0xd0,0xb5,0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd1,0x88,0xd0,0xb8,0xd0,0xb2,0xd0,
+0xba,0xd0,0xb8,0x3c,0x2f,0x68,0x31,0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,
+0x73,0x73,0x3d,0x22,0x75,0x70,0x6c,0x6f,0x61,0x64,0x2d,0x66,0x6f,0x72,0x6d,0x22,
+0x3e,0x3c,0x64,0x69,0x76,0x20,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x67,0x75,0x69,
+0x64,0x65,0x22,0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x74,0x65,0x78,0x74,0x2d,
+0x61,0x6c,0x69,0x67,0x6e,0x3a,0x63,0x65,0x6e,0x74,0x65,0x72,0x22,0x3e,0x3c,0x70,
+0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x63,0x6f,0x6c,0x6f,0x72,0x3a,0x23,0x33,
+0x33,0x43,0x43,0x30,0x30,0x22,0x3e,0x3c,0x62,0x3e,0xd0,0x9e,0xd0,0xb1,0xd0,0xbd,
+0xd0,0xbe,0xd0,0xb2,0xd0,0xbb,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,0x20,0xd0,
+0xbf,0xd1,0x80,0xd0,0xbe,0xd0,0xb3,0xd1,0x80,0xd0,0xb0,0xd0,0xbc,0xd0,0xbc,0xd0,
+0xbd,0xd0,0xbe,0xd0,0xb3,0xd0,0xbe,0x20,0xd0,0xbe,0xd0,0xb1,0xd0,0xb5,0xd1,0x81,
+0xd0,0xbf,0xd0,0xb5,0xd1,0x87,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd1,0x8f,0x20,0xd1,
+0x83,0xd1,0x81,0xd0,0xbf,0xd0,0xb5,0xd1,0x88,0xd0,0xbd,0xd0,0xbe,0x20,0xd0,0xb7,
+0xd0,0xb0,0xd0,0xb2,0xd0,0xb5,0xd1,0x80,0xd1,0x88,0xd0,0xb5,0xd0,0xbd,0xd0,0xbe,
+0x2e,0x3c,0x2f,0x62,0x3e,0x3c,0x62,0x72,0x3e,0xd0,0x9a,0xd0,0xbe,0xd0,0xbd,0xd1,
+0x82,0xd1,0x80,0xd0,0xbe,0xd0,0xbb,0xd0,0xbb,0xd0,0xb5,0xd1,0x80,0x20,0xd0,0xb1,
+0xd1,0x83,0xd0,0xb4,0xd0,0xb5,0xd1,0x82,0x20,0xd0,0xbf,0xd0,0xb5,0xd1,0x80,0xd0,
+0xb5,0xd0,0xb7,0xd0,0xb0,0xd0,0xb3,0xd1,0x80,0xd1,0x83,0xd0,0xb6,0xd0,0xb5,0xd0,
+0xbd,0x20,0xd1,0x87,0xd0,0xb5,0xd1,0x80,0xd0,0xb5,0xd0,0xb7,0x20,0x3c,0x73,0x70,
+0x61,0x6e,0x20,0x69,0x64,0x3d,0x22,0x63,0x6f,0x75,0x6e,0x74,0x2d,0x6e,0x75,0x6d,
+0x62,0x65,0x72,0x22,0x3e,0x35,0x3c,0x2f,0x73,0x70,0x61,0x6e,0x3e,0x20,0xd1,0x81,
+0xd0,0xb5,0xd0,0xba,0xd1,0x83,0xd0,0xbd,0xd0,0xb4,0x3c,0x2f,0x70,0x3e,0x3c,0x2f,
+0x64,0x69,0x76,0x3e,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x3c,0x73,0x63,0x72,0x69,0x70,
+0x74,0x20,0x74,0x79,0x70,0x65,0x3d,0x22,0x74,0x65,0x78,0x74,0x2f,0x6a,0x61,0x76,
+0x61,0x73,0x63,0x72,0x69,0x70,0x74,0x22,0x20,0x73,0x72,0x63,0x3d,0x22,0x75,0x70,
+0x6c,0x6f,0x61,0x64,0x2e,0x6a,0x73,0x22,0x3e,0x3c,0x2f,0x73,0x63,0x72,0x69,0x70,
+0x74,0x3e,0x3c,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,0x63,0x6f,0x75,0x6e,0x74,0x64,
+0x6f,0x77,0x6e,0x28,0x29,0x3b,0x3c,0x2f,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,0x3c,
+0x2f,0x64,0x69,0x76,0x3e,0x3c,0x2f,0x62,0x6f,0x64,0x79,0x3e,0x3c,0x2f,0x68,0x74,
+0x6d,0x6c,0x3e,};
+
+static const unsigned int dummy_align__upload_css = 3;
+static const unsigned char data__upload_css[] = {
+/* /upload.css (12 chars) */
+0x2f,0x75,0x70,0x6c,0x6f,0x61,0x64,0x2e,0x63,0x73,0x73,0x00,
+
+/* HTTP header */
+/* "HTTP/1.0 200 OK
+" (17 bytes) */
+0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d,
+0x0a,
+/* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)
+" (63 bytes) */
+0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33,
+0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
+0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
+0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
+/* "Content-type: text/css
+Content-Encoding: gzip
+
+" (50 bytes) */
+0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
+0x78,0x74,0x2f,0x63,0x73,0x73,0x0d,0x0a,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,
+0x45,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x3a,0x20,0x67,0x7a,0x69,0x70,0x0d,0x0a,
+0x0d,0x0a,
+/* raw file data (2151 bytes) */
+0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x0b,0xb5,0x58,0x5b,0x6f,0xa4,0x38,
+0x16,0xfe,0x2b,0xac,0xa2,0x96,0x3a,0x2d,0xa0,0xa9,0xaa,0x54,0x2a,0x01,0x75,0x6b,
+0x67,0x46,0x3d,0xd2,0x48,0xbb,0x6f,0x3b,0x4f,0x51,0x1e,0x0c,0x18,0xf0,0x06,0x6c,
+0x84,0x4d,0xa5,0xd2,0x0c,0xff,0x7d,0x8f,0x6f,0xe0,0xaa,0xa2,0x2a,0x91,0x46,0xab,
+0xee,0x44,0xe4,0xf8,0xf6,0xf9,0x9c,0xf3,0x9d,0x8b,0xbf,0x7e,0xf9,0x87,0x47,0x59,
+0xd7,0xa0,0x9a,0xfc,0xc4,0x61,0xc6,0xb9,0xb7,0xdf,0x84,0x51,0xb8,0xf6,0xfe,0xf2,
+0xfe,0xfd,0xc7,0x7f,0xbc,0x7f,0x91,0x0c,0x53,0x8e,0xe1,0xaf,0x92,0x88,0x90,0xb0,
+0xaf,0xd3,0x5c,0xef,0xcb,0xd7,0x2f,0x7e,0xca,0xf2,0xb7,0xa1,0x41,0x5d,0x49,0x68,
+0x1c,0x8d,0x5f,0xfc,0x1a,0x97,0x98,0xe6,0xbe,0x80,0xff,0xd5,0xd0,0xa2,0x3c,0x27,
+0xb4,0x84,0x81,0xb0,0x20,0x35,0xfe,0xb3,0xad,0x19,0xca,0xfd,0x90,0xa2,0x7d,0x8a,
+0x3a,0x3f,0xec,0xd5,0xdf,0x41,0x01,0x87,0xfb,0xbc,0x4f,0xe1,0xa7,0x1d,0x5a,0xc6,
+0x89,0x20,0x8c,0xc6,0x1d,0xae,0x91,0x20,0x7b,0x3c,0xde,0x64,0xac,0xa7,0x22,0x67,
+0xaf,0xd4,0x0f,0x53,0x41,0x07,0x81,0x0f,0x22,0x00,0xb0,0x25,0x8d,0x01,0x99,0xc0,
+0xdd,0x48,0x9a,0xd2,0x9c,0x3b,0xa4,0xac,0xcb,0x71,0x07,0x07,0x56,0xa2,0xa9,0x87,
+0x82,0x51,0x11,0x14,0xa8,0x21,0xf5,0x5b,0xcc,0x11,0xe5,0x01,0xc7,0x1d,0x29,0x92,
+0xe0,0x15,0xa7,0x2f,0x44,0x04,0x6a,0x27,0x0e,0xb7,0x0e,0x50,0xfe,0xdf,0x9e,0x8b,
+0x78,0x15,0x45,0x9f,0x92,0xa0,0xe1,0x17,0x46,0x52,0x94,0xbd,0x94,0x1d,0xa0,0xc9,
+0x83,0x8c,0xd5,0xac,0x8b,0x6f,0x7e,0x3c,0xfc,0xf8,0xf5,0xf7,0x55,0xd2,0x10,0x1a,
+0x54,0x98,0x94,0x95,0x88,0x77,0xeb,0xa8,0x3d,0x8c,0x4a,0x2b,0x66,0xce,0x66,0xb3,
+0x19,0x51,0x27,0x48,0x56,0x63,0x1f,0x71,0x92,0x63,0x3f,0xc7,0x02,0x91,0x9a,0xfb,
+0x05,0x29,0x33,0xd4,0xca,0xdb,0xca,0xcf,0xbe,0xc3,0x7e,0xc1,0x18,0x5c,0xc8,0xaf,
+0x30,0x82,0x5b,0xf8,0x95,0x3c,0xac,0xf5,0x1b,0x44,0xa8,0xdf,0x60,0xda,0xfb,0xa0,
+0x38,0x9f,0xe3,0x4c,0xad,0xe0,0x7d,0x03,0x6a,0x7f,0x1b,0x72,0xc2,0xdb,0x1a,0xbd,
+0xc5,0x69,0xcd,0xb2,0x97,0x11,0xf5,0x39,0x61,0x7e,0x86,0xe8,0x1e,0x71,0xbf,0xed,
+0x58,0xd9,0x61,0xce,0xfd,0x3d,0x9c,0xca,0xa6,0x99,0x84,0xd6,0x84,0xe2,0x40,0x2d,
+0x48,0xf6,0x58,0x42,0x43,0xb5,0xd1,0x68,0x8a,0x38,0x96,0xa3,0x7a,0xa3,0x98,0x32,
+0xf1,0xf9,0x29,0x03,0x2d,0x76,0xac,0xe6,0xcf,0xb7,0xd3,0x16,0x94,0x51,0x9c,0x98,
+0x1b,0x47,0xe3,0x53,0x45,0xf2,0x1c,0xd3,0x67,0x5f,0xe0,0x06,0xb0,0x08,0x7c,0x34,
+0x6f,0x44,0xc3,0x99,0xe2,0x44,0x07,0xd6,0x68,0x51,0x07,0xf6,0x1b,0x51,0x8c,0xe0,
+0x46,0x7b,0x50,0x4e,0x5c,0x31,0x80,0x33,0xb0,0x5e,0x48,0x08,0x60,0x44,0x94,0xa6,
+0xdd,0x93,0x20,0xa2,0xc6,0xcf,0xc6,0xb2,0x41,0xca,0x84,0x60,0x4d,0xbc,0x6a,0x0f,
+0x5e,0x0e,0x9f,0x38,0x1f,0x53,0x9f,0xb5,0x42,0x6b,0x8a,0x03,0x4e,0x5a,0x6a,0xb3,
+0xbf,0x1a,0x7b,0x44,0xd1,0x98,0x17,0x54,0xcb,0xb8,0x78,0xab,0x71,0x4c,0x04,0x78,
+0x4f,0x36,0x56,0x2b,0x23,0x04,0x07,0x88,0xd7,0xb8,0x19,0x41,0x9d,0x2f,0x83,0x31,
+0x5a,0x14,0x45,0xc9,0x8c,0x3a,0xbe,0x29,0x0a,0xf0,0x61,0xf0,0x3e,0xe5,0x82,0x41,
+0x8e,0x68,0x89,0xbb,0xd0,0xe0,0x96,0x72,0x23,0xb2,0x57,0x51,0xa2,0xb6,0x23,0xd2,
+0x42,0x47,0xd3,0x8c,0x6c,0x9a,0xc7,0x5a,0x4c,0xbf,0x87,0x79,0xc7,0x5a,0xe9,0xe0,
+0x81,0x60,0x65,0x59,0x63,0x67,0x43,0x3f,0xbc,0x3c,0xc3,0xec,0xe5,0x6a,0x17,0x0e,
+0x2c,0x31,0x58,0x0d,0x0c,0xc8,0x81,0xd0,0x86,0x01,0xd2,0xc5,0xe3,0x87,0xe8,0xd3,
+0x68,0x49,0xa6,0x78,0xa1,0xa4,0xbb,0xed,0xa7,0x44,0x79,0x83,0x35,0xe6,0x45,0x87,
+0x90,0xe4,0x14,0xac,0x8d,0x83,0x70,0x0b,0xba,0x82,0x9d,0xc0,0x22,0xca,0x14,0x41,
+0xb8,0x56,0x92,0x7d,0xa9,0xdc,0x25,0xee,0xc0,0x87,0x6f,0x07,0x69,0xc9,0xa2,0x66,
+0xaf,0xb1,0xf6,0x8d,0x51,0x3b,0xb8,0x8d,0x14,0x2b,0xdc,0x78,0x77,0x92,0x28,0x55,
+0x37,0x4c,0x27,0x5b,0x5a,0xa6,0xec,0x10,0x00,0x38,0x19,0x38,0xa4,0xeb,0x81,0x8f,
+0x80,0xd5,0x0f,0xc0,0x4b,0xf6,0x53,0x7e,0x2c,0x8d,0x2d,0x8b,0xc7,0x16,0x28,0x25,
+0x49,0x0e,0x8e,0x86,0x66,0x44,0xa8,0x17,0x6c,0xcc,0x18,0x10,0xf1,0x25,0xcd,0x81,
+0x24,0xd8,0xe7,0xa8,0x69,0x8f,0x82,0x45,0xc3,0x28,0x03,0xff,0xcc,0xb0,0x3f,0x7d,
+0x25,0xb3,0xd2,0x00,0xfd,0x98,0xf6,0x70,0x79,0xea,0x13,0xda,0xf6,0xc2,0x71,0x40,
+0x5c,0x03,0x3d,0xe7,0x33,0x6d,0x60,0x54,0x8b,0x63,0x42,0x2b,0x88,0x3f,0x22,0xd1,
+0x3e,0x66,0xfe,0xd2,0x6e,0x65,0x9d,0xd1,0x78,0xed,0x1d,0x78,0xad,0x3e,0x61,0x86,
+0xbd,0x27,0x9c,0xa4,0x35,0xb6,0x27,0x03,0x4f,0xe1,0x28,0x1d,0x0d,0x15,0x9d,0x64,
+0x18,0xd5,0xa6,0x37,0xd8,0x64,0x08,0xf4,0x14,0xc0,0x27,0xf1,0xd6,0xe2,0x6f,0x5a,
+0xfc,0xac,0x31,0x6b,0x11,0x44,0x07,0x2c,0x8e,0x24,0x60,0xd8,0x86,0x88,0xe7,0xc1,
+0x1a,0x03,0xb5,0x2d,0x46,0xc0,0xd6,0x0c,0xc7,0x7a,0x7d,0x92,0xf5,0x1d,0x87,0xd8,
+0xd7,0x32,0xa2,0x82,0xaf,0x96,0x3e,0x41,0x18,0x42,0x80,0x2e,0x7f,0xf6,0x9d,0x63,
+0x27,0xe1,0x60,0x16,0xe5,0xb8,0x40,0x7d,0x2d,0x46,0x07,0x55,0x56,0xe1,0xec,0x05,
+0xec,0x77,0x84,0xa2,0x43,0x10,0xc6,0x66,0x10,0x8e,0x79,0x75,0x80,0x5f,0x74,0x08,
+0x67,0x68,0x79,0xc1,0x9c,0x8e,0x9c,0xf3,0x69,0xdf,0xa4,0xb8,0x7b,0x8e,0x63,0x7b,
+0x63,0x42,0x29,0xee,0x02,0xde,0x42,0x4c,0x37,0x8a,0xbc,0x36,0x1b,0x82,0xd5,0xf1,
+0x6c,0xeb,0xcf,0xca,0xcb,0x9c,0x95,0x1c,0xd4,0x98,0x55,0x8b,0x77,0xfa,0x7b,0x5e,
+0x3e,0xa5,0x33,0xc7,0x54,0xd2,0xe9,0x0b,0x82,0xeb,0xdc,0xd5,0xb4,0x41,0x30,0xdf,
+0x54,0x0b,0x02,0xc8,0x16,0x19,0xae,0x17,0x2e,0x7b,0x69,0x41,0x8e,0x33,0xd6,0x41,
+0x72,0x66,0x74,0xc9,0x4d,0x54,0xf4,0x51,0x87,0x83,0x6f,0x4d,0x25,0x40,0xb8,0x81,
+0x20,0xe1,0x85,0xf7,0x32,0x56,0x78,0xe1,0x0e,0x7e,0x27,0x96,0x1c,0xde,0xba,0x3d,
+0x24,0x26,0x71,0xcb,0xb8,0xce,0x59,0x4d,0x72,0x8f,0x93,0x1a,0x42,0xc8,0x28,0xa4,
+0x57,0xd9,0xe0,0x2f,0x29,0xa9,0xea,0x09,0x33,0x5d,0xa6,0xe1,0x1a,0xb5,0x1c,0xc7,
+0x1c,0x43,0x36,0x81,0xcc,0x33,0x9a,0xe2,0x62,0x70,0x52,0x32,0x64,0x75,0x38,0x40,
+0x9f,0x66,0xf3,0x87,0xca,0xd2,0xe1,0x6b,0x27,0x75,0xd6,0x0d,0xaf,0x24,0x17,0x55,
+0xfc,0x78,0x3f,0xcf,0x8b,0x23,0x4f,0x19,0x30,0x2c,0x7b,0xc8,0x9d,0x53,0x3e,0xd3,
+0x39,0x73,0xf2,0x23,0x6f,0x23,0x63,0x98,0x9e,0xf3,0xbd,0xaf,0x87,0x9a,0x70,0x11,
+0xe8,0x24,0xa3,0xb4,0xa0,0x47,0x3c,0xa8,0x6a,0x4c,0x21,0xb4,0x82,0xf9,0x1e,0x14,
+0x27,0x26,0xf5,0x98,0xd2,0xe4,0x97,0x8e,0xa0,0x1a,0x82,0xd0,0x54,0xa0,0xa8,0xc2,
+0x64,0x26,0x75,0x2f,0x41,0x66,0x90,0x99,0x4d,0xe4,0xb8,0xd9,0xdd,0xed,0xb6,0x0f,
+0x8f,0x56,0x81,0xe1,0xfd,0x0e,0x74,0x0a,0xf9,0xc9,0xa9,0xa7,0x8e,0xa2,0x99,0xb3,
+0xf3,0x9c,0xd3,0x6c,0x09,0x53,0x14,0x45,0x62,0xe1,0xc9,0xeb,0xd8,0x5d,0xa5,0x86,
+0x94,0x0e,0x40,0xd7,0x10,0x73,0x2b,0x04,0x09,0x0a,0xb4,0x22,0x0d,0xb4,0x85,0x9f,
+0xae,0x4c,0xd1,0xe7,0xc8,0x97,0xff,0xc2,0xd5,0xf6,0xd6,0x2d,0xf0,0xe6,0x90,0x65,
+0x62,0xbf,0x53,0xfc,0xe9,0x78,0x64,0x90,0xce,0xc5,0x1e,0x4a,0xc1,0xe8,0xc0,0xa4,
+0x44,0x66,0x98,0x28,0xe9,0x54,0x29,0x15,0x59,0x28,0xd1,0x04,0x30,0x72,0xa2,0xb0,
+0x04,0x78,0x12,0x8c,0x12,0x26,0x1d,0x44,0xbc,0xc1,0x16,0x50,0x6f,0x02,0x31,0x63,
+0x54,0xb7,0x15,0xfa,0x6c,0xc4,0xdf,0xa2,0x5b,0x1b,0x3d,0x9d,0x20,0xf5,0x7f,0x8f,
+0x8d,0x40,0x38,0x99,0xba,0x0a,0x96,0xf5,0x3c,0x50,0xd1,0x45,0x87,0xe0,0x73,0xf9,
+0xe4,0x27,0x50,0x7c,0xd8,0x42,0x56,0x85,0x10,0xf0,0x2c,0xa8,0xd8,0x4c,0xa6,0xd4,
+0x05,0xb8,0x66,0xb6,0x52,0x6d,0x40,0x51,0x83,0xf5,0x9e,0x61,0xcd,0xa0,0x12,0xb7,
+0x31,0x48,0xd9,0xd3,0xc9,0x5b,0x92,0x68,0xee,0x4e,0xab,0x70,0x3b,0xa9,0x76,0x03,
+0x46,0x95,0xee,0x79,0xba,0xaf,0xe1,0x9e,0xaa,0xb8,0x34,0x33,0x6f,0x36,0x9b,0x1d,
+0x4a,0x77,0x96,0x83,0x32,0x56,0xf7,0x1c,0x54,0x7e,0x54,0x89,0x26,0x90,0xfc,0x91,
+0x88,0x6b,0x5c,0x98,0x68,0x6f,0x90,0x99,0x7b,0xa9,0x02,0xd2,0x04,0xec,0x69,0x83,
+0x13,0x8a,0x82,0x9b,0x25,0x9a,0x99,0xeb,0x07,0x09,0xcc,0xfa,0xb7,0x65,0xad,0xf5,
+0x5a,0x4d,0x2a,0xc5,0x45,0xf5,0xcb,0x2c,0x92,0xc5,0xbc,0x4a,0xae,0x13,0x7b,0x8f,
+0x0a,0x5f,0xbb,0x3a,0xdc,0xca,0x62,0x64,0x25,0x55,0x73,0x7c,0xbe,0xeb,0x6b,0xe1,
+0x23,0xc4,0xab,0x13,0xcd,0x81,0xe4,0xb5,0x22,0x02,0x43,0xaa,0x80,0x42,0x01,0x32,
+0xaf,0xc4,0x75,0x5a,0x3e,0x35,0x50,0x19,0xd7,0xc0,0xdb,0xa3,0x9c,0xa9,0x5b,0x0c,
+0xd6,0x67,0x55,0x20,0x4b,0x48,0x68,0x76,0x1a,0x44,0x49,0xdb,0xcb,0x86,0x87,0x51,
+0xe0,0xc0,0xa5,0x11,0x9b,0xa2,0x7a,0xe8,0x63,0xa0,0x97,0x91,0x05,0x80,0xca,0xf8,
+0xba,0x36,0x5a,0x90,0xf2,0xe0,0x4c,0x78,0x26,0x38,0x8b,0xbc,0x4e,0x71,0x7e,0x6a,
+0x63,0xa5,0xcf,0xd0,0xa6,0x75,0x55,0x0c,0x3b,0x99,0xdf,0x06,0xfd,0x59,0xe4,0xc9,
+0x52,0x16,0x68,0xae,0x4a,0x85,0x00,0xef,0xa1,0x96,0xe3,0x1a,0xb1,0xd1,0x08,0x34,
+0x18,0xd0,0x79,0x40,0x9d,0x88,0xf3,0x65,0xca,0xde,0x6f,0x6f,0xa7,0x04,0xe7,0x04,
+0x22,0xe3,0x3f,0x53,0x60,0x52,0x7f,0x5b,0xf6,0x87,0xf7,0x5b,0x0d,0x54,0x17,0xe8,
+0xa1,0x62,0x9e,0x02,0x6b,0x6a,0xf1,0xd8,0x91,0xcc,0x9f,0xa6,0x28,0x77,0xa6,0x1b,
+0x89,0x33,0x5d,0x7f,0x4e,0x2d,0x8a,0x6e,0x41,0x3c,0x51,0x11,0x9a,0xd8,0xb6,0xc5,
+0x1a,0x49,0xf3,0xbd,0x83,0x7c,0xa5,0x43,0xad,0x0a,0xa6,0x32,0x76,0xda,0x99,0x01,
+0x2b,0x0a,0x48,0x91,0x71,0x00,0xbe,0xa7,0xf1,0x3a,0x58,0x9c,0x4f,0xdd,0x15,0xcd,
+0xdd,0x64,0xa2,0xd2,0xc3,0x9c,0x84,0x75,0xd1,0xe7,0xb6,0x1c,0xb6,0x8b,0x91,0xb1,
+0xfd,0x3c,0xe2,0x1f,0xd3,0xd7,0xee,0x9b,0x4b,0x4e,0x2b,0x18,0xc1,0x95,0xc6,0xc5,
+0x51,0x8e,0x9d,0x36,0xf5,0x32,0xb2,0x0d,0xb2,0xfd,0xcd,0x0c,0x7f,0x12,0xa9,0x6b,
+0x7c,0xa4,0x9f,0x31,0x88,0x96,0xc1,0xaf,0xf1,0x3d,0x46,0x5b,0xeb,0x97,0x66,0xea,
+0xfa,0xb7,0xed,0xc3,0xc3,0xdd,0x31,0xf8,0x23,0x27,0xb5,0x20,0x26,0xd7,0x5d,0x6a,
+0xca,0xe6,0xc1,0x73,0xf4,0xd3,0xd8,0xd2,0x6d,0xe7,0xc1,0x6b,0x0b,0xcd,0xfd,0x1d,
+0x2d,0xcd,0x3c,0xd1,0x6d,0xa5,0x51,0xde,0x2c,0x5e,0x42,0xe9,0x8c,0x9e,0x9f,0x36,
+0x0f,0x2e,0xe1,0x74,0x46,0xaf,0x2e,0xd5,0x48,0x2f,0xb0,0xd9,0xaa,0x12,0x9e,0x2c,
+0xa0,0xbe,0x04,0xff,0x9d,0x77,0x55,0x6c,0xb7,0xe3,0x16,0xfb,0x7b,0xd3,0x34,0x92,
+0x77,0x66,0xd9,0xdb,0xbc,0x37,0xed,0x63,0x9b,0x69,0x42,0x7d,0x90,0x18,0xae,0x6f,
+0xe9,0xbe,0xff,0x3a,0xbb,0xf2,0xc7,0xed,0xe6,0x0e,0x68,0xa7,0xf2,0xb7,0x2d,0xb2,
+0xf2,0xbb,0x4d,0xb1,0x41,0xda,0x41,0x2f,0x3e,0x1e,0xb8,0xdc,0xd2,0x93,0xec,0xb5,
+0x9d,0x07,0x01,0x27,0x16,0xd9,0x37,0x87,0x77,0x89,0xf5,0x11,0xd8,0xd9,0xe3,0x26,
+0x5a,0x67,0x27,0xb0,0x51,0xb6,0x7e,0x5c,0xeb,0x58,0x6a,0xdf,0x3c,0x8e,0x69,0x65,
+0xee,0x62,0x85,0xd6,0xe6,0x0e,0xde,0x89,0x1b,0xe7,0xb7,0x9b,0x86,0x16,0xae,0x39,
+0x8f,0x39,0x9e,0x7a,0x72,0x9a,0x7e,0x2e,0x72,0x5f,0x64,0x66,0x57,0x5c,0x96,0x2e,
+0xe0,0x9b,0x97,0x9c,0x03,0x9c,0xc7,0x16,0x10,0x3a,0x83,0x67,0x10,0x9d,0xb1,0xeb,
+0x5c,0xd2,0x37,0xba,0x48,0x25,0x73,0x61,0xf3,0xce,0x74,0xc9,0xf9,0xcd,0xac,0xeb,
+0xbe,0xaf,0x27,0xd9,0x7b,0x5c,0xdf,0xca,0xf8,0xd8,0x3b,0x93,0x2e,0xb1,0xe8,0x1a,
+0x01,0x90,0xaa,0x07,0x16,0xf3,0xd7,0x13,0x3c,0x31,0x4e,0x6f,0x14,0xf6,0xbd,0xc0,
+0x3e,0x32,0xe8,0x37,0xe0,0x40,0x56,0x58,0x03,0x38,0x9b,0x7a,0xf0,0x54,0x29,0x7f,
+0x7a,0x2e,0x2e,0xc8,0x01,0x4a,0x08,0xdd,0x3e,0xc8,0xa2,0x13,0xea,0x51,0x5d,0x3b,
+0xaa,0x37,0x5d,0x53,0x39,0xab,0xef,0x33,0xde,0xbb,0xad,0xcc,0xc3,0x6d,0xf2,0x13,
+0x6a,0xf4,0x1c,0x1f,0xe0,0x31,0x78,0xe5,0xbc,0x3d,0x5f,0x38,0xd6,0xbe,0x52,0xab,
+0x93,0xef,0xe0,0xf5,0x78,0x6a,0x6a,0x65,0xfb,0x38,0x15,0xd7,0xab,0x7b,0x48,0xfb,
+0xb6,0xd0,0x82,0x6f,0xd3,0xe3,0xde,0x14,0x11,0xca,0xef,0xf0,0x42,0x8e,0x56,0xc9,
+0xef,0x03,0x7d,0x97,0x83,0x76,0x9d,0x4c,0x6f,0x6e,0xaa,0x75,0xfd,0x67,0x83,0x73,
+0x82,0x3c,0x46,0xeb,0x37,0x8f,0x67,0x1d,0xc6,0xd4,0x43,0x34,0xf7,0x3e,0x37,0xe8,
+0x10,0x28,0xd5,0x78,0xf1,0xee,0xfe,0xa1,0x3d,0xdc,0x0e,0xb6,0x67,0x76,0x35,0x3b,
+0x9e,0x36,0xc7,0xf0,0x50,0x68,0x4b,0xe6,0xc8,0x53,0x6f,0x80,0xe3,0xff,0x00,0x63,
+0x0c,0xb8,0xcc,0x3a,0x18,0x00,0x00,};
+
+static const unsigned int dummy_align__upload_js = 4;
+static const unsigned char data__upload_js[] = {
+/* /upload.js (11 chars) */
+0x2f,0x75,0x70,0x6c,0x6f,0x61,0x64,0x2e,0x6a,0x73,0x00,0x00,
+
+/* HTTP header */
+/* "HTTP/1.0 200 OK
+" (17 bytes) */
+0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x30,0x20,0x32,0x30,0x30,0x20,0x4f,0x4b,0x0d,
+0x0a,
+/* "Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)
+" (63 bytes) */
+0x53,0x65,0x72,0x76,0x65,0x72,0x3a,0x20,0x6c,0x77,0x49,0x50,0x2f,0x31,0x2e,0x33,
+0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
+0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
+0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
+/* "Content-type: application/x-javascript
+Content-Encoding: gzip
+
+" (66 bytes) */
+0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x61,0x70,
+0x70,0x6c,0x69,0x63,0x61,0x74,0x69,0x6f,0x6e,0x2f,0x78,0x2d,0x6a,0x61,0x76,0x61,
+0x73,0x63,0x72,0x69,0x70,0x74,0x0d,0x0a,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,
+0x45,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x3a,0x20,0x67,0x7a,0x69,0x70,0x0d,0x0a,
+0x0d,0x0a,
+/* raw file data (869 bytes) */
+0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x0b,0xb5,0x54,0xe1,0x6a,0xdc,0x46,
+0x10,0x7e,0x95,0xbd,0x25,0x18,0x09,0xcb,0xea,0x99,0x12,0x28,0x56,0xb7,0xa6,0x2e,
+0x69,0x62,0x88,0xdb,0x10,0x8e,0x12,0x30,0xa6,0xac,0x56,0xa3,0xbb,0xad,0x75,0xbb,
+0x57,0x69,0x75,0xee,0x61,0x0e,0xe2,0x73,0x4a,0x0b,0x0d,0x14,0xfa,0x02,0xfd,0xd3,
+0x07,0x30,0xa1,0x6e,0xec,0x24,0xbe,0x67,0xd8,0x7d,0xa3,0xce,0x9e,0x74,0x8e,0x1c,
+0x9a,0x9f,0xfd,0x21,0x21,0xed,0xcc,0xec,0x7c,0xf3,0xcd,0x37,0x93,0xd7,0x4a,0x18,
+0xa9,0x15,0xb9,0x17,0xf0,0xf0,0xb4,0x04,0x53,0x97,0x8a,0x64,0x5a,0xd4,0x63,0x50,
+0x26,0x1e,0x82,0x79,0x50,0x80,0xff,0xdc,0x9b,0xed,0x67,0xe8,0x31,0xcf,0xd7,0xfe,
+0x42,0xd7,0xca,0x64,0xfa,0x44,0x05,0xe1,0xe9,0x94,0x97,0x84,0xb3,0xfb,0x49,0x05,
+0x66,0x5f,0x19,0x28,0xa7,0xbc,0x08,0xd6,0x8e,0x68,0x6e,0x6f,0xdd,0x66,0x8c,0x6f,
+0x6c,0x04,0x27,0x52,0x61,0x58,0x5c,0x68,0xc1,0x7d,0xe2,0x78,0x54,0x42,0xce,0xe8,
+0x27,0x34,0x8c,0xf8,0x17,0xfd,0x8d,0x0d,0xbe,0xb5,0x15,0x7d,0x2c,0x3f,0x5d,0x25,
+0xdd,0x52,0xf5,0x38,0x85,0x92,0x86,0xb1,0x54,0x0a,0xca,0x47,0x83,0x83,0xc7,0x8c,
+0x47,0x7c,0x1e,0x6d,0xc3,0xa7,0x1d,0x80,0x88,0xfd,0xab,0x87,0xfb,0xbe,0x2a,0x0f,
+0x2f,0x8d,0x44,0xd2,0xe0,0xa0,0x43,0x9d,0x72,0x71,0x1c,0x8b,0xa1,0xa4,0x88,0x68,
+0x37,0x48,0x99,0xd0,0x2a,0x97,0xe5,0x38,0xa0,0xf6,0x0f,0xf7,0x1b,0x71,0xe7,0xf6,
+0x95,0xbd,0x74,0xcf,0xed,0xa5,0xbd,0xf1,0xbf,0xbf,0xb8,0x85,0x5d,0x12,0xf7,0xb3,
+0x5d,0xe2,0xc7,0x15,0x3e,0x97,0xa4,0x75,0xb8,0x71,0xe7,0x6e,0xe1,0x5e,0xba,0x33,
+0xf7,0x3b,0x1e,0x11,0x74,0x38,0xb3,0x37,0x76,0x89,0x56,0xff,0xbe,0x26,0xf6,0x0a,
+0x6f,0x40,0x7f,0xf7,0xdc,0xbd,0xc0,0xdb,0xae,0xdd,0xd9,0x2e,0x96,0x29,0x18,0xe6,
+0x41,0xfb,0x6b,0xfb,0x0a,0x93,0x5c,0xb8,0x85,0x0f,0x5c,0xd8,0x77,0x3e,0x9f,0x7f,
+0x62,0x1a,0xee,0xa4,0xac,0xd7,0x8f,0xd2,0xdd,0x35,0x59,0xcf,0x0e,0x1e,0x3f,0x32,
+0x66,0xf2,0x14,0x7e,0xac,0xa1,0x32,0xbb,0x3f,0x8d,0x8b,0x11,0xfe,0x32,0x05,0x27,
+0xe4,0xae,0x69,0xa7,0x6b,0xfa,0x12,0x3b,0x3b,0x85,0x67,0xdf,0xa6,0x3f,0x80,0x30,
+0x01,0x3d,0x90,0xa2,0xd4,0x95,0xce,0x4d,0xec,0x63,0x06,0x83,0x27,0x88,0xa5,0x75,
+0x8f,0xf5,0x04,0x54,0x40,0x1f,0x3e,0x18,0xd0,0x88,0x47,0xbd,0xfe,0x7b,0x43,0x05,
+0x2a,0x0b,0x42,0x7f,0xb4,0x33,0xd5,0x32,0x23,0xbc,0x80,0xd2,0x04,0xa2,0xc3,0xf3,
+0x77,0xbc,0x90,0x19,0x37,0xe0,0x99,0xce,0x75,0x19,0xac,0xd8,0x66,0xbc,0xa3,0x9d,
+0x6a,0x6f,0x36,0xe0,0xc3,0x6f,0xf8,0x18,0x02,0x2a,0xd5,0xa4,0x36,0x2b,0x12,0xfa,
+0x89,0xf8,0x3c,0x8d,0x0b,0x50,0x43,0x33,0x4a,0xc4,0xe6,0x66,0xd3,0xa7,0x8c,0xa5,
+0x87,0xe2,0x28,0x02,0xd6,0xdb,0x4e,0x64,0x1e,0xd0,0x5c,0x16,0x80,0x6d,0xca,0x62,
+0x33,0x9b,0x40,0x78,0x8a,0x47,0x7d,0xff,0xe7,0x8f,0xab,0x36,0x38,0x6c,0xf5,0xd5,
+0x40,0xa3,0xf6,0xcf,0xa6,0x2b,0xc4,0xbe,0x21,0x48,0xfb,0x85,0xbd,0xb6,0x6f,0xdd,
+0x39,0xf1,0xdc,0xfa,0xd6,0xbe,0xc1,0x93,0xd7,0xf8,0xdc,0x20,0x08,0x9f,0x25,0xc2,
+0x44,0x1e,0x72,0xbe,0xbe,0xf5,0xb0,0x7f,0x14,0x2b,0xc4,0xea,0xd3,0xe7,0x8c,0x7d,
+0x8f,0x62,0x96,0xd9,0xd7,0x98,0xcf,0x17,0x10,0x9e,0x62,0x4c,0x3f,0xba,0x17,0xb4,
+0x2a,0x42,0x11,0x8a,0x82,0x57,0x95,0xb7,0xb1,0xff,0x3c,0xdd,0xa4,0x24,0x93,0x15,
+0x4f,0x0b,0xc8,0x68,0x92,0x96,0xc0,0x8f,0xe7,0x78,0x71,0x0f,0x3e,0x44,0xfd,0x57,
+0x83,0x94,0xd0,0xcd,0x1c,0x43,0x56,0x68,0x51,0x47,0x17,0xf6,0x2d,0x8a,0xe8,0x6f,
+0x2f,0x8b,0x88,0xac,0xd4,0x72,0xe6,0x7e,0x45,0x11,0xae,0xc4,0x89,0x16,0x94,0xe2,
+0x95,0x97,0xd9,0x3b,0x54,0xe0,0xba,0x58,0x7b,0x41,0x30,0x62,0x89,0x91,0xff,0x78,
+0x1d,0x12,0x14,0xe5,0x72,0xa5,0x30,0xaf,0xea,0x05,0x8a,0x75,0x81,0x17,0x7b,0x91,
+0xa2,0xf4,0xdc,0xcb,0x1d,0x72,0x88,0x39,0xef,0x56,0x89,0x00,0x8e,0x90,0x9e,0xde,
+0xf6,0x7c,0xde,0x70,0xdb,0xeb,0xcf,0x3d,0x47,0x46,0x8e,0x41,0xd7,0x26,0xb9,0x9d,
+0x4f,0xad,0xc6,0xba,0xae,0x60,0xac,0xa7,0xc0,0x3a,0x03,0x2f,0x0a,0xe0,0xe5,0xa0,
+0x71,0x0e,0xda,0xa0,0x30,0x6a,0x3f,0x18,0x6e,0x89,0xb5,0xad,0x13,0x83,0xdb,0xa1,
+0x9d,0xd8,0xce,0x80,0xe2,0xb8,0xe0,0xc6,0x40,0x5e,0x9b,0xc1,0x3f,0x29,0xf9,0x04,
+0x19,0xaf,0xcc,0xac,0x80,0x18,0x59,0x9d,0x14,0x7c,0xc6,0x68,0x8a,0xab,0xe4,0x98,
+0xfa,0x9e,0xdc,0xee,0xa4,0x8f,0x3a,0xdd,0x7a,0x04,0x61,0x88,0x0b,0xe3,0x33,0xb8,
+0x1f,0xce,0x57,0xed,0xbf,0x4b,0x00,0xa3,0xfb,0x7b,0x4f,0xe2,0x54,0x2a,0x9a,0x74,
+0x9b,0xaa,0x95,0x28,0xa4,0x38,0xee,0x96,0xca,0x59,0x07,0x2e,0x8d,0xde,0x57,0xc1,
+0xff,0x57,0xe4,0x88,0xaa,0x9e,0x14,0x9a,0x67,0x7b,0x46,0x61,0xb1,0x08,0x6c,0xc4,
+0xd5,0xf0,0x4e,0x13,0x6e,0x9b,0xf4,0xc1,0x12,0x6f,0x03,0xbd,0xa2,0x31,0x12,0xd5,
+0x5d,0x03,0x33,0x23,0x59,0x35,0x33,0xb5,0x56,0xff,0x3c,0xf9,0x17,0x54,0xc3,0x58,
+0x63,0x1a,0x06,0x00,0x00,};
+
+
+
+const struct fsdata_file file__error_html[] = { {
+file_NULL,
+data__error_html,
+data__error_html + 12,
+sizeof(data__error_html) - 12,
+1,
+}};
+
+const struct fsdata_file file__index_html[] = { {
+file__error_html,
+data__index_html,
+data__index_html + 12,
+sizeof(data__index_html) - 12,
+1,
+}};
+
+const struct fsdata_file file__success_html[] = { {
+file__index_html,
+data__success_html,
+data__success_html + 16,
+sizeof(data__success_html) - 16,
+1,
+}};
+
+const struct fsdata_file file__upload_css[] = { {
+file__success_html,
+data__upload_css,
+data__upload_css + 12,
+sizeof(data__upload_css) - 12,
+1,
+}};
+
+const struct fsdata_file file__upload_js[] = { {
+file__upload_css,
+data__upload_js,
+data__upload_js + 12,
+sizeof(data__upload_js) - 12,
+1,
+}};
+
+#define FS_ROOT file__upload_js
+#define FS_NUMFILES 5
+

+ 65 - 0
iap/Modules/Ethernet/fsdata.h

@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * fsdata.h
+ *                     
+ * Author : Adam Dunkels <adam@sics.se>                               
+ *
+ * CHANGELOG: this file has been modified by Sergio Perez Alcaсiz <serpeal@upvnet.upv.es> 
+ *            Departamento de Informбtica de Sistemas y Computadores          
+ *            Universidad Politйcnica de Valencia                             
+ *            Valencia (Spain)    
+ *            Date: March 2003                                          
+ *
+ */
+
+#ifndef __FSDATA_H__
+#define __FSDATA_H__
+
+
+
+struct fsdata_file {
+  const struct fsdata_file *next;
+  const unsigned char *name;
+  const unsigned char *data;
+  int len;
+  u8_t http_header_included;
+#if HTTPD_PRECALCULATED_CHECKSUM
+  u16_t chksum_count;
+  const struct fsdata_chksum *chksum;
+#endif /* HTTPD_PRECALCULATED_CHECKSUM */
+};
+
+struct fsdata_file_noconst {
+  struct fsdata_file *next;
+  char *name;
+  char *data;
+  int len;
+};
+
+#endif /* __FSDATA_H__ */

+ 686 - 0
iap/Modules/Ethernet/httpserver.c

@@ -0,0 +1,686 @@
+
+#include "httpserver.h"
+#include "lwip/tcp.h"
+#include "fsdata.c"
+#include "main.h"
+#include "flash_if.h"
+#include "common_config.h"
+#include "settings_api.h"
+#include "crc.h"
+#include "gpio_io.h"
+#include "systick.h"
+
+#include <string.h>
+#include "tinystdio.h"
+
+/**
+  * @brief  Общая структура настроек
+  */
+extern SETTINGS_t sSettings;
+
+extern uint8_t fDoneReset;
+extern uint8_t fErrorReset;
+
+char debugMsg[40];
+
+static vu32 DataFlag=0;
+static vu32 size =0;
+static __IO uint32_t FlashWriteAddress;
+static u32 TotalReceived=0;
+static char LeftBytesTab[4];
+static u8 LeftBytes=0;
+static __IO u8 resetpage=0;
+static uint32_t ContentLengthOffset =0,BrowserFlag=0;
+static __IO uint32_t TotalData=0, checklogin=0;
+static bool fEraseFlash = true;
+
+static uint8_t reqCounter = 0;
+static uint8_t reqTimer = 0;
+
+struct http_state
+{
+  char *file;
+  u32_t left;
+};
+
+
+
+htmlpageState htmlpage;
+ 
+static const char http_crnl_2[4] =
+/* "\r\n--" */
+{0xd, 0xa,0x2d,0x2d};
+static const char octet_stream[14] = 
+/* "octet-stream" */
+{0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,0x0d, };
+static const char Content_Length[17] = 
+/* Content Length */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67,0x74, 0x68, 0x3a, 0x20, };
+
+
+static uint32_t Parse_Content_Length(char *data, uint32_t len);
+static void IAP_HTTP_writedata(char* data, uint32_t len);
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+static int fs_open(char *name, struct fs_file *file);
+
+uint16_t printLen = 0;
+char printBuf[1500];
+
+uint32_t oldAdd = USER_FLASH_FIRST_PAGE_ADDRESS;
+uint32_t deltaAdd = 0;
+
+/**
+  * @brief  callback function for handling connection errors
+  * @param  arg: pointer to an argument to be passed to callback function
+  * @param  err: LwIP error code   
+  * @retval none
+  */
+static void conn_err(void *arg, err_t err)
+{
+  struct http_state *hs;
+
+  hs = arg;
+  mem_free(hs);
+}
+
+/**
+  * @brief  closes tcp connection
+  * @param  pcb: pointer to a tcp_pcb struct
+  * @param  hs: pointer to a http_state struct
+  * @retval
+  */
+static void close_conn(struct tcp_pcb *pcb, struct http_state *hs)
+{
+  tcp_arg(pcb, NULL);
+  tcp_sent(pcb, NULL);
+  tcp_recv(pcb, NULL);
+  mem_free(hs);
+  tcp_close(pcb);
+
+  reqCounter++;
+}
+
+/**
+  * @brief sends data found in  member "file" of a http_state struct
+  * @param pcb: pointer to a tcp_pcb struct
+  * @param hs: pointer to a http_state struct
+  * @retval none
+  */
+static void send_data(struct tcp_pcb *pcb, struct http_state *hs)
+{
+  err_t err;
+  u16_t len;
+
+  /* We cannot send more data than space available in the send
+     buffer */
+  if (tcp_sndbuf(pcb) < hs->left)
+  {
+    len = tcp_sndbuf(pcb);
+  }
+  else
+  {
+    len = hs->left;
+  }
+  err = tcp_write(pcb, hs->file, len, 0);
+  if (err == ERR_OK)
+  {
+    hs->file += len;
+    hs->left -= len;
+  }
+}
+
+/**
+  * @brief tcp poll callback function
+  * @param arg: pointer to an argument to be passed to callback function
+  * @param pcb: pointer on tcp_pcb structure
+  * @retval err_t
+  */
+static err_t http_poll(void *arg, struct tcp_pcb *pcb)
+{
+  if (arg == NULL)
+  {
+    tcp_close(pcb);
+  }
+  else
+  {
+    send_data(pcb, (struct http_state *)arg);
+  }
+  return ERR_OK;
+}
+
+/**
+  * @brief callback function called after a successfull TCP data packet transmission  
+  * @param arg: pointer to an argument to be passed to callback function
+  * @param pcb: pointer on tcp_pcb structure
+  * @param len
+  * @retval err : LwIP error code
+  */
+static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
+{
+  struct http_state *hs;
+  hs = arg;
+
+  if (hs->left > 0)
+    send_data(pcb, hs);
+  else
+  {
+    close_conn(pcb, hs);
+	
+    if (htmlpage == UploadDonePage)
+	  fDoneReset = 1;
+	else if (htmlpage == UploadErrorPage)
+	  fErrorReset = 1;
+  }
+  return ERR_OK;
+}
+
+
+/**
+  * @brief callback function for handling TCP HTTP traffic
+  * @param arg: pointer to an argument structure to be passed to callback function
+  * @param pcb: pointer to a tcp_pcb structure
+  * @param p: pointer to a packet buffer
+  * @param err: LwIP error code
+  * @retval err
+  */
+/* goback.cgi - возврат в основную прошивку */
+/* upload.cgi - загрузка новой прошивки */
+static err_t http_recv(void *arg, struct tcp_pcb *pcb,  struct pbuf *p, err_t err)
+{
+  int32_t i, len=0;
+  uint32_t DataOffset, FilenameOffset;
+  char *data, *ptr, filename[13];
+  struct fs_file file = {0, 0};
+  struct http_state *hs;
+
+  hs = arg;
+
+  
+  
+  if (err == ERR_OK && p != NULL)
+  {
+    /* Inform TCP that we have taken the data */
+    tcp_recved(pcb, p->tot_len);
+    
+    if (hs->file == NULL)
+    {
+      data = p->payload;
+      len = p->tot_len;
+      
+	  printLen = p->tot_len;
+	  memcpy(printBuf, p->payload , printLen);
+	  //printf(printBuf);
+	  
+      /* process HTTP GET requests */
+      if (strncmp(data, "GET /", 5) == 0)
+      {/*
+        if ((strncmp(data, "GET /resetmcu.cgi", 17) ==0)&&(htmlpage == UploadDonePage))
+        {
+          htmlpage = ResetDonePage;
+          fs_open("/reset.html", &file);
+          hs->file = file.data;
+          hs->left = file.len;
+          pbuf_free(p);
+		  send_data(pcb, hs);   
+          resetpage = 1;
+          tcp_sent(pcb, http_sent);
+        }*/ 
+	    if (strncmp(data, "GET /upload.css", 15) == 0)
+	    {
+	      fs_open("/upload.css", &file);
+          hs->file = file.data;
+          hs->left = file.len;
+          pbuf_free(p);
+          send_data(pcb, hs);
+          tcp_sent(pcb, http_sent);
+	    }
+        else if (strncmp(data, "GET /upload.js", 14) == 0)
+        {
+	      fs_open("/upload.js", &file);
+          hs->file = file.data;
+          hs->left = file.len;
+          pbuf_free(p);
+          send_data(pcb, hs);
+          tcp_sent(pcb, http_sent);
+	    }
+	    /* Возврат в основную прошивку. Сбрасываем флаг loadmode,
+	       сохраняем настройки и перезагружаемся */
+        else if (strncmp(data, "GET /goback.cgi", 15)==0)
+        {
+          sSettings.bootParams.loadMode = 0;
+	      SETTINGS_Save();
+          Delay_ms(1010);
+		  NVIC_SystemReset();
+        }
+        else if (strncmp(data, "GET /favicon.ico", 16) == 0)
+        {
+          fs_open("/favicon.ico", &file);
+          hs->file = file.data;
+          hs->left = file.len;
+          send_data(pcb, hs);
+          tcp_sent(pcb, http_sent);
+        }
+        else
+        {
+          /*send the login page (which is the index page) */
+          htmlpage = LoginPage;
+          fs_open("/index.html", &file);
+          hs->file = file.data;
+          hs->left = file.len;
+          pbuf_free(p);
+          send_data(pcb, hs);
+          tcp_sent(pcb, http_sent);
+        }
+      }
+#if 1
+      /* process POST request for file upload and incoming data packets after POST request*/
+      else if ((strncmp(data, "POST /upload.cgi",16) == 0) || (DataFlag >= 1))
+      {
+		if (fEraseFlash) {
+		  FLASH_If_Erase(USER_FLASH_FIRST_PAGE_ADDRESS);
+		  fEraseFlash = false;
+		}
+
+        DataOffset = 0;
+        
+        /* POST Packet received */
+        if (DataFlag == 0)
+        { 
+          BrowserFlag = 0;
+          TotalReceived = 0;
+          
+          /* parse packet for Content-length field */
+          size = Parse_Content_Length(data, p->tot_len);
+           
+          /* parse packet for the octet-stream field */
+          for (i = 0; i < len; i++)
+          {
+             if (strncmp ((char*)(data+i), octet_stream, 13)==0)
+             {
+               DataOffset = i + 16;
+               break;
+             }
+          }  
+          /* case of MSIE8 : we do not receive data in the POST packet*/ 
+          if (DataOffset == 0)
+          {
+             DataFlag++;
+             BrowserFlag = 1;
+             pbuf_free(p);
+             return ERR_OK;
+             
+          }
+          /* case of Mozilla Firefox v3.6 : we receive data in the POST packet*/
+          else
+          {
+            TotalReceived = len - (ContentLengthOffset + 4);
+          }
+        }
+        
+        if (((DataFlag ==1)&&(BrowserFlag==1)) || ((DataFlag ==0)&&(BrowserFlag==0)))
+        { 
+           if ((DataFlag ==0)&&(BrowserFlag==0)) 
+           {
+             DataFlag++;
+           }
+           else if ((DataFlag ==1)&&(BrowserFlag==1))
+           {
+             /* parse packet for the octet-stream field */
+             for (i = 0; i < len; i++)
+             {
+               if (strncmp ((char*)(data+i), octet_stream, 13)==0)
+               {
+                 DataOffset = i+16;
+                 break;
+               }
+             }
+             TotalReceived += len;
+             DataFlag++;
+           }  
+                
+           /* parse packet for the filename field */
+           FilenameOffset = 0;
+           for (i = 0; i < len; i++)
+           {
+             if (strncmp ((char*)(data+i), "filename=", 9)==0)
+             {
+                FilenameOffset = i+10;
+                break;
+             }
+           }
+           i = 0;
+           if (FilenameOffset)
+           {
+             while((*(data+FilenameOffset + i)!=0x22 )&&(i<13))
+             {
+               filename[i] = *(data+FilenameOffset + i);
+               i++;
+             }
+             filename[i] = 0x0;
+           }
+           
+           if (i==0)
+           {
+             htmlpage = FileUploadPage;
+             /* no filename, in this case reload upload page */
+             fs_open("/upload.html", &file);
+             hs->file = file.data;
+             hs->left = file.len;
+             pbuf_free(p);
+             
+             /* send index.html page */ 
+             send_data(pcb, hs);
+          
+             /* Tell TCP that we wish be to informed of data that has been
+             successfully sent by a call to the http_sent() function. */
+             tcp_sent(pcb, http_sent); 
+             DataFlag=0;
+             return ERR_OK;
+
+           }
+
+           PRINT_USART("\n\r  IAP using HTTP  \n\r");
+           sprintf(debugMsg, "File: %s\n\r",filename);
+           PRINT_USART(debugMsg);
+           PRINT_USART("State: Erasing...\n\r");
+          
+           TotalData =0 ;
+           /* init flash */
+           FLASH_If_Init();
+           /* erase user flash area */
+           //FLASH_If_Erase(USER_FLASH_FIRST_PAGE_ADDRESS);
+
+           FlashWriteAddress = USER_FLASH_FIRST_PAGE_ADDRESS;
+          
+           /*indicate start of flash programming */
+           PRINT_USART("\n\rState: Programming..\n\r");
+         }
+         /* DataFlag >1 => the packet is data only  */
+         else 
+         {
+           TotalReceived +=len;
+         }
+        
+         ptr = (char*)(data + DataOffset);
+         len-= DataOffset;
+        
+         /* update Total data received counter */
+         TotalData +=len;
+        
+         /* check if last data packet */
+         if (TotalReceived == size)
+         {
+           /* if last packet need to remove the http boundary tag */
+           /* parse packet for "\r\n--" starting from end of data */
+           /*
+		   i = 4;
+           while (strncmp ((char*)(data+ p->tot_len -i),http_crnl_2 , 4))
+           {
+             i++;
+           }
+           len -= i;
+           TotalData -= i;
+           */
+           /* write data in Flash */
+           if (len)
+             IAP_HTTP_writedata(ptr,len);
+
+           DataFlag=0;
+           htmlpage = UploadDonePage;
+
+           PRINT_USART("Tot bytes Received:\n\r");
+           sprintf(debugMsg, "%d bytes \n\r",TotalData);
+           PRINT_USART(debugMsg);
+           PRINT_USART("State: Prog Finished \n\r");
+
+		   /* Проверяем CRC */
+   		   if (CRC_Read() == CRC_Calcucate()) {
+ 			 fs_open("/success.html", &file);
+             hs->file = file.data;
+             hs->left = file.len;
+             send_data(pcb, hs);
+			 tcp_sent(pcb, http_sent);
+			 htmlpage = UploadDonePage;
+           }
+
+		   else
+		   {
+		     fs_open("/error.html", &file);
+             hs->file = file.data;
+             hs->left = file.len;
+             send_data(pcb, hs);
+			 tcp_sent(pcb, http_sent);
+			 htmlpage = UploadErrorPage;
+		   }
+
+
+           /*
+		   sSettings.bootParams.loadMode = 0;
+           SETTINGS_Save();
+           IO_KeyBlockOn();
+           Delay_ms(1010);
+	       NVIC_SystemReset();
+		   */
+
+        }
+        /* not last data packet */
+        else
+        {
+          /* write data in flash */
+          if(len)
+            IAP_HTTP_writedata(ptr,len);
+        }
+        pbuf_free(p);
+      }
+      else
+      {
+       /* Bad HTTP requests */
+        PRINT_USART("Bad HTTP request\n\r");
+
+		pbuf_free(p);
+        close_conn(pcb, hs);
+      }
+#endif
+    }
+    else
+    {
+      pbuf_free(p);
+      close_conn(pcb,hs);
+    }
+  }
+  if (err == ERR_OK && p == NULL)
+  {
+    /* received empty frame */
+    PRINT_USART("Received empty frame\n\r");
+
+	close_conn(pcb, hs);
+  }
+  return ERR_OK;
+}
+
+/**
+  * @brief  callback function on TCP connection setup ( on port 80)
+  * @param  arg: pointer to an argument structure to be passed to callback function
+  * @param  pcb: pointer to a tcp_pcb structure
+  * &param  err: Lwip stack error code
+  * @retval err
+  */
+static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
+{
+  struct http_state *hs;
+
+  /* Allocate memory for the structure that holds the state of the connection */
+  hs = mem_malloc(sizeof(struct http_state));
+
+  if (hs == NULL)
+  {
+    return ERR_MEM;
+  }
+
+  /* Initialize the structure. */
+  hs->file = NULL;
+  hs->left = 0;
+
+  /* Tell TCP that this is the structure we wish to be passed for our
+     callbacks. */
+  tcp_arg(pcb, hs);
+
+  /* Tell TCP that we wish to be informed of incoming data by a call
+     to the http_recv() function. */
+  tcp_recv(pcb, http_recv);
+
+  tcp_err(pcb, conn_err);
+
+  tcp_poll(pcb, http_poll, 10);
+  return ERR_OK;
+}
+
+/**
+  * @brief  intialize HTTP webserver  
+  * @param  none
+  * @retval none
+  */
+void IAP_httpd_init(void)
+{
+  struct tcp_pcb *pcb;
+  /*create new pcb*/
+  pcb = tcp_new();
+  /* bind HTTP traffic to pcb */
+  tcp_bind(pcb, IP_ADDR_ANY, 80);
+  /* start listening on port 80 */
+  pcb = tcp_listen(pcb);
+  /* define callback function for TCP connection setup */
+  tcp_accept(pcb, http_accept);
+}
+
+/**
+  * @brief  Opens a file defined in fsdata.c ROM filesystem 
+  * @param  name : pointer to a file name
+  * @param  file : pointer to a fs_file structure  
+  * @retval  1 if success, 0 if fail
+  */
+static int fs_open(char *name, struct fs_file *file)
+{
+  struct fsdata_file_noconst *f;
+
+  for (f = (struct fsdata_file_noconst *)FS_ROOT; f != NULL; f = (struct fsdata_file_noconst *)f->next)
+  {
+    if (!strcmp(name, f->name))
+    {
+      file->data = f->data;
+      file->len = f->len;
+      return 1;
+    }
+  }
+  return 0;
+}
+
+/**
+  * @brief  Extract the Content_Length data from HTML data  
+  * @param  data : pointer on receive packet buffer 
+  * @param  len  : buffer length  
+  * @retval size : Content_length in numeric format
+  */
+static uint32_t Parse_Content_Length(char *data, uint32_t len)
+{
+  uint32_t i=0,size=0, S=1;
+  int32_t j=0;
+  char sizestring[6], *ptr;
+   
+  ContentLengthOffset =0;
+
+  /* find Content-Length data in packet buffer */
+  for (i=0;i<len;i++)
+  {
+    if (strncmp ((char*)(data+i), Content_Length, 16)==0)
+    {
+      ContentLengthOffset = i+16;
+      break;
+    }
+  }
+  /* read Content-Length value */
+  if (ContentLengthOffset)
+  {
+    i=0;
+    ptr = (char*)(data + ContentLengthOffset);
+    while(*(ptr+i)!=0x0d)
+    {
+      sizestring[i] = *(ptr+i);
+      i++;
+      ContentLengthOffset++; 
+    }
+    if (i>0)
+    {
+      /* transform string data into numeric format */
+      for(j=i-1;j>=0;j--)
+      {
+        size += (sizestring[j]-0x30)*S;
+        S=S*10;
+      }
+    }
+  }
+  return size;
+}
+
+/**
+  * @brief  writes received data in flash    
+  * @param  ptr: data pointer
+  * @param  len: data length
+  * @retval none 
+  */
+void IAP_HTTP_writedata(char * ptr, uint32_t len)            
+{
+  uint32_t count, i=0, j=0;
+  /* check if any left bytes from previous packet transfer*/
+  /* if it is the case do a concat with new data to create a 32-bit word */
+  if (LeftBytes)
+  {
+    while(LeftBytes<=3)
+    {
+      if(len>(j+1))
+      {
+        LeftBytesTab[LeftBytes++] = *(ptr+j);
+      }
+      else
+      {
+        LeftBytesTab[LeftBytes++] = 0xFF;
+      }
+      j++;
+    }
+    FLASH_If_Write(&FlashWriteAddress, (u32*)(LeftBytesTab),1);
+	
+    LeftBytes =0;
+    
+    /* update data pointer */
+    ptr = (char*)(ptr+j);
+    len = len -j;
+  }
+  
+  /* write received bytes into flash */
+  count = len/4;
+  
+  /* check if remaining bytes < 4 */
+  i= len%4;
+  if (i>0)
+  {
+    if (TotalReceived != size)
+    {
+      /* store bytes in LeftBytesTab */
+      LeftBytes=0;
+      for(;i>0;i--)
+      LeftBytesTab[LeftBytes++] = *(char*)(ptr+ len-i);  
+    }
+    else count++;
+  }
+  FLASH_If_Write(&FlashWriteAddress, (u32*)ptr ,count);
+}
+
+uint32_t ReturnFlashWriteAddress(void)
+{
+  return FlashWriteAddress;
+}
+
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

+ 69 - 0
iap/Modules/Ethernet/httpserver.h

@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * http.h
+ *                     
+ * Author : Adam Dunkels <adam@sics.se>                               
+ *
+ * CHANGELOG: this file has been modified by Sergio Perez Alcaсiz <serpeal@upvnet.upv.es> 
+ *            Departamento de Informбtica de Sistemas y Computadores          
+ *            Universidad Politйcnica de Valencia                             
+ *            Valencia (Spain)    
+ *            Date: March 2003                                          
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "lwip/def.h"
+#include "fsdata.h"
+#include "stm32f4xx.h"
+
+typedef enum 
+{
+  LoginPage = 0,
+  FileUploadPage,
+  UploadDonePage,
+  UploadErrorPage,
+  ResetDonePage
+  	
+}htmlpageState;
+
+struct fs_file {
+  char *data;
+  int len;
+};
+
+void IAP_httpd_init(void);
+
+uint16_t Finder(char* data, uint16_t len);
+
+uint32_t ReturnFlashWriteAddress(void);
+
+#endif /* __HTTPD_H__ */

+ 230 - 0
iap/Modules/Ethernet/lwipopts.h

@@ -0,0 +1,230 @@
+/**
+  ******************************************************************************
+  * @file    lwipopts.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    31-October-2011
+  * @brief   lwIP Options Configuration.
+  *          This file is based on Utilities\lwip_v1.3.2\src\include\lwip\opt.h 
+  *          and contains the lwIP configuration for the STM32F4x7 demonstration.
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  *
+  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
+  ******************************************************************************
+  */
+
+#ifndef __LWIPOPTS_H__
+#define __LWIPOPTS_H__
+
+/**
+ * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
+ * critical regions during buffer allocation, deallocation and memory
+ * allocation and deallocation.
+ */
+#define SYS_LIGHTWEIGHT_PROT    0
+
+/**
+ * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
+ * use lwIP facilities.
+ */
+#define NO_SYS                  1
+
+/* ---------- Memory options ---------- */
+/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
+   lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
+   byte alignment -> define MEM_ALIGNMENT to 2. */
+#define MEM_ALIGNMENT           4
+
+/* MEM_SIZE: the size of the heap memory. If the application will send
+a lot of data that needs to be copied, this should be set high. */
+#define MEM_SIZE                (5*1024)
+//#define MEM_SIZE                (10*1024)
+
+/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
+   sends a lot of data out of ROM (or other static memory), this
+   should be set high. */
+//#define MEMP_NUM_PBUF           100
+///#define MEMP_NUM_PBUF           40
+#define MEMP_NUM_PBUF           50
+/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+   per active UDP "connection". */
+#define MEMP_NUM_UDP_PCB        6
+/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB        10
+//#define MEMP_NUM_TCP_PCB        5
+/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
+   connections. */
+#define MEMP_NUM_TCP_PCB_LISTEN 5
+//#define MEMP_NUM_TCP_PCB_LISTEN 15
+/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
+   segments. */
+#define MEMP_NUM_TCP_SEG        25
+//#define MEMP_NUM_TCP_SEG        100	 
+/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
+   timeouts. */
+#define MEMP_NUM_SYS_TIMEOUT    10
+//#define MEMP_NUM_SYS_TIMEOUT    100
+
+//#define MEMP_NUM_RAW_PCB        20
+
+
+/* ---------- Pbuf options ---------- */
+/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
+#define PBUF_POOL_SIZE          15
+//#define PBUF_POOL_SIZE          25
+//#define PBUF_POOL_SIZE          18
+
+/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
+//#define PBUF_POOL_BUFSIZE       1500
+//#define PBUF_POOL_BUFSIZE       3024
+#define PBUF_POOL_BUFSIZE         1540
+
+
+
+/* ---------- TCP options ---------- */
+#define LWIP_TCP                1
+#define TCP_TTL                 255
+
+/* Controls if TCP should queue segments that arrive out of
+   order. Define to 0 if your device is low on memory. */
+#define TCP_QUEUE_OOSEQ         0
+
+/* TCP Maximum segment size. */
+#define TCP_MSS                 (1500 - 40)	  /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
+
+/* TCP sender buffer space (bytes). */
+//#define TCP_SND_BUF             (5*TCP_MSS)
+//#define TCP_SND_BUF             (18*TCP_MSS)
+#define TCP_SND_BUF             (18*TCP_MSS)
+
+/*  TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
+  as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
+//20 
+#define TCP_SND_QUEUELEN        (4* TCP_SND_BUF/TCP_MSS)
+//#define TCP_SND_QUEUELEN        (4* TCP_SND_BUF/TCP_MSS)
+
+/* TCP receive window. */
+#define TCP_WND                 (4*TCP_MSS)
+
+
+/* ---------- ICMP options ---------- */
+#define LWIP_ICMP                       1
+//#define ICMP_TTL			128
+
+/* ---------- DHCP options ---------- */
+/* Define LWIP_DHCP to 1 if you want DHCP configuration of
+   interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
+   turning this on does currently not work. */
+#define LWIP_DHCP               1
+
+
+/* ---------- UDP options ---------- */
+#define LWIP_UDP                1
+#define UDP_TTL                 255
+
+
+/* ---------- Statistics options ---------- */
+#define LWIP_STATS 1
+#define LWIP_PROVIDE_ERRNO 1
+
+
+/*
+   --------------------------------------
+   ---------- Checksum options ----------
+   --------------------------------------
+*/
+
+/* 
+The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
+ - To use this feature let the following define uncommented.
+ - To disable it and process by CPU comment the  the checksum.
+*/
+#define CHECKSUM_BY_HARDWARE 
+
+
+#ifdef CHECKSUM_BY_HARDWARE
+  /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
+  #define CHECKSUM_GEN_IP                 0
+  /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
+  #define CHECKSUM_GEN_UDP                0
+  /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
+  #define CHECKSUM_GEN_TCP                0 
+  /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
+  #define CHECKSUM_CHECK_IP               0
+  /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
+  #define CHECKSUM_CHECK_UDP              0
+  /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
+  #define CHECKSUM_CHECK_TCP              0
+#else
+  /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
+  #define CHECKSUM_GEN_IP                 1
+  /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
+  #define CHECKSUM_GEN_UDP                1
+  /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
+  #define CHECKSUM_GEN_TCP                1
+  /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
+  #define CHECKSUM_CHECK_IP               1
+  /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
+  #define CHECKSUM_CHECK_UDP              1
+  /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
+  #define CHECKSUM_CHECK_TCP              1
+#endif
+
+
+/*
+   ----------------------------------------------
+   ---------- Sequential layer options ----------
+   ----------------------------------------------
+*/
+/**
+ * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
+ */
+#define LWIP_NETCONN                    0
+
+/*
+   ------------------------------------
+   ---------- Socket options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
+ */
+#define LWIP_SOCKET                     0
+
+/*
+   -----------------------------------
+   ---------- DEBUG options ----------
+   -----------------------------------
+*/
+
+//#define LWIP_DEBUG
+
+#define NETIF_DEBUG                     LWIP_DBG_OFF
+#define TCP_DEBUG                       LWIP_DBG_ON
+#define ETHARP_DEBUG                    LWIP_DBG_OFF
+#define PBUF_DEBUG                      LWIP_DBG_OFF
+#define IP_DEBUG                        LWIP_DBG_OFF
+#define TCPIP_DEBUG                     LWIP_DBG_ON
+#define DHCP_DEBUG                      LWIP_DBG_ON
+#define UDP_DEBUG                       LWIP_DBG_OFF
+#define SOCKETS_DEBUG                   LWIP_DBG_ON
+#define MEMP_DEBUG                      LWIP_DBG_ON
+#define MEM_DEBUG                       LWIP_DBG_ON
+#define PING_DEBUG                      LWIP_DBG_OFF
+#define SNMP_MSG_DEBUG                  LWIP_DBG_OFF
+#define SNMP_MIB_DEBUG                  LWIP_DBG_OFF
+#define RAW_DEBUG                       LWIP_DBG_ON
+
+
+#endif /* __LWIPOPTS_H__ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

BIN
iap/Modules/Ethernet/makefsdata.exe


+ 240 - 0
iap/Modules/Ethernet/netconf.c

@@ -0,0 +1,240 @@
+/* Includes ------------------------------------------------------------------*/
+#include "lwip/mem.h"
+#include "lwip/memp.h"
+#include "lwip/tcp.h"
+#include "lwip/tcp_impl.h"
+#include "lwip/udp.h"
+#include "netif/etharp.h"
+#include "lwip/dhcp.h"
+#include "lwip/ip_addr.h"
+#include "ethernetif.h"
+#include "main.h"
+#include "netconf.h"
+#include "common_config.h"
+#include "settings_api.h"
+#include "tinystdio.h"
+#include "lwip/timers.h"
+#include "lwip/init.h"
+
+/* Private typedef -----------------------------------------------------------*/
+#define MAX_DHCP_TRIES        4
+
+/* Private define ------------------------------------------------------------*/
+typedef enum 
+{ 
+  DHCP_START=0,
+  DHCP_WAIT_ADDRESS,
+  DHCP_ADDRESS_ASSIGNED,
+  DHCP_TIMEOUT
+} 
+DHCP_State_TypeDef;
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+struct netif netif;
+uint32_t TCPTimer = 0;
+uint32_t ARPTimer = 0;
+uint32_t DHCPfineTimer = 0;
+uint32_t DHCPcoarseTimer = 0;
+DHCP_State_TypeDef DHCP_state = DHCP_START;
+
+
+/**
+  * @brief  Общая структура настроек
+  */
+extern SETTINGS_t sSettings;
+
+/* Private functions ---------------------------------------------------------*/
+void LwIP_DHCP_Process_Handle(void);
+/**
+  * @brief  Initializes the lwIP stack
+  * @param  None
+  * @retval None
+  */
+void LwIP_Init(void)
+{
+  struct ip_addr ipaddr;
+  struct ip_addr netmask;
+  struct ip_addr gw;
+  char str[20];
+
+  lwip_init();
+
+//  /* Initializes the dynamic memory heap defined by MEM_SIZE.*/
+//  mem_init();
+//
+//  /* Initializes the memory pools defined by MEMP_NUM_x.*/
+//  memp_init();
+
+  if (sSettings.sWebParams.dhcpEnable)
+  {	
+    ipaddr.addr = 0;
+    netmask.addr = 0;
+    gw.addr = 0;
+  }
+  else
+  {	
+	sprintf(str, " %s\n\r", sSettings.sWebTempParams.ip);
+    PRINT_USART("\n\rStatic IP address   \n\r");
+    PRINT_USART(str);
+	  
+	ipaddr.addr = ipaddr_addr(sSettings.sWebParams.ip);
+	netmask.addr = ipaddr_addr(sSettings.sWebParams.mask);
+	gw.addr = ipaddr_addr(sSettings.sWebParams.gate);
+  }	
+
+  netif_add(&netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);
+  netif_set_default(&netif);
+  netif_set_up(&netif);
+}
+
+/**
+  * @brief  Called when a frame is received
+  * @param  None
+  * @retval None
+  */
+void LwIP_Pkt_Handle(void)
+{
+  /* Read a received packet from the Ethernet buffers and send it to the lwIP for handling */
+  ethernetif_input(&netif);
+}
+
+///**
+//  * @brief  LwIP periodic tasks
+//  * @param  localtime the current LocalTime value
+//  * @retval None
+//  */
+//void LwIP_Periodic_Handle(__IO uint32_t localtime)
+//{
+//#if LWIP_TCP
+//  /* TCP periodic process every 250 ms */
+//  if (localtime - TCPTimer >= TCP_TMR_INTERVAL) {
+//    TCPTimer =  localtime;
+//    tcp_tmr();
+//  }
+//#endif
+//
+//  /* ARP periodic process every 5s */
+//  if ((localtime - ARPTimer) >= ARP_TMR_INTERVAL) {
+//    ARPTimer =  localtime;
+//    etharp_tmr();
+//  }
+//
+//  if (sSettings.sWebParams.dhcpEnable)
+//  {
+//    /* Fine DHCP periodic process every 500ms */
+//    if (localtime - DHCPfineTimer >= DHCP_FINE_TIMER_MSECS) {
+//      DHCPfineTimer =  localtime;
+//      dhcp_fine_tmr();
+//      if ((DHCP_state != DHCP_ADDRESS_ASSIGNED)&&(DHCP_state != DHCP_TIMEOUT)) {
+//        /* process DHCP state machine */
+//        LwIP_DHCP_Process_Handle();
+//      }
+//    }
+//
+//    /* DHCP Coarse periodic process every 60s */
+//    if (localtime - DHCPcoarseTimer >= DHCP_COARSE_TIMER_MSECS) {
+//      DHCPcoarseTimer =  localtime;
+//      dhcp_coarse_tmr();
+//    }
+//  }
+//
+//}
+
+/**
+  * @brief  LwIP periodic tasks
+  * @param  localtime the current LocalTime value
+  * @retval None
+  */
+void LwIP_Periodic_Handle(__IO uint32_t localtime)
+{
+  if (sSettings.sWebParams.dhcpEnable)
+  {
+    /* Fine DHCP periodic process every 500ms */
+
+      if ((DHCP_state != DHCP_ADDRESS_ASSIGNED)&&(DHCP_state != DHCP_TIMEOUT)) {
+        /* process DHCP state machine */
+        LwIP_DHCP_Process_Handle();    
+      }
+  }
+
+  sys_check_timeouts();
+}
+
+/**
+  * @brief  LwIP_DHCP_Process_Handle
+  * @param  None
+  * @retval None
+  */
+void LwIP_DHCP_Process_Handle()
+{
+  struct ip_addr ipaddr;
+  struct ip_addr netmask;
+  struct ip_addr gw;
+
+  switch (DHCP_state)
+  {
+    case DHCP_START:
+    {
+      dhcp_start(&netif);
+      DHCP_state = DHCP_WAIT_ADDRESS;
+	  PRINT_USART("\n\rLooking for DHCP server please wait...\n\r");
+    }
+    break;
+
+    case DHCP_WAIT_ADDRESS:
+    {
+	  ipaddr = netif.ip_addr;
+      netmask = netif.netmask;
+      gw = netif.gw;
+	  
+      if (ipaddr.addr != 0) 
+	  {
+        DHCP_state = DHCP_ADDRESS_ASSIGNED;	
+
+        /* Stop DHCP */
+        dhcp_stop(&netif);
+    
+        PRINT_USART("Parameters assigned by a DHCP server:\n\r     IP:   ");
+        PRINT_USART(ipaddr_ntoa(&ipaddr));
+		PRINT_USART("\n\r");
+          
+		PRINT_USART("Netmask:   ");
+		PRINT_USART(ipaddr_ntoa(&netmask));
+		PRINT_USART("\n\r");
+		  
+		PRINT_USART("Gateway:   ");
+		PRINT_USART(ipaddr_ntoa(&gw));
+		PRINT_USART("\n\r");
+
+      } else {
+        /* DHCP timeout */
+        if (netif.dhcp->tries > MAX_DHCP_TRIES) 
+		{
+          DHCP_state = DHCP_TIMEOUT;
+
+          /* Stop DHCP */
+          dhcp_stop(&netif);
+
+//		  ipaddr.addr = ipaddr_addr(sSettings.sWebTempParams.ip);
+//	      netmask.addr = ipaddr_addr(sSettings.sWebTempParams.mask);
+//	      gw.addr = ipaddr_addr(sSettings.sWebTempParams.gate);
+          
+          ipaddr.addr = ipaddr_addr("192.168.14.48");
+          netmask.addr = ipaddr_addr("255.255.255.0");
+          gw.addr = ipaddr_addr("192.168.14.1");
+
+          netif_set_addr(&netif, &ipaddr , &netmask, &gw);
+		  
+		  PRINT_USART("DHCP timeout\n\r");
+          PRINT_USART("\n\rStatic IP address\n\r");
+	      PRINT_USART(ipaddr_ntoa(&ipaddr));
+		  PRINT_USART("\n\r");
+        }
+      }
+    }
+    break;
+    default: break;
+  }
+}     
+
+/*********** Portions COPYRIGHT 2012 Embest Tech. Co., Ltd.*****END OF FILE****/

+ 69 - 0
iap/Modules/Ethernet/netconf.h

@@ -0,0 +1,69 @@
+/**
+  ******************************************************************************
+  * @file    netconf.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    31-October-2011 
+  * @brief   This file contains all the functions prototypes for the netconf.c 
+  *          file.
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  *
+  * <h2><center>&copy; Portions COPYRIGHT 2011 STMicroelectronics</center></h2>
+  ******************************************************************************
+  */
+/**
+  ******************************************************************************
+  * <h2><center>&copy; Portions COPYRIGHT 2012 Embest Tech. Co., Ltd.</center></h2>
+  * @file    netconf.h
+  * @author  CMP Team
+  * @version V1.0.0
+  * @date    28-December-2012
+  * @brief   This file contains all the functions prototypes for the netconf.c 
+  *          file.
+  *          Modified to support the STM32F4DISCOVERY, STM32F4DIS-BB and
+  *          STM32F4DIS-LCD modules. 
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, Embest SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+  * OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+  * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+  * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  ******************************************************************************
+  */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __NETCONF_H
+#define __NETCONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+   
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+void LwIP_Init(void);
+void LwIP_Pkt_Handle(void);
+void LwIP_Periodic_Handle(__IO uint32_t localtime);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONF_H */
+
+
+/*********** Portions COPYRIGHT 2012 Embest Tech. Co., Ltd.*****END OF FILE****/
+

+ 56 - 0
iap/Modules/crc.c

@@ -0,0 +1,56 @@
+/******************************* (C) LiteMesh **********************************
+* @module  crc
+ * @file    crc.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   crc
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    kim  First release.
+ *******************************************************************************
+ */
+   
+#include "stm32f4xx.h"
+#include "crc.h"
+#include "common_config.h"
+/**
+  * @brief  
+  * @retval 
+  */
+void CRC_Init(void)
+{
+  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
+  CRC->CR |= CRC_CR_RESET;  
+}
+
+/**
+  * @brief  
+  * @retval 
+  */
+void CRC_DeInit(void)
+{
+  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, DISABLE);
+}
+/**
+  * @brief Читаем crc из последних 4х байт записанной прошивки
+  * @retval 
+  */
+uint32_t CRC_Read(void) {
+  uint32_t* ptr = (uint32_t*)USER_FLASH_CRC_ADDRESS;
+  return *ptr;
+}
+
+/**
+  * @brief Считаем crc для записанной прошивки
+  * @retval 
+  */
+uint32_t CRC_Calcucate(void) {
+  uint32_t res;
+  /* Reset CRC */
+  CRC->CR = ((uint8_t)0x01);
+  for(uint32_t* ptr=(uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS;ptr != (uint32_t*)USER_FLASH_CRC_ADDRESS;ptr++)
+    CRC->DR = *ptr; // добавляем всю прошивку в CRC
+  res = CRC->DR;
+  return res;
+}
+ /******************************* (C) SWITRON *********************************/

+ 35 - 0
iap/Modules/crc.h

@@ -0,0 +1,35 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  crc
+ * @file    crc.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   crc
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    kim  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef CRC_H
+#define CRC_H
+   
+#include "stm32f4xx.h"
+
+/**
+  * @brief  
+  */
+void CRC_Init(void);
+/**
+  * @brief Читаем crc из последних 4х байт записанной прошивки
+  * @retval 
+  */
+uint32_t CRC_Read(void);
+/**
+  * @brief Считаем crc для записанной прошивки
+  * @retval 
+  */
+uint32_t CRC_Calcucate(void);
+
+#endif /* #ifndef CRC_H */
+/****************************** (C) SWITRON ***************** end of file ****/

+ 138 - 0
iap/Modules/flash_if.c

@@ -0,0 +1,138 @@
+/**
+  ******************************************************************************
+  * @file    flash_if.c 
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    31-October-2011
+  * @brief   This file provides high level routines to manage internal Flash 
+  *          programming (erase and write). 
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  *
+  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
+  ******************************************************************************
+  */
+
+/* Includes ------------------------------------------------------------------*/
+#include "flash_if.h"
+#include "httpserver.h"
+#include "common_config.h"
+#include "wdg.h"
+
+#include "tinystdio.h"
+
+/**
+  * @brief  Чтение данных из flash
+  * @param  address
+  * @retval data
+  */
+uint32_t flash_read(uint32_t address)
+{
+  return (*(__IO uint32_t*) address);
+}
+
+/**
+  * @brief  Unlocks Flash for write access
+  * @param  None
+  * @retval None
+  */
+void FLASH_If_Init(void)
+{ 
+  FLASH_Unlock(); 
+}
+
+/**
+  * @brief  This function does an erase of all user flash area
+  * @param  StartSector: start of user flash area
+  * @retval 0: user flash area successfully erased
+  *         1: error occurred
+  */
+int8_t FLASH_If_Erase(uint32_t StartSector)
+{
+  uint32_t FlashAddress;
+  
+  FlashAddress = StartSector;
+
+  /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
+     be done by word */ 
+ 
+  if (FlashAddress <= (uint32_t) USER_FLASH_LAST_PAGE_ADDRESS)
+  {
+	FLASH_Unlock();
+	GPIOE->ODR ^= WDT_PIN;
+    FLASH_EraseSector(FLASH_Sector_5, VoltageRange_3); /* 128 Kbyte */
+	GPIOE->ODR ^= WDT_PIN;
+    FLASH_EraseSector(FLASH_Sector_6, VoltageRange_3); /* 128 Kbyte */
+	GPIOE->ODR ^= WDT_PIN;
+	FLASH_EraseSector(FLASH_Sector_7, VoltageRange_3); /* 128 Kbyte */
+	GPIOE->ODR ^= WDT_PIN;
+	/* Check if we use more than 512K flash */
+	if (USER_FLASH_END_ADDRESS > 0x08000000 + 0x7FFFF) {
+        FLASH_EraseSector(FLASH_Sector_8, VoltageRange_3); /* 128 Kbyte */
+        GPIOE->ODR ^= WDT_PIN;
+        FLASH_EraseSector(FLASH_Sector_9, VoltageRange_3); /* 128 Kbyte */
+        GPIOE->ODR ^= WDT_PIN;
+	}
+	FLASH_Lock();
+  }
+  else
+  {
+    return (1);
+  }
+
+  return (0);
+}
+/**
+  * @brief  This function writes a data buffer in flash (data are 32-bit aligned).
+  * @note   After writing data buffer, the flash content is checked.
+  * @param  FlashAddress: start address for writing data buffer
+  * @param  Data: pointer on data buffer
+  * @param  DataLength: length of data buffer (unit is 32-bit word)   
+  * @retval 0: Data successfully written to Flash memory
+  *         1: Error occurred while writing data in Flash memory
+  *         2: Written Data in flash memory is different from expected one
+  */
+uint32_t FLASH_If_Write(__IO uint32_t* FlashAddress, uint32_t* Data ,uint16_t DataLength)
+{
+  uint32_t i = 0;
+  uint32_t delta;
+  /*
+  delta = 0x0805FFFF - *FlashAddress; // ReturnFlashWriteAddress();
+  printf("%i", delta);
+  
+  if ((delta < 1460) && (DataLength != 1))
+	DataLength = delta / 4;
+  */
+  for (i = 0; (i < DataLength) && (*FlashAddress <= (USER_FLASH_END_ADDRESS)); i++)
+  {
+    /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
+       be done by word */ 
+    if (FLASH_ProgramWord(*FlashAddress, *(uint32_t*)(Data+i)) == FLASH_COMPLETE)
+    {
+     /* Check the written value */
+      if (*(uint32_t*)*FlashAddress != *(uint32_t*)(Data+i))
+      {
+        /* Flash content doesn't match SRAM content */
+        return(2);
+      }
+      /* Increment FLASH destination address */
+      *FlashAddress += 4;
+    }
+    else
+    {
+      /* Error occurred while writing data in Flash memory */
+      return (1);
+    }
+  }
+
+  return (0);
+}
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

+ 44 - 0
iap/Modules/flash_if.h

@@ -0,0 +1,44 @@
+/**
+  ******************************************************************************
+  * @file    flash_if.h 
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    31-October-2011
+  * @brief   Header for flash_if.c module
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  *
+  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __FLASH_IF_H
+#define __FLASH_IF_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+#define USER_FLASH_SIZE   (USER_FLASH_END_ADDRESS - USER_FLASH_FIRST_PAGE_ADDRESS)
+
+/**
+  * @brief  Чтение данных из flash
+  */
+uint32_t flash_read(uint32_t address);
+
+uint32_t FLASH_If_Write(__IO uint32_t* Address, uint32_t* Data, uint16_t DataLength);
+int8_t FLASH_If_Erase(uint32_t StartSector);
+void FLASH_If_Init(void);
+
+#endif /* __FLASH_IF_H */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

+ 48 - 0
iap/Modules/gpio_io.c

@@ -0,0 +1,48 @@
+/********************************* (C) РОТЕК ***********************************
+ * @module  gpio_io
+ * @file    gpio_io.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   gpio_io
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+#include "stm32f4xx.h"  
+#include "gpio_io.h"
+#include <stdbool.h>
+
+#include "tinystdio.h"
+
+/**
+  * @brief  Инициализация дискретных входов-выходов
+  * @retval 
+  */
+void IO_Init(void)
+{
+	  GPIO_InitTypeDef GPIO_InitStructure;
+
+	  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOE, ENABLE);
+
+	  /* ----------------------------- Inputs ---------------------------------- */
+
+	  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN;
+	  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
+	  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+	  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
+
+	  /* BUTTON DEFAULT - " " */
+	  GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_10;
+	  GPIO_Init(GPIOE, &GPIO_InitStructure);
+}
+
+/**
+  * @brief  Получить состояние кнопки DEFAULT
+  */
+bool IO_BtnDefaultPressed(void)
+{
+  	return !GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_10);  // BUTTON DEFAULT
+}
+/********************************* (C) РОТЕК **********************************/

+ 31 - 0
iap/Modules/gpio_io.h

@@ -0,0 +1,31 @@
+/********************************* (C) РОТЕК ***********************************
+ * @module  gpio_io
+ * @file    gpio_io.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   gpio_io
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef GPIO_IO_H
+#define GPIO_IO_H
+
+#include <stdbool.h>
+
+/**
+  * @brief  Инициализация дискретных входов-выходов
+  */
+void IO_Init(void);
+  
+/**
+  * @brief  Получить состояние кнопки DEFAULT
+  */
+bool IO_BtnDefaultPressed(void);
+
+#endif /* #ifndef GPIO_IO_H */
+
+/********************************* (C) РОТЕК **********************************/

+ 136 - 0
iap/Modules/led.c

@@ -0,0 +1,136 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  led
+ * @file    led.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Template
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+   
+#include "stm32f4xx.h"
+#include "led.h"
+
+LED_t LED_GreenInt;
+LED_t LED_RedInt;
+
+LED_t LEDS[2];
+
+/**
+  * @brief  
+  * @retval 
+  */
+void LED_Init(void)
+{
+	 GPIO_InitTypeDef GPIO_InitStructure;
+
+	  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA, ENABLE);
+
+	  LEDS[GREEN_STATUS].GPIOx = GPIOA;
+	  LEDS[GREEN_STATUS].GPIO_Pin = GPIO_Pin_3;
+	  LEDS[GREEN_STATUS].revers = 1;
+
+	  LEDS[RED_STATUS].GPIOx = GPIOA;
+	  LEDS[RED_STATUS].GPIO_Pin = GPIO_Pin_4;
+	  LEDS[RED_STATUS].revers = 1;
+
+	  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
+
+	  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+	  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
+	  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+	  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+	  GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+	  LED_Off(GREEN_STATUS);
+	  LED_Off(RED_STATUS);
+}
+
+/**
+* @brief  Мигает красным, индикация ошибки
+  */
+void LED_Blinky_Red(void)
+{
+  LED_Toggle(RED_STATUS);
+}
+
+/**
+  * @brief  Мигает желтым, индикация режима IAPviaSD
+  */
+void LED_Blinky_Yellow(void)
+{
+  LED_Toggle(GREEN_STATUS);
+  LED_Toggle(RED_STATUS);
+}
+
+/**
+  * @brief  Мигает зеленым, индикация режима IAPviaETH
+  */
+void LED_Blinky_Green(void)
+{
+  LED_Toggle(GREEN_STATUS);
+}
+
+/**
+  * @brief  
+  */
+void LED_On(LED_NAMES_t led)
+{
+  API_LED_On(LEDS[led].GPIOx, LEDS[led].GPIO_Pin, LEDS[led].revers);
+}
+
+/**
+  * @brief  
+  */
+void LED_Off(LED_NAMES_t led)
+{
+  API_LED_Off(LEDS[led].GPIOx, LEDS[led].GPIO_Pin, LEDS[led].revers);
+}
+
+/**
+  * @brief  Изменить состояние LED 
+  */
+void LED_Toggle(LED_NAMES_t led)
+{
+  LEDS[led].GPIOx->ODR ^= LEDS[led].GPIO_Pin;
+}
+
+/**
+  * @brief  Включить LED 
+  * @param  port
+  * @param  pin
+  * @param  revers: 0 - для включения LED нужно установить уровень
+  *                 1 - для включения LED нужно сбросить уровень
+  * @retval 
+  */
+void API_LED_On(GPIO_TypeDef* port, uint16_t pin, uint8_t revers)
+{
+  if (revers == 0)
+    port->BSRRL = pin;
+  else
+    port->BSRRH = pin;
+}
+
+/**
+  * @brief  Выключить LED 
+  * @param  port
+  * @param  pin
+  * @param  revers: 0 - для выключения LED нужно снять уровень
+  *                 1 - для выключения LED нужно установить уровень
+  * @retval 
+  */
+void API_LED_Off(GPIO_TypeDef* port, uint16_t pin, uint8_t revers)
+{
+  if (revers == 0)
+    port->BSRRH = pin;
+  else
+    port->BSRRL = pin;
+
+}
+
+
+
+
+ /******************************* (C) LiteMesh *********************************/

+ 85 - 0
iap/Modules/led.h

@@ -0,0 +1,85 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  led
+ * @file    led.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   led
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef LED_H
+#define LED_H
+   
+#include "stm32f4xx.h"
+
+/**
+  * @brief  
+  */
+typedef struct {
+
+  GPIO_TypeDef* GPIOx;
+  uint16_t      GPIO_Pin;
+  uint8_t       revers;
+
+} LED_t;  
+
+typedef enum
+{
+  GREEN_STATUS = 0,
+  RED_STATUS
+} LED_NAMES_t;
+
+/**
+  * @brief  
+  */
+void LED_Init(void);
+
+/**
+* @brief  Мигает красным, индикация ошибки
+  */
+void LED_Blinky_Red(void);
+
+/**
+  * @brief  Мигает желтым, индикация режима IAPviaSD
+  */
+void LED_Blinky_Yellow(void);
+
+/**
+  * @brief  Мигает зеленым, индикация режима IAPviaETH
+  */
+void LED_Blinky_Green(void);
+
+/**
+  * @brief  
+  */
+void LED_On(LED_NAMES_t led);
+
+/**
+  * @brief  
+  */
+void LED_Off(LED_NAMES_t led);
+
+/**
+  * @brief  Изменить состояние LED 
+  */
+void LED_Toggle(LED_NAMES_t led);
+
+/**
+  * @brief  
+  */
+void API_LED_On(GPIO_TypeDef* port, uint16_t pin, uint8_t revers);
+
+/**
+  * @brief  
+  */
+void API_LED_Off(GPIO_TypeDef* port, uint16_t pin, uint8_t revers);
+
+
+
+#endif /* #ifndef LED_H */
+
+/****************************** (C) LiteMesh ***************** end of file ****/

+ 264 - 0
iap/Modules/settings_api.c

@@ -0,0 +1,264 @@
+/********************************* (C) ROTEK ***********************************
+ * @module  settings_api
+ * @file    settings_api.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Settings
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+#include "stm32f4xx.h"  
+#include "settings_api.h"
+#include "common_config.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include "tinystdio.h"
+
+
+#define DBG if(0)
+
+/**
+  * @brief  Флаг подтверждения новых сетевых параметров пользователем
+  */  
+bool fConfirmWebParams = false;
+   
+/**
+  * @brief  Общая структура настроек
+  */
+SETTINGS_t sSettings;
+
+/**
+  * @brief  Установить параметры обновления ПО по умолчанию
+  */
+void SETTINGS_SetBootParamsDef(void)
+{
+  sSettings.bootParams.loadMode = 1;
+  sSettings.bootParams.bootTry = 0;
+}
+
+/**
+  * @brief  Установить параметры сетевого подключения по умолчанию
+  */
+void SETTINGS_SetWebParamsDef(void)
+{
+  strcpy(sSettings.sWebParams.ip, "192.168.1.2");
+  strcpy(sSettings.sWebParams.gate, "192.168.1.1");
+  strcpy(sSettings.sWebParams.mask, "255.255.255.0");
+  sSettings.sWebParams.dhcpEnable = 1;
+}
+
+/**
+  * @brief  Установить временные параметры сетевого подключения по умолчанию
+  */
+void SETTINGS_SetTempWebParamsDef(void)
+{
+  strcpy(sSettings.sWebTempParams.ip, "192.168.1.2");
+  strcpy(sSettings.sWebTempParams.gate, "192.168.1.1");
+  strcpy(sSettings.sWebTempParams.mask, "255.255.255.0");
+  sSettings.sWebTempParams.dhcpEnable = 1;
+}
+
+/**
+  * @brief  Установить параметры SNMP по умолчанию
+  */
+void SETTINGS_SetSnmpDef(void)
+{
+  strcpy(sSettings.sSnmp.sysDescr, "");
+  strcpy(sSettings.sSnmp.readCommunity, "public");
+  strcpy(sSettings.sSnmp.writeCommunity, "public");
+  strcpy(sSettings.sSnmp.sysContact, "");
+  strcpy(sSettings.sSnmp.sysName, "BT-6701");
+  strcpy(sSettings.sSnmp.sysLocation, "");
+  strcpy(sSettings.sSnmp.managerIP, "0.0.0.0");
+  strcpy(sSettings.sSnmp.managerIP2, "0.0.0.0");
+  strcpy(sSettings.sSnmp.managerIP3, "0.0.0.0");
+}
+
+/**
+  * @brief  Установить Информацию об устройстве по умолчанию
+  */
+void SETTINGS_SetInfoDef(void)
+{
+  strcpy(sSettings.sInfo.productionData, "09.10.2015");
+  strcpy(sSettings.sInfo.mac, DEVICE_MAC);
+  strcpy(sSettings.sInfo.serialNumber, "KN-03-00003");
+  strcpy(sSettings.sInfo.comments, "");
+}
+
+/**
+  * @brief  Установить флаги по умолчанию
+  */
+void SETTINGS_SetFlagsDef(void)
+{
+  sSettings.sFlags.netsettingsChanged = false;
+}
+
+/**
+  * @brief  Сброс настроек в значения по умолчанию
+  */
+void SETTINGS_SetDefault(void)
+{
+  SETTINGS_SetWebParamsDef();
+  SETTINGS_SetTempWebParamsDef();
+  SETTINGS_SetSnmpDef();
+}
+
+/**
+  * @brief  Сброс всех настроек в значения по умолчанию
+  */
+void SETTINGS_SetAllDefault(void)
+{
+  SETTINGS_SetBootParamsDef();
+  SETTINGS_SetWebParamsDef();
+  SETTINGS_SetTempWebParamsDef();
+  SETTINGS_SetInfoDef();
+
+  sSettings.CritSecCRC = SETTINGS_GetCritSecCRC();
+
+//  sSettings.controlWorld = SETTINGS_CONTROL_WORD;
+}
+  
+/**
+  * @brief  Запись структуры настроек во flesh
+  */
+void SETTINGS_Save(void)
+{
+  /* Calc critical section CRC and store to the settings structure */
+  sSettings.CritSecCRC = SETTINGS_GetCritSecCRC();
+
+  SETTINGS_WriteToFlash((uint8_t*)&sSettings, sizeof(sSettings));
+}
+
+/**
+  * @brief  Загрузка структуры настроек из flesh
+  */
+void SETTINGS_Load(void)
+{
+  SETTINGS_ReadFromFlash((uint8_t*)&sSettings, sizeof(sSettings));
+
+  /* Проверка CRC критической секции сектора настроек.
+   * Если CRC не совпадает, скорее всего настройки отсутствуют,
+   * прошиваем значения по умолчанию */
+  uint32_t crc = SETTINGS_GetCritSecCRC();
+
+   if (sSettings.CritSecCRC != crc) {
+       printf("\n\rIAP: Bad critical settings sector CRC. Factory defaults restored.\n\r");
+       SETTINGS_SetAllDefault();
+       SETTINGS_Save();
+   }
+}
+
+/**
+  * @brief  
+  */
+void SETTINGS_WriteToFlash(uint8_t *data, uint32_t size)
+{
+  uint32_t baseAddress = SETTINGS_SECTOR;
+  uint32_t checkCrc = 0;
+  uint32_t crc = SETTINGS_GetCRC();
+  bool fAlarm = 0;	
+  FLASH_Status status;
+	   
+  for (uint8_t i = 0; i < 3; i++)
+  {	
+	fAlarm = 0;
+    FLASH_Unlock();
+  
+    SETTINGS_EraseFlashSector();
+
+    for (uint32_t i = 0; i < size; i++)
+        if ((status = FLASH_ProgramByte(baseAddress++, *data++)) != FLASH_COMPLETE) {
+             DBG printf("FLASH_ProgramByte error: status = %d\r\n", status);
+             break;
+         }
+
+    if ((status = FLASH_ProgramWord((uint32_t)CRC_ADDRESS, crc)) != FLASH_COMPLETE) {
+         DBG printf("FLASH_ProgramWord error: status = %d\r\n", status);
+     }
+  
+    FLASH_Lock();
+    
+	/* Считываем что записали */
+	SETTINGS_ReadFromFlash((uint8_t*)&sSettings, sizeof(sSettings));
+	
+	checkCrc = SETTINGS_GetCRC();
+	
+	/* Проверяем  CRC того что было записано */	  
+	if (checkCrc == crc)
+	  break;
+	else 
+	  fAlarm = 1; // Авария
+}
+
+  /* Произошел сбой при записи - висим */
+  if (fAlarm)
+	while (1)
+	{};
+}
+
+/**
+  * @brief  
+  */
+void SETTINGS_ReadFromFlash(uint8_t *data, uint32_t size)
+{
+  uint32_t baseAddress = SETTINGS_SECTOR;
+  
+  for (uint32_t i = 0; i < size; i++)
+	*data++ = (*(uint32_t*)baseAddress++);;
+}
+
+/**
+  * @brief  Очистка сектора настроек
+  * @retval 
+  */
+void SETTINGS_EraseFlashSector(void)
+{
+  FLASH_Status status; 
+ 
+  if ((status = FLASH_EraseSector(FLASH_Sector_1, VoltageRange_3)) != FLASH_COMPLETE) {
+      DBG printf("SETTINGS_EraseFlashSector error: status = %d/r/n", status);
+  }
+}
+
+/**
+  * @brief  
+  * @retval 
+  */
+uint32_t SETTINGS_GetCRC(void)
+{
+  CRC_ResetDR();
+  return CRC_CalcBlockCRC((uint32_t*)&sSettings, sizeof(sSettings)/4);
+}
+
+/**
+  * @brief
+  * @retval
+  */
+uint32_t SETTINGS_GetCritSecCRC(void)
+{
+  CRC_ResetDR();
+  uint32_t critsec_len = (uint32_t)((uint8_t *)(&sSettings.CritSecCRC) - (uint8_t *)&sSettings) / 4;
+  return CRC_CalcBlockCRC((uint32_t *)&sSettings, critsec_len);
+}
+
+/**
+  * @brief  Преобразует mac адрес строкового формата в массив uint8_t
+  * @param  mac - буфер для вывода mac адреса
+  */
+void SETTINGS_GetMac(uint8_t *mac)
+{
+  char dummy[2];
+  char *macPtr = sSettings.sInfo.mac;	
+  
+  for (uint8_t i = 0; i < 6; i++)
+  {
+    strncpy(dummy, macPtr+i*3, 2);
+	mac[i] = (uint8_t)strtol(dummy, NULL, 16);
+  }
+}
+
+/********************************* (C) ROTEK **********************************/

+ 205 - 0
iap/Modules/settings_api.h

@@ -0,0 +1,205 @@
+/********************************* (C) РОТЕК ***********************************
+ * @module  settings_api
+ * @file    settings_api.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   settings_api
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef SETTINGS_API_H
+#define SETTINGS_API_H
+
+#include "stm32f4xx.h"
+#include <stdbool.h>
+
+/**
+* @brief  Параметры обновления ПО
+  */
+typedef struct
+{
+  uint8_t loadMode; // 0 - основная прошивка, 1 - режим обновления ПО
+  uint8_t bootTry;  // Признак 
+  
+} BOOT_PARAMS_t;
+
+/**
+  * @brief  Параметры сетевого подключения
+  */
+typedef struct
+{
+  char    ip[15];
+  char    gate[15];
+  char    mask[15];
+  uint8_t dhcpEnable;  // 0 - DHCP отключен, 1 - включен
+	
+} WEB_PARAMS_t;
+
+/**
+  * @brief  Параметры SNMP
+  */
+typedef struct
+{
+  char sysDescr[160];
+  char readCommunity[20];
+  char writeCommunity[20];
+  char sysContact[50];
+  char sysName[20];
+  char sysLocation[110];
+  char managerIP[20];
+  char managerIP2[20];
+  char managerIP3[20];
+  
+} SNMP_t;
+
+/**
+  * @brief  Информация об устройстве
+  */
+typedef struct
+{
+  char  productionData[40];  // Дата производства
+  char  mac[18];             // MAC адрес
+  char  serialNumber[16];    // Серийный номер
+  char  comments[110];       // Комментарии
+  
+} DEVICE_INFO_t; 
+
+/**
+  * @brief  Флаги, ключи и т.д.
+  */
+typedef struct
+{
+  bool netsettingsChanged;   // Признак изменения сетевых настроек пользователем
+  char testState[16];        // Статус производственного тестирования
+} FLAGS_t;
+  
+/**
+  * @brief  Общая структура настроек
+  */
+typedef struct
+{
+  BOOT_PARAMS_t bootParams;
+  WEB_PARAMS_t  sWebParams;
+  WEB_PARAMS_t  sWebTempParams;
+  SNMP_t        sSnmp;
+  DEVICE_INFO_t sInfo;
+  FLAGS_t       sFlags;
+  uint32_t      CritSecCRC;
+  //uint32_t      controlWorld;  // Слово для контроля целостности структуры настроек
+
+} SETTINGS_t;
+
+
+/**
+  * @brief
+  * @retval
+  */
+uint32_t SETTINGS_GetCritSecCRC(void);
+/**
+  * @brief  Установить параметры обновления ПО по умолчанию
+  */
+void SETTINGS_SetBootParamsDef(void);
+
+/**
+  * @brief  Установить параметры сетевого подключения по умолчанию
+  */
+void SETTINGS_SetWebParamsDef(void);
+
+/**
+  * @brief  Установить временные параметры сетевого подключения по умолчанию
+  */
+void SETTINGS_SetTempWebParamsDef(void);
+
+/**
+  * @brief  Установить параметры SNMP по умолчанию
+  */
+void SETTINGS_SetSnmpDef(void);
+
+/**
+  * @brief  Установить Информацию об устройстве по умолчанию
+  */
+void SETTINGS_SetInfoDef(void);
+
+/**
+  * @brief  Установить флаги по умолчанию
+  */
+void SETTINGS_SetFlagsDef(void);
+
+/**
+  * @brief  Очистка сектора настроек
+  */
+void SETTINGS_EraseFlashSector(void);
+
+/**
+  * @brief  Сброс настроек в значения по умолчанию
+  */
+void SETTINGS_SetDefault(void);
+
+/**
+  * @brief  Сброс всех настроек в значения по умолчанию кроме сетевых настроек
+  */
+void SETTINGS_SetPartDefault(void);
+
+/**
+  * @brief  Сброс всех настроек в значения по умолчанию
+  */
+void SETTINGS_SetAllDefault(void);
+
+/**
+  * @brief  Установка настроек для отладки
+  */
+void SETTINGS_SetDefaultDebug(void);
+
+/**
+  * @brief  Запись структуры настроек во flesh
+  */
+void SETTINGS_Save(void);
+
+/**
+  * @brief  Загрузка структуры настроек из flesh
+  */
+void SETTINGS_Load(void);
+
+/**
+  * @brief  
+  */
+void SETTINGS_WriteToFlash(uint8_t *data, uint32_t size);
+
+/**
+  * @brief
+  */
+void SETTINGS_ReadFromFlash(uint8_t *data, uint32_t size);
+
+/**
+  * @brief  
+  */
+uint32_t SETTINGS_GetCRC(void);
+
+/**
+  * @brief  Преобразует mac адрес строкового формата в массив uint8_t
+  * @param  mac - буфер для вывода mac адреса
+  */
+void SETTINGS_GetMac(uint8_t *mac);
+
+/**
+  * @brief  Установить дату производства
+  */
+void SETTINGS_SetProDate(char *proDate, uint8_t len);
+
+/**
+  * @brief  Установить статус тестирования "T2OK"
+  */
+void SETTINGS_SetT2OK(void);
+
+/**
+  * @brief  Включить DHCP
+  */
+void SETTINGS_SetDHCPOn(void);
+
+#endif /* #ifndef SETTINGS_API_H */
+
+/********************************* (C) РОТЕК **********************************/

+ 256 - 0
iap/Modules/systick.c

@@ -0,0 +1,256 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  systick
+ * @file    systick.c
+ * @version 1.0.0
+ * @date    29.05.2015
+ * $brief   Functions to work with System Timer. 
+ *          Module is based on code teplofizik, 2013
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * 29.05.2015   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+   
+#include "stm32f4xx.h"
+#include "systick.h"
+#include <stdbool.h>
+#include <string.h>
+
+extern void Time_Update(void);
+
+typedef struct
+{
+  TTimerHandler Handler;
+  uint16_t      Countdown;
+  uint16_t      Reload;
+  bool          Run;    // Запущено
+  bool          Fired;  // Сработало
+    
+} THandlers;
+
+volatile uint32_t  TimingDelay;
+volatile uint8_t   StopDelayFlag = 0;
+
+static THandlers Handlers[TIMER_HANDLERS];
+static uint32_t  TimerFrequency;
+static int       TimerCount;
+
+
+/**
+  * @brief  Обработчик прерывания системного таймера
+  * @retval нет
+  */
+void SysTick_Handler(void)
+{
+  int i;
+ 
+  Time_Update();
+  
+  TimingDelay_Decrement();
+    
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    if(Handlers[i].Run)
+    {
+      if(--Handlers[i].Countdown == 0)
+      {
+        Handlers[i].Countdown = Handlers[i].Reload;
+
+	/* Запишем, что сработало */
+	Handlers[i].Fired = true;
+      }
+    }
+  }
+}
+
+/**
+  * @brief  Запуск таймера с заданной частотой
+  * @retval нет
+  */
+void timer_Init(uint32_t Frequency)
+{
+  if(!Frequency) return;
+
+  /* Сбросим параметры */
+  TimerCount = 0;
+  TimerFrequency = Frequency;
+  memset(&Handlers[0], 0, sizeof(Handlers));
+
+  /* Настройка частоты */
+  SysTick_Config(clock_GetSYS() / Frequency);
+}
+
+/**
+  * @brief  Добавить функцию в список вызова. 
+  *         Handler будет вызываться с заданной частотой
+  * @retval нет
+  */
+void timer_AddFunction(uint16_t Frequency, TTimerHandler Handler)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    /* Найдем пустой слот */
+    if(!Handlers[i].Handler)
+    {
+      /* Обработчик, частота опроса */
+      Handlers[i].Run       =  true;
+      Handlers[i].Fired     =  false;
+      Handlers[i].Handler   =  Handler;
+      Handlers[i].Reload    =  Frequency;
+      Handlers[i].Countdown =  Handlers[i].Reload;
+
+      TimerCount++;
+
+      return;
+    }
+  }
+}
+
+/**
+  * @brief  Изменить частоту таймера
+  * @retval нет
+  */
+void timer_ChangeFrequency(TTimerHandler Handler, uint16_t Frequency)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    if(Handlers[i].Handler == Handler)
+    {
+      Handlers[i].Reload = Frequency;
+      Handlers[i].Countdown = Handlers[i].Reload;
+      break;
+    }
+  }
+}
+
+/**
+  * @brief  Возобночить работу задачи
+  * @retval нет
+  */
+void timer_Resume(TTimerHandler Handler)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    if(Handlers[i].Handler == Handler)
+    {
+      Handlers[i].Run = true;
+      break;
+    }
+  }
+}
+
+/**
+  * @brief  Перезапуск задачи
+  * @retval нет
+  */
+void timer_Restart(TTimerHandler Handler)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    if(Handlers[i].Handler == Handler)
+    {
+      Handlers[i].Run = true;
+      Handlers[i].Countdown = Handlers[i].Reload;
+      break;
+    }
+  }
+}
+
+/**
+  * @brief  Перезапуск задачи. Задача будет вызвана сразу.
+  * @retval нет
+  */
+void timer_RestartAtOnce(TTimerHandler Handler)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    if(Handlers[i].Handler == Handler)
+    {
+      Handlers[i].Run = true;
+      Handlers[i].Countdown = 1;
+      break;
+    }
+  }
+}
+
+/**
+  * @brief  Остановить задачу
+  * @retval нет
+  */
+void timer_Stop(TTimerHandler Handler)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    if(Handlers[i].Handler == Handler)
+    {
+      Handlers[i].Run = false;
+      Handlers[i].Fired =  false;
+      break;
+    }
+  }
+}
+
+/**
+  * @brief  Функция перебора и вызова актуальных задач. 
+  *         Должна вызываться в главном цикле
+  * @retval нет
+  */
+void timer_Main(void)
+{
+  int i;
+
+  for(i = 0; i < TIMER_HANDLERS; i++)
+  {
+    /* Если сработало - вызовем */
+    if(Handlers[i].Fired)
+    {
+      Handlers[i].Fired = false;
+      Handlers[i].Handler();
+    }
+  }
+}
+
+/**
+  * @brief  
+  * @retval Частота тактирования ядра
+  */
+uint32_t clock_GetSYS(void)
+{
+  return SystemCoreClock;
+}
+
+/**
+  * @brief  Задержка в миллисекундах
+  * @retval нет
+  */
+void Delay_ms(uint32_t nTime)
+{
+  TimingDelay = nTime;
+  while(TimingDelay);
+}
+
+/**
+  * @brief  Вспомогательная функция для реализации Delay_ms
+  * @retval нет
+  */
+void TimingDelay_Decrement(void) {
+
+  if (TimingDelay)
+    TimingDelay--;
+}
+
+
+
+//******************************** (C) POTEK ***********************************

+ 81 - 0
iap/Modules/systick.h

@@ -0,0 +1,81 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  systick
+ * @file    systick.h
+ * @version 1.0.0
+ * @date    29.05.2015
+ * $brief   Functions to work with System Timer. 
+ *          Module is based on code teplofizik, 2013
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * 29.05.2015   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+#ifndef SYSTICK_H
+#define SYSTICK_H
+   
+#include <stdint.h>
+
+#define TIMER_HANDLERS    20  // Максимально количество обработчкиков
+
+typedef void (*TTimerHandler)();
+
+/**
+  * @brief  Запуск таймера с заданной частотой
+  */
+void timer_Init(uint32_t Frequency);
+
+/**
+  * @brief  Добавить функцию в список вызова. 
+  *         Handler будет вызываться с заданной частотой
+  */
+void timer_AddFunction(uint16_t Frequency, TTimerHandler Handler);
+
+/**
+  * @brief  Изменить частоту таймера
+  */
+void timer_ChangeFrequency(TTimerHandler Handler, uint16_t Frequency);
+
+/**
+  * @brief  Возобночить работу задачи
+  */
+void timer_Resume(TTimerHandler Handler);
+
+/**
+  * @brief  Перезапуск задачи
+  */
+void timer_Restart(TTimerHandler Handler);
+
+/**
+  * @brief  Перезапуск задачи. Задача будет вызвана сразу.
+  */
+void timer_RestartAtOnce(TTimerHandler Handler);
+
+/**
+  * @brief  Остановить задачу
+  */
+void timer_Stop(TTimerHandler Handler);
+
+/**
+  * @brief  Функция перебора и вызова актуальных задач. 
+  *         Должна вызываться в главном цикле
+  */
+void timer_Main(void);
+
+/**
+  * @brief  
+  * @retval Частота тактирования ядра
+  */
+uint32_t clock_GetSYS(void);
+
+/**
+  * @brief  Задержка в миллисекундах
+  */
+void Delay_ms(__IO uint32_t nTime);
+
+/**
+  * @brief  Вспомогательная функция для реализации Delay_ms
+  */
+void TimingDelay_Decrement(void);
+
+#endif // SYSTICK_H

+ 86 - 0
iap/Modules/usart.c

@@ -0,0 +1,86 @@
+/********************************* (C) РОТЕК ***********************************
+ * @module  usart
+ * @file    usart.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Template
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+#include "stm32f4xx.h"  
+#include "usart.h"
+#include "tinystdio.h"
+
+   
+#ifdef __GNUC__    
+  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
+#else    
+  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)    
+#endif  
+
+
+PUTCHAR_PROTOTYPE   
+{   
+  //ITM_SendChar((u8) ch);
+  return ch;   
+}   
+
+void putchar_(uint8_t c) {
+    //while (!(USER_USART->SR & USART_FLAG_TXE));
+    //USER_USART->DR = (uint16_t)c;
+#ifdef SWOTRACE
+    ITM_SendChar(c);
+#endif
+}
+
+void putc_(void* p, char c) {
+    (void)p;
+    putchar_(c);
+}
+
+/**
+  * @brief  
+  * @retval 
+  */
+void InitUSART( void) {
+
+  GPIO_InitTypeDef  GPIO_InitStructure;
+  USART_InitTypeDef USART_InitStructure;
+    
+  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
+  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
+    
+  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
+  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+  GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+  GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1);
+  GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);
+
+  USART_InitStructure.USART_BaudRate = 115200;
+  USART_InitStructure.USART_WordLength = USART_WordLength_9b;
+  USART_InitStructure.USART_StopBits = USART_StopBits_1;
+  USART_InitStructure.USART_Parity = USART_Parity_Even;
+  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+  USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
+  USART_Init(USER_USART, &USART_InitStructure);
+
+  USART_Cmd(USER_USART, ENABLE);
+  
+    
+  USART_ITConfig(USER_USART, USART_IT_RXNE, DISABLE);
+  USART_ITConfig(USER_USART, USART_IT_TXE, DISABLE);
+
+  init_printf(NULL, putc_);
+}
+
+
+
+
+/********************************* (C) РОТЕК **********************************/

+ 36 - 0
iap/Modules/usart.h

@@ -0,0 +1,36 @@
+/******************************* (C) LiteMesh **********************************
+ * @module  usart
+ * @file    usart.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Template
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef USART_H
+#define USART_H
+
+/**
+  * @brief  
+  */
+#define USER_USART         USART1
+  
+
+/**
+  * @brief  
+  */
+void InitUSART(void);
+   
+/**
+  * @brief  
+  * @retval 
+  */
+
+
+#endif /* #ifndef USART_H */
+
+/****************************** (C) LiteMesh ***************** end of file ****/

+ 77 - 0
iap/Modules/wdg.c

@@ -0,0 +1,77 @@
+/********************************* (C) РОТЕК ***********************************
+ * @module  wdg
+ * @file    wdg.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   External watchdog (pin PE11)
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+#include "stm32f4xx.h"  
+#include "wdg.h"
+
+/**
+  * @brief  
+  * @retval 
+  */
+void WDG_Init(void)
+{
+  
+  GPIO_InitTypeDef GPIO_InitStructure;
+  NVIC_InitTypeDef          NVIC_InitStructure;
+  TIM_TimeBaseInitTypeDef   TIM_TimeBaseStructure;
+  
+  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
+  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM13, ENABLE);
+  
+  GPIO_InitStructure.GPIO_Pin = WDT_PIN;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
+  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+  GPIO_Init(GPIOC, &GPIO_InitStructure);
+  
+  NVIC_InitStructure.NVIC_IRQChannel = TIM8_UP_TIM13_IRQn;
+  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x6;
+  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0;
+  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+  NVIC_Init(&NVIC_InitStructure);
+
+  NVIC_SetPriority(TIM8_UP_TIM13_IRQn, 2);
+  
+  /* APB1 Timer clock is 60Mhz, configure timer clock to 10khz (1 update event per 100 us) */
+  TIM_TimeBaseStructure.TIM_Prescaler = 6000 - 1;
+  /* Configure timer period to 100ms */
+  TIM_TimeBaseStructure.TIM_Period = 1000;
+  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
+  TIM_TimeBaseStructure.TIM_CounterMode	= TIM_CounterMode_Up;
+  TIM_TimeBaseInit(TIM13, &TIM_TimeBaseStructure);
+  
+  TIM_Cmd(TIM13, ENABLE);
+  TIM_ITConfig(TIM13, TIM_IT_Update, ENABLE);
+  
+}
+
+/**
+  * @brief  Дергаем пином (сброс внешнего WDT)
+  * @retval 
+  */
+void TIM8_UP_TIM13_IRQHandler(void)
+{
+  TIM_ClearITPendingBit(TIM13, TIM_IT_Update);
+  GPIOC->ODR ^= WDT_PIN;
+}
+
+/**
+  * @brief  Дергаем пином (сброс внешнего WDT)
+  */
+void WDT_Reset(void)
+{
+  GPIOC->ODR ^= WDT_PIN;
+}
+
+
+/********************************* (C) РОТЕК **********************************/

+ 36 - 0
iap/Modules/wdg.h

@@ -0,0 +1,36 @@
+/********************************* (C) РОТЕК ***********************************
+ * @module  wdg
+ * @file    wdg.h
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   External watchdog
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+
+/* Define to prevent recursive  ----------------------------------------------*/
+#ifndef WDG_H
+#define WDG_H
+
+#define WDT_PIN   GPIO_Pin_0
+
+/**
+  * @brief  
+  */
+void WDG_Init(void);
+  
+/**
+  * @brief  Дергаем пином (сброс внешнего WDT)
+  */
+void vTaskWdt(void *pvParameters);
+
+/**
+  * @brief  Дергаем пином (сброс внешнего WDT)
+  */
+void WDT_Reset(void);
+
+#endif /* #ifndef WDG_H */
+
+/********************************* (C) РОТЕК **********************************/

+ 269 - 0
iap/User/main.c

@@ -0,0 +1,269 @@
+#include "stm32f4xx.h"
+#include "common_config.h"
+#include "main.h"
+#include "led.h"
+#include "systick.h"
+#include "usart.h"
+#include "httpserver.h"
+#include "flash_if.h"
+#include "settings_api.h"
+#include "gpio_io.h"
+#include "crc.h"
+#include "wdg.h"
+#include "tinystdio.h"
+#include "time.h"
+#include "string.h"
+
+#include "stm32f4x7_eth.h"
+#include "netconf.h"
+
+
+#define FW_FILE_NAME "stm32prs.bin"
+
+bool IAPviaETH = false;
+uint8_t fDoneReset = 0;
+uint8_t fErrorReset = 0;
+uint8_t fUpload = 0;
+uint8_t fInvalidFw = 0;
+uint8_t fBootFailed = 0;
+uint32_t resetCounter = 0;
+bool UpdateTimeoutFlag = false;
+
+/* this variable is used to create a time reference incremented by 10ms */
+__IO uint32_t LocalTime = 0; 
+
+pFunction Jump_To_App;
+
+uint32_t JumpAdd;
+
+/**
+  * @brief  Общая структура настроек
+  */
+extern SETTINGS_t sSettings;
+
+void UpdateTimeout_Handler(void);
+
+void main(void)
+{
+  	uint8_t bootTry;
+  	uint8_t loadMode;
+
+    WDG_Init();
+    IO_Init();
+    InitUSART();
+
+  /* Enable PWR peripheral clock */
+  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
+
+  /* Allow access to BKP Domain */
+  PWR_BackupAccessCmd(ENABLE);
+
+  /* Включаем тактирование модуля CRC */
+  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
+  
+  /* Проверка флага, определяющего состояние устройства. */
+  /* Флаг установлен - работает Bootloader               */
+  /* Флаг сброшен - запускается основная программа       */
+
+  SETTINGS_Load();
+  
+  /* Проверка флага bootTry. Если флаг установлен, значит произошел сбой в 
+     основной прошивке. Нужно загружать bootloader и ждать обновления ПО */
+  /* TODO remove if tested */
+  //bootTry = sSettings.bootParams.bootTry;
+  loadMode = RTC_ReadBackupRegister(RTC_BKP_DR1);
+  bootTry = RTC_ReadBackupRegister(RTC_BKP_DR2);
+  printf("loadMode: %d\r\nbootTry: %d\r\n", loadMode, bootTry);
+  
+  if (bootTry > 1)
+  {
+    bootTry--;
+    RTC_WriteBackupRegister(RTC_BKP_DR2, bootTry);
+
+    /* Check if valid stack address (RAM address) then jump to user application */
+    if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
+    {
+        JumpAdd = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
+        Jump_To_App = (pFunction) JumpAdd;
+        __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
+        Jump_To_App();
+    }
+    else {
+        /* Флеш пустая, нечего загружать, висим в аварийном режиме */
+        fInvalidFw = 1;
+        PRINT_USART("\n\rFW empty. Started bootloader\n\r");
+    }
+  }
+  else if (bootTry == 1)
+  {
+    fBootFailed = 1;
+    PRINT_USART("\n\rFW boot failed. Started bootloader\n\r");
+
+    bootTry = 0;
+    loadMode = 1;
+    RTC_WriteBackupRegister(RTC_BKP_DR2, bootTry);
+    RTC_WriteBackupRegister(RTC_BKP_DR1, loadMode);
+  }
+
+  /* Флаг не установлен прыгаем на основную программу */
+  if (loadMode == 0)
+  {
+      printf("Run main FW\n\r");
+      //printf("*(__IO uint32_t*)(USER_FLASH_FIRST_PAGE_ADDRESS) = 0x%X\n\r", *(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS);
+      //printf("*(__IO uint32_t*)(USER_FLASH_FIRST_PAGE_ADDRESS + 4) = 0x%X\n\r", *(__IO uint32_t*)(USER_FLASH_FIRST_PAGE_ADDRESS + 4));
+
+      /* Set bootTry flag every time to ensure that
+       * IAP will starts again if FW is corrupted */
+      bootTry = BOOT_TRY;
+      RTC_WriteBackupRegister(RTC_BKP_DR2, bootTry);
+
+    /* Check if valid stack address (RAM address) then jump to user application */
+    if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
+    {
+      /* Jump to user application */
+      JumpAdd = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
+      Jump_To_App = (pFunction) JumpAdd;
+      /* Initialize user application's Stack Pointer */
+      __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
+      Jump_To_App();
+    }
+  }
+  
+  /* Загружается Bootloader... */
+  
+  SysTick_Config(120000);
+  LED_Init();
+
+
+  PRINT_USART("\n\rBootloader starting...   \n\r");
+
+  LED_On(RED_STATUS);
+
+  ETH_BSP_Config();
+  LwIP_Init();
+  IAP_httpd_init();
+  CRC_Init();
+
+  //Если нажата DEF начинаем обновление с sd
+  if (IO_BtnDefaultPressed()) 
+  {
+//	IAPviaETH = false;
+//    timer_AddFunction(500, &LED_Blinky_Yellow);
+//    SD_NVIC_Init();
+  } else {
+    IAPviaETH = true;
+    timer_AddFunction(500, &LED_Blinky_Green);
+  }
+  
+  /* Check if valid stack address (RAM address) */
+  if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) {
+      timer_AddFunction(1000, &UpdateTimeout_Handler);
+  }
+  else {
+      /* Флеш пустая, нечего загружать, висим в аварийном режиме */
+      fInvalidFw = 1;
+  }
+
+
+  while (1)
+  {
+    timer_Main();
+
+    if (IAPviaETH) { // Обновление по ETH
+      /* check if any packet received */
+      if (ETH_CheckFrameReceived())
+      { 
+        /* process received ethernet packet */
+        LwIP_Pkt_Handle();
+      }
+      /* handle periodic timers for LwIP */
+      LwIP_Periodic_Handle(LocalTime);
+	
+	  if (fDoneReset)
+	  {
+		resetCounter++;
+	    if (resetCounter > 100000)
+		{  
+	      loadMode = 0;
+	      bootTry = BOOT_TRY;
+	      RTC_WriteBackupRegister(RTC_BKP_DR1, loadMode);
+	      RTC_WriteBackupRegister(RTC_BKP_DR2, bootTry);
+	      /* Set FW update flag */
+	      RTC_WriteBackupRegister(RTC_BKP_DR3, 1);
+
+          NVIC_SystemReset();
+		}  
+	  }	
+	  if (fErrorReset)
+	  {
+		resetCounter++;
+	    if (resetCounter > 100000) {
+          NVIC_SystemReset();
+	    }
+	  }
+    }
+
+    //Если нажата DEF переходим в основную прошивку
+    if (IO_BtnDefaultPressed() || UpdateTimeoutFlag)
+    {
+      if (!fUpload && ((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) != 0xFFFFFFFF)) {
+          PRINT_USART("\n\rUpdate timeout... Return to main FW\n\r");
+          loadMode = 0;
+          bootTry = BOOT_TRY;
+          RTC_WriteBackupRegister(RTC_BKP_DR1, loadMode);
+          RTC_WriteBackupRegister(RTC_BKP_DR2, bootTry);
+		  NVIC_SystemReset();
+      }
+    }
+  }
+}
+
+/**
+  * @brief  Updates the system local time
+  * @param  None
+  * @retval None
+  */
+void Time_Update(void)
+{
+  LocalTime += SYSTEMTICK_PERIOD_MS;
+}
+
+/**
+  * @brief
+  */
+u32_t sys_now(void) {
+    return LocalTime;
+}
+
+/**
+  * @brief  Error handler
+  * @param  None
+  * @retval None
+  */
+void Error_Handler(void) {
+  LED_Off(RED_STATUS);
+  LED_Off(GREEN_STATUS);
+  timer_AddFunction(500, &LED_Blinky_Red);
+  while (1)
+  {
+    timer_Main();
+  }
+}
+
+/**
+  * @brief
+  */
+void UpdateTimeout_Handler(void)
+{
+    static char lcdbuf[32] = {0};
+    static uint8_t time = UPDATE_TIMEOUT;
+
+    if ((fUpload) || (fInvalidFw)) return;
+
+    if (time == 0) {
+        UpdateTimeoutFlag = true;
+    }
+    else {
+        time--;
+    }
+}

+ 85 - 0
iap/User/main.h

@@ -0,0 +1,85 @@
+/**
+  ******************************************************************************
+  * @file    main.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    31-October-2011
+  * @brief   This file contains all the functions prototypes for the main.c 
+  *          file.
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  *
+  * <h2><center>&copy; Portions COPYRIGHT 2011 STMicroelectronics</center></h2>
+  ******************************************************************************
+  */
+/**
+  ******************************************************************************
+  * <h2><center>&copy; Portions COPYRIGHT 2012 Embest Tech. Co., Ltd.</center></h2>
+  * @file    main.h
+  * @author  CMP Team
+  * @version V1.0.0
+  * @date    28-December-2012
+  * @brief   This file contains all the functions prototypes for the main.c 
+  *          file.     
+  *          Modified to support the STM32F4DISCOVERY, STM32F4DIS-BB and
+  *          STM32F4DIS-LCD modules. 
+  ******************************************************************************
+  * @attention
+  *
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+  * TIME. AS A RESULT, Embest SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+  * OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+  * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+  * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+  ******************************************************************************
+  */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __MAIN_H
+#define __MAIN_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f4xx.h"
+#include "stm32f4x7_eth_bsp.h"
+#include "common_config.h"
+   
+#ifdef USART_DEBUG_ENABLE
+#define PRINT_USART(x) printf(x) 
+#else 
+#define PRINT_USART(x)
+#endif
+   
+/* MII and RMII mode selection, for STM324xG-EVAL Board(MB786) RevB ***********/
+#define RMII_MODE
+
+typedef  void (*pFunction)(void);
+   
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */  
+void Time_Update(void);
+void Delay(uint32_t nCount);
+void Error_Handler(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MAIN_H */
+
+
+/*********** Portions COPYRIGHT 2012 Embest Tech. Co., Ltd.*****END OF FILE****/
+
+

+ 176 - 0
iap/User/stm32f4xx_it.c

@@ -0,0 +1,176 @@
+/**
+  ******************************************************************************
+  * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c 
+  * @author  MCD Application Team
+  * @version V1.5.0
+  * @date    06-March-2015
+  * @brief   Main Interrupt Service Routines.
+  *          This file provides template for all exceptions handler and 
+  *          peripherals interrupt service routine.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
+  *
+  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+  * You may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * Unless required by applicable law or agreed to in writing, software 
+  * distributed under the License is distributed on an "AS IS" BASIS, 
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  *
+  ******************************************************************************
+  */
+
+/* Includes ------------------------------------------------------------------*/
+#include <stddef.h>
+#include "stm32f4xx_it.h"
+
+
+extern size_t xMinimumEverFreeBytesRemaining;
+
+/** @addtogroup Template_Project
+  * @{
+  */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/******************************************************************************/
+/*            Cortex-M4 Processor Exceptions Handlers                         */
+/******************************************************************************/
+
+/**
+  * @brief  This function handles NMI exception.
+  * @param  None
+  * @retval None
+  */
+void NMI_Handler(void)
+{
+}
+
+/**
+  * @brief  This function handles Hard Fault exception.
+  * @param  None
+  * @retval None
+  */
+void HardFault_Handler(void)
+{
+  /* TODO Uncomment in production */
+  //NVIC_SystemReset();
+  /* Go to infinite loop when Hard Fault exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles Memory Manage exception.
+  * @param  None
+  * @retval None
+  */
+void MemManage_Handler(void)
+{
+  /* Go to infinite loop when Memory Manage exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles Bus Fault exception.
+  * @param  None
+  * @retval None
+  */
+void BusFault_Handler(void)
+{
+  /* Go to infinite loop when Bus Fault exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles Usage Fault exception.
+  * @param  None
+  * @retval None
+  */
+void UsageFault_Handler(void)
+{
+  /* Go to infinite loop when Usage Fault exception occurs */
+  while (1)
+  {
+  }
+}
+
+/**
+  * @brief  This function handles SVCall exception.
+  * @param  None
+  * @retval None
+  */
+/*
+void SVC_Handler(void)
+{
+}
+*/
+
+/**
+  * @brief  This function handles Debug Monitor exception.
+  * @param  None
+  * @retval None
+  */
+void DebugMon_Handler(void)
+{
+}
+
+/**
+  * @brief  This function handles PendSVC exception.
+  * @param  None
+  * @retval None
+  */
+/*void PendSV_Handler(void)
+{
+}
+*/
+/**
+  * @brief  This function handles SysTick Handler.
+  * @param  None
+  * @retval None
+  */
+/*void SysTick_Handler(void)
+{
+  TimingDelay_Decrement();
+}
+*/
+
+/******************************************************************************/
+/*                 STM32F4xx Peripherals Interrupt Handlers                   */
+/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
+/*  available peripheral interrupt handler's name please refer to the startup */
+/*  file (startup_stm32f4xx.s).                                               */
+/******************************************************************************/
+
+/**
+  * @brief  This function handles PPP interrupt request.
+  * @param  None
+  * @retval None
+  */
+/*void PPP_IRQHandler(void)
+{
+}*/
+
+/**
+  * @}
+  */ 
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 60 - 0
iap/User/stm32f4xx_it.h

@@ -0,0 +1,60 @@
+/**
+  ******************************************************************************
+  * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.h 
+  * @author  MCD Application Team
+  * @version V1.5.0
+  * @date    06-March-2015
+  * @brief   This file contains the headers of the interrupt handlers.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
+  *
+  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+  * You may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * Unless required by applicable law or agreed to in writing, software 
+  * distributed under the License is distributed on an "AS IS" BASIS, 
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_IT_H
+#define __STM32F4xx_IT_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f4xx.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+void NMI_Handler(void);
+void HardFault_Handler(void);
+void MemManage_Handler(void);
+void BusFault_Handler(void);
+void UsageFault_Handler(void);
+void SVC_Handler(void);
+void DebugMon_Handler(void);
+void PendSV_Handler(void);
+void SysTick_Handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_IT_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 399 - 0
iap/lwip/port/STM32F4x7/FreeRTOS/ethernetif.c

@@ -0,0 +1,399 @@
+/**
+ * @file
+ * Ethernet Interface Skeleton
+ *
+ */
+
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
+ * This file is a skeleton for developing Ethernet network interface
+ * drivers for lwIP. Add code to the low_level functions and do a
+ * search-and-replace for the word "ethernetif" to replace it with
+ * something that better describes your network interface.
+ */
+
+#include "lwip/opt.h"
+#include "lwip/def.h"
+#include "lwip/mem.h"
+#include "lwip/pbuf.h"
+#include "lwip/sys.h"
+#include "netif/etharp.h"
+#include "err.h"
+#include "ethernetif.h"
+#include "lwip/timers.h"
+
+#include "common_config.h"
+#include "settings_api.h"
+#include "stm32f4x7_eth.h"
+#include <string.h>
+
+
+#define netifMTU                                (1500)
+#define netifINTERFACE_TASK_STACK_SIZE		( 150 )
+#define netifINTERFACE_TASK_PRIORITY		( configMAX_PRIORITIES - 1 )
+#define netifGUARD_BLOCK_TIME			( 250 )
+/* The time to block waiting for input. */
+#define emacBLOCK_TIME_WAITING_FOR_INPUT	( ( TickType_t ) 100 )
+
+/* Define those to better describe your network interface. */
+#define IFNAME0 's'
+#define IFNAME1 't'
+
+
+static struct netif *s_pxNetIf = NULL;
+SemaphoreHandle_t s_xSemaphore = NULL;
+          
+
+/* Ethernet Rx & Tx DMA Descriptors */
+extern ETH_DMADESCTypeDef  DMARxDscrTab[ETH_RXBUFNB], DMATxDscrTab[ETH_TXBUFNB];
+
+/* Ethernet Receive buffers  */
+extern uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE]; 
+
+/* Ethernet Transmit buffers */
+extern uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE]; 
+
+/* Global pointers to track current transmit and receive descriptors */
+extern ETH_DMADESCTypeDef  *DMATxDescToSet;
+extern ETH_DMADESCTypeDef  *DMARxDescToGet;
+
+/* Global pointer for last received frame infos */
+extern ETH_DMA_Rx_Frame_infos *DMA_RX_FRAME_infos;
+
+
+
+
+static void ethernetif_input( void * pvParameters );
+static void arp_timer(void *arg);
+
+
+/**
+ * In this function, the hardware should be initialized.
+ * Called from ethernetif_init().
+ *
+ * @param netif the already initialized lwip network interface structure
+ *        for this ethernetif
+ */
+static void low_level_init(struct netif *netif)
+{
+  uint8_t mac[6];
+  uint32_t i;
+ 
+  /* set netif MAC hardware address length */
+  netif->hwaddr_len = ETHARP_HWADDR_LEN;
+	
+  /* set netif MAC hardware address */
+  
+  SETTINGS_GetMac(mac);
+
+  netif->hwaddr[0] =  mac[0];
+  netif->hwaddr[1] =  mac[1];
+  netif->hwaddr[2] =  mac[2];
+  netif->hwaddr[3] =  mac[3];
+  netif->hwaddr[4] =  mac[4];
+  netif->hwaddr[5] =  mac[5];
+
+  /* set netif maximum transfer unit */
+  netif->mtu = 1500;
+
+  /* Accept broadcast address and ARP traffic */
+  netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
+  
+  s_pxNetIf =netif;
+ 
+  /* create binary semaphore used for informing ethernetif of frame reception */
+  if (s_xSemaphore == NULL)
+  {
+    s_xSemaphore= xSemaphoreCreateCounting(20,0);
+  }
+
+  /* initialize MAC address in ethernet MAC */ 
+  ETH_MACAddressConfig(ETH_MAC_Address0, netif->hwaddr); 
+  
+  /* Initialize Tx Descriptors list: Chain Mode */
+  ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
+  /* Initialize Rx Descriptors list: Chain Mode  */
+  ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
+  
+  /* Enable Ethernet Rx interrrupt */
+  { 
+    for(i=0; i<ETH_RXBUFNB; i++)
+    {
+      ETH_DMARxDescReceiveITConfig(&DMARxDscrTab[i], ENABLE);
+    }
+  }
+
+#ifdef CHECKSUM_BY_HARDWARE
+  /* Enable the checksum insertion for the Tx frames */
+  {
+    for(i=0; i<ETH_TXBUFNB; i++)
+    {
+      ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i], ETH_DMATxDesc_ChecksumTCPUDPICMPFull);
+    }
+  } 
+#endif
+  
+  /* create the task that handles the ETH_MAC */
+  xTaskCreate(ethernetif_input, "Eth_if", netifINTERFACE_TASK_STACK_SIZE, NULL,
+              netifINTERFACE_TASK_PRIORITY,NULL);
+  
+  /* Enable MAC and DMA transmission and reception */
+  ETH_Start();   
+}
+
+
+/**
+ * This function should do the actual transmission of the packet. The packet is
+ * contained in the pbuf that is passed to the function. This pbuf
+ * might be chained.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
+ * @return ERR_OK if the packet could be sent
+ *         an err_t value if the packet couldn't be sent
+ *
+ * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
+ *       strange results. You might consider waiting for space in the DMA queue
+ *       to become availale since the stack doesn't retry to send a packet
+ *       dropped because of memory failure (except for the TCP timers).
+ */
+
+static err_t low_level_output(struct netif *netif, struct pbuf *p)
+{
+  static SemaphoreHandle_t xTxSemaphore = NULL;
+  struct pbuf *q;
+  uint32_t l = 0;
+  u8 *buffer ;
+  
+  if (xTxSemaphore == NULL)
+  {
+    vSemaphoreCreateBinary (xTxSemaphore);
+  } 
+   
+  if (xSemaphoreTake(xTxSemaphore, netifGUARD_BLOCK_TIME))
+  {
+    buffer =  (u8 *)(DMATxDescToSet->Buffer1Addr);
+    for(q = p; q != NULL; q = q->next) 
+    {
+      memcpy((u8_t*)&buffer[l], q->payload, q->len);
+      l = l + q->len;
+    }
+    ETH_Prepare_Transmit_Descriptors(l);
+    xSemaphoreGive(xTxSemaphore);
+  }
+
+  return ERR_OK;
+}
+
+
+	
+  	
+
+/**
+ * Should allocate a pbuf and transfer the bytes of the incoming
+ * packet from the interface into the pbuf.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return a pbuf filled with the received packet (including MAC header)
+ *         NULL on memory error
+ */
+static struct pbuf * low_level_input(struct netif *netif)
+{
+  struct pbuf *p, *q;
+  u16_t len;
+  uint32_t l=0,i =0;
+  FrameTypeDef frame;
+  u8 *buffer;
+  __IO ETH_DMADESCTypeDef *DMARxNextDesc;
+  
+  p = NULL;
+  
+  /* Get received frame */
+  frame = ETH_Get_Received_Frame_interrupt();
+  
+  /* check that frame has no error */
+  if ((frame.descriptor->Status & ETH_DMARxDesc_ES) == (uint32_t)RESET)
+  {
+    
+    /* Obtain the size of the packet and put it into the "len" variable. */
+    len = frame.length;
+    buffer = (u8 *)frame.buffer;
+
+    /* We allocate a pbuf chain of pbufs from the pool. */
+    p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+ 
+    /* Copy received frame from ethernet driver buffer to stack buffer */
+    if (p != NULL)
+    { 
+      for (q = p; q != NULL; q = q->next)
+      {
+        memcpy((u8_t*)q->payload, (u8_t*)&buffer[l], q->len);
+        l = l + q->len;
+      } 
+    }
+  }
+  
+  /* Release descriptors to DMA */
+  /* Check if received frame with multiple DMA buffer segments */
+  if (DMA_RX_FRAME_infos->Seg_Count > 1)
+  {
+    DMARxNextDesc = DMA_RX_FRAME_infos->FS_Rx_Desc;
+  }
+  else
+  {
+    DMARxNextDesc = frame.descriptor;
+  }
+  
+  /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
+  for (i=0; i<DMA_RX_FRAME_infos->Seg_Count; i++)
+  {  
+    DMARxNextDesc->Status = ETH_DMARxDesc_OWN;
+    DMARxNextDesc = (ETH_DMADESCTypeDef *)(DMARxNextDesc->Buffer2NextDescAddr);
+  }
+  
+  /* Clear Segment_Count */
+  DMA_RX_FRAME_infos->Seg_Count =0;
+  
+  
+  /* When Rx Buffer unavailable flag is set: clear it and resume reception */
+  if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET)  
+  {
+    /* Clear RBUS ETHERNET DMA flag */
+    ETH->DMASR = ETH_DMASR_RBUS;
+      
+    /* Resume DMA reception */
+    ETH->DMARPDR = 0;
+  }
+  return p;
+}
+
+
+/**
+ * This function is the ethernetif_input task, it is processed when a packet 
+ * is ready to be read from the interface. It uses the function low_level_input() 
+ * that should handle the actual reception of bytes from the network
+ * interface. Then the type of the received packet is determined and
+ * the appropriate input function is called.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ */
+/*
+void ethernetif_input( void * pvParameters )
+{
+  struct pbuf *p;
+  
+  for( ;; )
+  {
+    if (xSemaphoreTake( s_xSemaphore, emacBLOCK_TIME_WAITING_FOR_INPUT)==pdTRUE)
+    {
+      p = low_level_input( s_pxNetIf );
+      if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))
+      {
+        pbuf_free(p);
+        p=NULL;
+      }
+    }
+  }
+} 
+*/
+
+void ethernetif_input(void * pvParameters)
+{
+  struct pbuf *p;
+
+  for( ;; )
+  {
+    if(xSemaphoreTake(s_xSemaphore, emacBLOCK_TIME_WAITING_FOR_INPUT)==pdTRUE)
+    {
+GET_NEXT_FRAGMENT:
+      p = low_level_input( s_pxNetIf );
+      if (p != NULL)
+      {
+        if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))
+        {
+          pbuf_free(p);
+          p=NULL;
+        }
+        else
+        {
+          xSemaphoreTake(s_xSemaphore, 0);
+          goto GET_NEXT_FRAGMENT;
+        }
+      }
+    }
+  }
+}
+      
+/**
+ * Should be called at the beginning of the program to set up the
+ * network interface. It calls the function low_level_init() to do the
+ * actual setup of the hardware.
+ *
+ * This function should be passed as a parameter to netif_add().
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return ERR_OK if the loopif is initialized
+ *         ERR_MEM if private data couldn't be allocated
+ *         any other err_t on error
+ */
+err_t ethernetif_init(struct netif *netif)
+{
+  LWIP_ASSERT("netif != NULL", (netif != NULL));
+
+#if LWIP_NETIF_HOSTNAME
+  /* Initialize interface hostname */
+  netif->hostname = "lwip";
+#endif /* LWIP_NETIF_HOSTNAME */
+
+  netif->name[0] = IFNAME0;
+  netif->name[1] = IFNAME1;
+
+  netif->output = etharp_output;
+  netif->linkoutput = low_level_output;
+
+  /* initialize the hardware */
+  low_level_init(netif);
+  
+  etharp_init();
+  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
+
+  return ERR_OK;
+}
+
+
+static void arp_timer(void *arg)
+{
+  etharp_tmr();
+  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
+}

+ 12 - 0
iap/lwip/port/STM32F4x7/FreeRTOS/ethernetif.h

@@ -0,0 +1,12 @@
+#ifndef __ETHERNETIF_H__
+#define __ETHERNETIF_H__
+
+
+#include "lwip/err.h"
+#include "lwip/netif.h"
+
+err_t ethernetif_init(struct netif *netif);
+
+
+
+#endif 

+ 586 - 0
iap/lwip/port/STM32F4x7/FreeRTOS/sys_arch.c

@@ -0,0 +1,586 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+
+//*****************************************************************************
+//
+// Include OS functionality.
+//
+//*****************************************************************************
+
+/* ------------------------ System architecture includes ----------------------------- */
+#include "arch/sys_arch.h"
+
+/* ------------------------ lwIP includes --------------------------------- */
+#include "lwip/opt.h"
+
+#include "lwip/debug.h"
+#include "lwip/def.h"
+#include "lwip/sys.h"
+#include "lwip/mem.h"
+#include "lwip/stats.h"
+
+#define LWIP_PLATFORM_DIAG(x)   printf(message)
+
+/* Very crude mechanism used to determine if the critical section handling
+functions are being called from an interrupt context or not.  This relies on
+the interrupt handler setting this variable manually. */
+portBASE_TYPE xInsideISR = pdFALSE;
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_mbox_new
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Creates a new mailbox
+ * Inputs:
+ *      int size                -- Size of elements in the mailbox
+ * Outputs:
+ *      sys_mbox_t              -- Handle to new mailbox
+ *---------------------------------------------------------------------------*/
+err_t sys_mbox_new( sys_mbox_t *pxMailBox, int iSize )
+{
+err_t xReturn = ERR_MEM;
+
+	*pxMailBox = xQueueCreate( iSize, sizeof( void * ) );
+
+	if( *pxMailBox != NULL )
+	{
+		xReturn = ERR_OK;
+		SYS_STATS_INC_USED( mbox );
+	}
+
+	return xReturn;
+}
+
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_mbox_free
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Deallocates a mailbox. If there are messages still present in the
+ *      mailbox when the mailbox is deallocated, it is an indication of a
+ *      programming error in lwIP and the developer should be notified.
+ * Inputs:
+ *      sys_mbox_t mbox         -- Handle of mailbox
+ * Outputs:
+ *      sys_mbox_t              -- Handle to new mailbox
+ *---------------------------------------------------------------------------*/
+void sys_mbox_free( sys_mbox_t *pxMailBox )
+{
+unsigned long ulMessagesWaiting;
+
+	ulMessagesWaiting = uxQueueMessagesWaiting( *pxMailBox );
+	configASSERT( ( ulMessagesWaiting == 0 ) );
+
+	#if SYS_STATS
+	{
+		if( ulMessagesWaiting != 0UL )
+		{
+			SYS_STATS_INC( mbox.err );
+		}
+
+		SYS_STATS_DEC( mbox.used );
+	}
+	#endif /* SYS_STATS */
+
+	vQueueDelete( *pxMailBox );
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_mbox_post
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Post the "msg" to the mailbox.
+ * Inputs:
+ *      sys_mbox_t mbox         -- Handle of mailbox
+ *      void *data              -- Pointer to data to post
+ *---------------------------------------------------------------------------*/
+void sys_mbox_post( sys_mbox_t *pxMailBox, void *pxMessageToPost )
+{
+	while( xQueueSendToBack( *pxMailBox, &pxMessageToPost, portMAX_DELAY ) != pdTRUE );
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_mbox_trypost
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Try to post the "msg" to the mailbox.  Returns immediately with
+ *      error if cannot.
+ * Inputs:
+ *      sys_mbox_t mbox         -- Handle of mailbox
+ *      void *msg               -- Pointer to data to post
+ * Outputs:
+ *      err_t                   -- ERR_OK if message posted, else ERR_MEM
+ *                                  if not.
+ *---------------------------------------------------------------------------*/
+err_t sys_mbox_trypost( sys_mbox_t *pxMailBox, void *pxMessageToPost )
+{
+err_t xReturn;
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
+
+	if( xInsideISR != pdFALSE )
+	{
+		xReturn = xQueueSendFromISR( *pxMailBox, &pxMessageToPost, &xHigherPriorityTaskWoken );
+	}
+	else
+	{
+		xReturn = xQueueSend( *pxMailBox, &pxMessageToPost, ( TickType_t ) 0 );
+	}
+
+	if( xReturn == pdPASS )
+	{
+		xReturn = ERR_OK;
+	}
+	else
+	{
+		/* The queue was already full. */
+		xReturn = ERR_MEM;
+		SYS_STATS_INC( mbox.err );
+	}
+
+	return xReturn;
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_arch_mbox_fetch
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Blocks the thread until a message arrives in the mailbox, but does
+ *      not block the thread longer than "timeout" milliseconds (similar to
+ *      the sys_arch_sem_wait() function). The "msg" argument is a result
+ *      parameter that is set by the function (i.e., by doing "*msg =
+ *      ptr"). The "msg" parameter maybe NULL to indicate that the message
+ *      should be dropped.
+ *
+ *      The return values are the same as for the sys_arch_sem_wait() function:
+ *      Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
+ *      timeout.
+ *
+ *      Note that a function with a similar name, sys_mbox_fetch(), is
+ *      implemented by lwIP.
+ * Inputs:
+ *      sys_mbox_t mbox         -- Handle of mailbox
+ *      void **msg              -- Pointer to pointer to msg received
+ *      u32_t timeout           -- Number of milliseconds until timeout
+ * Outputs:
+ *      u32_t                   -- SYS_ARCH_TIMEOUT if timeout, else number
+ *                                  of milliseconds until received.
+ *---------------------------------------------------------------------------*/
+u32_t sys_arch_mbox_fetch( sys_mbox_t *pxMailBox, void **ppvBuffer, u32_t ulTimeOut )
+{
+void *pvDummy;
+TickType_t xStartTime, xEndTime, xElapsed;
+unsigned long ulReturn;
+
+	xStartTime = xTaskGetTickCount();
+
+	if( NULL == ppvBuffer )
+	{
+		ppvBuffer = &pvDummy;
+	}
+
+	if( ulTimeOut != 0UL )
+	{
+		configASSERT( xInsideISR == ( portBASE_TYPE ) 0 );
+
+		if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), ulTimeOut/ portTICK_PERIOD_MS ) )
+		{
+			xEndTime = xTaskGetTickCount();
+			xElapsed = ( xEndTime - xStartTime ) * portTICK_PERIOD_MS;
+
+			ulReturn = xElapsed;
+		}
+		else
+		{
+			/* Timed out. */
+			*ppvBuffer = NULL;
+			ulReturn = SYS_ARCH_TIMEOUT;
+		}
+	}
+	else
+	{
+		while( pdTRUE != xQueueReceive( *pxMailBox, &( *ppvBuffer ), portMAX_DELAY ) );
+		xEndTime = xTaskGetTickCount();
+		xElapsed = ( xEndTime - xStartTime ) * portTICK_PERIOD_MS;
+
+		if( xElapsed == 0UL )
+		{
+			xElapsed = 1UL;
+		}
+
+		ulReturn = xElapsed;
+	}
+
+	return ulReturn;
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_arch_mbox_tryfetch
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Similar to sys_arch_mbox_fetch, but if message is not ready
+ *      immediately, we'll return with SYS_MBOX_EMPTY.  On success, 0 is
+ *      returned.
+ * Inputs:
+ *      sys_mbox_t mbox         -- Handle of mailbox
+ *      void **msg              -- Pointer to pointer to msg received
+ * Outputs:
+ *      u32_t                   -- SYS_MBOX_EMPTY if no messages.  Otherwise,
+ *                                  return ERR_OK.
+ *---------------------------------------------------------------------------*/
+u32_t sys_arch_mbox_tryfetch( sys_mbox_t *pxMailBox, void **ppvBuffer )
+{
+void *pvDummy;
+unsigned long ulReturn;
+long lResult;
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
+
+	if( ppvBuffer== NULL )
+	{
+		ppvBuffer = &pvDummy;
+	}
+
+	if( xInsideISR != pdFALSE )
+	{
+		lResult = xQueueReceiveFromISR( *pxMailBox, &( *ppvBuffer ), &xHigherPriorityTaskWoken );
+	}
+	else
+	{
+		lResult = xQueueReceive( *pxMailBox, &( *ppvBuffer ), 0UL );
+	}
+
+	if( lResult == pdPASS )
+	{
+		ulReturn = ERR_OK;
+	}
+	else
+	{
+		ulReturn = SYS_MBOX_EMPTY;
+	}
+
+	return ulReturn;
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_sem_new
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Creates and returns a new semaphore. The "ucCount" argument specifies
+ *      the initial state of the semaphore.
+ *      NOTE: Currently this routine only creates counts of 1 or 0
+ * Inputs:
+ *      sys_mbox_t mbox         -- Handle of mailbox
+ *      u8_t ucCount              -- Initial ucCount of semaphore (1 or 0)
+ * Outputs:
+ *      sys_sem_t               -- Created semaphore or 0 if could not create.
+ *---------------------------------------------------------------------------*/
+err_t sys_sem_new( sys_sem_t *pxSemaphore, u8_t ucCount )
+{
+err_t xReturn = ERR_MEM;
+
+	vSemaphoreCreateBinary( ( *pxSemaphore ) );
+
+	if( *pxSemaphore != NULL )
+	{
+		if( ucCount == 0U )
+		{
+			xSemaphoreTake( *pxSemaphore, 1UL );
+		}
+
+		xReturn = ERR_OK;
+		SYS_STATS_INC_USED( sem );
+	}
+	else
+	{
+		SYS_STATS_INC( sem.err );
+	}
+
+	return xReturn;
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_arch_sem_wait
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Blocks the thread while waiting for the semaphore to be
+ *      signaled. If the "timeout" argument is non-zero, the thread should
+ *      only be blocked for the specified time (measured in
+ *      milliseconds).
+ *
+ *      If the timeout argument is non-zero, the return value is the number of
+ *      milliseconds spent waiting for the semaphore to be signaled. If the
+ *      semaphore wasn't signaled within the specified time, the return value is
+ *      SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
+ *      (i.e., it was already signaled), the function may return zero.
+ *
+ *      Notice that lwIP implements a function with a similar name,
+ *      sys_sem_wait(), that uses the sys_arch_sem_wait() function.
+ * Inputs:
+ *      sys_sem_t sem           -- Semaphore to wait on
+ *      u32_t timeout           -- Number of milliseconds until timeout
+ * Outputs:
+ *      u32_t                   -- Time elapsed or SYS_ARCH_TIMEOUT.
+ *---------------------------------------------------------------------------*/
+u32_t sys_arch_sem_wait( sys_sem_t *pxSemaphore, u32_t ulTimeout )
+{
+TickType_t xStartTime, xEndTime, xElapsed;
+unsigned long ulReturn;
+
+	xStartTime = xTaskGetTickCount();
+
+	if( ulTimeout != 0UL )
+	{
+		if( xSemaphoreTake( *pxSemaphore, ulTimeout / portTICK_PERIOD_MS ) == pdTRUE )
+		{
+			xEndTime = xTaskGetTickCount();
+			xElapsed = (xEndTime - xStartTime) * portTICK_PERIOD_MS;
+			ulReturn = xElapsed;
+		}
+		else
+		{
+			ulReturn = SYS_ARCH_TIMEOUT;
+		}
+	}
+	else
+	{
+		while( xSemaphoreTake( *pxSemaphore, portMAX_DELAY ) != pdTRUE );
+		xEndTime = xTaskGetTickCount();
+		xElapsed = ( xEndTime - xStartTime ) * portTICK_PERIOD_MS;
+
+		if( xElapsed == 0UL )
+		{
+			xElapsed = 1UL;
+		}
+
+		ulReturn = xElapsed;
+	}
+
+	return ulReturn;
+}
+
+/** Create a new mutex
+ * @param mutex pointer to the mutex to create
+ * @return a new mutex */
+err_t sys_mutex_new( sys_mutex_t *pxMutex )
+{
+err_t xReturn = ERR_MEM;
+
+	*pxMutex = xSemaphoreCreateMutex();
+
+	if( *pxMutex != NULL )
+	{
+		xReturn = ERR_OK;
+		SYS_STATS_INC_USED( mutex );
+	}
+	else
+	{
+		SYS_STATS_INC( mutex.err );
+	}
+
+	return xReturn;
+}
+
+/** Lock a mutex
+ * @param mutex the mutex to lock */
+void sys_mutex_lock( sys_mutex_t *pxMutex )
+{
+	while( xSemaphoreTake( *pxMutex, portMAX_DELAY ) != pdPASS );
+}
+
+/** Unlock a mutex
+ * @param mutex the mutex to unlock */
+void sys_mutex_unlock(sys_mutex_t *pxMutex )
+{
+	xSemaphoreGive( *pxMutex );
+}
+
+
+/** Delete a semaphore
+ * @param mutex the mutex to delete */
+void sys_mutex_free( sys_mutex_t *pxMutex )
+{
+	SYS_STATS_DEC( mutex.used );
+	vQueueDelete( *pxMutex );
+}
+
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_sem_signal
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Signals (releases) a semaphore
+ * Inputs:
+ *      sys_sem_t sem           -- Semaphore to signal
+ *---------------------------------------------------------------------------*/
+void sys_sem_signal( sys_sem_t *pxSemaphore )
+{
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
+
+	if( xInsideISR != pdFALSE )
+	{
+		xSemaphoreGiveFromISR( *pxSemaphore, &xHigherPriorityTaskWoken );
+	}
+	else
+	{
+		xSemaphoreGive( *pxSemaphore );
+	}
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_sem_free
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Deallocates a semaphore
+ * Inputs:
+ *      sys_sem_t sem           -- Semaphore to free
+ *---------------------------------------------------------------------------*/
+void sys_sem_free( sys_sem_t *pxSemaphore )
+{
+	SYS_STATS_DEC(sem.used);
+	vQueueDelete( *pxSemaphore );
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_init
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Initialize sys arch
+ *---------------------------------------------------------------------------*/
+void sys_init(void)
+{
+}
+
+u32_t sys_now(void)
+{
+	return xTaskGetTickCount();
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_thread_new
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      Starts a new thread with priority "prio" that will begin its
+ *      execution in the function "thread()". The "arg" argument will be
+ *      passed as an argument to the thread() function. The id of the new
+ *      thread is returned. Both the id and the priority are system
+ *      dependent.
+ * Inputs:
+ *      char *name              -- Name of thread
+ *      void (* thread)(void *arg) -- Pointer to function to run.
+ *      void *arg               -- Argument passed into function
+ *      int stacksize           -- Required stack amount in bytes
+ *      int prio                -- Thread priority
+ * Outputs:
+ *      sys_thread_t            -- Pointer to per-thread timeouts.
+ *---------------------------------------------------------------------------*/
+sys_thread_t sys_thread_new( const char *pcName, void( *pxThread )( void *pvParameters ), void *pvArg, int iStackSize, int iPriority )
+{
+TaskHandle_t xCreatedTask;
+portBASE_TYPE xResult;
+sys_thread_t xReturn;
+
+	xResult = xTaskCreate( pxThread, pcName, iStackSize, pvArg, iPriority, &xCreatedTask );
+
+	if( xResult == pdPASS )
+	{
+		xReturn = xCreatedTask;
+	}
+	else
+	{
+		xReturn = NULL;
+	}
+
+	return xReturn;
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_arch_protect
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      This optional function does a "fast" critical region protection and
+ *      returns the previous protection level. This function is only called
+ *      during very short critical regions. An embedded system which supports
+ *      ISR-based drivers might want to implement this function by disabling
+ *      interrupts. Task-based systems might want to implement this by using
+ *      a mutex or disabling tasking. This function should support recursive
+ *      calls from the same task or interrupt. In other words,
+ *      sys_arch_protect() could be called while already protected. In
+ *      that case the return value indicates that it is already protected.
+ *
+ *      sys_arch_protect() is only required if your port is supporting an
+ *      operating system.
+ * Outputs:
+ *      sys_prot_t              -- Previous protection level (not used here)
+ *---------------------------------------------------------------------------*/
+sys_prot_t sys_arch_protect( void )
+{
+	if( xInsideISR == pdFALSE )
+	{
+		taskENTER_CRITICAL();
+	}
+	return ( sys_prot_t ) 1;
+}
+
+/*---------------------------------------------------------------------------*
+ * Routine:  sys_arch_unprotect
+ *---------------------------------------------------------------------------*
+ * Description:
+ *      This optional function does a "fast" set of critical region
+ *      protection to the value specified by pval. See the documentation for
+ *      sys_arch_protect() for more information. This function is only
+ *      required if your port is supporting an operating system.
+ * Inputs:
+ *      sys_prot_t              -- Previous protection level (not used here)
+ *---------------------------------------------------------------------------*/
+void sys_arch_unprotect( sys_prot_t xValue )
+{
+	(void) xValue;
+	if( xInsideISR == pdFALSE )
+	{
+		taskEXIT_CRITICAL();
+	}
+}
+
+/*
+ * Prints an assertion messages and aborts execution.
+ */
+void sys_assert( const char *pcMessage )
+{
+	(void) pcMessage;
+
+	for (;;)
+	{
+	}
+}
+/*-------------------------------------------------------------------------*
+ * End of File:  sys_arch.c
+ *-------------------------------------------------------------------------*/
+

+ 311 - 0
iap/lwip/port/STM32F4x7/Standalone/ethernetif.c

@@ -0,0 +1,311 @@
+/**
+ * @file
+ * Ethernet Interface for standalone applications (without RTOS) - works only for 
+ * ethernet polling mode (polling for ethernet frame reception)
+ *
+ */
+
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#include "lwip/mem.h"
+#include "netif/etharp.h"
+#include "ethernetif.h"
+#include "stm32f4x7_eth.h"
+#include "main.h"
+#include "common_config.h"   
+#include "settings_api.h"
+
+#include <string.h>
+
+/* Network interface name */
+#define IFNAME0 's'
+#define IFNAME1 't'
+
+
+/* Ethernet Rx & Tx DMA Descriptors */
+extern ETH_DMADESCTypeDef  DMARxDscrTab[ETH_RXBUFNB], DMATxDscrTab[ETH_TXBUFNB];
+
+/* Ethernet Driver Receive buffers  */
+extern uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE]; 
+
+/* Ethernet Driver Transmit buffers */
+extern uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE]; 
+
+/* Global pointers to track current transmit and receive descriptors */
+extern ETH_DMADESCTypeDef  *DMATxDescToSet;
+extern ETH_DMADESCTypeDef  *DMARxDescToGet;
+
+/* Global pointer for last received frame infos */
+extern ETH_DMA_Rx_Frame_infos *DMA_RX_FRAME_infos;
+
+
+
+
+/**
+ * In this function, the hardware should be initialized.
+ * Called from ethernetif_init().
+ *
+ * @param netif the already initialized lwip network interface structure
+ *        for this ethernetif
+ */
+static void low_level_init(struct netif *netif)
+{
+  uint8_t mac[6];
+#ifdef CHECKSUM_BY_HARDWARE
+  int i; 
+#endif
+  /* set MAC hardware address length */
+  netif->hwaddr_len = ETHARP_HWADDR_LEN;
+
+  /* set MAC hardware address */
+  
+  SETTINGS_GetMac(mac);
+  
+  netif->hwaddr[0] =  mac[0];
+  netif->hwaddr[1] =  mac[1];
+  netif->hwaddr[2] =  mac[2];
+  netif->hwaddr[3] =  mac[3];
+  netif->hwaddr[4] =  mac[4];
+  netif->hwaddr[5] =  mac[5];
+  
+  /* initialize MAC address in ethernet MAC */ 
+  ETH_MACAddressConfig(ETH_MAC_Address0, netif->hwaddr); 
+
+  /* maximum transfer unit */
+  netif->mtu = 1500;
+
+  /* device capabilities */
+  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
+  netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
+
+  /* Initialize Tx Descriptors list: Chain Mode */
+  ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
+  /* Initialize Rx Descriptors list: Chain Mode  */
+  ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
+  
+#ifdef CHECKSUM_BY_HARDWARE
+  /* Enable the TCP, UDP and ICMP checksum insertion for the Tx frames */
+  for(i=0; i<ETH_TXBUFNB; i++)
+    {
+      ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i], ETH_DMATxDesc_ChecksumTCPUDPICMPFull);
+    }
+#endif
+
+   /* Note: TCP, UDP, ICMP checksum checking for received frame are enabled in DMA config */
+
+  /* Enable MAC and DMA transmission and reception */
+  ETH_Start();
+
+}
+
+/**
+ * This function should do the actual transmission of the packet. The packet is
+ * contained in the pbuf that is passed to the function. This pbuf
+ * might be chained.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
+ * @return ERR_OK if the packet could be sent
+ *         an err_t value if the packet couldn't be sent
+ *
+ * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
+ *       strange results. You might consider waiting for space in the DMA queue
+ *       to become availale since the stack doesn't retry to send a packet
+ *       dropped because of memory failure (except for the TCP timers).
+ */
+
+static err_t low_level_output(struct netif *netif, struct pbuf *p)
+{
+  struct pbuf *q;
+  int framelength = 0;
+  u8 *buffer =  (u8 *)(DMATxDescToSet->Buffer1Addr);
+  
+  /* copy frame from pbufs to driver buffers */
+  for(q = p; q != NULL; q = q->next) 
+  {
+    memcpy((u8_t*)&buffer[framelength], q->payload, q->len);
+	framelength = framelength + q->len;
+  }
+  
+  /* Note: padding and CRC for transmitted frame 
+     are automatically inserted by DMA */
+
+  /* Prepare transmit descriptors to give to DMA*/ 
+  ETH_Prepare_Transmit_Descriptors(framelength);
+
+  return ERR_OK;
+}
+
+/**
+ * Should allocate a pbuf and transfer the bytes of the incoming
+ * packet from the interface into the pbuf.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return a pbuf filled with the received packet (including MAC header)
+ *         NULL on memory error
+ */
+static struct pbuf * low_level_input(struct netif *netif)
+{
+  struct pbuf *p, *q;
+  u16_t len;
+  int l =0;
+  FrameTypeDef frame;
+  u8 *buffer;
+  uint32_t i=0;
+  __IO ETH_DMADESCTypeDef *DMARxNextDesc;
+  
+  
+  p = NULL;
+  
+  /* get received frame */
+  frame = ETH_Get_Received_Frame();
+  
+  /* Obtain the size of the packet and put it into the "len" variable. */
+  len = frame.length;
+  buffer = (u8 *)frame.buffer;
+  
+  /* We allocate a pbuf chain of pbufs from the Lwip buffer pool */
+  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+  
+  /* copy received frame to pbuf chain */
+  if (p != NULL)
+  {
+    for (q = p; q != NULL; q = q->next)
+    {
+      memcpy((u8_t*)q->payload, (u8_t*)&buffer[l], q->len);
+      l = l + q->len;
+    }    
+  }
+  
+  /* Release descriptors to DMA */
+  /* Check if frame with multiple DMA buffer segments */
+  if (DMA_RX_FRAME_infos->Seg_Count > 1)
+  {
+    DMARxNextDesc = DMA_RX_FRAME_infos->FS_Rx_Desc;
+  }
+  else
+  {
+    DMARxNextDesc = frame.descriptor;
+  }
+  
+  /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
+  for (i=0; i<DMA_RX_FRAME_infos->Seg_Count; i++)
+  {  
+    DMARxNextDesc->Status = ETH_DMARxDesc_OWN;
+    DMARxNextDesc = (ETH_DMADESCTypeDef *)(DMARxNextDesc->Buffer2NextDescAddr);
+  }
+  
+  /* Clear Segment_Count */
+  DMA_RX_FRAME_infos->Seg_Count =0;
+  
+  /* When Rx Buffer unavailable flag is set: clear it and resume reception */
+  if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET)  
+  {
+    /* Clear RBUS ETHERNET DMA flag */
+    ETH->DMASR = ETH_DMASR_RBUS;
+    /* Resume DMA reception */
+    ETH->DMARPDR = 0;
+  }
+  return p;
+}
+
+/**
+ * This function should be called when a packet is ready to be read
+ * from the interface. It uses the function low_level_input() that
+ * should handle the actual reception of bytes from the network
+ * interface. Then the type of the received packet is determined and
+ * the appropriate input function is called.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ */
+err_t ethernetif_input(struct netif *netif)
+{
+  err_t err;
+  struct pbuf *p;
+
+  /* move received packet into a new pbuf */
+  p = low_level_input(netif);
+
+  /* no packet could be read, silently ignore this */
+  if (p == NULL) return ERR_MEM;
+
+  /* entry point to the LwIP stack */
+  err = netif->input(p, netif);
+  
+  if (err != ERR_OK)
+  {
+    LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
+    pbuf_free(p);
+    p = NULL;
+  }
+  return err;
+}
+
+/**
+ * Should be called at the beginning of the program to set up the
+ * network interface. It calls the function low_level_init() to do the
+ * actual setup of the hardware.
+ *
+ * This function should be passed as a parameter to netif_add().
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return ERR_OK if the loopif is initialized
+ *         ERR_MEM if private data couldn't be allocated
+ *         any other err_t on error
+ */
+err_t ethernetif_init(struct netif *netif)
+{
+  LWIP_ASSERT("netif != NULL", (netif != NULL));
+  
+#if LWIP_NETIF_HOSTNAME
+  /* Initialize interface hostname */
+  netif->hostname = "lwip";
+#endif /* LWIP_NETIF_HOSTNAME */
+
+  netif->name[0] = IFNAME0;
+  netif->name[1] = IFNAME1;
+  /* We directly use etharp_output() here to save a function call.
+   * You can instead declare your own function an call etharp_output()
+   * from it if you have to do some checks before sending (e.g. if link
+   * is available...) */
+  netif->output = etharp_output;
+  netif->linkoutput = low_level_output;
+
+  /* initialize the hardware */
+  low_level_init(netif);
+
+  return ERR_OK;
+}
+
+
+

+ 11 - 0
iap/lwip/port/STM32F4x7/Standalone/ethernetif.h

@@ -0,0 +1,11 @@
+#ifndef __ETHERNETIF_H__
+#define __ETHERNETIF_H__
+
+
+#include "lwip/err.h"
+#include "lwip/netif.h"
+
+err_t ethernetif_init(struct netif *netif);
+err_t ethernetif_input(struct netif *netif);
+
+#endif

+ 1 - 0
iap/lwip/port/STM32F4x7/arch/bpstruct.h

@@ -0,0 +1 @@
+#pragma pack(push,1)

+ 93 - 0
iap/lwip/port/STM32F4x7/arch/cc.h

@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __CC_H__
+#define __CC_H__
+
+#include "cpu.h"
+
+typedef unsigned   char    u8_t;
+typedef signed     char    s8_t;
+typedef unsigned   short   u16_t;
+typedef signed     short   s16_t;
+typedef unsigned   long    u32_t;
+typedef signed     long    s32_t;
+typedef u32_t mem_ptr_t;
+typedef int sys_prot_t;
+
+
+#define U16_F "u"
+#define S16_F "d"
+#define X16_F "x"
+#define U32_F "u"
+#define S32_F "d"
+#define X32_F "x"
+#define SZT_F "u"
+
+
+
+
+
+/* define compiler specific symbols */
+#if defined (__ICCARM__)
+
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_STRUCT 
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+#define PACK_STRUCT_USE_INCLUDES
+
+#elif defined (__CC_ARM)
+
+#define PACK_STRUCT_BEGIN __packed
+#define PACK_STRUCT_STRUCT 
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+
+#elif defined (__GNUC__)
+
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+
+#elif defined (__TASKING__)
+
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_STRUCT
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+
+#endif
+
+#define LWIP_PLATFORM_ASSERT(x) do { if(!(x)) while(1); } while(0)
+
+#endif /* __CC_H__ */

+ 37 - 0
iap/lwip/port/STM32F4x7/arch/cpu.h

@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __CPU_H__
+#define __CPU_H__
+
+#define BYTE_ORDER LITTLE_ENDIAN
+
+#endif /* __CPU_H__ */

+ 1 - 0
iap/lwip/port/STM32F4x7/arch/epstruct.h

@@ -0,0 +1 @@
+#pragma pack(pop)

+ 44 - 0
iap/lwip/port/STM32F4x7/arch/init.h

@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __ARCH_INIT_H__
+#define __ARCH_INIT_H__
+
+#define TCPIP_INIT_DONE(arg)  tcpip_init_done(arg)
+
+void tcpip_init_done(void *);
+int wait_for_tcpip_init(void);
+
+#endif /* __ARCH_INIT_H__ */
+
+
+
+

+ 38 - 0
iap/lwip/port/STM32F4x7/arch/lib.h

@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __LIB_H__
+#define __LIB_H__
+
+#include <string.h>
+
+
+#endif /* __LIB_H__ */

+ 40 - 0
iap/lwip/port/STM32F4x7/arch/perf.h

@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __PERF_H__
+#define __PERF_H__
+
+#define PERF_START    /* null definition */
+#define PERF_STOP(x)  /* null definition */
+
+#endif /* __PERF_H__ */

+ 56 - 0
iap/lwip/port/STM32F4x7/arch/sys_arch.h

@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __ARCH_SYS_ARCH_H__
+#define __ARCH_SYS_ARCH_H__
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
+#include "semphr.h"
+
+#define SYS_MBOX_NULL					( ( QueueHandle_t ) NULL )
+#define SYS_SEM_NULL					( ( SemaphoreHandle_t ) NULL )
+#define SYS_DEFAULT_THREAD_STACK_DEPTH	configMINIMAL_STACK_SIZE
+
+typedef SemaphoreHandle_t sys_sem_t;
+typedef SemaphoreHandle_t sys_mutex_t;
+typedef QueueHandle_t sys_mbox_t;
+typedef TaskHandle_t sys_thread_t;
+
+#define sys_mbox_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
+#define sys_mbox_set_invalid( x ) ( ( *x ) = NULL )
+#define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
+#define sys_sem_set_invalid( x ) ( ( *x ) = NULL )
+
+
+#endif /* __ARCH_SYS_ARCH_H__ */
+