Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partition changes to enable full featured ESP32 build #469

Merged
merged 15 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .scripts/replace_fs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import platform
Import ("env")

OS_NAME = platform.system().lower()
FS_PATH = "./dist/bin/"

if OS_NAME == "windows" :
FS_PATH += "win32/mklittlefs.exe"
elif OS_NAME == "linux" :
FS_PATH += "linux64/mklittlefs"
elif OS_NAME == "linux64" :
FS_PATH += "linux64/mklittlefs"
elif OS_NAME == "darwin" :
FS_PATH += "macos/mklittlefs"
else:
print("ERROR: Could not determine OS type. Got: " + str (OS_NAME))

print("Replace MKSPIFFSTOOL with " + FS_PATH)
env.Replace (MKSPIFFSTOOL = FS_PATH)
6 changes: 6 additions & 0 deletions ESP32_partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1D0000,
app1, app, ota_1, 0x1E0000,0x1D0000,
spiffs, data, spiffs, 0x3B0000,0x50000,
29 changes: 29 additions & 0 deletions ESP8266_loader.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x009000, 0x004000,
otadata, data, ota, 0x00E000, 0x002000,
phy_init, data, phy, 0x00F000, 0x001000
app0, app, ota_0, 0x010000, 0x1D0000,
app1, app, ota_1, 0x1E0000, 0x1D0000,
spiffs, data, spiffs, 0x3B0000, 0x050000,
*/

MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
irom0_0_seg : org = 0x40201010, len = 0x79ff0
}

PROVIDE ( _FS_start = 0x4027B000 );
PROVIDE ( _FS_end = 0x402FB000 );
PROVIDE ( _FS_page = 0x100 );
PROVIDE ( _FS_block = 0x2000 );
PROVIDE ( _EEPROM_start = 0x402fb000 );
/* The following symbols are DEPRECATED and will be REMOVED in a future release */
PROVIDE ( _SPIFFS_start = 0x4027B000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );

INCLUDE "local.eagle.app.v6.common.ld"
21 changes: 20 additions & 1 deletion ESPixelStick/src/FileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ void c_FileMgr::Begin ()
}
else
{
logcon (F ("Flash file system initialized."));
#ifdef ARDUINO_ARCH_ESP32
logcon (String (F ("Flash file system initialized. Used = ")) + String (LittleFS.usedBytes ()) + String (F (" out of ")) + String (LittleFS.totalBytes()) );
#else
logcon (String (F ("Flash file system initialized.")));
#endif // def ARDUINO_ARCH_ESP32

//listDir (LittleFS, String ("/"), 3);
}

Expand Down Expand Up @@ -122,6 +127,20 @@ void c_FileMgr::GetConfig (JsonObject& json)

} // GetConfig

//-----------------------------------------------------------------------------
void c_FileMgr::GetStatus (JsonObject& json)
{
// DEBUG_START;

#ifdef ARDUINO_ARCH_ESP32
json[F ("size")] = LittleFS.totalBytes ();
json[F ("used")] = LittleFS.usedBytes ();
#endif // def ARDUINO_ARCH_ESP32

// DEBUG_END;

} // GetConfig

