Skip to content

Commit

Permalink
Tweaks to ensure the build still fits on these devices
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Sep 20, 2024
1 parent a6ae7ff commit 831a568
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
25 changes: 14 additions & 11 deletions README_BuildProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ These contain:

This is a partial list of definitions that can be added in a `BOARD.py` file's `info.build.makefile` array, eg: `'DEFINES+=-DBLUETOOTH_NAME_PREFIX=\'"Puck.js"\''`

* `SAVE_ON_FLASH` - Remove some features (like any ES6 support) to target devices with ~128kB Flash
* `SAVE_ON_FLASH_EXTREME` - Pull out as many features as possible to target devices with ~128kB Flash that also want things like Filesystem support
* `ESPR_PACKED_SYMPTR` - Packs string offsets of builtin symbols into their function pointers in JswSymPtr, saves 2 bytes per symbol
* `BLUETOOTH_NAME_PREFIX="..."` - NRF52 only: Make the Bluetooth LE device's name `BLUETOOTH_NAME_PREFIX` followed by the last 2 bytes of the MAC address.
* `BLUETOOTH_ADVERTISING_INTERVAL=375` - set the default Bluetooth advertising interval (default 375)
* `NFC_DEFAULT_URL="http://foo"` - If defined, set the advertised NFC URL to the one given, plus `?a=ble_address`. Only do it for a fresh boot - not when code has been saved.
Expand All @@ -123,14 +120,7 @@ This is a partial list of definitions that can be added in a `BOARD.py` file's `
* `JSMODULESOURCES+=libs/.../foo.min.js` - include the given JS file as a module that can be used via `require("foo")`
* `JSVAR_MALLOC` - Allocate space for variables at jsvInit time, rather than statically
* `JSVAR_FORCE_16_BYTE` - Force 16 byte JsVars (rather than packing bits to get JsVar size down to the minimum possible)
* `JSVAR_FORCE_NO_INLINE` - Opposite of `JSVAR_FORCE_INLINE`. Force getter/setter functions not to be inlined. Saves ~2% code size. Ideally just leave it up to the compiler
* `JSVAR_FORCE_INLINE` - Opposite of `JSVAR_FORCE_NO_INLINE`. Force getter/setter functions to be inlined. 2% faster but ~10% extra code size.
* `NO_VECTOR_FONT=1` - don't compile in the vector font (this is usually only done for SAVE_ON_FLASH)
* `NO_DUMP_HARDWARE_INITIALISATION=1` - don't create lines like `digitalWrite(D1,1)` for `dump()/save()` to recreate hardware state
* `USE_FONT_6X8=1` - Also include in a 6x8 fixed width bitmap font
* `USE_TAB_COMPLETE=0` - Don't include tab completion (default is yes unless SAVE_ON_FLASH is defined)
* `USE_DEBUGGER=0` - Don't include the debugger (default is yes unless SAVE_ON_FLASH is defined)
* `USE_NETWORK_JS=0` - Don't include JS networking lib used for handling AT commands (default is yes if networking is enabled)
* `ESPR_DCDC_ENABLE=1` - On NRF52 use the built-in DCDC converter (requires external hardware)
* `ESPR_DCDC_HV_ENABLE=1` - On NRF52840 use the built-in high-voltage (REG0) DCDC converter (requires external hardware)
* `ESPR_REGOUT0_1_8V=1` - On NRF52830/40 set the REG0 VCC voltage to 1.8v (the default is 3.3v)
Expand All @@ -145,10 +135,23 @@ This is a partial list of definitions that can be added in a `BOARD.py` file's `
* `ESPR_JSVAR_FLASH_BUFFER_SIZE=32` - The buffer size in bytes we use when executing/iterating over data in external flash memory (default 16). Should be set based on benchmarks.
* `ESPR_PBF_FONTS` - Enable support for loading and displaying Pebble-style PBF font files with `g.setFontPBF`
* `ESPR_BLUETOOTH_ANCS` - Enable Apple ANCS(notification), AMS and CTS support
* `ESPR_USE_STEPPER_TIMER` - add builtin `Stepper` class to handle higher speed stepper handling

There are some specifically that are useful for cutting a few bytes out of the build:

* `SAVE_ON_FLASH` - Remove some features (like any ES6 support) to target devices with ~128kB Flash
* `SAVE_ON_FLASH_EXTREME` - Pull out as many features as possible to target devices with ~128kB Flash that also want things like Filesystem support
* `ESPR_PACKED_SYMPTR` - Packs string offsets of builtin symbols into their function pointers in JswSymPtr, saves 2 bytes per symbol
* `JSVAR_FORCE_NO_INLINE` - Opposite of `JSVAR_FORCE_INLINE`. Force getter/setter functions not to be inlined. Saves ~2% code size. Ideally just leave it up to the compiler
* `JSVAR_FORCE_INLINE` - Opposite of `JSVAR_FORCE_NO_INLINE`. Force getter/setter functions to be inlined. 2% faster but ~10% extra code size.
* `NO_VECTOR_FONT=1` - don't compile in the vector font (this is usually only done for SAVE_ON_FLASH)
* `NO_DUMP_HARDWARE_INITIALISATION=1` - don't create lines like `digitalWrite(D1,1)` for `dump()/save()` to recreate hardware state
* `USE_TAB_COMPLETE=0` - Don't include tab completion (default is yes unless SAVE_ON_FLASH is defined)
* `USE_DEBUGGER=0` - Don't include the debugger (default is yes unless SAVE_ON_FLASH is defined)
* `USE_NETWORK_JS=0` - Don't include JS networking lib used for handling AT commands (default is yes if networking is enabled)
* `ESPR_NO_SOFTWARE_SERIAL` - don't build in software serial support
* `ESPR_NO_SOFTWARE_I2C` - don't build in software I2C support
* `ESPR_NO_BLUETOOTH_MESSAGES` - don't include text versions of Bluetooth error messages (just the error number)
* `ESPR_USE_STEPPER_TIMER` - add builtin `Stepper` class to handle higher speed stepper handling
* `ESPR_LIMIT_DATE_RANGE` - limits the acceptable range for Date years (saves a few hundred bytes)

These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)
Expand Down
1 change: 1 addition & 0 deletions boards/PICO_R1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'DEFINES+=-DPIN_NAMES_DIRECT=1', # Package skips out some pins, so we can't assume each port starts from 0
'DEFINES += -DESPR_USE_STEPPER_TIMER=1', # Build in the code for stepping using the timer
'DEFINES += -DESPR_LIMIT_DATE_RANGE', # not enough code memory left for the full range of Date()
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol
'STLIB=STM32F401xE',
'PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f4/lib/startup_stm32f401xx.o'
]
Expand Down
3 changes: 3 additions & 0 deletions boards/PIXLJS.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
'DEFINES+=-DSAVE_ON_FLASH_MATH',
'DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_private_key.pem',
'DFU_SETTINGS=--application-version 0xff --hw-version 52 --sd-req 0x8C,0x91',
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol
'DEFINES+=-DESPR_LIMIT_DATE_RANGE', # limits the acceptable range for Date years (saves a few hundred bytes)
'DEFINES+=-DESPR_NO_BLUETOOTH_MESSAGES', # don't include text versions of Bluetooth error messages (just the error number)
'INCLUDE += -I$(ROOT)/libs/pixljs',
'WRAPPERSOURCES += libs/pixljs/jswrap_pixljs.c',
'JSMODULESOURCES += libs/js/graphical_menu.min.js'
Expand Down

0 comments on commit 831a568

Please sign in to comment.