Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gen3] reduce flash usage #2705

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hal/inc/hal_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
#define HAL_PLATFORM_NCP_UPDATABLE (0)
#endif /* HAL_PLATFORM_NCP_UPDATABLE */

#ifndef HAL_PLATFORM_NCP_UPDATES_DISABLED
#define HAL_PLATFORM_NCP_UPDATES_DISABLED (0)
#endif /* HAL_PLATFORM_NCP_UPDATES_DISABLED */

#ifndef HAL_PLATFORM_MCU_ANY
#define HAL_PLATFORM_MCU_ANY (0xFF)
#endif // HAL_PLATFORM_MCU_ANY
Expand Down
4 changes: 4 additions & 0 deletions hal/network/ncp/wifi/platform_ncp_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ int getWifiNcpFirmwareVersion(uint16_t* ncpVersion) {
} // anonymous

int platform_ncp_update_module(const hal_module_t* module) {
#if !HAL_PLATFORM_NCP_UPDATES_DISABLED
const auto ncpClient = particle::wifiNetworkManager()->ncpClient();
SPARK_ASSERT(ncpClient);
OtaUpdateSourceStream::ReadStreamFunc readCallback;
Expand Down Expand Up @@ -156,6 +157,9 @@ int platform_ncp_update_module(const hal_module_t* module) {
LOG(INFO, "ESP32 firmware version updated to version %d", version);
}
return HAL_UPDATE_APPLIED;
#else
return SYSTEM_ERROR_NOT_SUPPORTED;
#endif // !HAL_PLATFORM_NCP_UPDATES_DISABLED
}

