extern "C" void user_init(){ ... }
Also all the SDK headers have to be put into extern "C" block:
extern "C" {
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
}
Explore... Chat... Share...
extern "C" void user_init(){ ... }
extern "C" {
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
}
When you succeed with that part you may get a bunch of errors regarding missing _sbrk_r function. To fix those you will likely have to override new, new[], delete, and delete[] operators to use os_malloc & os_free provided in the Espressif SDK.
/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++ -Idriver -Iuser -Idriver/include -Iuser/include -Iinclude -I/opt/Espressif/include/ -I/opt/Espressif/ESP8266_SDK/include -I/opt/Espressif/ESP8266_SDK/include/json -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -fno-rtti -fno-exceptions -c user/user_main.cpp -o build/user/user_main.o
/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar cru build/app_app.a build/user/user_main.o
/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -L/opt/Espressif/ESP8266_SDK/lib -T/opt/Espressif/ESP8266_SDK/ld/eagle.app.v6.ld -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lupgrade -lmain -lpp build/app_app.a -Wl,--end-group -o build/app.out
build/app_app.a(user_main.o):(.text+0x0): undefined reference to `operator delete(void*)'
build/app_app.a(user_main.o): In function `user_init':
/home/user/Documents/dev/hardware/wifinoise/esp8266/tests/c_vector_test/user/user_main.cpp:19: undefined reference to `operator delete(void*)'
/home/user/Documents/dev/hardware/wifinoise/esp8266/tests/c_vector_test/user/user_main.cpp:23: undefined reference to `operator new(unsigned int)'
build/app_app.a(user_main.o): In function `operator-<int*, std::vector<int> >':
/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_iterator.h:898: undefined reference to `operator new(unsigned int)'
build/app_app.a(user_main.o): In function `__copy_m<int>':
/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:371: undefined reference to `operator delete(void*)'
collect2: error: ld returned 1 exit status
make: *** [build/app.out] Error 1
void *operator new(size_t size) {
return os_malloc(size);
}
void *operator new[](size_t size) {
return os_malloc(size);
}
void operator delete(void * ptr) {
os_free(ptr);
}
void operator delete[](void * ptr) {
os_free(ptr);
}
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
extern "C" void abort() {
while(true); // enter an infinite loop and get reset by the WDT
}
void __cxa_pure_virtual(void) {
abort();
}
void __cxa_deleted_virtual(void) {
abort();
}
#ifndef __MEM_H__
#define __MEM_H__
//void *pvPortMalloc( size_t xWantedSize );
//void vPortFree( void *pv );
//void *pvPortZalloc(size_t size);
#define os_malloc pvPortMalloc
#define os_free vPortFree
#define os_zalloc pvPortZalloc
#endif
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]