Commit to be compliant with ESP's SDK 1.5.1. Also, add binary blobs.

This commit is contained in:
cnlohr 2016-01-28 20:38:48 -05:00
parent 997ad27cc2
commit ae55f193cf
10 changed files with 64 additions and 49 deletions

BIN
embedded8266/0x00000.bin Normal file

Binary file not shown.

BIN
embedded8266/0x40000.bin Normal file

Binary file not shown.

View File

@ -23,7 +23,7 @@ SRCS:=driver/uart.c \
GCC_FOLDER:=~/esp8266/esp-open-sdk/xtensa-lx106-elf
ESPTOOL_PY:=~/esp8266/esptool/esptool.py
FW_TOOL:=~/esp8266/other/esptool/esptool
SDK:=/home/cnlohr/esp8266/esp_iot_sdk_v1.3.0
SDK:=/home/cnlohr/esp8266/esp_iot_sdk_v1.5.1
PORT:=/dev/ttyUSB0
#PORT:=/dev/ttyACM0
@ -52,6 +52,7 @@ LDFLAGS_CORE:=\
$(SDK)/lib/libphy.a \
$(SDK)/lib/liblwip.a \
$(SDK)/lib/libpp.a \
$(SDK)/lib/libcrypto.a \
$(SDK)/lib/libmain.a \
$(XTGCCLIB) \
-T $(SDK)/ld/eagle.app.v6.ld \

View File