int platform_ncp_fetch_module_info(hal_module_t* module) {
Expand Down
4 changes: 4 additions & 0 deletions hal/network/ncp_client/esp32/esp32_ncp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ int Esp32NcpClient::getFirmwareModuleVersionImpl(uint16_t* ver) {
}

int Esp32NcpClient::updateFirmware(InputStream* file, size_t size) {
#if !HAL_PLATFORM_NCP_UPDATES_DISABLED
const NcpClientLock lock(this);
CHECK(checkParser());
auto resp = parser_.sendCommand("AT+FWUPD=%u", (unsigned)size);
Expand Down Expand Up @@ -351,6 +352,9 @@ int Esp32NcpClient::updateFirmware(InputStream* file, size_t size) {
off();
CHECK(on());
return 0;
#else
return SYSTEM_ERROR_NOT_SUPPORTED;
#endif // !HAL_PLATFORM_NCP_UPDATES_DISABLED
}

void Esp32NcpClient::processEvents() {
Expand Down
4 changes: 4 additions & 0 deletions hal/network/ncp_client/sara/sara_ncp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,11 @@ int SaraNcpClient::configureApn(const CellularNetworkConfig& conf) {
CHECK_PARSER_OK(setModuleFunctionality(CellularFunctionality::AIRPLANE));
auto resp = parser_.sendCommand("AT+CGDCONT=%d,\"%s\",\"%s%s\"",
UBLOX_DEFAULT_CID, UBLOX_DEFAULT_PDP_TYPE,
#if CHAP_SUPPORT
(netConf_.hasUser() && netConf_.hasPassword()) ? "CHAP:" : "",
#else
"",
#endif // CHAP_SUPPORT
netConf_.hasApn() ? netConf_.apn() : "");
const int r = CHECK_PARSER(resp.readResult());
CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_AT_NOT_OK);
Expand Down
2 changes: 1 addition & 1 deletion hal/src/nRF52840/hal_platform_nrf52840_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
#define HAL_PLATFORM_RESUMABLE_OTA (1)

#ifndef HAL_PLATFORM_ERROR_MESSAGES
#define HAL_PLATFORM_ERROR_MESSAGES (1)
#define HAL_PLATFORM_ERROR_MESSAGES (0)
#endif // HAL_PLATFORM_ERROR_MESSAGES

#define HAL_PLATFORM_PROHIBIT_XIP (1)
Expand Down
12 changes: 6 additions & 6 deletions hal/src/nRF52840/lwip/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ void sys_unlock_tcpip_core(void);
* this option does not affect outgoing packet sizes, which can be controlled
* via IP_FRAG.
*/
#define IP_REASSEMBLY 1
#define IP_REASSEMBLY (PLATFORM_ID != PLATFORM_TRACKER)

/**
* IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
* that this option does not affect incoming packet sizes, which can be
* controlled via IP_REASSEMBLY.
*/
#define IP_FRAG 1
#define IP_FRAG (PLATFORM_ID != PLATFORM_TRACKER)

/**
* IP_OPTIONS_ALLOWED: Defines the behavior for IP options.
Expand Down Expand Up @@ -1635,11 +1635,11 @@ void sys_unlock_tcpip_core(void);
/**
* LWIP_IPV6==1: Enable IPv6
*/
#if PLATFORM_ID != PLATFORM_TRACKER
#define LWIP_IPV6 1
#else
// #if PLATFORM_ID != PLATFORM_TRACKER
// #define LWIP_IPV6 1
// #else
#define LWIP_IPV6_DEFINES_ONLY 1
#endif // PLATFORM_ID != PLATFORM_TRACKER
// #endif // PLATFORM_ID != PLATFORM_TRACKER

/**
* IPV6_REASS_MAXAGE: Maximum time (in multiples of IP6_REASS_TMR_INTERVAL - so seconds, normally)
Expand Down
4 changes: 2 additions & 2 deletions hal/src/nRF52840/lwip/lwippppopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
/**
* CHAP_SUPPORT==1: Support CHAP.
*/
#define CHAP_SUPPORT (PLATFORM_ID != PLATFORM_TRACKER)
#define CHAP_SUPPORT 0

/**
* MSCHAP_SUPPORT==1: Support MSCHAP.
Expand Down Expand Up @@ -294,7 +294,7 @@
/**
* LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library
*/
#define LWIP_USE_EXTERNAL_MBEDTLS 0
#define LWIP_USE_EXTERNAL_MBEDTLS 1

/*
* PPP Timeouts
Expand Down
2 changes: 1 addition & 1 deletion hal/src/nRF52840/mbedtls/mbedtls_config_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@
*
* This module is required for SSL/TLS server support.
*/
#define MBEDTLS_SSL_SRV_C
//#define MBEDTLS_SSL_SRV_C

/**
* \def MBEDTLS_SSL_TLS_C
Expand Down
1 change: 1 addition & 0 deletions hal/src/tracker/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define HAL_PLATFORM_I2C_BUFFER_SIZE(x) (x == HAL_I2C_INTERFACE2 ? 512 : HAL_PLATFORM_I2C_BUFFER_SIZE_DEFAULT)
#define HAL_PLATFORM_USART_NUM (2)
#define HAL_PLATFORM_NCP_UPDATABLE (1)
#define HAL_PLATFORM_NCP_UPDATES_DISABLED (1)
#define HAL_PLATFORM_ESP32_NCP (1)

#define HAL_PLATFORM_PMIC_BQ24195 (1)
Expand Down
3 changes: 3 additions & 0 deletions modules/shared/nRF52840/part1_build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ endif

LDFLAGS += -u uxTopUsedPriority -Wl,--wrap=InitSwHash512 -Wl,--wrap=ProcessSwHash512 -Wl,--wrap=FinishSwHash512

# Disable float support in wiring Print
GLOBAL_DEFINES += PARTICLE_WIRING_PRINT_NO_FLOAT

INCLUDE_DIRS += $(SHARED_MODULAR)/inc/system-part1
SYSTEM_PART1_MODULE_SRC_PATH = $(SYSTEM_PART1_MODULE_PATH)/src

Expand Down
8 changes: 6 additions & 2 deletions modules/shared/system_module_version.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ endif
else
# There is no need to carry SoftDevice dependency on Tracker, since they are manufactured
# with the latest one. Update NCP firmware instead.
ESP32_NCP_DEPENDENCY = 7
SYSTEM_PART1_MODULE_DEPENDENCY2 ?= ${MODULE_FUNCTION_NCP_FIRMWARE},0,${ESP32_NCP_DEPENDENCY}

# Since 5.6.0 NCP updates are disabled. Device should be above 3.0.0-alpha.2 (3001)
# to already have latest ESP32 NCP firmware.
# ESP32_NCP_DEPENDENCY = 7
# SYSTEM_PART1_MODULE_DEPENDENCY2 ?= ${MODULE_FUNCTION_NCP_FIRMWARE},0,${ESP32_NCP_DEPENDENCY}
SYSTEM_PART1_MODULE_DEPENDENCY2 ?= ${MODULE_FUNCTION_SYSTEM_PART},1,3001
endif
endif
endif # ($(PLATFORM_MCU),nRF52840)
Expand Down
2 changes: 1 addition & 1 deletion third_party/lwip/lwip
Submodule lwip updated 1 files
+16 −0 src/api/sockets.c
7 changes: 7 additions & 0 deletions wiring/inc/spark_wiring_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class Print

size_t printNumber(unsigned long, uint8_t);
size_t printNumber(unsigned long long, uint8_t);
#ifndef PARTICLE_WIRING_PRINT_NO_FLOAT
size_t printFloat(double, uint8_t);
#endif // PARTICLE_WIRING_PRINT_NO_FLOAT
protected:
void setWriteError(int err = 1) { write_error = err; }

Expand All @@ -82,8 +84,11 @@ class Print
template <typename T, std::enable_if_t<!std::is_base_of<Printable, T>::value && (std::is_integral<T>::value || std::is_convertible<T, unsigned long long>::value ||
std::is_convertible<T, long long>::value), int> = 0>
size_t print(T, int = DEC);
#ifndef PARTICLE_WIRING_PRINT_NO_FLOAT
size_t print(float, int = 2);
size_t print(double, int = 2);
#endif // PARTICLE_WIRING_PRINT_NO_FLOAT

size_t print(const Printable&);
size_t print(const __FlashStringHelper*);

Expand All @@ -96,8 +101,10 @@ class Print
n += println();
return n;
}
#ifndef PARTICLE_WIRING_PRINT_NO_FLOAT
size_t println(float, int = 2);
size_t println(double, int = 2);
#endif // PARTICLE_WIRING_PRINT_NO_FLOAT
size_t println(const Printable&);
size_t println(void);
size_t println(const __FlashStringHelper*);
Expand Down
6 changes: 6 additions & 0 deletions wiring/src/spark_wiring_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ size_t Print::print(char c)
return write(c);
}

#ifndef PARTICLE_WIRING_PRINT_NO_FLOAT
size_t Print::print(float n, int digits)
{
return printFloat((double)n, digits);
Expand All @@ -69,6 +70,7 @@ size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
#endif // PARTICLE_WIRING_PRINT_NO_FLOAT

size_t Print::print(const Printable& x)
{
Expand Down Expand Up @@ -101,6 +103,7 @@ size_t Print::println(char c)
return n;
}

#ifndef PARTICLE_WIRING_PRINT_NO_FLOAT
size_t Print::println(float num, int digits)
{
return println((double)num, digits);
Expand All @@ -112,6 +115,7 @@ size_t Print::println(double num, int digits)
n += println();
return n;
}
#endif // PARTICLE_WIRING_PRINT_NO_FLOAT

size_t Print::println(const Printable& x)
{
Expand Down Expand Up @@ -166,6 +170,7 @@ size_t Print::printNumber(unsigned long n, uint8_t base) {
return write(str);
}

#ifndef PARTICLE_WIRING_PRINT_NO_FLOAT
size_t Print::printFloat(double number, uint8_t digits)
{
size_t n = 0;
Expand Down Expand Up @@ -210,6 +215,7 @@ size_t Print::printFloat(double number, uint8_t digits)

return n;
}
#endif // PARTICLE_WIRING_PRINT_NO_FLOAT

size_t Print::vprintf(bool newline, const char* format, va_list args)
{
Expand Down