[core] Organize GCC compilation flags
This commit is contained in:
@@ -44,32 +44,9 @@ queue.AppendPublic(
|
||||
"-march=armv5te",
|
||||
"-mthumb",
|
||||
"-mthumb-interwork",
|
||||
"-g",
|
||||
"-O2",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fno-strict-aliasing",
|
||||
"-fsigned-char",
|
||||
"-Wno-comment",
|
||||
"-Wno-write-strings",
|
||||
"-Wno-char-subscripts",
|
||||
"-Wno-missing-braces",
|
||||
"-Wno-attributes",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
"-nostdlib",
|
||||
"-Wall",
|
||||
"-Wno-format",
|
||||
"-Wno-unknown-pragmas",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++11",
|
||||
"-MMD",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-Wno-literal-suffix",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
# SDK options
|
||||
("CFG_OS_FREERTOS", "1"),
|
||||
@@ -92,9 +69,7 @@ queue.AppendPublic(
|
||||
"-mcpu=arm968e-s",
|
||||
"-marm",
|
||||
"-mthumb-interwork",
|
||||
"-g",
|
||||
"--specs=nano.specs",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-wrap,bk_flash_get_info",
|
||||
"-Wl,-wrap,bk_flash_erase",
|
||||
"-Wl,-wrap,bk_flash_write",
|
||||
@@ -103,6 +78,17 @@ queue.AppendPublic(
|
||||
"-Wl,-wrap,bk_printf",
|
||||
],
|
||||
)
|
||||
queue.AppendPrivate(
|
||||
CCFLAGS=[
|
||||
"-Wno-comment",
|
||||
"-Wno-char-subscripts",
|
||||
"-Wno-missing-braces",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-Wno-format",
|
||||
"-Wno-unknown-pragmas",
|
||||
],
|
||||
)
|
||||
|
||||
srcs_core = []
|
||||
|
||||
@@ -330,8 +316,8 @@ queue.AddLibrary(
|
||||
CCFLAGS=[
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-w",
|
||||
],
|
||||
CFLAGS=["-<-Wall>"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -17,27 +17,7 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-g2",
|
||||
"-w",
|
||||
"-O2",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fmessage-length=0",
|
||||
"-fno-common",
|
||||
"-fno-short-enums",
|
||||
"-fomit-frame-pointer",
|
||||
"-fsigned-char",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
"-Wno-pointer-sign",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
# borrowed from RtlDuino/development/rtl87xx/platform.txt
|
||||
"-std=gnu++11",
|
||||
"-MMD",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
# other options
|
||||
@@ -52,17 +32,11 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-g",
|
||||
"--specs=nano.specs",
|
||||
"-Os",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--cref",
|
||||
# the entrypoint in ROM (?)
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
# start function table in startup.c
|
||||
"-Wl,--undefined=gImage2EntryFun0",
|
||||
"-Wl,--no-enum-size-warning",
|
||||
"-Wl,--no-wchar-size-warning",
|
||||
"-Wl,-wrap,rom_psk_CalcGTK",
|
||||
"-Wl,-wrap,rom_psk_CalcPTK",
|
||||
"-Wl,-wrap,CalcMIC",
|
||||
@@ -88,6 +62,14 @@ queue.AppendPublic(
|
||||
"-Wl,-wrap,__rtl_vfprintf_r_v1_00",
|
||||
],
|
||||
)
|
||||
queue.AppendPrivate(
|
||||
CFLAGS=[
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-Wno-incompatible-pointer-types",
|
||||
"-Wno-int-conversion",
|
||||
"-Wno-pointer-sign",
|
||||
],
|
||||
)
|
||||
|
||||
# Sources - from SDK project/realtek_amebaz_va0_example/GCC-RELEASE/application.mk
|
||||
# - "console" is disabled as it introduces build error, and is generally useless
|
||||
@@ -203,6 +185,9 @@ queue.AddLibrary(
|
||||
"+<component/common/network/mdns>",
|
||||
"+<component/common/network/libwsclient>",
|
||||
],
|
||||
options=dict(
|
||||
CFLAGS=["-w"],
|
||||
),
|
||||
)
|
||||
|
||||
# Sources - lwIP
|
||||
|
||||
@@ -21,30 +21,14 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mcmse",
|
||||
"-mfloat-abi=soft",
|
||||
"-g",
|
||||
"-gdwarf-3",
|
||||
"-Os",
|
||||
"-MMD",
|
||||
"-fstack-usage",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fmessage-length=0",
|
||||
"-fno-common",
|
||||
"-fno-short-enums",
|
||||
"-fomit-frame-pointer",
|
||||
"-fsigned-char",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
"-Wall",
|
||||
"-Wpointer-arith",
|
||||
"-Wno-write-strings",
|
||||
"-Wno-maybe-uninitialized",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=c++11",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-fno-use-cxa-atexit",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
@@ -68,19 +52,9 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mcmse",
|
||||
"-mfloat-abi=soft",
|
||||
"-g",
|
||||
"--specs=nosys.specs",
|
||||
"-nostartfiles",
|
||||
"-nodefaultlibs",
|
||||
"-nostdlib",
|
||||
"-Os",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--warn-section-align",
|
||||
"-Wl,--cref",
|
||||
"-Wl,--build-id=none",
|
||||
"-Wl,--use-blx",
|
||||
"-Wl,--undefined=gRamStartFun",
|
||||
"-Wl,-no-enum-size-warning",
|
||||
"-Wl,-wrap,aesccmp_construct_mic_iv",
|
||||
"-Wl,-wrap,aesccmp_construct_mic_header1",
|
||||
"-Wl,-wrap,aesccmp_construct_ctr_preload",
|
||||
@@ -362,6 +336,11 @@ queue.AddLibrary(
|
||||
"+<src/include>",
|
||||
"+<src/include/netif>",
|
||||
],
|
||||
options=dict(
|
||||
CFLAGS=[
|
||||
"-Wno-implicit-function-declaration",
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
# Sources - mbedTLS
|
||||
|
||||
@@ -18,11 +18,33 @@ family: Family = env["FAMILY_OBJ"]
|
||||
# Move common core sources (env.AddCoreSources()) and Arduino libs
|
||||
# below per-family sources (to maintain child families taking precedence)
|
||||
|
||||
# Global flags (applying to the SDK)
|
||||
# Global public flags
|
||||
# Refer to https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
|
||||
env.Append(
|
||||
CCFLAGS=[
|
||||
# Newer versions of GCC complain about undefined macros in #if
|
||||
"-Wno-undef",
|
||||
# C Language Options
|
||||
"-fsigned-char", # Let the type char be signed
|
||||
# Debugging Options
|
||||
"-g2", # produce debugging information; the default level is 2
|
||||
# Optimization Options
|
||||
"-Os", # optimize for size; enables all -O2 optimizations except those that often increase code size
|
||||
"-fdata-sections", # place each function or data item into its own section
|
||||
"-ffunction-sections", # place each function or data item into its own section
|
||||
"-fno-strict-aliasing", # (don't) assume the strictest aliasing rules applicable
|
||||
# Preprocessor Options
|
||||
"-MMD", # output a rule suitable for make describing the dependencies of the main source file
|
||||
# Code Generation Options
|
||||
"-fno-common", # place uninitialized global variables in the BSS section of the object file
|
||||
"-fno-exceptions", # disable exception handling
|
||||
# Developer Options
|
||||
"-fstack-usage", # output stack usage information for the program, on a per-function basis
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++11",
|
||||
"-fno-rtti", # disable generation of information about every class with virtual functions
|
||||
],
|
||||
)
|
||||
|
||||
@@ -62,11 +84,19 @@ queue.AddExternalLibrary("ltchiptool") # uf2ota source code
|
||||
queue.AddExternalLibrary("flashdb")
|
||||
queue.AddExternalLibrary("printf")
|
||||
|
||||
# Flags & linker options
|
||||
# Non-SDK defines & linker options
|
||||
queue.AppendPublic(
|
||||
CCFLAGS=[
|
||||
"-Wreturn-type",
|
||||
"-Wno-undef",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-Werror=implicit-function-declaration",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-Wno-literal-suffix",
|
||||
"-Wno-write-strings",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
("LIBRETUYA", 1),
|
||||
("LT_VERSION", env.ReadLTVersion(platform.get_dir(), platform.version)),
|
||||
@@ -82,6 +112,13 @@ queue.AppendPublic(
|
||||
"$VARIANTS_DIR",
|
||||
],
|
||||
LINKFLAGS=[
|
||||
"-g2",
|
||||
"-Os",
|
||||
"-Wl,--build-id=none",
|
||||
"-Wl,--cref",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--no-enum-size-warning",
|
||||
"-Wl,--no-wchar-size-warning",
|
||||
# malloc.c wrappers
|
||||
"-Wl,-wrap,malloc",
|
||||
"-Wl,-wrap,calloc",
|
||||
|
||||
@@ -48,7 +48,6 @@ def env_add_core_sources(env: Environment, queue, name: str, path: str) -> bool:
|
||||
"+<*.c*>",
|
||||
"+<common/*.c*>",
|
||||
"+<compat/*.c*>",
|
||||
"+<fixups/*.c*>",
|
||||
"+<port/*.c*>",
|
||||
"+<posix/*.c>",
|
||||
"+<wraps/*.c>",
|
||||
@@ -58,10 +57,23 @@ def env_add_core_sources(env: Environment, queue, name: str, path: str) -> bool:
|
||||
"!<.>",
|
||||
"!<compat>",
|
||||
"!<config>",
|
||||
"!<fixups>",
|
||||
"!<port>",
|
||||
],
|
||||
)
|
||||
queue.AddLibrary(
|
||||
name=f"core_{name}_fixups",
|
||||
base_dir=path,
|
||||
srcs=[
|
||||
"+<fixups/*.c*>",
|
||||
],
|
||||
includes=[
|
||||
"!<fixups>",
|
||||
],
|
||||
options=dict(
|
||||
# disable all warnings for fixups
|
||||
CCFLAGS=["-w"],
|
||||
),
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ class LibraryQueue:
|
||||
def BuildLibraries(self):
|
||||
if self.built:
|
||||
raise RuntimeError("Cannot build a library queue twice")
|
||||
self.Print()
|
||||
|
||||
# add public options to the environment
|
||||
apply_options(self.env, self.options_public)
|
||||
|
||||
@@ -169,6 +169,7 @@ bool LibreTuya::otaSwitch(bool force) {
|
||||
bool LibreTuya::wdtEnable(uint32_t timeout) {
|
||||
wdt_ctrl(WCMD_SET_PERIOD, &timeout);
|
||||
wdt_ctrl(WCMD_POWER_UP, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void LibreTuya::wdtDisable() {
|
||||
|
||||
@@ -36,6 +36,7 @@ WiFiStatus eventTypeToStatus(uint8_t type) {
|
||||
case RW_EVT_STA_DISCONNECTED:
|
||||
return WL_DISCONNECTED;
|
||||
}
|
||||
return WL_IDLE_STATUS;
|
||||
}
|
||||
|
||||
WiFiAuthMode securityTypeToAuthMode(uint8_t type) {
|
||||
|
||||
@@ -54,6 +54,7 @@ size_t IPv6Address::printTo(Print &p) const {
|
||||
|
||||
}
|
||||
return n; */
|
||||
return 0;
|
||||
}
|
||||
|
||||
String IPv6Address::toString() const {
|
||||
|
||||
@@ -104,6 +104,7 @@ class UpdateClass {
|
||||
public:
|
||||
String md5String(void) {
|
||||
// return _md5.toString();
|
||||
return "";
|
||||
}
|
||||
|
||||
void md5(uint8_t *result) {
|
||||
|
||||
@@ -61,6 +61,7 @@ bool LwIPServer::begin(uint16_t port, bool reuseAddr) {
|
||||
_active = true;
|
||||
_noDelay = false;
|
||||
_sockAccepted = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LwIPServer::end() {
|
||||
|
||||
@@ -183,6 +183,7 @@ bool LibreTuya::otaSwitch(bool force) {
|
||||
bool LibreTuya::wdtEnable(uint32_t timeout) {
|
||||
watchdog_init(timeout);
|
||||
watchdog_start();
|
||||
return true;
|
||||
}
|
||||
|
||||
void LibreTuya::wdtDisable() {
|
||||
|
||||
@@ -179,7 +179,7 @@ void handleRtwEvent(uint16_t event, char *data, int len, int flags) {
|
||||
if (len != 124)
|
||||
return;
|
||||
eventId = ARDUINO_EVENT_WIFI_AP_STACONNECTED;
|
||||
memcpy(eventInfo.wifi_ap_staconnected.mac, (const char *)data[10], 6);
|
||||
memcpy(eventInfo.wifi_ap_staconnected.mac, (const char *)data + 10, 6);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_DISASSOC:
|
||||
|
||||
@@ -35,7 +35,7 @@ extern rtw_wifi_setting_t wifi_setting;
|
||||
extern unsigned char sta_password[65];
|
||||
extern unsigned char ap_password[65];
|
||||
extern void reset_wifi_struct(void);
|
||||
extern rtw_mode_t wifi_mode;
|
||||
extern wifi_mode_t wifi_mode;
|
||||
extern WiFiAuthMode securityTypeToAuthMode(uint8_t type);
|
||||
// WiFiEvents.cpp
|
||||
extern void startWifiTask();
|
||||
|
||||
@@ -103,6 +103,7 @@ bool TwoWire::end() {
|
||||
i2c_reset(_i2c);
|
||||
delete _i2c;
|
||||
_i2c = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TwoWire::setClock(uint32_t freq) {
|
||||
@@ -110,6 +111,7 @@ bool TwoWire::setClock(uint32_t freq) {
|
||||
i2c_frequency(_i2c, freq);
|
||||
}
|
||||
_freq = freq;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TwoWire::beginTransmission(uint8_t address) {
|
||||
|
||||
@@ -106,53 +106,3 @@ void analogWrite(pin_size_t pinNumber, int value) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _tone_argument {
|
||||
uint32_t ulPin;
|
||||
uint32_t timer_id;
|
||||
};
|
||||
|
||||
void _tone_timer_handler(const void *argument) {
|
||||
struct _tone_argument *arg = (struct _tone_argument *)argument;
|
||||
|
||||
uint32_t ulPin = (uint32_t)argument;
|
||||
|
||||
noTone(arg->ulPin);
|
||||
|
||||
os_timer_delete(arg->timer_id);
|
||||
|
||||
free((struct _tone_argument *)arg);
|
||||
}
|
||||
|
||||
void _tone(uint32_t ulPin, unsigned int frequency, unsigned long duration) {
|
||||
pwmout_t *obj;
|
||||
|
||||
if ((pinTable[ulPin].supported & PIN_PWM) != PIN_PWM) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pinTable[ulPin].enabled != PIN_PWM) {
|
||||
if ((pinTable[ulPin].enabled == PIN_GPIO) || (pinTable[ulPin].enabled == PIN_IRQ)) {
|
||||
pinRemoveMode(ulPin);
|
||||
}
|
||||
gpio_pin_struct[ulPin] = malloc(sizeof(pwmout_t));
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[ulPin];
|
||||
pwmout_init(obj, pinTable[ulPin].gpio);
|
||||
pwmout_period(obj, 1.0 / frequency);
|
||||
pwmout_pulsewidth(obj, 1.0 / (frequency * 2));
|
||||
pinTable[ulPin].enabled = PIN_PWM;
|
||||
|
||||
} else {
|
||||
// There is already a PWM configured
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[ulPin];
|
||||
pwmout_period(obj, 1.0 / frequency);
|
||||
pwmout_pulsewidth(obj, 1.0 / (frequency * 2));
|
||||
}
|
||||
|
||||
if (duration > 0) {
|
||||
struct _tone_argument *arg = (struct _tone_argument *)malloc(sizeof(struct _tone_argument));
|
||||
arg->ulPin = ulPin;
|
||||
arg->timer_id = os_timer_create(_tone_timer_handler, 0, arg);
|
||||
os_timer_start(arg->timer_id, duration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ void pinRemoveMode(pin_size_t pinNumber) {
|
||||
}
|
||||
if (pinEnabled(pin, PIN_GPIO)) {
|
||||
gpio_t *obj = (gpio_t *)gpio_pin_struct[pinNumber];
|
||||
gpio_deinit(obj, pin->gpio);
|
||||
gpio_deinit(obj);
|
||||
free(obj);
|
||||
}
|
||||
if (pinEnabled(pin, PIN_IRQ)) {
|
||||
@@ -107,9 +107,9 @@ void digitalWrite(pin_size_t pinNumber, PinStatus status) {
|
||||
PinStatus digitalRead(pin_size_t pinNumber) {
|
||||
PinInfo *pin = pinInfo(pinNumber);
|
||||
if (!pin)
|
||||
return;
|
||||
return LOW;
|
||||
if (pin->enabled != PIN_GPIO)
|
||||
return;
|
||||
return LOW;
|
||||
|
||||
gpio_t *gpio = (gpio_t *)gpio_pin_struct[pinNumber];
|
||||
return gpio_read(gpio);
|
||||
|
||||
@@ -18,7 +18,7 @@ static void gpioIrqHandler(uint32_t id, gpio_irq_event event) {
|
||||
}
|
||||
|
||||
void attachInterrupt(pin_size_t interruptNumber, voidFuncPtr callback, PinStatus mode) {
|
||||
attachInterruptParam(interruptNumber, callback, mode, NULL);
|
||||
attachInterruptParam(interruptNumber, (voidFuncPtrParam)callback, mode, NULL);
|
||||
}
|
||||
|
||||
void attachInterruptParam(pin_size_t interruptNumber, voidFuncPtrParam callback, PinStatus mode, void *param) {
|
||||
|
||||
@@ -36,11 +36,13 @@ extern "C" {
|
||||
#include <rtl8710c.h>
|
||||
#endif
|
||||
|
||||
#include <gpio_api.h>
|
||||
#undef MBED_GPIO_API_H // ..no comment
|
||||
#include <gpio_ex_api.h>
|
||||
|
||||
#include <analogin_api.h>
|
||||
#include <analogout_api.h>
|
||||
#include <flash_api.h>
|
||||
#include <gpio_api.h>
|
||||
#include <gpio_ex_api.h>
|
||||
#include <gpio_irq_api.h>
|
||||
#include <gpio_irq_ex_api.h>
|
||||
#include <i2c_api.h>
|
||||
|
||||
@@ -8,4 +8,5 @@ __attribute__((weak)) uint32_t __get_IPSR()
|
||||
{
|
||||
uint32_t result;
|
||||
asm volatile ("MRS %0, ipsr" : "=r" (result) );
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user