Skip to content

Commit b84efec

Browse files
committed
Change ioBuffer FIFO from 4 byte blocks to variable length blocks. Far more efficient for USB/BLE/other block data
1 parent aa3ce23 commit b84efec

38 files changed

+385
-405
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Pipboy: allow audio files to be played at the same time as (silent) video. add audioStopped/videoStopped events and audioStop method
1818
Pipboy: Pip.audioStartVar(wav,{overlap:true}) can now play sounds over the top of other sounds. audioRead now doesn't stop audio playback
1919
STM32: Ensure proper distribution of analogRead values (now `0<=analogRead()<1` as on other boards) and add docs (fix #2612)
20+
Change ioBuffer FIFO from 4 byte blocks to variable length blocks. Far more efficient for USB/BLE/other block data
2021

2122
2v25 : ESP32C3: Get analogRead working correctly
2223
Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535)

boards/BANGLEJS2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# 'default_console_baudrate' : "9600",
2727
'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.
2828
# Currently leaves around 38k of free stack - *loads* more than we need
29-
'io_buffer_size' : 512, # How big is the input buffer (in 4 byte words). Default on nRF52 is 256
29+
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
3030
'bootloader' : 1,
3131
'binary_name' : 'espruino_%v_banglejs2.hex',
3232
'build' : {

boards/BANGLEJS2_IFLASH.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# 'default_console_baudrate' : "9600",
3232
'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.
3333
# Currently leaves around 38k of free stack - *loads* more than we need
34-
'io_buffer_size' : 512, # How big is the input buffer (in 4 byte words). Default on nRF52 is 256
34+
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
3535
'bootloader' : 1,
3636
'binary_name' : 'espruino_%v_banglejs2_iflash.hex',
3737
'build' : {

boards/BANGLEJS2_NOFLASH.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
info = {
1919
'name' : "Bangle.js 2 (No external flash)", # Using SMA Q3
2020
# A build for Bangle.js 2 that uses only internal flash
21-
'boardname' : "BANGLEJS2",
21+
'boardname' : "BANGLEJS2",
2222
'link' : [ "https://espruino.com/Bangle.js2" ],
2323
'espruino_page_link' : 'Bangle.js2',
2424
'default_console' : "EV_TERMINAL",
@@ -28,7 +28,7 @@
2828
# 'default_console_baudrate' : "9600",
2929
'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.
3030
# Currently leaves around 38k of free stack - *loads* more than we need
31-
'io_buffer_size' : 512, # How big is the input buffer (in 4 byte words). Default on nRF52 is 256
31+
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
3232
'bootloader' : 1,
3333
'binary_name' : 'espruino_%v_banglejs2_noflash.hex',
3434
'build' : {
@@ -54,8 +54,8 @@
5454
'DEFINES += -DESPR_DCDC_ENABLE=1', # Use DC/DC converter
5555
'ESPR_BLUETOOTH_ANCS=1', # Enable ANCS (Apple notifications) support
5656
'DEFINES += -DSPIFLASH_SLEEP_CMD', # SPI flash needs to be explicitly slept and woken up
57-
'DEFINES += -DSPIFLASH_READ2X', # Read SPI flash at 2x speed using MISO and MOSI for IO
58-
'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.
57+
'DEFINES += -DSPIFLASH_READ2X', # Read SPI flash at 2x speed using MISO and MOSI for IO
58+
'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.
5959
'DEFINES += -DAPP_TIMER_OP_QUEUE_SIZE=6', # Bangle.js accelerometer poll handler needs something else in queue size
6060
'DEFINES+=-DBLUETOOTH_NAME_PREFIX=\'"Bangle.js"\'',
6161
'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
@@ -124,7 +124,7 @@
124124
'BTN1' : { 'pin' : 'D17', 'pinstate' : 'IN_PULLDOWN' }, # Pin negated in software
125125
'LED1' : { 'pin' : 'D8', 'novariable':True }, # Backlight flash for low level debug - but in code we just use 'fake' LEDs
126126
'LCD' : {
127-
'width' : 176, 'height' : 176,
127+
'width' : 176, 'height' : 176,
128128
'bpp' : 3, # LCD is native 3 bit (fastest transfers), but 4 is faster for drawing and slow to transfer
129129
'controller' : 'LPM013M126', # LPM013M126C
130130
'pin_cs' : 'D5',
@@ -145,18 +145,18 @@
145145
'GPS' : {
146146
'device' : 'Casic URANUS',
147147
'pin_en' : 'D29',
148-
'pin_rx' : 'D30',
148+
'pin_rx' : 'D30',
149149
'pin_tx' : 'D31'
150150
},
151151
'BAT' : {
152152
'pin_charging' : 'D23', # active low
153153
'pin_voltage' : 'D3'
154154
},
155155
'HEARTRATE' : {
156-
'device' : 'VC31', 'addr' : 0x33,
157-
'pin_sda' : 'D24',
158-
'pin_scl' : 'D32',
159-
'pin_en' : 'D21',
156+
'device' : 'VC31', 'addr' : 0x33,
157+
'pin_sda' : 'D24',
158+
'pin_scl' : 'D32',
159+
'pin_en' : 'D21',
160160
'pin_int' : 'D22'
161161
},
162162
'ACCEL' : {
@@ -165,7 +165,7 @@
165165
'pin_scl' : 'D37'
166166
},
167167
'MAG' : { # Magnetometer/compass
168-
'device' : 'UNKNOWN_0C',
168+
'device' : 'UNKNOWN_0C',
169169
'addr' : 0x0C,
170170
'pin_sda' : 'D44',
171171
'pin_scl' : 'D45'
@@ -174,7 +174,7 @@
174174
'device' : 'BMP280', # v2.1 uses Goertek SPL06-001 - we handle both
175175
'addr' : 0x76, # both versions use the same address
176176
'pin_sda' : 'D47',
177-
'pin_scl' : 'D2'
177+
'pin_scl' : 'D2'
178178
},
179179
'SPIFLASH' : {
180180
'pin_cs' : 'D14',

boards/CURIO.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
'default_console' : "EV_SERIAL1",
5454
'default_console_baudrate' : "115200",
5555
'variables' : 16383, # See note above
56-
'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
56+
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
5757
'binary_name' : 'espruino_%v_curio.bin',
5858
'build' : {
5959
'optimizeflags' : '-Og',
@@ -161,21 +161,21 @@ def get_pins():
161161
# pinutils.findpin(pins, "PD5", True)["functions"]["ADC2_IN0"]=0;
162162
# pinutils.findpin(pins, "PD8", True)["functions"]["NEGATED"]=0; # LED negated - but ESP32 port ignores negation
163163
# D12-D17 are SPI (internal SPI) - not sure they should even be exposed??
164-
164+
165165
pinutils.findpin(pins, "PD18", True)["functions"]["USB"]=0; # D-
166166
pinutils.findpin(pins, "PD19", True)["functions"]["USB"]=0; # D+
167167
pinutils.findpin(pins, "PD20", True)["functions"]["USART1_RX"]=0;
168168
pinutils.findpin(pins, "PD21", True)["functions"]["USART1_TX"]=0;
169169
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0; # added for issue #2589 fix
170170
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0; # added for issue #2589 fix
171-
172-
# SPI added for issue #2601
171+
172+
# SPI added for issue #2601
173173
# See esp-idf-4 /components/soc/esp32c3/include/soc/soc_caps.h
174174
pinutils.findpin(pins, "PD6", True)["functions"]["SPI1_SCK"]=0;
175175
pinutils.findpin(pins, "PD2", True)["functions"]["SPI1_MISO"]=0;
176176
pinutils.findpin(pins, "PD7", True)["functions"]["SPI1_MOSI"]=0;
177177

178-
178+
179179

180180
# everything is non-5v tolerant
181181
for pin in pins:

boards/DICKENS.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
# o D14 VCC
3939
# D15 D17
4040
# D2 D19
41-
# GND D18
42-
#
41+
# GND D18
42+
#
4343

4444
# unfitted header (assuming same dir as Button flex header)
4545
# VCC D10
@@ -61,7 +61,7 @@
6161
'espruino_page_link' : '',
6262
'default_console' : "EV_BLUETOOTH",
6363
'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.
64-
'io_buffer_size' : 512,
64+
'io_buffer_size' : 2048, # How big is the input buffer (in bytes). Default on nRF52 is 1024
6565
'bootloader' : 1,
6666
'binary_name' : 'espruino_%v_dickens.hex',
6767
'build' : {
@@ -163,16 +163,16 @@
163163
'pin_sck' : 'D12',
164164
'pin_mosi' : 'D5',
165165
'pin_miso' : 'D27',
166-
'pin_en' : 'D43',
166+
'pin_en' : 'D43',
167167
'pin_bl' : 'D33', # Also enables the power supply for the vibration motor
168168
'bitrate' : 32000000
169169
},
170170
'BAT' : {
171-
'pin_charging' : 'D13',
171+
'pin_charging' : 'D13',
172172
'pin_voltage' : 'D4'
173173
},
174174
'MAG' : { # Magnetometer/compass
175-
'device' : 'GMC303',
175+
'device' : 'GMC303',
176176
'addr' : 0x0C,
177177
'pin_sda' : 'D9',
178178
'pin_scl' : 'D10'
@@ -196,7 +196,7 @@
196196
'pin_miso' : 'D23', # D1
197197
'pin_wp' : 'D21', # D2
198198
'pin_rst' : 'D24', # D3
199-
'size' : 4096*1024,
199+
'size' : 4096*1024,
200200
'memmap_base' : 0x60000000 # map into the address space (in software)
201201
}
202202
};
@@ -224,7 +224,7 @@ def get_pins():
224224
pinutils.findpin(pins, "PD46", True)["functions"]["NEGATED"]=0; # ok
225225
pinutils.findpin(pins, "PD42", True)["functions"]["NEGATED"]=0; # ok
226226
pinutils.findpin(pins, "PD28", True)["functions"]["NEGATED"]=0; # ok
227-
227+
228228

229229
# everything is non-5v tlerant
230230
for pin in pins:

boards/ESP32.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# A Note about the 'variables' parameter on ESP32 Builds
1919
# ------------------------------------------------------
20-
#
20+
#
2121
# For the ESP32 build, the number of JsVars is governed by two factors:
2222
# * Available memory
2323
# * Maximum number of JsVars for the used JsVar format
@@ -50,8 +50,8 @@
5050
'espruino_page_link' : 'ESP32',
5151
'default_console' : "EV_SERIAL1",
5252
'default_console_baudrate' : "115200",
53-
'variables' : 16383, # See note above
54-
'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
53+
'variables' : 16383, # See note above
54+
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
5555
'binary_name' : 'espruino_%v_esp32.bin',
5656
'build' : {
5757
'optimizeflags' : '-Og',
@@ -65,7 +65,7 @@
6565
'NEOPIXEL',
6666
'FILESYSTEM',
6767
'FLASHFS',
68-
'BLUETOOTH'
68+
'BLUETOOTH'
6969
],
7070
'makefile' : [
7171
'DEFINES+=-DESP_PLATFORM -DESP32=1',
@@ -187,16 +187,16 @@ def get_pins():
187187
pinutils.findpin(pins, "PD10", True)["functions"]["USART1_TX"]=0; # doesn't match jshardwareUart?
188188
pinutils.findpin(pins, "PD32", True)["functions"]["USART1_RX"]=0; # doesn't match jshardwareUart?
189189
pinutils.findpin(pins, "PD16", True)["functions"]["USART3_RX"]=0;
190-
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;
191-
190+
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;
191+
192192
pinutils.findpin(pins, "PD16", True)["functions"]["I2C2_SCL"]=1; # added for issue #2589 fix
193193
pinutils.findpin(pins, "PD17", True)["functions"]["I2C2_SDA"]=1; # added for issue #2589 fix
194194
pinutils.findpin(pins, "PD22", True)["functions"]["I2C1_SCL"]=0; # SCL moved from P21 for issue #2589
195195
pinutils.findpin(pins, "PD21", True)["functions"]["I2C1_SDA"]=0; # SDA moved from P22 for issue #2589
196196

197197
# These SPI Pin defs used in jshSPISetup as of issue #2601
198198
# see esp-idf-4 /components/soc/esp32/include/soc/spi_pins.h
199-
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCK"]=0;
199+
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCK"]=0;
200200
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_MISO"]=0;
201201
pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MOSI"]=0;
202202
pinutils.findpin(pins, "PD18", True)["functions"]["SPI2_SCK"]=0;

boards/ESP32C3_IDF4.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# A Note about the 'variables' parameter on ESP32 Builds
2121
# ------------------------------------------------------
22-
#
22+
#
2323
# For the ESP32 build, the number of JsVars is governed by two factors:
2424
# * Available memory
2525
# * Maximum number of JsVars for the used JsVar format
@@ -52,8 +52,8 @@
5252
'espruino_page_link' : 'ESP32',
5353
'default_console' : "EV_SERIAL1",
5454
'default_console_baudrate' : "115200",
55-
'variables' : 16383, # See note above
56-
'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
55+
'variables' : 16383, # See note above
56+
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
5757
'binary_name' : 'espruino_%v_esp32c3.bin',
5858
'build' : {
5959
'optimizeflags' : '-Og',
@@ -67,14 +67,14 @@
6767
# 'FILESYSTEM',
6868
# 'FLASHFS',
6969
'BLUETOOTH',
70-
'NEOPIXEL'
70+
'NEOPIXEL'
7171
],
7272
'makefile' : [
7373
'DEFINES+=-DESP_PLATFORM -DESP32=1',
7474
'DEFINES+=-DESP_STACK_SIZE=25000',
7575
'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time
7676
'DEFINES+=-DUSE_FONT_6X8',
77-
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
77+
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
7878
'ESP32_FLASH_MAX=1572864'
7979
]
8080
}
@@ -153,25 +153,25 @@ def get_pins():
153153
pinutils.findpin(pins, "PD2", True)["functions"]["ADC1_IN2"]=0;
154154
pinutils.findpin(pins, "PD3", True)["functions"]["ADC1_IN3"]=0;
155155
pinutils.findpin(pins, "PD4", True)["functions"]["ADC1_IN4"]=0;
156-
# pinutils.findpin(pins, "PD5", True)["functions"]["ADC2_IN0"]=0;
156+
# pinutils.findpin(pins, "PD5", True)["functions"]["ADC2_IN0"]=0;
157157
# On supermini D8 is (inverted) LED
158158
# On supermini D9 is (inverted) Button
159159
# D12-D17 are SPI (internal SPI) - not sure they should even be exposed??
160-
160+
161161
pinutils.findpin(pins, "PD18", True)["functions"]["USB"]=0; # D-
162162
pinutils.findpin(pins, "PD19", True)["functions"]["USB"]=0; # D+
163163
pinutils.findpin(pins, "PD20", True)["functions"]["USART1_RX"]=0;
164164
pinutils.findpin(pins, "PD21", True)["functions"]["USART1_TX"]=0;
165165
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0; # added for issue #2589 fix
166166
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0; # added for issue #2589 fix
167-
168-
# SPI added for issue #2601
167+
168+
# SPI added for issue #2601
169169
# See esp-idf-4 /components/soc/esp32c3/include/soc/soc_caps.h
170170
pinutils.findpin(pins, "PD6", True)["functions"]["SPI1_SCK"]=0;
171171
pinutils.findpin(pins, "PD2", True)["functions"]["SPI1_MISO"]=0;
172172
pinutils.findpin(pins, "PD7", True)["functions"]["SPI1_MOSI"]=0;
173173

174-
174+
175175

176176
# everything is non-5v tolerant
177177
for pin in pins:

boards/ESP32S3_IDF4.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# A Note about the 'variables' parameter on ESP32 Builds
2121
# ------------------------------------------------------
22-
#
22+
#
2323
# For the ESP32 build, the number of JsVars is governed by two factors:
2424
# * Available memory
2525
# * Maximum number of JsVars for the used JsVar format
@@ -52,8 +52,8 @@
5252
'espruino_page_link' : 'ESP32',
5353
'default_console' : "EV_SERIAL1",
5454
'default_console_baudrate' : "115200",
55-
'variables' : 16383, # See note above
56-
'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
55+
'variables' : 16383, # See note above
56+
'io_buffer_size' : 4096, # How big is the input buffer (in bytes). Default on nRF52 is 1024
5757
'binary_name' : 'espruino_%v_esp32s3.bin',
5858
'build' : {
5959
'optimizeflags' : '-Og',
@@ -67,14 +67,14 @@
6767
'NEOPIXEL',
6868
'FILESYSTEM',
6969
# 'FLASHFS',
70-
'BLUETOOTH'
70+
'BLUETOOTH'
7171
],
7272
'makefile' : [
7373
'DEFINES+=-DESP_PLATFORM -DESP32=1',
7474
'DEFINES+=-DESP_STACK_SIZE=25000',
7575
'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time
7676
'DEFINES+=-DUSE_FONT_6X8',
77-
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
77+
'DEFINES+=-DUSB_CDC', # Comment out to disable USB_CDC if board has uart interface
7878
'ESP32_FLASH_MAX=1572864'
7979
]
8080
}
@@ -149,14 +149,14 @@ def get_pins():
149149
# Todo review as ESP32-S3 has there are 45 Physical GPIO pins Numbered 0->21 and 26->48
150150
# see https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
151151
pins = pinutils.generate_pins(0,39) # 40 General Purpose I/O Pins.
152-
152+
153153
# I2C added for issue #2589 - all decided by user (not defined in specs)
154-
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0;
155-
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0;
156-
pinutils.findpin(pins, "PD18", True)["functions"]["I2C2_SDA"]=0;
157-
pinutils.findpin(pins, "PD19", True)["functions"]["I2C2_SCL"]=0;
154+
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0;
155+
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0;
156+
pinutils.findpin(pins, "PD18", True)["functions"]["I2C2_SDA"]=0;
157+
pinutils.findpin(pins, "PD19", True)["functions"]["I2C2_SCL"]=0;
158158

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

0 commit comments

Comments
 (0)