Optimization flags for all NRF52 targets to reduce code size (#8854)

* changes of variants/nrf52840/nrf52.ini and variants/nrf52840/rak4631/platformio.ini

* try for nrf52 size reduction, faketec exclude unused radios and meshlink refactor

* can't exclude LR11X0 as in schematic there's option for LR1121

* remove -Map flag and -Wl

* removed spaces causing error

---------

Co-authored-by: macvenez <macvenez@gmail.com>
This commit is contained in:
Donato
2025-12-04 22:32:42 +01:00
committed by GitHub
parent aa85fbbcc4
commit 2f4eb25b2f
7 changed files with 40 additions and 220 deletions

View File

@@ -5,6 +5,8 @@ board = promicro-nrf52840
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/diy/nrf52_promicro_diy_tcxo
-D NRF52_PROMICRO_DIY
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/diy/nrf52_promicro_diy_tcxo>
lib_deps =
${nrf52840_base.lib_deps}
@@ -20,6 +22,8 @@ build_flags =
${inkhud.build_flags}
-I variants/nrf52840/diy/nrf52_promicro_diy_tcxo
-D NRF52_PROMICRO_DIY
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
build_src_filter =
${nrf52_base.build_src_filter}
${inkhud.build_src_filter}

View File

@@ -9,6 +9,30 @@ board_level = extra
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/meshlink
-D MESHLINK
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
-DRADIOLIB_EXCLUDE_LR11X0=1
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/meshlink>
lib_deps =
${nrf52840_base.lib_deps}
debug_tool = jlink
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
; Note: as of 6/2013 the serial/bootloader based programming takes approximately 30 seconds
;upload_protocol = jlink
[env:meshlink_eink]
extends = nrf52840_base
board = meshlink
board_level = extra
;board_check = true
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/meshlink
-D MESHLINK
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
-DRADIOLIB_EXCLUDE_LR11X0=1
-D USE_EINK
-D EINK_DISPLAY_MODEL=GxEPD2_213_B74
-D EINK_WIDTH=250
-D EINK_HEIGHT=122

View File

@@ -1,31 +0,0 @@
; MeshLink board developed by LoraItalia. NRF52840, eByte E22900M22S (Will also come with other frequencies), 25w MPPT solar charger (5v,12v,18v selectable), support for gps, buzzer, oled or e-ink display, 10 gpios, hardware watchdog
; https://www.loraitalia.it
; firmware for boards with a 250x122 e-ink display
[env:meshlink_eink]
extends = nrf52840_base
board = meshlink
board_level = extra
;board_check = true
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/meshlink_eink
-D MESHLINK
-D EINK_DISPLAY_MODEL=GxEPD2_213_B74
-D EINK_WIDTH=250
-D EINK_HEIGHT=122
-D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk
-D EINK_LIMIT_FASTREFRESH=5 ; How many consecutive fast-refreshes are permitted
-D EINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates
-D EINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates
-D EINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated
-D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached.
-D EINK_HASQUIRK_VICIOUSFASTREFRESH ; Identify that pixels drawn by fast-refresh are harder to clear
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/meshlink_eink>
lib_deps =
${nrf52840_base.lib_deps}
https://github.com/meshtastic/GxEPD2/archive/55f618961db45a23eff0233546430f1e5a80f63a.zip
debug_tool = jlink
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
; Note: as of 6/2013 the serial/bootloader based programming takes approximately 30 seconds
;upload_protocol = jlink

View File

@@ -1,23 +0,0 @@
#include "variant.h"
#include "nrf.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[] = {
// P0
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
// P1
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
void initVariant()
{
pinMode(PIN_LED1, OUTPUT);
digitalWrite(PIN_LED1, HIGH); // turn off the white led while booting
// otherwise it will stay lit for several seconds (could be annoying)
#ifdef PIN_WD_EN
pinMode(PIN_WD_EN, OUTPUT);
digitalWrite(PIN_WD_EN, HIGH); // Enable the Watchdog at boot
#endif
}

View File

@@ -1,153 +0,0 @@
#ifndef _VARIANT_MESHLINK_
#define _VARIANT_MESHLINK_
#ifndef MESHLINK
#define MESHLINK
#endif
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
// #define USE_LFXO // Board uses 32khz crystal for LF
#define USE_LFRC // Board uses RC for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (2)
#define NUM_ANALOG_OUTPUTS (0)
#define BUTTON_PIN (-1) // If defined, this will be used for user button presses,
#define BUTTON_NEED_PULLUP
// LEDs
#define PIN_LED1 (24) // Built in white led for status
#define LED_BLUE PIN_LED1
#define LED_BUILTIN PIN_LED1
#define LED_STATE_ON 0 // State when LED is litted
#define LED_INVERTED 1
// Testing USB detection
// #define NRF_APM
/*
* Analog pins
*/
#define PIN_A1 (3) // P0.03/AIN1
#define ADC_RESOLUTION 14
// Other pins
// #define PIN_AREF (2)
// static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
#define PIN_SERIAL1_RX (32 + 8)
#define PIN_SERIAL1_TX (7)
/*
* SPI Interfaces
*/
#define SPI_INTERFACES_COUNT 2
#define PIN_SPI_MISO (8)
#define PIN_SPI_MOSI (32 + 9)
#define PIN_SPI_SCK (11)
#define PIN_SPI1_MISO (23)
#define PIN_SPI1_MOSI (21)
#define PIN_SPI1_SCK (19)
static const uint8_t SS = 12;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
/*
* eink display pins
*/
#define USE_EINK
#define PIN_EINK_CS (15)
#define PIN_EINK_BUSY (16)
#define PIN_EINK_DC (14)
#define PIN_EINK_RES (17)
#define PIN_EINK_SCLK (19)
#define PIN_EINK_MOSI (21) // also called SDI
/*
* Wire Interfaces
*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (1)
#define PIN_WIRE_SCL (27)
// QSPI Pins
#define PIN_QSPI_SCK 19
#define PIN_QSPI_CS 22
#define PIN_QSPI_IO0 21
#define PIN_QSPI_IO1 23
#define PIN_QSPI_IO2 32
#define PIN_QSPI_IO3 20
// On-board QSPI Flash
#define EXTERNAL_FLASH_DEVICES W25Q16JVUXIQ
#define EXTERNAL_FLASH_USE_QSPI
#define USE_SX1262
#define SX126X_CS (12)
#define SX126X_DIO1 (32 + 1)
#define SX126X_BUSY (32 + 3)
#define SX126X_RESET (6)
// #define SX126X_RXEN (13)
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// pin 25 is used to enable or disable the watchdog. This pin has to be disabled when cpu is put to sleep
// otherwise the timer will expire and wd will reboot the cpu
#define PIN_WD_EN (25)
#define PIN_GPS_PPS (26) // Pulse per second input from the GPS
#define GPS_TX_PIN PIN_SERIAL1_TX // This is for bits going TOWARDS the CPU
#define GPS_RX_PIN PIN_SERIAL1_RX // This is for bits going TOWARDS the GPS
// #define GPS_THREAD_INTERVAL 50
// Define pin to enable GPS toggle (set GPIO to LOW) via user button triple press
#define PIN_GPS_EN (0)
#define GPS_EN_ACTIVE LOW
#define PIN_BUZZER (31) // P0.31/AIN7
// Battery
// The battery sense is hooked to pin A0 (2)
#define BATTERY_PIN (2)
// and has 12 bit resolution
#define BATTERY_SENSE_RESOLUTION_BITS 12
#define BATTERY_SENSE_RESOLUTION 4096.0
#undef AREF_VOLTAGE
#define AREF_VOLTAGE 3.0
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
#define ADC_MULTIPLIER 1.42 // fine tuning of voltage
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
#endif

View File

@@ -11,7 +11,7 @@ platform_packages =
; Don't renovate toolchain-gccarmnoneeabi
platformio/toolchain-gccarmnoneeabi@~1.90301.0
build_type = debug
build_type = release
build_flags =
-include variants/nrf52840/cpp_overrides/lfs_util.h
${arduino_base.build_flags}
@@ -21,6 +21,17 @@ build_flags =
-DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818
-DMESHTASTIC_EXCLUDE_AUDIO=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
-Os
build_unflags =
-Ofast
-Og
-ggdb3
-ggdb2
-g3
-g2
-g
-g1
-g0
build_src_filter =
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/api/> -<mesh/http/> -<modules/esp32> -<platform/rp2xx0> -<mesh/eth/> -<mesh/raspihttp> -<serialization/>

View File

@@ -12,18 +12,6 @@ build_flags = ${nrf52840_base.build_flags}
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
-DRADIOLIB_EXCLUDE_LR11X0=1
-Os
-Wl,-Map=$BUILD_DIR/output.map
build_unflags =
-Ofast
-Og
-ggdb3
-ggdb2
-g3
-g2
-g
-g1
-g0
build_src_filter = ${nrf52_base.build_src_filter} \
+<../variants/nrf52840/rak4631> \
+<mesh/eth/> \