I have created a C++ project in Codewarrior 10.3 targeting Kinetis K61FN1M0VMJ12. I am attempting to do a Bootloader that will reprogram Flash in the field. I need to instantiate my Flash class in RAM so it can perform flash erase and write operations. However, using "new" only creates a RAM pointer to the flash-based code. How can I get the class (about 1200 bytes long) onto the heap?
I am using "new" in C++ with the intent of creating a copy of a class on the heap. The location on the heap is necessary for hardware reasons in writing to Flash memory. I am using:
static Watchdog *wd;
Flash *flash;
wd = new(std::nothrow) Watchdog;
flash = new(std::nothrow) Flash();
The problem is that the only thing that ends up in RAM is the pointer.
I am using gnu C++ compiler chain on eclipse for Codewarrior. Does anyone know of a compiler directive that is causing the problem, or that would actually create an instance on the stack? All the manuals I have indicate that “new” should instantiate the object on the heap.
BTW, Watchdog *wd is used by various functions in the main.cpp file. Flash *flash is used in two or three files that need special access to Flash registers in the processor.
Regards,
Don DenTandt