@ -92,7 +92,7 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
{
case 'e': case 'E': //(FE#\n) <- # = sector.
{
if( nr < 128 )
if( nr < 16 )
{
buffend += ets_sprintf(buffend, "!FE%d\r\n", nr );
break;
@ -108,7 +108,7 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
case 'b': case 'B': //(FB#\n) <- # = block.
{
if( nr < 8 )
if( nr < 1 ) //Not allowed to erase boot sector.
{
buffend += ets_sprintf(buffend, "!FB%d\r\n", nr );
break;
@ -133,7 +133,7 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
{
colon++;
const char * colon2 = (const char *) ets_strstr( (char*)colon, "\t" );
if( colon2 && nr >= 524288)
if( colon2 && nr >= 65536)
{
colon2++;
int datlen = (int)len - (colon2 - pusrdata);
@ -510,7 +510,13 @@ void ICACHE_FLASH_ATTR issue_command_udp(void *arg, char *pusrdata, unsigned sho
int r = issue_command( retbuf, 1300, pusrdata, len );
if( r > 0 )
{
espconn_sent( (struct espconn *)arg, retbuf, r );
//YUCK! Since SDK 1.4.0, we have to do this ridiculous thing to respond to senders.
struct espconn * rc = (struct espconn *)arg;
remot_info * ri = 0;
espconn_get_connection_info( rc, &ri, 0);
ets_memcpy( rc->proto.udp->remote_ip, ri->remote_ip, 4 );
rc->proto.udp->remote_port = ri->remote_port;
espconn_sendto( rc, retbuf, r );
}
}
@ -563,7 +569,7 @@ void ICACHE_FLASH_ATTR CSInit()
espconn_regist_time(pHTTPServer, 15, 0); //timeout
}
void CSTick( int slowtick )
void ICACHE_FLASH_ATTR CSTick( int slowtick )
{
static uint8_t tick_flag = 0;

View File

@ -8,20 +8,24 @@
uint32 mfs_at = 0;
void FindMPFS()
void ICACHE_FLASH_ATTR FindMPFS()
{
uint32 mfs_check[2];
EnterCritical();
flashchip->chip_size = 0x01000000;
spi_flash_read( MFS_START, mfs_check, sizeof( mfs_check ) );
if( strncmp( "MPFSPFS", mfs_check ) == 0 ) { mfs_at = MFS_START; goto done; }
if( strncmp( "MPFSMPFS", mfs_check, 8 ) == 0 ) { mfs_at = MFS_START; goto done; }
spi_flash_read( MFS_ALTERNATIVE_START, mfs_check, sizeof( mfs_check ) );
if( strncmp( "MPFSPFS", mfs_check ) == 0 ) { mfs_at = MFS_ALTERNATIVE_START; goto done; }
printf( "MFS Not found at regular address (%08x).\n", mfs_check[0], mfs_check[1] );
spi_flash_read( MFS_ALTERNATIVE_START, mfs_check, sizeof( mfs_check ) );
if( strncmp( "MPFSMPFS", mfs_check, 8 ) == 0 ) { mfs_at = MFS_ALTERNATIVE_START; goto done; }
printf( "MFS Not found at alternative address (%08x%08x).\n", mfs_check[0], mfs_check[1] );
done:
printf( "MFS Found at: %08x\n", mfs_at );
flashchip->chip_size = 0x00080000;
ExitCritical();
}
@ -32,7 +36,7 @@ extern SpiFlashChip * flashchip;
//Returns size of file if non-empty
//If positive, populates mfi.
//Returns -1 if can't find file or reached end of file list.
int8_t MFSOpenFile( const char * fname, struct MFSFileInfo * mfi )
int8_t ICACHE_FLASH_ATTR MFSOpenFile( const char * fname, struct MFSFileInfo * mfi )
{
if( mfs_at == 0 )
{

View File

@ -106,7 +106,7 @@ void PushBlob( const uint8 * buffer, int len )
}
int8_t TCPCanSend( struct espconn * conn, int size )
int8_t ICACHE_FLASH_ATTR TCPCanSend( struct espconn * conn, int size )
{
#ifdef SAFESEND
return TCPDoneSend( conn );

View File

@ -30,7 +30,7 @@ extern const char * enctypes[6];// = { "open", "wep", "wpa", "wpa2", "wpa_wpa2",
char tohex1( uint8_t i );
int8_t fromhex1( char c ); //returns -1 if not hex char.
int32 my_atoi( const char * in );
int32 my_atoi( const char * in );
void Uint32To10Str( char * out, uint32 dat );
//For holding TX packet buffers

Binary file not shown.

View File

@ -42,7 +42,7 @@ static uint8_t hpa_running = 0;
void ICACHE_FLASH_ATTR CustomStart( );
void user_rf_pre_init()
void ICACHE_FLASH_ATTR user_rf_pre_init()
{
}
@ -78,6 +78,39 @@ int wf = 0;
//Tasks that happen all the time.
static void ICACHE_FLASH_ATTR HandleIPStuff()
{
//Idle Event.
struct station_config wcfg;
char stret[256];
char *stt = &stret[0];
struct ip_info ipi;
int stat = wifi_station_get_connect_status();
//printf( "STAT: %d %d\n", stat, wifi_get_opmode() );
if( stat == STATION_WRONG_PASSWORD || stat == STATION_NO_AP_FOUND || stat == STATION_CONNECT_FAIL )
{
wifi_set_opmode_current( 2 );
stt += ets_sprintf( stt, "Connection failed: %d\n", stat );
uart0_sendStr(stret);
}
if( stat == STATION_GOT_IP && !printed_ip )
{
wifi_station_get_config( &wcfg );
wifi_get_ip_info(0, &ipi);
stt += ets_sprintf( stt, "STAT: %d\n", stat );
stt += ets_sprintf( stt, "IP: %d.%d.%d.%d\n", (ipi.ip.addr>>0)&0xff,(ipi.ip.addr>>8)&0xff,(ipi.ip.addr>>16)&0xff,(ipi.ip.addr>>24)&0xff );
stt += ets_sprintf( stt, "NM: %d.%d.%d.%d\n", (ipi.netmask.addr>>0)&0xff,(ipi.netmask.addr>>8)&0xff,(ipi.netmask.addr>>16)&0xff,(ipi.netmask.addr>>24)&0xff );
stt += ets_sprintf( stt, "GW: %d.%d.%d.%d\n", (ipi.gw.addr>>0)&0xff,(ipi.gw.addr>>8)&0xff,(ipi.gw.addr>>16)&0xff,(ipi.gw.addr>>24)&0xff );
stt += ets_sprintf( stt, "WCFG: /%s/%s/\n", wcfg.ssid, wcfg.password );
uart0_sendStr(stret);
printed_ip = 1;
}
}
static void procTask(os_event_t *events)
{
system_os_post(procTaskPrio, 0, 0 );
@ -119,42 +152,13 @@ static void procTask(os_event_t *events)
if( events->sig == 0 && events->par == 0 )
{
CSTick( 0 );
//Idle Event.
struct station_config wcfg;
char stret[256];
char *stt = &stret[0];
struct ip_info ipi;
int stat = wifi_station_get_connect_status();
//printf( "STAT: %d %d\n", stat, wifi_get_opmode() );
if( stat == STATION_WRONG_PASSWORD || stat == STATION_NO_AP_FOUND || stat == STATION_CONNECT_FAIL )
{
wifi_set_opmode_current( 2 );
stt += ets_sprintf( stt, "Connection failed: %d\n", stat );
uart0_sendStr(stret);
}
if( stat == STATION_GOT_IP && !printed_ip )
{
wifi_station_get_config( &wcfg );
wifi_get_ip_info(0, &ipi);
stt += ets_sprintf( stt, "STAT: %d\n", stat );
stt += ets_sprintf( stt, "IP: %d.%d.%d.%d\n", (ipi.ip.addr>>0)&0xff,(ipi.ip.addr>>8)&0xff,(ipi.ip.addr>>16)&0xff,(ipi.ip.addr>>24)&0xff );
stt += ets_sprintf( stt, "NM: %d.%d.%d.%d\n", (ipi.netmask.addr>>0)&0xff,(ipi.netmask.addr>>8)&0xff,(ipi.netmask.addr>>16)&0xff,(ipi.netmask.addr>>24)&0xff );
stt += ets_sprintf( stt, "GW: %d.%d.%d.%d\n", (ipi.gw.addr>>0)&0xff,(ipi.gw.addr>>8)&0xff,(ipi.gw.addr>>16)&0xff,(ipi.gw.addr>>24)&0xff );
stt += ets_sprintf( stt, "WCFG: /%s/%s/\n", wcfg.ssid, wcfg.password );
uart0_sendStr(stret);
printed_ip = 1;
}
HandleIPStuff();
}
}
//Timer event.
static void myTimer(void *arg)
static void ICACHE_FLASH_ATTR myTimer(void *arg)
{
CSTick( 1 );
// uart0_sendStr(".");
@ -166,11 +170,10 @@ static void myTimer(void *arg)
//Called when new packet comes in.
static void udpserver_recv(void *arg, char *pusrdata, unsigned short len)
static void ICACHE_FLASH_ATTR udpserver_recv(void *arg, char *pusrdata, unsigned short len)
{
struct espconn *pespconn = (struct espconn *)arg;
// uint8_t buffer[MAX_FRAME];
// uint8_t ledout[] = { 0x00, 0xff, 0xaa, 0x00, 0xff, 0xaa, };
uart0_sendStr("X");
ws2812_push( pusrdata+3, len );
@ -187,7 +190,7 @@ void ICACHE_FLASH_ATTR user_init(void)
uart_init(BIT_RATE_115200, BIT_RATE_115200);
int wifiMode = wifi_get_opmode();
uart0_sendStr("\r\nCustom Server\r\n");
uart0_sendStr("\r\nColorChord\r\n");
//Uncomment this to force a system restore.
// system_restore();

View File

@ -16,7 +16,8 @@ execute_reflash : execute_reflash.c md5.c
gcc -o $@ $^
push : pushtodev page.mpfs
./pushtodev $(IP) 1048576 page.mpfs
./pushtodev $(IP) 65536 page.mpfs
# ./pushtodev $(IP) 1048576 page.mpfs
clean :
rm -rf mfsmaker page.mpfs pushtodev execute_reflash