//-----------------------------------------------------------------------------
void c_FileMgr::SetSpiIoPins ()
{
Expand Down
1 change: 1 addition & 0 deletions ESPixelStick/src/FileMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class c_FileMgr
void Poll ();
void GetConfig (JsonObject& json);
bool SetConfig (JsonObject& json);
void GetStatus (JsonObject& json);

void handleFileUpload (const String & filename, size_t index, uint8_t * data, size_t len, bool final);

Expand Down
4 changes: 2 additions & 2 deletions ESPixelStick/src/GPIO_Defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ typedef enum
// #define BOARD_ESP32_LOLIN_D32_PRO_ETH
// #define BOARD_ESP32_MH_ET_LIVE_MiniKit

// #define SUPPORT_OutputType_UCS1903
// #define SUPPORT_OutputType_GS8208
#define SUPPORT_OutputType_UCS1903
#define SUPPORT_OutputType_GS8208

// Platform specific GPIO definitions
#if defined (BOARD_ESP32_CAM)
Expand Down
4 changes: 2 additions & 2 deletions ESPixelStick/src/GPIO_Defs_ESP32_generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#define RMT_LAST OutputChannelId_RMT_4

#define SUPPORT_OutputType_WS2801 // requires a change in the html directory
// #define SUPPORT_OutputType_APA102 // requires a change in the html directory
// #define SUPPORT_OutputType_TM1814 // requires a change in the html directory
#define SUPPORT_OutputType_APA102 // requires a change in the html directory
#define SUPPORT_OutputType_TM1814 // requires a change in the html directory
// #define SUPPORT_OutputType_TLS3001 // requires a change in the html directory

#define SUPPORT_RELAY_OUTPUT
Expand Down
4 changes: 4 additions & 0 deletions ESPixelStick/src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ void c_WebMgr::ProcessXJRequest (AsyncWebSocketClient* client)
OutputMgr.GetStatus (status);
// DEBUG_V ("");

// Get File Manager Stats
FileMgr.GetStatus (system);
// DEBUG_V ("");

memset (&WebSocketFrameCollectionBuffer[0], 0x00, sizeof (WebSocketFrameCollectionBuffer));
strcpy (WebSocketFrameCollectionBuffer, "XJ");
size_t msgOffset = strlen (WebSocketFrameCollectionBuffer);
Expand Down
77 changes: 33 additions & 44 deletions ESPixelStick/src/network/EthernetDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
static fsm_Eth_state_Boot fsm_Eth_state_Boot_imp;
static fsm_Eth_state_PoweringUp fsm_Eth_state_PoweringUp_imp;
static fsm_Eth_state_ConnectingToEth fsm_Eth_state_ConnectingToEth_imp;
static fsm_Eth_state_ConnectedToEth fsm_Eth_state_ConnectedToEth_imp;
static fsm_Eth_state_ConnectionFailed fsm_Eth_state_ConnectionFailed_imp;
static fsm_Eth_state_WaitForIP fsm_Eth_state_WaitForIP_imp;
static fsm_Eth_state_GotIp fsm_Eth_state_GotIp_imp;
static fsm_Eth_state_DeviceInitFailed fsm_Eth_state_DeviceInitFailed_imp;

//-----------------------------------------------------------------------------
Expand All @@ -44,8 +44,8 @@ c_EthernetDriver::c_EthernetDriver ()
fsm_Eth_state_Boot_imp.SetParent (this);
fsm_Eth_state_PoweringUp_imp.SetParent (this);
fsm_Eth_state_ConnectingToEth_imp.SetParent (this);
fsm_Eth_state_ConnectedToEth_imp.SetParent (this);
fsm_Eth_state_ConnectionFailed_imp.SetParent (this);
fsm_Eth_state_WaitForIP_imp.SetParent (this);
fsm_Eth_state_GotIp_imp.SetParent (this);
fsm_Eth_state_DeviceInitFailed_imp.SetParent (this);

// this gets called pre-setup so there is nothing we can do here.
Expand Down Expand Up @@ -204,7 +204,7 @@ bool c_EthernetDriver::IsConnected ()
{
// DEBUG_V("");

return (pCurrentFsmState == &fsm_Eth_state_ConnectedToEth_imp);
return (pCurrentFsmState == &fsm_Eth_state_WaitForIP_imp);

} // IsConnected

Expand Down Expand Up @@ -511,31 +511,13 @@ void fsm_Eth_state_ConnectingToEth::Init ()

} // fsm_Eth_state_ConnectingToEthUsingConfig::Init

/*****************************************************************************/
void fsm_Eth_state_ConnectingToEth::Poll ()
{
// DEBUG_START;

// wait for the connection to complete via the callback function
// uint32_t CurrentTimeMS = millis ();

// @TODO Ethernet connection timeout is currently hardcoded. Add
// to network config.
// if (CurrentTimeMS - pEthernetDriver->GetFsmStartTime () > (60000))
// {
// logcon (F ("Ethernet Failed to connect"));
// fsm_Eth_state_ConnectionFailed_imp.Init ();
// }

// DEBUG_END;
} // fsm_Eth_state_ConnectingToEth::Poll

/*****************************************************************************/
void fsm_Eth_state_ConnectingToEth::OnConnect ()
{
// DEBUG_START;

pEthernetDriver->SetUpIp ();
fsm_Eth_state_WaitForIP_imp.Init ();

// DEBUG_END;

Expand All @@ -546,72 +528,79 @@ void fsm_Eth_state_ConnectingToEth::OnGotIp ()
{
// DEBUG_START;

fsm_Eth_state_ConnectedToEth_imp.Init ();
fsm_Eth_state_GotIp_imp.Init ();
pEthernetDriver->SetUpIp ();

// DEBUG_END;

} // fsm_Eth_state_ConnectingToEth::OnConnect

/*****************************************************************************/
/*****************************************************************************/
void fsm_Eth_state_ConnectedToEth::Init ()
void fsm_Eth_state_WaitForIP::Init ()
{
// DEBUG_START;

pEthernetDriver->SetFsmState (this);
pEthernetDriver->AnnounceState ();
pEthernetDriver->SetFsmStartTime (millis ());

logcon (String (F ("Ethernet Connected with IP: ")) + pEthernetDriver->GetIpAddress ().toString ());
// DEBUG_V (String (" gateway: ") + pEthernetDriver->GetIpGateway ().toString ());
// DEBUG_V (String (" netmask: ") + pEthernetDriver->GetIpSubNetMask ().toString ());
// DEBUG_END;

pEthernetDriver->NetworkStateChanged (true);
} // fsm_Eth_state_WaitForIP::Init

/*****************************************************************************/
void fsm_Eth_state_WaitForIP::OnGotIp ()
{
// DEBUG_START;

fsm_Eth_state_GotIp_imp.Init ();

// DEBUG_END;

} // fsm_Eth_state_ConnectedToEth::Init
} // fsm_Eth_state_WaitForIP::OnGotIp

