- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
has anyone succesfully used C++ on PSoC? I want to use a C++ source code. On the first run I want to know if it will fit into a 5LP. I switched to the latest ARM GCC release (9-2020-q2). I replaced the GCC exe file with the G++ exe file.
There was an issue in CyLib.c with the initialization of the SysTick Callbacks regarding the void* 0 pointer. Replacing it with "nullptr" resolved the issue. Now, it seems(!) that it can be linked. As expected, it won't fit into the device on the first run, the error message is:
Build error: <...>/xyz.elf section `.ARM.exidx' will not fit in region `rom'
The bad thing is that the .elf file is deleted directly after the build process - it can be seen shortly in file explorer. Trying to copy it while it exists results in a empty file, unfortunately. I assume the created file is filled with valuable content for checking how much the flash content is in size. Too bad that the output window doesn't show the size in this configuration.
There's also an error "cm3gcc.ld:91: undefined symbol `RomVectors' referenced in expression". I don't know if this is related to the error mentioned above.
So, I've two questions:
1) how to get the information regarding the build size / prevent that the .elf file is deleted
2) how to check what's going on with those RomVectors?
Regards
Solved! Go to Solution.
- Labels:
-
PSoC Creator Software
- Tags:
- c++
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> has anyone succesfully used C++ on PSoC?
I answered I have.
But please note that C++ is not supported by PSoC Creator, so what we are doing is hacking
and not guaranteed nor recommended.
And I also can not guarantee nor recommend it (at least for the time being).
Having written above, you know, I tried my hack using CY8CKIT-059 😉
schematic
pins
animal.h
==============
#ifndef _ANIMAL_H_
#define _ANIMAL_H_
extern "C" {
#include "project.h"
}
#include "stdio.h"
class animal {
public:
animal(char *name) ;
~animal() ;
void move(int x, int y) ;
void go(int x, int y) ;
private:
char *_name ;
int _x ;
int _y ;
} ;
#endif /* _ANIMAL_H_ */
==============
animal.cpp
==============
extern "C" {
#include "project.h"
}
#include <stdio.h>
#include <string.h>
#include "main.h"
#include "animal.h"
animal::animal(char *name)
{
_name = new char[strlen(name) + 1] ;
strcpy(_name, name) ;
_x = 0 ;
_y = 0 ;
}
animal::~animal(void)
{
delete [] _name ;
_x = 0 ;
_y = 0 ;
}
void animal::move(int x, int y)
{
_x += x ;
_y += y ;
snprintf(str, STR_LEN, "%s moved to %d %d\n",_name, _x, _y) ;
print(str) ;
}
void animal::go(int x, int y)
{
_x = x ;
_y = y ;
snprintf(str, STR_LEN, "%s moved to %d %d\n",_name, _x, _y) ;
print(str) ;
}
==============
main.h
==============
#ifndef _MAIN_H_
#define _MAIN_H_
extern "C" {
#include "project.h"
extern char str[] ;
extern void print(char *str) ;
}
#define STR_LEN 64
void *operator new(size_t size) ;
void operator delete(void *ptr) ;
void *operator new[] (size_t size) ;
void operator delete[] (void *ptr) ;
#endif /* _MAIN_H_ */
==============
main.cpp
==============
extern "C" {
#include "project.h"
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "animal.h"
#include "main.h"
char str[STR_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
}
int main(void)
{
animal *cat ;
init_hardware() ;
print("\x1b[2J\x1b[;H") ;
print("PSoC 5LP C++ Test (Experimental) ") ;
snprintf(str, STR_LEN, "(%s %s)\n", __DATE__,__TIME__) ;
print(str) ;
cat = new animal("mikan") ;
cat->move(3, 3) ;
cat->move(3, 3) ;
cat->go(2, 4) ;
for(;;) {
}
}
void *operator new(size_t size)
{
return malloc(size) ;
}
void operator delete(void *ptr)
{
free(ptr) ;
}
void *operator new[] (size_t size)
{
return malloc(size) ;
}
void operator delete[] (void *ptr)
{
free(ptr) ;
}
==============
Tera Term Log
So the good news is at least my c++ program could be compiled and my cat can walk a little.
The bad news is that there is no one who will guarantee nor support for further exploration.
moto