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

Use PSRAM #357

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions firmware/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ platform = espressif32
framework = arduino
board = esp32dev
build_flags =
-DCORE_DEBUG_LEVEL=5
-I${protocol.include_dir}
-D_GLIBCXX_USE_C99
-DENABLE_FPS
-g
-frtti
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-nostdlib
#-DENABLE_CRASHDUMP
#-DENABLE_PERFMON
# use this while debugging
Expand Down
21 changes: 18 additions & 3 deletions firmware/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
#include <utility>

#include <Arduino.h> //do we need this?
#include "ioMain.hpp"
#include "physicsMain.hpp"
#include "tasks/taskRegistry.hpp"
#include "utils/serial.hpp"

#include <cstdlib>
#include <new>

void *operator new(size_t size) noexcept { return ps_malloc(size); }
void operator delete(void *p) noexcept { free(p); }
void *operator new[](size_t size) noexcept { return operator new(size); }
void operator delete[](void *p) noexcept { operator delete(p); }
void *operator new(size_t size, std::nothrow_t) noexcept { return operator new(size); }
void operator delete(void *p, std::nothrow_t) noexcept { operator delete(p); }
void *operator new[](size_t size, std::nothrow_t) noexcept { return operator new(size); }
void operator delete[](void *p, std::nothrow_t) noexcept { operator delete(p); }


void setup()
{
psramInit();
Serial.begin(115200);
bool ramFound = psramInit();
log_d("Ram found %d", ramFound);
DPSerial::init();

DPSerial::sendInstantDebugLog("========== START ==========");

Tasks.emplace(
std::piecewise_construct,
std::forward_as_tuple("I/O"),
Expand Down
4 changes: 3 additions & 1 deletion utils/serial/src/cppLib/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ uint64_t CppLib::open(char *port)
return 0;
}
logString("Open successfull");
// logString("Free heap: %i of %i (%.3f %%). Largest block: %i", ESP.getFreeHeap(), ESP.getHeapSize(), 100*ESP.getFreeHeap()/(float)ESP.getHeapSize(), ESP.getMaxAllocHeap());
return (uint64_t)s_handle;
}

Expand All @@ -40,7 +41,7 @@ void CppLib::close()
}

void CppLib::poll()
{
{
bool receivedSync = false;
bool receivedHeartbeat = false;
bool receivedPosition = false;
Expand All @@ -50,6 +51,7 @@ void CppLib::poll()

while (s_receiveQueue.size() > 0)
{
logString("Received some data....");
auto packet = s_receiveQueue.front();
s_receiveQueue.pop();

Expand Down
1 change: 1 addition & 0 deletions utils/serial/src/serial/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ bool DPSerial::readHeader()

bool DPSerial::readPayload()
{
logString("Received some payload");
const uint16_t size = s_receiveHeader.PayloadSize;
std::vector<char> received;
received.reserve(size);
Expand Down