/*****************************************************************************/
void fsm_Eth_state_ConnectedToEth::OnDisconnect ()
void fsm_Eth_state_WaitForIP::OnDisconnect ()
{
// DEBUG_START;

fsm_Eth_state_ConnectionFailed_imp.Init ();
pEthernetDriver->NetworkStateChanged (false);
fsm_Eth_state_ConnectingToEth_imp.Init ();

// DEBUG_END;

} // fsm_Eth_state_ConnectedToEth::OnDisconnect
} // fsm_Eth_state_WaitForIP::OnDisconnect

/*****************************************************************************/
/*****************************************************************************/
void fsm_Eth_state_ConnectionFailed::Init ()
void fsm_Eth_state_GotIp::Init ()
{
// DEBUG_START;

pEthernetDriver->SetFsmState (this);
pEthernetDriver->AnnounceState ();
pEthernetDriver->NetworkStateChanged (false);
pEthernetDriver->NetworkStateChanged (true);

ETH_m.stop ();
logcon (String (F ("Ethernet Connected with IP: ")) + pEthernetDriver->GetIpAddress ().toString ());
// DEBUG_V (String (" gateway: ") + pEthernetDriver->GetIpGateway ().toString ());
// DEBUG_V (String (" netmask: ") + pEthernetDriver->GetIpSubNetMask ().toString ());

// DEBUG_END;

} // fsm_Eth_state_ConnectionFailed::Init
} // fsm_Eth_state_GotIp::Init

/*****************************************************************************/
void fsm_Eth_state_ConnectionFailed::Poll ()
void fsm_Eth_state_GotIp::OnDisconnect ()
{
// DEBUG_START;

pEthernetDriver->NetworkStateChanged (false);

// take some recovery action
fsm_Eth_state_ConnectingToEth_imp.Init ();

ETH_m.start ();

// DEBUG_END;
} // fsm_Eth_state_ConnectionFailed::Poll
} // fsm_Eth_state_GotIp::OnDisconnect

/*****************************************************************************/
/*****************************************************************************/
Expand All @@ -625,6 +614,6 @@ void fsm_Eth_state_DeviceInitFailed::Init ()

// DEBUG_END;

} // fsm_Eth_state_ConnectionFailed::Init
} // fsm_Eth_state_DeviceInitFailed::Init

#endif // def SUPPORT_ETHERNET
26 changes: 13 additions & 13 deletions ESPixelStick/src/network/EthernetDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class c_EthernetDriver
protected:
friend class fsm_Eth_state_Boot;
friend class fsm_Eth_state_ConnectingToEth;
friend class fsm_Eth_state_ConnectedToEth;
friend class fsm_Eth_state_ConnectionFailed;
friend class fsm_Eth_state_WaitForIP;
friend class fsm_Eth_state_GotIp;
friend class fsm_Eth_state_DeviceInitFailed;
friend class fsm_Eth_state;
fsm_Eth_state * pCurrentFsmState = nullptr;
Expand Down Expand Up @@ -144,40 +144,40 @@ class fsm_Eth_state_PoweringUp : public fsm_Eth_state
class fsm_Eth_state_ConnectingToEth : public fsm_Eth_state
{
public:
virtual void Poll (void);
virtual void Poll (void) {}
virtual void Init (void);
virtual void GetStateName (String& sName) { sName = F ("Connecting"); }
virtual void OnConnect (void);
virtual void OnGotIp (void);
virtual void OnDisconnect (void) { LOG_PORT.print ("."); }
virtual void OnDisconnect (void) {}

}; // fsm_Eth_state_ConnectingToEth

/*****************************************************************************/
class fsm_Eth_state_ConnectedToEth : public fsm_Eth_state
class fsm_Eth_state_WaitForIP : public fsm_Eth_state
{
public:
virtual void Poll (void) {}
virtual void Init (void);
virtual void GetStateName (String& sName) { sName = F ("Connected"); }
virtual void GetStateName (String& sName) { sName = F ("Wait for IP Address"); }
virtual void OnConnect (void) {}
virtual void OnGotIp (void) {}
virtual void OnGotIp (void);
virtual void OnDisconnect (void);

}; // fsm_Eth_state_ConnectedToEth
}; // fsm_Eth_state_WaitForIP

/*****************************************************************************/
class fsm_Eth_state_ConnectionFailed : public fsm_Eth_state
class fsm_Eth_state_GotIp : public fsm_Eth_state
{
public:
virtual void Poll (void);
virtual void Poll (void) {}
virtual void Init (void);
virtual void GetStateName (String& sName) { sName = F ("Connection Failed"); }
virtual void GetStateName (String& sName) { sName = F ("Got IP"); }
virtual void OnConnect (void) {}
virtual void OnGotIp (void) {}
virtual void OnDisconnect (void) {}
virtual void OnDisconnect (void);

}; // fsm_Eth_state_ConnectionFailed
}; // fsm_Eth_state_GotIp

/*****************************************************************************/
class fsm_Eth_state_DeviceInitFailed : public fsm_Eth_state
Expand Down
Loading