using DMAMEM

Hey guys, I'm wondering why certain things dont seem to be able to be allocated to RAM2 instead of RAM1. My example being "
DMAMEM RingBuf<FsFile, sizeof(DATA_LOGGER_FRAME) * 15> BUFFER; //Enough to store 60ms of data" produces error: "Compilation error: section attribute not allowed for 'BUFFER'" in the code:

Code:
#ifndef DATA_LOGGER_H
#define DATA_LOGGER_H

#include "Structs.h"
#include "Telemetry.h"
#include "SdFat.h"
#include "RingBuf.h"

const int DATA_LOGGER_DISABLED = 0;
const int DATA_LOGGER_ENABLED = 1;

class DATALOGGER {
public:
  DATALOGGER(DRONE_SETTINGS drone_settings, TELEMETRY* telemetry);
  void start();
  void startDataLogging();
  void endDataLogging();
  void endDataLoggingEmergency();
  void addData(RECEIVER_DATA* receiver_data, IMU_DATA* imu_data, ALTITUDE_DATA* altitude_data, SAFETY_DATA* safety_data, DRONE_ARMING_DATA* drone_arming_data, GPS_DATA* gps_data, STEPPER_MOTOR_DATA* stepper_motor_data, TELEMETRY_DATA* telemetry_data, ESC_DATA* esc_data, PID_DATA* pid_data);
private:
  DRONE_SETTINGS drone_settings;
  TELEMETRY* telemetry;
  const String DIRECTORY_TO_BINARY_FILE = "drone_data.bin";
  const String DIRECTORY_TO_TEXT_FILE = "drone_data.txt";
  const String DIRECTORY_TO_EMERGENCY_TEXT_FILE = "emergency_dump.txt";
  const String DIRECTORY_TO_ROOT = "/";
  const uint64_t FILE_PRE_ALLOCATION_SIZE = sizeof(DATA_LOGGER_FRAME) * 250 * 1800; //Enough To Store 30 Minutes Of Flight
  SdFs SD;
  FsFile BINARY_FILE, TEXT_FILE, EMERGENCY_DUMP_FILE;
  DMAMEM RingBuf<FsFile, sizeof(DATA_LOGGER_FRAME) * 15> BUFFER; //Enough to store 60ms of data
  const size_t BUFFER_WRITE_OUT_SIZE = 4096; //old value 4096 but with inclusion of massive pid struct I expanded write size
  uint32_t FLIGHT_NUMBER = 1;
  bool DISABLE_DATA_LOGGER = false;
  String getDirectoryWithFlightNumberAdded(String existing_directory, uint32_t flight);
  void deleteAllExistingFiles();
  void processEmergencyDumpFile();
};

#endif

Any ideas what I'm doing wrong or how to make it work?
 
You're telling the compiler that you want RingBuf to be stored in a different location from the rest of the class data member. If you want the RingBuf to be in DMAMEM, you'll have to either put the entire class in DMAMEM (not sure that works), or define it separately from the class.
 
Technically you'd put the objects in DMAMEM, not the class. Here an example: c1 lives in ITCM, c2 lives in DMAMEM and c3 in FLASHMEM
C++:
class myClass
{
public:
  unsigned i = 42;
};

myClass c1;
DMAMEM myClass c2;
FLASHMEM const myClass c3;

void setup()
{
  while (!Serial){ };
  Serial.printf("&c1.i (ITCM): %p\n&c2.i (DMAMEM): %p\n&c3.i (FLASH): %p\n", &c1.i, &c2.i, &c3.i);
}

void loop() {}

which prints:
Code:
&c1.i (ITCM): 0x200021a0
&c2.i (DMAMEM): 0x20200000
&c3.i (FLASH): 0x60001650
 
Last edited:
Back
Top