Skip to content

Commit

Permalink
Change ioBuffer FIFO from 4 byte blocks to variable length blocks. Fa…
Browse files Browse the repository at this point in the history
…r more efficient for USB/BLE/other block data
  • Loading branch information
gfwilliams committed Feb 26, 2025
1 parent aa3ce23 commit b84efec
Show file tree
Hide file tree
Showing 38 changed files with 385 additions and 405 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Pipboy: allow audio files to be played at the same time as (silent) video. add audioStopped/videoStopped events and audioStop method
Pipboy: Pip.audioStartVar(wav,{overlap:true}) can now play sounds over the top of other sounds. audioRead now doesn't stop audio playback
STM32: Ensure proper distribution of analogRead values (now `0<=analogRead()<1` as on other boards) and add docs (fix #2612)
Change ioBuffer FIFO from 4 byte blocks to variable length blocks. Far more efficient for USB/BLE/other block data

2v25 : ESP32C3: Get analogRead working correctly
Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535)
Expand Down
2 changes: 1 addition & 1 deletion boards/BANGLEJS2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# 'default_console_baudrate' : "9600",
'variables' : 12000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
# Currently leaves around 38k of free stack - *loads* more than we need
'io_buffer_size' : 512, # How big is the input buffer (in 4 byte words). Default on nRF52 is 256
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'bootloader' : 1,
'binary_name' : 'espruino_%v_banglejs2.hex',
'build' : {
Expand Down
2 changes: 1 addition & 1 deletion boards/BANGLEJS2_IFLASH.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# 'default_console_baudrate' : "9600",
'variables' : 12000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
# Currently leaves around 38k of free stack - *loads* more than we need
'io_buffer_size' : 512, # How big is the input buffer (in 4 byte words). Default on nRF52 is 256
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'bootloader' : 1,
'binary_name' : 'espruino_%v_banglejs2_iflash.hex',
'build' : {
Expand Down
24 changes: 12 additions & 12 deletions boards/BANGLEJS2_NOFLASH.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
info = {
'name' : "Bangle.js 2 (No external flash)", # Using SMA Q3
# A build for Bangle.js 2 that uses only internal flash
'boardname' : "BANGLEJS2",
'boardname' : "BANGLEJS2",
'link' : [ "https://espruino.com/Bangle.js2" ],
'espruino_page_link' : 'Bangle.js2',
'default_console' : "EV_TERMINAL",
Expand All @@ -28,7 +28,7 @@
# 'default_console_baudrate' : "9600",
'variables' : 12000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
# Currently leaves around 38k of free stack - *loads* more than we need
'io_buffer_size' : 512, # How big is the input buffer (in 4 byte words). Default on nRF52 is 256
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'bootloader' : 1,
'binary_name' : 'espruino_%v_banglejs2_noflash.hex',
'build' : {
Expand All @@ -54,8 +54,8 @@
'DEFINES += -DESPR_DCDC_ENABLE=1', # Use DC/DC converter
'ESPR_BLUETOOTH_ANCS=1', # Enable ANCS (Apple notifications) support
'DEFINES += -DSPIFLASH_SLEEP_CMD', # SPI flash needs to be explicitly slept and woken up
'DEFINES += -DSPIFLASH_READ2X', # Read SPI flash at 2x speed using MISO and MOSI for IO
'DEFINES += -DESPR_JSVAR_FLASH_BUFFER_SIZE=32', # The buffer size we use when executing/iterating over data in flash memory (default 16). Should be set based on benchmarks.
'DEFINES += -DSPIFLASH_READ2X', # Read SPI flash at 2x speed using MISO and MOSI for IO
'DEFINES += -DESPR_JSVAR_FLASH_BUFFER_SIZE=32', # The buffer size we use when executing/iterating over data in flash memory (default 16). Should be set based on benchmarks.
'DEFINES += -DAPP_TIMER_OP_QUEUE_SIZE=6', # Bangle.js accelerometer poll handler needs something else in queue size
'DEFINES+=-DBLUETOOTH_NAME_PREFIX=\'"Bangle.js"\'',
'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
Expand Down Expand Up @@ -124,7 +124,7 @@
'BTN1' : { 'pin' : 'D17', 'pinstate' : 'IN_PULLDOWN' }, # Pin negated in software
'LED1' : { 'pin' : 'D8', 'novariable':True }, # Backlight flash for low level debug - but in code we just use 'fake' LEDs
'LCD' : {
'width' : 176, 'height' : 176,
'width' : 176, 'height' : 176,
'bpp' : 3, # LCD is native 3 bit (fastest transfers), but 4 is faster for drawing and slow to transfer
'controller' : 'LPM013M126', # LPM013M126C
'pin_cs' : 'D5',
Expand All @@ -145,18 +145,18 @@
'GPS' : {
'device' : 'Casic URANUS',
'pin_en' : 'D29',
'pin_rx' : 'D30',
'pin_rx' : 'D30',
'pin_tx' : 'D31'
},
'BAT' : {
'pin_charging' : 'D23', # active low
'pin_voltage' : 'D3'
},
'HEARTRATE' : {
'device' : 'VC31', 'addr' : 0x33,
'pin_sda' : 'D24',
'pin_scl' : 'D32',
'pin_en' : 'D21',
'device' : 'VC31', 'addr' : 0x33,
'pin_sda' : 'D24',
'pin_scl' : 'D32',
'pin_en' : 'D21',
'pin_int' : 'D22'
},
'ACCEL' : {
Expand All @@ -165,7 +165,7 @@
'pin_scl' : 'D37'
},
'MAG' : { # Magnetometer/compass
'device' : 'UNKNOWN_0C',
'device' : 'UNKNOWN_0C',
'addr' : 0x0C,
'pin_sda' : 'D44',
'pin_scl' : 'D45'
Expand All @@ -174,7 +174,7 @@
'device' : 'BMP280', # v2.1 uses Goertek SPL06-001 - we handle both
'addr' : 0x76, # both versions use the same address
'pin_sda' : 'D47',
'pin_scl' : 'D2'
'pin_scl' : 'D2'
},
'SPIFLASH' : {
'pin_cs' : 'D14',
Expand Down
10 changes: 5 additions & 5 deletions boards/CURIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
'default_console' : "EV_SERIAL1",
'default_console_baudrate' : "115200",
'variables' : 16383, # See note above
'io_buffer_size' : 1024, # How big is the input buffer (in 4 byte words). Default is 256, but this makes us less likely to drop data
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'binary_name' : 'espruino_%v_curio.bin',
'build' : {
'optimizeflags' : '-Og',
Expand Down Expand Up @@ -161,21 +161,21 @@ def get_pins():
# pinutils.findpin(pins, "PD5", True)["functions"]["ADC2_IN0"]=0;
# pinutils.findpin(pins, "PD8", True)["functions"]["NEGATED"]=0; # LED negated - but ESP32 port ignores negation
# D12-D17 are SPI (internal SPI) - not sure they should even be exposed??

pinutils.findpin(pins, "PD18", True)["functions"]["USB"]=0; # D-
pinutils.findpin(pins, "PD19", True)["functions"]["USB"]=0; # D+
pinutils.findpin(pins, "PD20", True)["functions"]["USART1_RX"]=0;
pinutils.findpin(pins, "PD21", True)["functions"]["USART1_TX"]=0;
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0; # added for issue #2589 fix
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0; # added for issue #2589 fix
# SPI added for issue #2601

# SPI added for issue #2601
# See esp-idf-4 /components/soc/esp32c3/include/soc/soc_caps.h
pinutils.findpin(pins, "PD6", True)["functions"]["SPI1_SCK"]=0;
pinutils.findpin(pins, "PD2", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD7", True)["functions"]["SPI1_MOSI"]=0;



# everything is non-5v tolerant
for pin in pins:
Expand Down
16 changes: 8 additions & 8 deletions boards/DICKENS.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
# o D14 VCC
# D15 D17
# D2 D19
# GND D18
#
# GND D18
#

# unfitted header (assuming same dir as Button flex header)
# VCC D10
Expand All @@ -61,7 +61,7 @@
'espruino_page_link' : '',
'default_console' : "EV_BLUETOOTH",
'variables' : 5000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
'io_buffer_size' : 512,
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'bootloader' : 1,
'binary_name' : 'espruino_%v_dickens.hex',
'build' : {
Expand Down Expand Up @@ -163,16 +163,16 @@
'pin_sck' : 'D12',
'pin_mosi' : 'D5',
'pin_miso' : 'D27',
'pin_en' : 'D43',
'pin_en' : 'D43',
'pin_bl' : 'D33', # Also enables the power supply for the vibration motor
'bitrate' : 32000000
},
'BAT' : {
'pin_charging' : 'D13',
'pin_charging' : 'D13',
'pin_voltage' : 'D4'
},
'MAG' : { # Magnetometer/compass
'device' : 'GMC303',
'device' : 'GMC303',
'addr' : 0x0C,
'pin_sda' : 'D9',
'pin_scl' : 'D10'
Expand All @@ -196,7 +196,7 @@
'pin_miso' : 'D23', # D1
'pin_wp' : 'D21', # D2
'pin_rst' : 'D24', # D3
'size' : 4096*1024,
'size' : 4096*1024,
'memmap_base' : 0x60000000 # map into the address space (in software)
}
};
Expand Down Expand Up @@ -224,7 +224,7 @@ def get_pins():
pinutils.findpin(pins, "PD46", True)["functions"]["NEGATED"]=0; # ok
pinutils.findpin(pins, "PD42", True)["functions"]["NEGATED"]=0; # ok
pinutils.findpin(pins, "PD28", True)["functions"]["NEGATED"]=0; # ok


# everything is non-5v tlerant
for pin in pins:
Expand Down
14 changes: 7 additions & 7 deletions boards/ESP32.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# A Note about the 'variables' parameter on ESP32 Builds
# ------------------------------------------------------
#
#
# For the ESP32 build, the number of JsVars is governed by two factors:
# * Available memory
# * Maximum number of JsVars for the used JsVar format
Expand Down Expand Up @@ -50,8 +50,8 @@
'espruino_page_link' : 'ESP32',
'default_console' : "EV_SERIAL1",
'default_console_baudrate' : "115200",
'variables' : 16383, # See note above
'io_buffer_size' : 1024, # How big is the input buffer (in 4 byte words). Default is 256, but this makes us less likely to drop data
'variables' : 16383, # See note above
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'binary_name' : 'espruino_%v_esp32.bin',
'build' : {
'optimizeflags' : '-Og',
Expand All @@ -65,7 +65,7 @@
'NEOPIXEL',
'FILESYSTEM',
'FLASHFS',
'BLUETOOTH'
'BLUETOOTH'
],
'makefile' : [
'DEFINES+=-DESP_PLATFORM -DESP32=1',
Expand Down Expand Up @@ -187,16 +187,16 @@ def get_pins():
pinutils.findpin(pins, "PD10", True)["functions"]["USART1_TX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD32", True)["functions"]["USART1_RX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD16", True)["functions"]["USART3_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;

pinutils.findpin(pins, "PD16", True)["functions"]["I2C2_SCL"]=1; # added for issue #2589 fix
pinutils.findpin(pins, "PD17", True)["functions"]["I2C2_SDA"]=1; # added for issue #2589 fix
pinutils.findpin(pins, "PD22", True)["functions"]["I2C1_SCL"]=0; # SCL moved from P21 for issue #2589
pinutils.findpin(pins, "PD21", True)["functions"]["I2C1_SDA"]=0; # SDA moved from P22 for issue #2589

# These SPI Pin defs used in jshSPISetup as of issue #2601
# see esp-idf-4 /components/soc/esp32/include/soc/spi_pins.h
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCK"]=0;
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCK"]=0;
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MOSI"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["SPI2_SCK"]=0;
Expand Down
20 changes: 10 additions & 10 deletions boards/ESP32C3_IDF4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# A Note about the 'variables' parameter on ESP32 Builds
# ------------------------------------------------------
#
#
# For the ESP32 build, the number of JsVars is governed by two factors:
# * Available memory
# * Maximum number of JsVars for the used JsVar format
Expand Down Expand Up @@ -52,8 +52,8 @@
'espruino_page_link' : 'ESP32',
'default_console' : "EV_SERIAL1",
'default_console_baudrate' : "115200",
'variables' : 16383, # See note above
'io_buffer_size' : 1024, # How big is the input buffer (in 4 byte words). Default is 256, but this makes us less likely to drop data
'variables' : 16383, # See note above
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'binary_name' : 'espruino_%v_esp32c3.bin',
'build' : {
'optimizeflags' : '-Og',
Expand All @@ -67,14 +67,14 @@
# 'FILESYSTEM',
# 'FLASHFS',
'BLUETOOTH',
'NEOPIXEL'
'NEOPIXEL'
],
'makefile' : [
'DEFINES+=-DESP_PLATFORM -DESP32=1',
'DEFINES+=-DESP_STACK_SIZE=25000',
'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time
'DEFINES+=-DUSE_FONT_6X8',
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
'ESP32_FLASH_MAX=1572864'
]
}
Expand Down Expand Up @@ -153,25 +153,25 @@ def get_pins():
pinutils.findpin(pins, "PD2", True)["functions"]["ADC1_IN2"]=0;
pinutils.findpin(pins, "PD3", True)["functions"]["ADC1_IN3"]=0;
pinutils.findpin(pins, "PD4", True)["functions"]["ADC1_IN4"]=0;
# pinutils.findpin(pins, "PD5", True)["functions"]["ADC2_IN0"]=0;
# pinutils.findpin(pins, "PD5", True)["functions"]["ADC2_IN0"]=0;
# On supermini D8 is (inverted) LED
# On supermini D9 is (inverted) Button
# D12-D17 are SPI (internal SPI) - not sure they should even be exposed??

pinutils.findpin(pins, "PD18", True)["functions"]["USB"]=0; # D-
pinutils.findpin(pins, "PD19", True)["functions"]["USB"]=0; # D+
pinutils.findpin(pins, "PD20", True)["functions"]["USART1_RX"]=0;
pinutils.findpin(pins, "PD21", True)["functions"]["USART1_TX"]=0;
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0; # added for issue #2589 fix
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0; # added for issue #2589 fix
# SPI added for issue #2601

# SPI added for issue #2601
# See esp-idf-4 /components/soc/esp32c3/include/soc/soc_caps.h
pinutils.findpin(pins, "PD6", True)["functions"]["SPI1_SCK"]=0;
pinutils.findpin(pins, "PD2", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD7", True)["functions"]["SPI1_MOSI"]=0;



# everything is non-5v tolerant
for pin in pins:
Expand Down
22 changes: 11 additions & 11 deletions boards/ESP32S3_IDF4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# A Note about the 'variables' parameter on ESP32 Builds
# ------------------------------------------------------
#
#
# For the ESP32 build, the number of JsVars is governed by two factors:
# * Available memory
# * Maximum number of JsVars for the used JsVar format
Expand Down Expand Up @@ -52,8 +52,8 @@
'espruino_page_link' : 'ESP32',
'default_console' : "EV_SERIAL1",
'default_console_baudrate' : "115200",
'variables' : 16383, # See note above
'io_buffer_size' : 1024, # How big is the input buffer (in 4 byte words). Default is 256, but this makes us less likely to drop data
'variables' : 16383, # See note above
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
'binary_name' : 'espruino_%v_esp32s3.bin',
'build' : {
'optimizeflags' : '-Og',
Expand All @@ -67,14 +67,14 @@
'NEOPIXEL',
'FILESYSTEM',
# 'FLASHFS',
'BLUETOOTH'
'BLUETOOTH'
],
'makefile' : [
'DEFINES+=-DESP_PLATFORM -DESP32=1',
'DEFINES+=-DESP_STACK_SIZE=25000',
'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time
'DEFINES+=-DUSE_FONT_6X8',
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
'ESP32_FLASH_MAX=1572864'
]
}
Expand Down Expand Up @@ -149,14 +149,14 @@ def get_pins():
# Todo review as ESP32-S3 has there are 45 Physical GPIO pins Numbered 0->21 and 26->48
# see https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
pins = pinutils.generate_pins(0,39) # 40 General Purpose I/O Pins.

# I2C added for issue #2589 - all decided by user (not defined in specs)
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0;
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["I2C2_SDA"]=0;
pinutils.findpin(pins, "PD19", True)["functions"]["I2C2_SCL"]=0;
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0;
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["I2C2_SDA"]=0;
pinutils.findpin(pins, "PD19", True)["functions"]["I2C2_SCL"]=0;

# SPI added for issue #2601
# SPI added for issue #2601
# - for SPI1 use pins that will bypass GPIO matrix (So Quicker) see esp-idf-4 /components/soc/esp32s3/include/soc/spi_pins.h
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_SCK"]=0;
pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MISO"]=0;
Expand Down
Loading

0 comments on commit b84efec

Please sign in to comment.