From 9d10a3da66cd799b659457ca9785be1a33105dc6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 27 May 2022 12:59:54 -0700 Subject: [PATCH] Conditionalize LTO --- devices/ble_hci/common-hal/_bleio/att.c | 1 + extmod/moduasyncio.c | 2 + extmod/modubinascii.c | 2 + extmod/moductypes.c | 2 +- extmod/moduhashlib.c | 2 +- extmod/moduheapq.c | 2 +- extmod/modujson.c | 2 +- extmod/modutimeq.c | 2 +- extmod/moduzlib.c | 2 +- extmod/vfs_fat.c | 2 +- extmod/vfs_posix_file.c | 2 +- main.c | 2 +- ports/atmel-samd/Makefile | 9 +- ports/atmel-samd/common-hal/_pew/PewPew.c | 2 +- .../atmel-samd/common-hal/analogio/AnalogIn.c | 2 +- .../common-hal/analogio/AnalogOut.c | 2 +- .../atmel-samd/common-hal/audiobusio/I2SOut.c | 2 +- .../atmel-samd/common-hal/audiobusio/PDMIn.c | 280 +++++++++--------- .../atmel-samd/common-hal/audioio/AudioOut.c | 2 +- ports/atmel-samd/common-hal/busio/I2C.c | 2 +- ports/atmel-samd/common-hal/busio/SPI.c | 1 + ports/atmel-samd/common-hal/busio/UART.c | 2 +- ports/atmel-samd/common-hal/countio/Counter.c | 2 +- .../common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/frequencyio/FrequencyIn.c | 2 +- .../common-hal/microcontroller/Pin.c | 1 + .../common-hal/microcontroller/__init__.c | 2 +- ports/atmel-samd/common-hal/ps2io/Ps2.c | 2 +- ports/atmel-samd/common-hal/pulseio/PulseIn.c | 2 +- .../atmel-samd/common-hal/pulseio/PulseOut.c | 2 +- ports/atmel-samd/common-hal/pwmio/PWMOut.c | 2 +- .../common-hal/rotaryio/IncrementalEncoder.c | 2 +- ports/atmel-samd/common-hal/rtc/RTC.c | 2 +- ports/atmel-samd/common-hal/sdioio/SDCard.c | 2 +- ports/atmel-samd/common-hal/touchio/TouchIn.c | 2 +- ports/atmel-samd/mpconfigport.mk | 8 + .../common-hal/digitalio/DigitalInOut.c | 2 +- ports/broadcom/common-hal/sdioio/SDCard.c | 2 +- ports/espressif/Makefile | 2 - .../espressif/common-hal/analogio/AnalogIn.c | 2 +- .../espressif/common-hal/analogio/AnalogOut.c | 2 +- .../espressif/common-hal/audiobusio/I2SOut.c | 2 +- ports/espressif/common-hal/busio/I2C.c | 2 +- ports/espressif/common-hal/busio/UART.c | 2 +- ports/espressif/common-hal/countio/Counter.c | 2 +- .../common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- ports/litex/Makefile | 4 +- .../litex/common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- ports/mimxrt10xx/Makefile | 7 +- .../common-hal/analogio/AnalogOut.c | 2 +- .../common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/__init__.c | 2 +- ports/mimxrt10xx/common-hal/pwmio/PWMOut.c | 2 +- ports/mimxrt10xx/common-hal/rtc/RTC.c | 2 +- ports/nrf/Makefile | 8 - ports/nrf/common-hal/analogio/AnalogIn.c | 4 +- ports/nrf/common-hal/analogio/AnalogOut.c | 2 +- ports/nrf/common-hal/audiopwmio/PWMAudioOut.c | 2 +- ports/nrf/common-hal/busio/I2C.c | 2 +- ports/nrf/common-hal/busio/UART.c | 2 +- ports/nrf/common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/Processor.c | 3 +- ports/nrf/common-hal/pulseio/PulseOut.c | 2 +- ports/nrf/common-hal/pwmio/PWMOut.c | 2 +- ports/nrf/common-hal/rtc/RTC.c | 2 +- ports/nrf/mpconfigport.mk | 8 + .../bindings/rp2pio/StateMachine.c | 2 +- .../common-hal/analogio/AnalogIn.c | 2 +- .../common-hal/analogio/AnalogOut.c | 2 +- .../common-hal/audiobusio/I2SOut.c | 2 +- .../raspberrypi/common-hal/audiobusio/PDMIn.c | 2 +- .../common-hal/audiopwmio/PWMAudioOut.c | 2 +- .../raspberrypi/common-hal/countio/Counter.c | 2 +- .../common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/__init__.c | 2 +- .../raspberrypi/common-hal/pulseio/PulseIn.c | 2 +- .../raspberrypi/common-hal/pulseio/PulseOut.c | 2 +- ports/raspberrypi/common-hal/pwmio/PWMOut.c | 2 +- ports/stm/Makefile | 2 - ports/stm/common-hal/analogio/AnalogIn.c | 2 +- ports/stm/common-hal/analogio/AnalogOut.c | 2 +- ports/stm/common-hal/busio/I2C.c | 2 +- ports/stm/common-hal/busio/SPI.c | 2 +- ports/stm/common-hal/busio/UART.c | 2 +- ports/stm/common-hal/digitalio/DigitalInOut.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- ports/stm/common-hal/pulseio/PulseOut.c | 2 +- ports/stm/common-hal/pwmio/PWMOut.c | 2 +- ports/stm/common-hal/sdioio/SDCard.c | 2 +- ports/stm/peripherals/timers.c | 2 +- ports/unix/modffi.c | 2 +- ports/unix/modmachine.c | 2 +- py/argcheck.c | 2 +- py/bc.c | 2 +- py/binary.c | 2 +- py/builtinevex.c | 2 +- py/builtinhelp.c | 2 + py/builtinimport.c | 2 +- py/circuitpy_defns.mk | 13 +- py/compile.c | 10 +- py/enum.c | 2 + py/lexer.c | 2 +- py/makeqstrdata.py | 2 +- py/modbuiltins.c | 2 +- py/modmath.c | 2 +- py/modmicropython.c | 2 +- py/modstruct.c | 2 +- py/modthread.c | 2 +- py/moduerrno.c | 2 +- py/obj.c | 2 +- py/obj.h | 2 +- py/objarray.c | 2 +- py/objcomplex.c | 2 +- py/objdeque.c | 2 +- py/objdict.c | 2 +- py/objexcept.c | 2 +- py/objfloat.c | 2 +- py/objgenerator.c | 2 +- py/objint.c | 2 +- py/objint_longlong.c | 2 +- py/objint_mpz.c | 2 +- py/objlist.c | 2 +- py/objnamedtuple.c | 2 +- py/objobject.c | 2 +- py/objrange.c | 2 +- py/objset.c | 2 +- py/objslice.c | 2 +- py/objstr.c | 2 +- py/objstringio.c | 2 +- py/objstrunicode.c | 2 +- py/objtuple.c | 2 +- py/objtype.c | 2 +- py/parse.c | 2 +- py/parsenum.c | 2 +- py/persistentcode.c | 2 +- py/proto.c | 2 + py/qstr.c | 1 + py/runtime.c | 2 +- py/runtime.h | 2 + py/sequence.c | 2 +- py/stream.c | 2 +- py/vm.c | 1 + runtime.py | 10 + shared-bindings/_pew/PewPew.c | 2 +- shared-bindings/_stage/Layer.c | 2 +- shared-bindings/_stage/Text.c | 2 +- .../i2c_device/I2CDevice.c | 2 +- .../spi_device/SPIDevice.c | 2 +- shared-bindings/alarm/SleepMemory.c | 2 +- shared-bindings/alarm/pin/PinAlarm.c | 2 +- shared-bindings/alarm/time/TimeAlarm.c | 2 +- shared-bindings/analogio/AnalogOut.c | 2 +- shared-bindings/audiobusio/I2SOut.c | 2 +- shared-bindings/audiobusio/PDMIn.c | 2 +- shared-bindings/audiocore/RawSample.c | 2 +- shared-bindings/audiocore/WaveFile.c | 2 +- shared-bindings/audioio/AudioOut.c | 2 +- shared-bindings/audiomixer/Mixer.c | 2 +- shared-bindings/audiomixer/MixerVoice.c | 2 +- shared-bindings/audiomp3/MP3Decoder.c | 2 +- shared-bindings/audiopwmio/PWMAudioOut.c | 2 +- shared-bindings/bitbangio/I2C.c | 2 +- shared-bindings/bitbangio/SPI.c | 2 +- shared-bindings/busio/I2C.c | 2 +- shared-bindings/busio/SPI.c | 2 +- shared-bindings/busio/UART.c | 2 +- shared-bindings/digitalio/DigitalInOut.c | 2 +- shared-bindings/digitalio/Pull.c | 1 + shared-bindings/displayio/Bitmap.c | 2 +- shared-bindings/displayio/ColorConverter.c | 2 +- shared-bindings/displayio/Display.c | 2 +- shared-bindings/displayio/EPaperDisplay.c | 2 +- shared-bindings/displayio/FourWire.c | 2 +- shared-bindings/displayio/Group.c | 2 +- shared-bindings/displayio/I2CDisplay.c | 2 +- shared-bindings/displayio/OnDiskBitmap.c | 2 +- shared-bindings/displayio/Palette.c | 2 +- shared-bindings/displayio/Shape.c | 2 +- shared-bindings/displayio/TileGrid.c | 2 +- shared-bindings/fontio/BuiltinFont.c | 2 +- .../framebufferio/FramebufferDisplay.c | 2 +- shared-bindings/frequencyio/FrequencyIn.c | 2 +- shared-bindings/math/__init__.c | 2 +- .../memorymonitor/AllocationAlarm.c | 2 +- .../memorymonitor/AllocationSize.c | 2 +- shared-bindings/microcontroller/Pin.c | 2 +- shared-bindings/microcontroller/Processor.c | 2 +- shared-bindings/microcontroller/__init__.c | 2 +- shared-bindings/multiterminal/__init__.c | 2 +- shared-bindings/neopixel_write/__init__.c | 2 +- shared-bindings/nvm/ByteArray.c | 2 +- shared-bindings/os/__init__.c | 1 + shared-bindings/paralleldisplay/ParallelBus.c | 2 +- shared-bindings/ps2io/Ps2.c | 2 +- shared-bindings/pulseio/PulseIn.c | 2 +- shared-bindings/pulseio/PulseOut.c | 2 +- shared-bindings/pwmio/PWMOut.c | 2 +- shared-bindings/random/__init__.c | 2 +- shared-bindings/rtc/RTC.c | 2 +- shared-bindings/sdioio/SDCard.c | 2 +- shared-bindings/storage/__init__.c | 2 +- shared-bindings/struct/__init__.c | 2 +- shared-bindings/supervisor/__init__.c | 2 +- shared-bindings/synthio/MidiTrack.c | 2 +- shared-bindings/terminalio/Terminal.c | 2 +- shared-bindings/time/__init__.c | 2 +- shared-bindings/touchio/TouchIn.c | 2 +- shared-bindings/usb_cdc/Serial.c | 2 +- shared-bindings/usb_cdc/__init__.c | 1 + shared-bindings/usb_hid/Device.c | 1 + shared-bindings/usb_hid/__init__.c | 2 + shared-bindings/usb_midi/PortIn.c | 2 +- shared-bindings/usb_midi/PortOut.c | 2 +- shared-bindings/usb_midi/__init__.c | 1 + shared-bindings/util.c | 2 +- shared-bindings/vectorio/Circle.c | 2 +- shared-bindings/vectorio/Polygon.c | 2 +- shared-bindings/vectorio/Rectangle.c | 2 +- shared-bindings/vectorio/VectorShape.c | 2 +- shared-bindings/zlib/__init__.c | 2 +- shared-module/audiocore/WaveFile.c | 2 +- shared-module/audiomp3/MP3Decoder.c | 2 +- shared-module/bitbangio/I2C.c | 2 +- shared-module/bitbangio/SPI.c | 2 +- shared-module/board/__init__.c | 2 +- shared-module/msgpack/__init__.c | 2 +- shared-module/storage/__init__.c | 1 + shared-module/struct/__init__.c | 2 +- shared-module/usb_hid/Device.c | 2 +- shared-module/usb_hid/__init__.c | 1 + shared-module/usb_midi/PortIn.c | 2 +- shared-module/usb_midi/PortOut.c | 2 +- shared-module/usb_midi/__init__.c | 1 + shared/libc/abort_.c | 2 +- shared/netutils/netutils.c | 2 +- supervisor/shared/safe_mode.c | 2 +- .../compressed_string.h} | 29 +- supervisor/shared/{ => translate}/translate.c | 6 +- supervisor/shared/translate/translate.h | 55 ++++ supervisor/shared/translate/translate_impl.h | 52 ++++ supervisor/supervisor.mk | 2 +- 243 files changed, 534 insertions(+), 413 deletions(-) create mode 100644 runtime.py rename supervisor/shared/{translate.h => translate/compressed_string.h} (81%) rename supervisor/shared/{ => translate}/translate.c (97%) create mode 100644 supervisor/shared/translate/translate.h create mode 100644 supervisor/shared/translate/translate_impl.h diff --git a/devices/ble_hci/common-hal/_bleio/att.c b/devices/ble_hci/common-hal/_bleio/att.c index abfe7429f4..f649967ca9 100644 --- a/devices/ble_hci/common-hal/_bleio/att.c +++ b/devices/ble_hci/common-hal/_bleio/att.c @@ -44,6 +44,7 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" #include "supervisor/shared/tick.h" +#include "supervisor/shared/translate/translate.h" STATIC uint16_t max_mtu = BT_ATT_DEFAULT_LE_MTU; // 23 STATIC unsigned long timeout = 5000; diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index 016ffcbc99..c4c4d36ad8 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -33,6 +33,8 @@ #include "shared-bindings/supervisor/__init__.h" #endif +#include "supervisor/shared/translate/translate.h" + #if MICROPY_PY_UASYNCIO // Used when task cannot be guaranteed to be non-NULL. diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 7157be31fa..5aa9eacefd 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -11,6 +11,8 @@ #include "py/runtime.h" #include "py/binary.h" +#include "supervisor/shared/translate/translate.h" + static void check_not_unicode(const mp_obj_t arg) { #if MICROPY_CPYTHON_COMPAT if (mp_obj_is_str(arg)) { diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 265cbd6d5d..f770ead006 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -11,7 +11,7 @@ #include "py/objtuple.h" #include "py/binary.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_UCTYPES diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 741f43c74c..a84254c566 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -8,7 +8,7 @@ #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_UHASHLIB diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index 34867a5838..0200245f86 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -6,7 +6,7 @@ #include "py/objlist.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_UHEAPQ diff --git a/extmod/modujson.c b/extmod/modujson.c index 9a4db7c273..cff02ae95c 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -13,7 +13,7 @@ #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_UJSON diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index 495675ad1d..fcef14ce98 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -10,7 +10,7 @@ #include "py/runtime.h" #include "py/smallint.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_UTIMEQ diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index b1eeac934b..6a1a2d6111 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -10,7 +10,7 @@ #include "py/stream.h" #include "py/mperrno.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_UZLIB diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index ed5cc6095f..d19a53a9ef 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -20,7 +20,7 @@ #include "extmod/vfs_fat.h" #include "shared/timeutils/timeutils.h" #include "supervisor/filesystem.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if FF_MAX_SS == FF_MIN_SS #define SECSIZE(fs) (FF_MIN_SS) diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index a984ace4a2..94ddbe5f7b 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -8,7 +8,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "extmod/vfs_posix.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if (defined(MICROPY_VFS_POSIX) && MICROPY_VFS_POSIX) || (defined(MICROPY_VFS_POSIX_FILE) && MICROPY_VFS_POSIX_FILE) diff --git a/main.c b/main.c index 17fe8167f2..d2b3edb16a 100644 --- a/main.c +++ b/main.c @@ -58,7 +58,7 @@ #include "supervisor/shared/status_leds.h" #include "supervisor/shared/tick.h" #include "supervisor/shared/traceback.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/workflow.h" #include "supervisor/usb.h" #include "supervisor/workflow.h" diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 4bcbb5cf83..281b5efd2f 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -123,8 +123,6 @@ $(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY)) #Debugging/Optimization ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 -Og -Os - # You may want to disable -flto if it interferes with debugging. - CFLAGS += -flto -flto-partition=one # You may want to enable these flags to make setting breakpoints easier. # CFLAGS += -fno-inline -fno-ipa-sra ifeq ($(CHIP_FAMILY), samd21) @@ -147,11 +145,8 @@ else CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) endif - CFLAGS += -flto - ifeq ($(CIRCUITPY_FULL_BUILD),0) CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20 - CFLAGS += -flto-partition=one endif ifdef CFLAGS_BOARD @@ -168,8 +163,7 @@ CFLAGS += \ -mcpu=cortex-m0plus \ -msoft-float \ -mfloat-abi=soft \ - -DSAMD21 \ - -flto-partition=one + -DSAMD21 endif ifeq ($(CHIP_FAMILY), samd51) CFLAGS += \ @@ -206,7 +200,6 @@ endif CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs -LDFLAGS += -flto=$(shell $(NPROC)) LIBS := -lgcc -lc # Use toolchain libm if we're not using our own. diff --git a/ports/atmel-samd/common-hal/_pew/PewPew.c b/ports/atmel-samd/common-hal/_pew/PewPew.c index 40cd52134a..c4d94e3dbd 100644 --- a/ports/atmel-samd/common-hal/_pew/PewPew.c +++ b/ports/atmel-samd/common-hal/_pew/PewPew.c @@ -35,7 +35,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" #include "samd/timers.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "timer_handler.h" diff --git a/ports/atmel-samd/common-hal/analogio/AnalogIn.c b/ports/atmel-samd/common-hal/analogio/AnalogIn.c index e6db95b358..d15be8308a 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogIn.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogIn.c @@ -37,7 +37,7 @@ #include "samd/adc.h" #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_adc_sync.h" diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index 2f38fce700..b4d556429c 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/audioio/AudioOut.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_dac_sync.h" diff --git a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c index eb98cc8d27..447252aace 100644 --- a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c +++ b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -40,7 +40,7 @@ #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index c3bdd95793..3711ba9c1b 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -37,7 +37,7 @@ #include "shared-bindings/audiobusio/PDMIn.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" @@ -58,11 +58,11 @@ #define MIN_MIC_CLOCK 1000000 #ifdef SAMD21 -#define SERCTRL(name) I2S_SERCTRL_ ## name +#define SERCTRL(name) I2S_SERCTRL_##name #endif #ifdef SAM_D5X_E5X -#define SERCTRL(name) I2S_RXCTRL_ ## name +#define SERCTRL(name) I2S_RXCTRL_##name #endif // Set by interrupt handler when DMA block has finished transferring. @@ -80,102 +80,104 @@ void pdmin_reset(void) { pdmin_dma_block_done = false; pdmin_event_channel = EVSYS_SYNCH_NUM; - while (I2S->SYNCBUSY.reg & I2S_SYNCBUSY_ENABLE) {} + while (I2S->SYNCBUSY.reg & I2S_SYNCBUSY_ENABLE) { + } I2S->INTENCLR.reg = I2S_INTENCLR_MASK; I2S->INTFLAG.reg = I2S_INTFLAG_MASK; I2S->CTRLA.reg &= ~I2S_SYNCBUSY_ENABLE; - while (I2S->SYNCBUSY.reg & I2S_SYNCBUSY_ENABLE) {} + while (I2S->SYNCBUSY.reg & I2S_SYNCBUSY_ENABLE) { + } I2S->CTRLA.reg = I2S_CTRLA_SWRST; } // Caller validates that pins are free. -void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, - const mcu_pin_obj_t* clock_pin, - const mcu_pin_obj_t* data_pin, - uint32_t sample_rate, - uint8_t bit_depth, - bool mono, - uint8_t oversample) { +void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, + const mcu_pin_obj_t *clock_pin, + const mcu_pin_obj_t *data_pin, + uint32_t sample_rate, + uint8_t bit_depth, + bool mono, + uint8_t oversample) { self->clock_pin = clock_pin; // PA10, PA20 -> SCK0, PB11 -> SCK1 #ifdef SAMD21 - if (clock_pin == &pin_PA10 + if (clock_pin == &pin_PA10 #if defined(PIN_PA20) && !defined(IGNORE_PIN_PA20) - || clock_pin == &pin_PA20 - #endif - ) { - self->clock_unit = 0; - #if defined(PIN_PB11) && !defined(IGNORE_PIN_PB11) - } else if (clock_pin == &pin_PB11) { - self->clock_unit = 1; + || clock_pin == &pin_PA20 #endif + ) { + self->clock_unit = 0; + #if defined(PIN_PB11) && !defined(IGNORE_PIN_PB11) + } else if (clock_pin == &pin_PB11) { + self->clock_unit = 1; + #endif #endif #ifdef SAM_D5X_E5X - if (clock_pin == &pin_PA10 || clock_pin == &pin_PB16) { - self->clock_unit = 0; + if (clock_pin == &pin_PA10 || clock_pin == &pin_PB16) { + self->clock_unit = 0; } else if (clock_pin == &pin_PB12 - #if defined(PIN_PB28) && !defined(IGNORE_PIN_PB28) - || data_pin == &pin_PB28) { - #else - ) { + #if defined(PIN_PB28) && !defined(IGNORE_PIN_PB28) + || data_pin == &pin_PB28) { + #else + ) { #endif - self->clock_unit = 1; + self->clock_unit = 1; #endif - } else { - raise_ValueError_invalid_pin_name(MP_QSTR_clock); - } +} else { + raise_ValueError_invalid_pin_name(MP_QSTR_clock); +} - self->data_pin = data_pin; // PA07, PA19 -> SD0, PA08, PB16 -> SD1 +self->data_pin = data_pin; // PA07, PA19 -> SD0, PA08, PB16 -> SD1 #ifdef SAMD21 - if (false +if (false #if defined(PIN_PA07) && !defined(IGNORE_PIN_PA07) - || data_pin == &pin_PA07 + || data_pin == &pin_PA07 #endif #if defined(PIN_PA19) && !defined(IGNORE_PIN_PA19) - || data_pin == &pin_PA19 + || data_pin == &pin_PA19 #endif - ) { - self->serializer = 0; - } - else if (false + ) { + self->serializer = 0; +} else if (false #if defined(PIN_PA08) && !defined(IGNORE_PIN_PA08) - || data_pin == &pin_PA08 + || data_pin == &pin_PA08 #endif - #if defined (PIN_PB16) && !defined(IGNORE_PIN_PB16) - || data_pin == &pin_PB16 + #if defined(PIN_PB16) && !defined(IGNORE_PIN_PB16) + || data_pin == &pin_PB16 #endif - ) { - self->serializer = 1; + ) { + self->serializer = 1; #endif #ifdef SAM_D5X_E5X - if (data_pin == &pin_PB10 || data_pin == &pin_PA22) { - self->serializer = 1; +if (data_pin == &pin_PB10 || data_pin == &pin_PA22) { + self->serializer = 1; #endif - } else { - raise_ValueError_invalid_pin_name(MP_QSTR_data); - } +}else { + raise_ValueError_invalid_pin_name(MP_QSTR_data); +} - if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) { - mp_raise_NotImplementedError(translate("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); - } +if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) { + mp_raise_NotImplementedError(translate("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); +} - turn_on_i2s(); +turn_on_i2s(); - if (I2S->CTRLA.bit.ENABLE == 0) { - I2S->CTRLA.bit.SWRST = 1; - while (I2S->CTRLA.bit.SWRST == 1) {} - } else { - #ifdef SAMD21 - if ((I2S->CTRLA.vec.SEREN & (1 << self->serializer)) != 0) { - mp_raise_RuntimeError(translate("Serializer in use")); - } - #endif - #ifdef SAM_D5X_E5X - if (I2S->CTRLA.bit.RXEN == 1) { - mp_raise_RuntimeError(translate("Serializer in use")); - } - #endif +if (I2S->CTRLA.bit.ENABLE == 0) { + I2S->CTRLA.bit.SWRST = 1; + while (I2S->CTRLA.bit.SWRST == 1) { } +} else { + #ifdef SAMD21 + if ((I2S->CTRLA.vec.SEREN & (1 << self->serializer)) != 0) { + mp_raise_RuntimeError(translate("Serializer in use")); + } + #endif + #ifdef SAM_D5X_E5X + if (I2S->CTRLA.bit.RXEN == 1) { + mp_raise_RuntimeError(translate("Serializer in use")); + } + #endif +} #ifdef SAM_D5X_E5X #define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_J #endif @@ -183,69 +185,69 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, #define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G #endif - uint32_t clock_divisor = (uint32_t) roundf( 48000000.0f / sample_rate / oversample); - float mic_clock_freq = 48000000.0f / clock_divisor; - self->sample_rate = mic_clock_freq / oversample; - if (mic_clock_freq < MIN_MIC_CLOCK || clock_divisor == 0) { - mp_raise_ValueError(translate("sampling rate out of range")); - } - // Find a free GCLK to generate the MCLK signal. - uint8_t gclk = find_free_gclk(clock_divisor); - if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError(translate("Unable to find free GCLK")); - } - self->gclk = gclk; +uint32_t clock_divisor = (uint32_t)roundf(48000000.0f / sample_rate / oversample); +float mic_clock_freq = 48000000.0f / clock_divisor; +self->sample_rate = mic_clock_freq / oversample; +if (mic_clock_freq < MIN_MIC_CLOCK || clock_divisor == 0) { + mp_raise_ValueError(translate("sampling rate out of range")); +} +// Find a free GCLK to generate the MCLK signal. +uint8_t gclk = find_free_gclk(clock_divisor); +if (gclk > GCLK_GEN_NUM) { + mp_raise_RuntimeError(translate("Unable to find free GCLK")); +} +self->gclk = gclk; - enable_clock_generator(self->gclk, CLOCK_48MHZ, clock_divisor); - connect_gclk_to_peripheral(self->gclk, I2S_GCLK_ID_0 + self->clock_unit); +enable_clock_generator(self->gclk, CLOCK_48MHZ, clock_divisor); +connect_gclk_to_peripheral(self->gclk, I2S_GCLK_ID_0 + self->clock_unit); - // Clock unit configuration +// Clock unit configuration - uint32_t clkctrl = I2S_CLKCTRL_MCKSEL_GCLK | - I2S_CLKCTRL_NBSLOTS(2) | - I2S_CLKCTRL_FSWIDTH_SLOT | - I2S_CLKCTRL_SLOTSIZE_16; +uint32_t clkctrl = I2S_CLKCTRL_MCKSEL_GCLK | + I2S_CLKCTRL_NBSLOTS(2) | + I2S_CLKCTRL_FSWIDTH_SLOT | + I2S_CLKCTRL_SLOTSIZE_16; - // Serializer configuration +// Serializer configuration #ifdef SAMD21 - uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_PDM2) | SERCTRL(DATASIZE_32); +uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_PDM2) | SERCTRL(DATASIZE_32); #endif #ifdef SAM_D5X_E5X - uint32_t serctrl = (self->clock_unit << I2S_RXCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_PDM2) | SERCTRL(DATASIZE_32); +uint32_t serctrl = (self->clock_unit << I2S_RXCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_PDM2) | SERCTRL(DATASIZE_32); #endif - // Configure the I2S peripheral - i2s_set_enable(false); +// Configure the I2S peripheral +i2s_set_enable(false); - I2S->CLKCTRL[self->clock_unit].reg = clkctrl; +I2S->CLKCTRL[self->clock_unit].reg = clkctrl; #ifdef SAMD21 - I2S->SERCTRL[self->serializer].reg = serctrl; +I2S->SERCTRL[self->serializer].reg = serctrl; #endif #ifdef SAM_D5X_E5X - I2S->RXCTRL.reg = serctrl; +I2S->RXCTRL.reg = serctrl; #endif - i2s_set_enable(true); +i2s_set_enable(true); - // Run the clock all the time. This eliminates startup delay for the microphone, - // which can be 10-100ms. Turn serializer on as needed. - i2s_set_clock_unit_enable(self->clock_unit, true); +// Run the clock all the time. This eliminates startup delay for the microphone, +// which can be 10-100ms. Turn serializer on as needed. +i2s_set_clock_unit_enable(self->clock_unit, true); - claim_pin(clock_pin); - claim_pin(data_pin); +claim_pin(clock_pin); +claim_pin(data_pin); - gpio_set_pin_function(self->clock_pin->number, GPIO_I2S_FUNCTION); - gpio_set_pin_function(self->data_pin->number, GPIO_I2S_FUNCTION); +gpio_set_pin_function(self->clock_pin->number, GPIO_I2S_FUNCTION); +gpio_set_pin_function(self->data_pin->number, GPIO_I2S_FUNCTION); - self->bytes_per_sample = oversample >> 3; - self->bit_depth = bit_depth; +self->bytes_per_sample = oversample >> 3; +self->bit_depth = bit_depth; } -bool common_hal_audiobusio_pdmin_deinited(audiobusio_pdmin_obj_t* self) { +bool common_hal_audiobusio_pdmin_deinited(audiobusio_pdmin_obj_t *self) { return self->clock_pin == NULL; } -void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) { +void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t *self) { if (common_hal_audiobusio_pdmin_deinited(self)) { return; } @@ -264,24 +266,24 @@ void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) { self->data_pin = NULL; } -uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t* self) { +uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t *self) { return self->bit_depth; } -uint32_t common_hal_audiobusio_pdmin_get_sample_rate(audiobusio_pdmin_obj_t* self) { +uint32_t common_hal_audiobusio_pdmin_get_sample_rate(audiobusio_pdmin_obj_t *self) { return self->sample_rate; } -static void setup_dma(audiobusio_pdmin_obj_t* self, uint32_t length, - DmacDescriptor* descriptor, - DmacDescriptor* second_descriptor, - uint32_t words_per_buffer, uint8_t words_per_sample, - uint32_t* first_buffer, uint32_t* second_buffer) { +static void setup_dma(audiobusio_pdmin_obj_t *self, uint32_t length, + DmacDescriptor *descriptor, + DmacDescriptor *second_descriptor, + uint32_t words_per_buffer, uint8_t words_per_sample, + uint32_t *first_buffer, uint32_t *second_buffer) { descriptor->BTCTRL.reg = DMAC_BTCTRL_VALID | - DMAC_BTCTRL_BLOCKACT_NOACT | - DMAC_BTCTRL_EVOSEL_BLOCK | - DMAC_BTCTRL_DSTINC | - DMAC_BTCTRL_BEATSIZE_WORD; + DMAC_BTCTRL_BLOCKACT_NOACT | + DMAC_BTCTRL_EVOSEL_BLOCK | + DMAC_BTCTRL_DSTINC | + DMAC_BTCTRL_BEATSIZE_WORD; // Block transfer count is the number of beats per block (aka descriptor). // In this case there are two bytes per beat so divide the length by two. @@ -291,7 +293,7 @@ static void setup_dma(audiobusio_pdmin_obj_t* self, uint32_t length, } descriptor->BTCNT.reg = block_transfer_count; - descriptor->DSTADDR.reg = ((uint32_t) first_buffer + sizeof(uint32_t) * block_transfer_count); + descriptor->DSTADDR.reg = ((uint32_t)first_buffer + sizeof(uint32_t) * block_transfer_count); descriptor->DESCADDR.reg = 0; if (length * words_per_sample > words_per_buffer) { descriptor->DESCADDR.reg = ((uint32_t)second_descriptor); @@ -314,7 +316,7 @@ static void setup_dma(audiobusio_pdmin_obj_t* self, uint32_t length, block_transfer_count = length * words_per_sample - words_per_buffer; second_descriptor->DESCADDR.reg = 0; } - second_descriptor->DSTADDR.reg = ((uint32_t) second_buffer + sizeof(uint32_t) * block_transfer_count); + second_descriptor->DSTADDR.reg = ((uint32_t)second_buffer + sizeof(uint32_t) * block_transfer_count); second_descriptor->BTCNT.reg = block_transfer_count; #ifdef SAMD21 @@ -324,10 +326,10 @@ static void setup_dma(audiobusio_pdmin_obj_t* self, uint32_t length, second_descriptor->SRCADDR.reg = (uint32_t)&I2S->RXDATA; #endif second_descriptor->BTCTRL.reg = DMAC_BTCTRL_VALID | - DMAC_BTCTRL_BLOCKACT_NOACT | - DMAC_BTCTRL_EVOSEL_BLOCK | - DMAC_BTCTRL_DSTINC | - DMAC_BTCTRL_BEATSIZE_WORD; + DMAC_BTCTRL_BLOCKACT_NOACT | + DMAC_BTCTRL_EVOSEL_BLOCK | + DMAC_BTCTRL_DSTINC | + DMAC_BTCTRL_BEATSIZE_WORD; } } @@ -341,7 +343,7 @@ static void setup_dma(audiobusio_pdmin_obj_t* self, uint32_t length, // higher sample rate than specified. Then after the audio is // recorded, a more expensive filter non-real-time filter could be // used to down-sample and low-pass. -const uint16_t sinc_filter [OVERSAMPLING] = { +const uint16_t sinc_filter[OVERSAMPLING] = { 0, 2, 9, 21, 39, 63, 94, 132, 179, 236, 302, 379, 467, 565, 674, 792, 920, 1055, 1196, 1341, 1487, 1633, 1776, 1913, @@ -353,26 +355,26 @@ const uint16_t sinc_filter [OVERSAMPLING] = { }; #ifdef SAMD21 -#define REPEAT_16_TIMES(X) do { for(uint8_t j=0; j<4; j++) { X X X X } } while (0) +#define REPEAT_16_TIMES(X) do { for (uint8_t j = 0; j < 4; j++) { X X X X } } while (0) #else -#define REPEAT_16_TIMES(X) do { X X X X X X X X X X X X X X X X } while(0) +#define REPEAT_16_TIMES(X) do { X X X X X X X X X X X X X X X X } while (0) #endif static uint16_t filter_sample(uint32_t pdm_samples[4]) { uint16_t running_sum = 0; const uint16_t *filter_ptr = sinc_filter; - for (uint8_t i = 0; i < OVERSAMPLING/16; i++) { + for (uint8_t i = 0; i < OVERSAMPLING / 16; i++) { // The sample is 16-bits right channel in the upper two bytes and 16-bits left channel // in the lower two bytes. // We just ignore the upper bits uint32_t pdm_sample = pdm_samples[i]; - REPEAT_16_TIMES( { - if (pdm_sample & 0x8000) { - running_sum += *filter_ptr; - } - filter_ptr++; - pdm_sample <<= 1; + REPEAT_16_TIMES({ + if (pdm_sample & 0x8000) { + running_sum += *filter_ptr; } + filter_ptr++; + pdm_sample <<= 1; + } ); } return running_sum; @@ -380,8 +382,8 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) { // output_buffer may be a byte buffer or a halfword buffer. // output_buffer_length is the number of slots, not the number of bytes. -uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* self, - uint16_t* output_buffer, uint32_t output_buffer_length) { +uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t *self, + uint16_t *output_buffer, uint32_t output_buffer_length) { uint8_t dma_channel = dma_allocate_channel(); pdmin_event_channel = find_sync_event_channel_raise(); pdmin_dma_block_done = false; @@ -399,7 +401,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se COMPILER_ALIGNED(16) DmacDescriptor second_descriptor; setup_dma(self, output_buffer_length, dma_descriptor(dma_channel), &second_descriptor, - words_per_buffer, words_per_sample, first_buffer, second_buffer); + words_per_buffer, words_per_sample, first_buffer, second_buffer); uint8_t trigger_source = I2S_DMAC_ID_RX_0; #ifdef SAMD21 @@ -444,7 +446,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se // Flip back and forth between processing the first and second buffers. uint32_t *buffer = first_buffer; - DmacDescriptor* descriptor = dma_descriptor(dma_channel); + DmacDescriptor *descriptor = dma_descriptor(dma_channel); if (buffers_processed % 2 == 1) { buffer = second_buffer; descriptor = &second_descriptor; @@ -459,7 +461,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se uint16_t value = filter_sample(buffer + i * words_per_sample); if (self->bit_depth == 8) { // Truncate to 8 bits. - ((uint8_t*) output_buffer)[values_output] = value >> 8; + ((uint8_t *)output_buffer)[values_output] = value >> 8; } else { output_buffer[values_output] = value; } @@ -471,7 +473,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se // Compute how many more samples we need, and if the last buffer is the last // set of samples needed, adjust the DMA count to only fetch as necessary. remaining_samples_needed = output_buffer_length - values_output; - if (remaining_samples_needed <= samples_per_buffer*2 && + if (remaining_samples_needed <= samples_per_buffer * 2 && remaining_samples_needed > samples_per_buffer) { // Adjust the DMA settings for the current buffer, which will be processed // after the other buffer, which is now receiving samples via DMA. @@ -484,7 +486,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se // Set up to receive the last set of samples (don't include the alternate buffer, now in use). uint32_t samples_needed_for_last_buffer = remaining_samples_needed - samples_per_buffer; descriptor->BTCNT.reg = samples_needed_for_last_buffer * words_per_sample; - descriptor->DSTADDR.reg = ((uint32_t) buffer) + descriptor->DSTADDR.reg = ((uint32_t)buffer) + samples_needed_for_last_buffer * words_per_sample * sizeof(buffer[0]); // Break chain to alternate buffer. diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index 1e1eb80e9c..a565a77042 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -35,7 +35,7 @@ #include "shared-bindings/audioio/AudioOut.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index c539cc3abc..2ca193c99f 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -35,7 +35,7 @@ #include "samd/sercom.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "common-hal/busio/__init__.h" diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c index fde15824c8..3bb0cabf9e 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.c +++ b/ports/atmel-samd/common-hal/busio/SPI.c @@ -33,6 +33,7 @@ #include "peripheral_clk_config.h" #include "supervisor/board.h" +#include "supervisor/shared/translate/translate.h" #include "common-hal/busio/__init__.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index ce471f8c1a..3a9b628e0b 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -34,7 +34,7 @@ #include "py/mperrno.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/tick.h" #include "hpl_sercom_config.h" diff --git a/ports/atmel-samd/common-hal/countio/Counter.c b/ports/atmel-samd/common-hal/countio/Counter.c index c68b9e18ef..e3694615ab 100644 --- a/ports/atmel-samd/common-hal/countio/Counter.c +++ b/ports/atmel-samd/common-hal/countio/Counter.c @@ -7,7 +7,7 @@ #include "eic_handler.h" #include "samd/external_interrupts.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_countio_counter_construct(countio_counter_obj_t *self, const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { diff --git a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c index dee927ce88..8358ac4d87 100644 --- a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +++ b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c @@ -34,7 +34,7 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" digitalinout_result_t common_hal_digitalio_digitalinout_construct( digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin) { diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index 4a6a620603..22200c5d1c 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -48,7 +48,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/time/__init__.h" #include "supervisor/shared/tick.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #ifdef SAMD21 #include "hpl/gclk/hpl_gclk_base.h" diff --git a/ports/atmel-samd/common-hal/microcontroller/Pin.c b/ports/atmel-samd/common-hal/microcontroller/Pin.c index 1460ece59e..b36286e5f2 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Pin.c +++ b/ports/atmel-samd/common-hal/microcontroller/Pin.c @@ -27,6 +27,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index 6856f4a48b..60b35a2c5c 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -36,7 +36,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" #include "supervisor/shared/safe_mode.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_mcu_delay_us(uint32_t delay) { mp_hal_delay_us(delay); diff --git a/ports/atmel-samd/common-hal/ps2io/Ps2.c b/ports/atmel-samd/common-hal/ps2io/Ps2.c index ad7b110803..43f40aa48e 100644 --- a/ports/atmel-samd/common-hal/ps2io/Ps2.c +++ b/ports/atmel-samd/common-hal/ps2io/Ps2.c @@ -43,7 +43,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/ps2io/Ps2.h" #include "supervisor/port.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define STATE_IDLE 0 #define STATE_RECV 1 diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c index 8cc455c958..8bf889bed3 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -44,7 +44,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/pulseio/PulseIn.h" #include "supervisor/shared/tick.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/port.h" // This timer is shared amongst all PulseIn objects as a higher resolution clock. diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c index b0407a1136..dc98e4bd18 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c @@ -36,7 +36,7 @@ #include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/pulseio/PulseOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "timer_handler.h" // This timer is shared amongst all PulseOut objects under the assumption that diff --git a/ports/atmel-samd/common-hal/pwmio/PWMOut.c b/ports/atmel-samd/common-hal/pwmio/PWMOut.c index 854e70094f..c6e9e07304 100644 --- a/ports/atmel-samd/common-hal/pwmio/PWMOut.c +++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.c @@ -38,7 +38,7 @@ #include "hal/utils/include/utils_repeat_macro.h" #include "samd/pins.h" #include "samd/timers.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #undef ENABLE diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c index 856fe04dbc..d253e0967e 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -33,7 +33,7 @@ #include "eic_handler.h" #include "samd/external_interrupts.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self, const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b) { diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c index 455f176763..0ebb61e11b 100644 --- a/ports/atmel-samd/common-hal/rtc/RTC.c +++ b/ports/atmel-samd/common-hal/rtc/RTC.c @@ -37,7 +37,7 @@ #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/rtc/RTC.h" #include "supervisor/port.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // This is the time in seconds since 2000 that the RTC was started. // TODO: Change the offset to ticks so that it can be a subsecond adjustment. diff --git a/ports/atmel-samd/common-hal/sdioio/SDCard.c b/ports/atmel-samd/common-hal/sdioio/SDCard.c index 10ccb63a55..7ce8a1e1b1 100644 --- a/ports/atmel-samd/common-hal/sdioio/SDCard.c +++ b/ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -32,7 +32,7 @@ #include "shared-bindings/sdioio/SDCard.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "genhdr/sdiodata.h" diff --git a/ports/atmel-samd/common-hal/touchio/TouchIn.c b/ports/atmel-samd/common-hal/touchio/TouchIn.c index 1c0062d52a..c3fae041fb 100644 --- a/ports/atmel-samd/common-hal/touchio/TouchIn.c +++ b/ports/atmel-samd/common-hal/touchio/TouchIn.c @@ -33,7 +33,7 @@ #include "py/mphal.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/touchio/TouchIn.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Native touchio only exists for SAMD21 #ifdef SAMD21 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 9cd5b39d70..38abbb81f6 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -78,6 +78,8 @@ endif SUPEROPT_GC = 0 SUPEROPT_VM = 0 +CIRCUITPY_LTO = one + ifeq ($(CIRCUITPY_FULL_BUILD),0) # On the smallest boards, this saves about 180 bytes. On other boards, it may -increase- space used. CFLAGS_BOARD = -fweb -frename-registers @@ -94,6 +96,12 @@ ifeq ($(CHIP_FAMILY),samd51) # No native touchio on SAMD51. CIRCUITPY_TOUCHIO_USE_NATIVE = 0 +ifeq ($(CIRCUITPY_FULL_BUILD),1) +CIRCUITPY_LTO ?= balanced +else +CIRCUITPY_LTO ?= one +endif + # The ?='s allow overriding in mpconfigboard.mk. diff --git a/ports/broadcom/common-hal/digitalio/DigitalInOut.c b/ports/broadcom/common-hal/digitalio/DigitalInOut.c index 38a7cbb2b8..d8ac3472de 100644 --- a/ports/broadcom/common-hal/digitalio/DigitalInOut.c +++ b/ports/broadcom/common-hal/digitalio/DigitalInOut.c @@ -32,7 +32,7 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "peripherals/broadcom/gpio.h" diff --git a/ports/broadcom/common-hal/sdioio/SDCard.c b/ports/broadcom/common-hal/sdioio/SDCard.c index 85a84ac213..27b36041de 100644 --- a/ports/broadcom/common-hal/sdioio/SDCard.c +++ b/ports/broadcom/common-hal/sdioio/SDCard.c @@ -35,7 +35,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" #include "supervisor/port.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "peripherals/broadcom/cpu.h" #include "peripherals/broadcom/defines.h" diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 96360d06bd..acdf496edb 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -165,8 +165,6 @@ else # RISC-V is larger than xtensa so do -Os for it OPTIMIZATION_FLAGS ?= -Os endif - # TODO: Test with -flto - ### CFLAGS += -flto endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk diff --git a/ports/espressif/common-hal/analogio/AnalogIn.c b/ports/espressif/common-hal/analogio/AnalogIn.c index 4d390e615c..a81a8add22 100644 --- a/ports/espressif/common-hal/analogio/AnalogIn.c +++ b/ports/espressif/common-hal/analogio/AnalogIn.c @@ -28,7 +28,7 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "py/mperrno.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "components/driver/include/driver/adc_common.h" #include "components/esp_adc_cal/include/esp_adc_cal.h" diff --git a/ports/espressif/common-hal/analogio/AnalogOut.c b/ports/espressif/common-hal/analogio/AnalogOut.c index 2bceefc9f7..cc99d4faa1 100644 --- a/ports/espressif/common-hal/analogio/AnalogOut.c +++ b/ports/espressif/common-hal/analogio/AnalogOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #ifdef CONFIG_IDF_TARGET_ESP32S2 #include "components/driver/include/driver/dac_common.h" diff --git a/ports/espressif/common-hal/audiobusio/I2SOut.c b/ports/espressif/common-hal/audiobusio/I2SOut.c index 6548f46071..440151e881 100644 --- a/ports/espressif/common-hal/audiobusio/I2SOut.c +++ b/ports/espressif/common-hal/audiobusio/I2SOut.c @@ -42,7 +42,7 @@ #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "driver/i2s.h" diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index 23906fe2d2..92bd4fb157 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -32,7 +32,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) { diff --git a/ports/espressif/common-hal/busio/UART.c b/ports/espressif/common-hal/busio/UART.c index 27323fecf4..7322abc8ef 100644 --- a/ports/espressif/common-hal/busio/UART.c +++ b/ports/espressif/common-hal/busio/UART.c @@ -38,7 +38,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "supervisor/port.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/tick.h" uint8_t never_reset_uart_mask = 0; diff --git a/ports/espressif/common-hal/countio/Counter.c b/ports/espressif/common-hal/countio/Counter.c index d18196051f..bdfc44522c 100644 --- a/ports/espressif/common-hal/countio/Counter.c +++ b/ports/espressif/common-hal/countio/Counter.c @@ -29,7 +29,7 @@ #include "common-hal/microcontroller/Pin.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_countio_counter_construct(countio_counter_obj_t *self, const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { diff --git a/ports/espressif/common-hal/digitalio/DigitalInOut.c b/ports/espressif/common-hal/digitalio/DigitalInOut.c index 1ab232b29a..a3e8f41147 100644 --- a/ports/espressif/common-hal/digitalio/DigitalInOut.c +++ b/ports/espressif/common-hal/digitalio/DigitalInOut.c @@ -26,7 +26,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "components/driver/include/driver/gpio.h" diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index e4782c30ab..5ceefa411f 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -33,7 +33,7 @@ #include "common-hal/microcontroller/Processor.h" #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "esp_sleep.h" #include "esp_system.h" diff --git a/ports/litex/Makefile b/ports/litex/Makefile index 6fe9e46bec..6b1e33c8d1 100644 --- a/ports/litex/Makefile +++ b/ports/litex/Makefile @@ -81,8 +81,6 @@ ifeq ($(DEBUG), 1) else CFLAGS += -DNDEBUG -ggdb3 OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions - # TODO: Test with -flto - ### CFLAGS += -flto endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk @@ -99,7 +97,7 @@ LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -W LIBS := -lgcc -lc -LDFLAGS += -flto -ffreestanding -nostartfiles -Wl,--gc-section -Wl,-Bstatic -Wl,-melf32lriscv -nostartfiles \ +LDFLAGS += -ffreestanding -nostartfiles -Wl,--gc-section -Wl,-Bstatic -Wl,-melf32lriscv -nostartfiles \ -Wl,--no-warn-mismatch \ -Wl,--build-id=none diff --git a/ports/litex/common-hal/digitalio/DigitalInOut.c b/ports/litex/common-hal/digitalio/DigitalInOut.c index 96cc95dfa6..a48d698fcb 100644 --- a/ports/litex/common-hal/digitalio/DigitalInOut.c +++ b/ports/litex/common-hal/digitalio/DigitalInOut.c @@ -27,7 +27,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "csr.h" diff --git a/ports/litex/common-hal/microcontroller/Processor.c b/ports/litex/common-hal/microcontroller/Processor.c index ff2f041876..12c3787c79 100644 --- a/ports/litex/common-hal/microcontroller/Processor.c +++ b/ports/litex/common-hal/microcontroller/Processor.c @@ -31,7 +31,7 @@ #include "common-hal/microcontroller/Processor.h" #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "csr.h" #include "generated/soc.h" diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index 4a74b8fce5..4b05c91714 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -75,7 +75,7 @@ INC += \ # NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt. -CFLAGS += -Os -ftree-vrp -DNDEBUG -ffreestanding +CFLAGS += -ftree-vrp -DNDEBUG # TinyUSB defines CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_MIDI_RX_BUFSIZE=512 -DCFG_TUD_CDC_RX_BUFSIZE=512 -DCFG_TUD_MIDI_TX_BUFSIZE=512 -DCFG_TUD_CDC_TX_BUFSIZE=512 -DCFG_TUD_MSC_BUFSIZE=1024 @@ -84,12 +84,8 @@ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX -DCFG_TUD_MIDI_RX_BUFSIZE=512 -DCFG_ # Never set -fno-inline because we use inline to move small functions into routines that must be # in RAM. If inlining is disallowed, then we may end up calling a function in flash when we cannot. ifeq ($(DEBUG), 1) - # You may want to disable -flto if it interferes with debugging. - # CFLAGS += -flto -flto-partition=none # You may want to enable these flags to make setting breakpoints easier. CFLAGS += -fno-ipa-sra -else - #CFLAGS += -flto -flto-partition=none endif CFLAGS += $(INC) -ggdb -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes @@ -105,7 +101,6 @@ CFLAGS += \ -mfloat-abi=hard \ -mfpu=fpv5-sp-d16 \ -DCPU_$(CHIP_VARIANT) \ - -DDEBUG \ -DIMXRT10XX \ -g3 -Wno-unused-parameter \ -ffunction-sections -fdata-sections -fstack-usage diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c index de807e7e5c..14e1faab09 100644 --- a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c @@ -29,7 +29,7 @@ #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c index 27753f47dc..dde7b3badd 100644 --- a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c @@ -36,7 +36,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define IOMUXC_SW_MUX_CTL_PAD_MUX_MODE_ALT5 5U diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 3ea454a2b3..8de63061ad 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -37,7 +37,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" #include "supervisor/shared/safe_mode.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define DBL_TAP_REG SNVS->LPGPR[3] diff --git a/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c index 29f72e21e4..97892b1095 100644 --- a/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c +++ b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -35,7 +35,7 @@ #include "fsl_pwm.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "periph.h" // Debug print support set to zero to enable debug printing diff --git a/ports/mimxrt10xx/common-hal/rtc/RTC.c b/ports/mimxrt10xx/common-hal/rtc/RTC.c index a58b37ae62..7ed65a3499 100644 --- a/ports/mimxrt10xx/common-hal/rtc/RTC.c +++ b/ports/mimxrt10xx/common-hal/rtc/RTC.c @@ -33,7 +33,7 @@ #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/rtc/RTC.h" #include "common-hal/rtc/RTC.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "fsl_snvs_hp.h" diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 68bc3cc41c..bbe102ffc8 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -84,14 +84,6 @@ INC += -I../../lib/mp-readline INC += -I../../lib/tinyusb/src INC += -I../../supervisor/shared/usb -ifeq ($(MCU_CHIP),nrf52833) - OPTIMIZATION_FLAGS ?= -Os -flto -flto-partition=one -else - ifeq ($(INTERNAL_FLASH_FILESYSTEM),1) - OPTIMIZATION_FLAGS ?= -Os -flto - endif -endif - #Debugging/Optimization ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c index 347426af99..b9d4b6a199 100644 --- a/ports/nrf/common-hal/analogio/AnalogIn.c +++ b/ports/nrf/common-hal/analogio/AnalogIn.c @@ -29,7 +29,7 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/microcontroller/Pin.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "nrf_saadc.h" #include "nrf_gpio.h" @@ -77,7 +77,7 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { // Something else might have used the ADC in a different way, // so we completely re-initialize it. - nrf_saadc_value_t value; + nrf_saadc_value_t value = -1; const nrf_saadc_channel_config_t config = { .resistor_p = NRF_SAADC_RESISTOR_DISABLED, diff --git a/ports/nrf/common-hal/analogio/AnalogOut.c b/ports/nrf/common-hal/analogio/AnalogOut.c index 4efd56795a..38ff935674 100644 --- a/ports/nrf/common-hal/analogio/AnalogOut.c +++ b/ports/nrf/common-hal/analogio/AnalogOut.c @@ -31,7 +31,7 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index 6728bf1e44..bc6302cb42 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -37,7 +37,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/tick.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // TODO: This should be the same size as PWMOut.c:pwms[], but there's no trivial way to accomplish that STATIC audiopwmio_pwmaudioout_obj_t *active_audio[4]; diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 6c645a512b..2bd1416f5a 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -32,7 +32,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "py/mperrno.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "nrfx_twim.h" #include "nrfx_spim.h" diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 5c08f50012..04c502a4bd 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -33,7 +33,7 @@ #include "py/mperrno.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "nrfx_uarte.h" #include "nrf_gpio.h" diff --git a/ports/nrf/common-hal/digitalio/DigitalInOut.c b/ports/nrf/common-hal/digitalio/DigitalInOut.c index b42d7dc704..95e488f3b7 100644 --- a/ports/nrf/common-hal/digitalio/DigitalInOut.c +++ b/ports/nrf/common-hal/digitalio/DigitalInOut.c @@ -26,7 +26,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "nrf_gpio.h" diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index fa2dfad6a4..2fca3a3c0a 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -31,7 +31,6 @@ #include "common-hal/alarm/__init__.h" #include "shared-bindings/microcontroller/ResetReason.h" -#include "supervisor/shared/translate.h" #include "nrfx_saadc.h" #ifdef BLUETOOTH_SD @@ -72,7 +71,7 @@ uint32_t common_hal_mcu_processor_get_frequency(void) { } float common_hal_mcu_processor_get_voltage(void) { - nrf_saadc_value_t value; + nrf_saadc_value_t value = -1; const nrf_saadc_channel_config_t config = { .resistor_p = NRF_SAADC_RESISTOR_DISABLED, diff --git a/ports/nrf/common-hal/pulseio/PulseOut.c b/ports/nrf/common-hal/pulseio/PulseOut.c index 1c3c317a05..2f822b4184 100644 --- a/ports/nrf/common-hal/pulseio/PulseOut.c +++ b/ports/nrf/common-hal/pulseio/PulseOut.c @@ -35,7 +35,7 @@ #include "py/runtime.h" #include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pwmio/PWMOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // A single timer is shared amongst all PulseOut objects under the assumption that // the code is single threaded. diff --git a/ports/nrf/common-hal/pwmio/PWMOut.c b/ports/nrf/common-hal/pwmio/PWMOut.c index 619acdfab6..1bd38e7a6e 100644 --- a/ports/nrf/common-hal/pwmio/PWMOut.c +++ b/ports/nrf/common-hal/pwmio/PWMOut.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "common-hal/pwmio/PWMOut.h" #include "shared-bindings/pwmio/PWMOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "nrf_gpio.h" diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c index ecc687b5e9..29d308eccc 100644 --- a/ports/nrf/common-hal/rtc/RTC.c +++ b/ports/nrf/common-hal/rtc/RTC.c @@ -33,7 +33,7 @@ #include "common-hal/rtc/RTC.h" #include "shared-bindings/rtc/RTC.h" #include "supervisor/port.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // This is the time in seconds since 2000 that the RTC was started. __attribute__((section(".uninitialized"))) static uint32_t rtc_offset[3]; diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 6cbbce1846..4bb4f3dfb4 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -71,6 +71,11 @@ NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 # Defined here because system_nrf52840.c doesn't #include any of our own include files. CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS +ifeq ($(INTERNAL_FLASH_FILESYSTEM),1) + OPTIMIZATION_FLAGS ?= -Os + CIRCUITPY_LTO=balanced +endif + else ifeq ($(MCU_CHIP),nrf52833) MCU_SERIES = m4 @@ -87,5 +92,8 @@ SOFTDEV_VERSION ?= 7.0.1 BOOT_SETTING_ADDR = 0x7F000 NRF_DEFINES += -DNRF52833_XXAA -DNRF52833 +OPTIMIZATION_FLAGS ?= -Os + +CIRCUITPY_LTO=one endif endif diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 2c7efb09d8..1203f4abac 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -40,7 +40,7 @@ #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class StateMachine: diff --git a/ports/raspberrypi/common-hal/analogio/AnalogIn.c b/ports/raspberrypi/common-hal/analogio/AnalogIn.c index d164d9a18b..b827068e1a 100644 --- a/ports/raspberrypi/common-hal/analogio/AnalogIn.c +++ b/ports/raspberrypi/common-hal/analogio/AnalogIn.c @@ -28,7 +28,7 @@ #include "shared-bindings/analogio/AnalogIn.h" #include "shared-bindings/microcontroller/Pin.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "src/rp2_common/hardware_adc/include/hardware/adc.h" diff --git a/ports/raspberrypi/common-hal/analogio/AnalogOut.c b/ports/raspberrypi/common-hal/analogio/AnalogOut.c index 4efd56795a..38ff935674 100644 --- a/ports/raspberrypi/common-hal/analogio/AnalogOut.c +++ b/ports/raspberrypi/common-hal/analogio/AnalogOut.c @@ -31,7 +31,7 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); diff --git a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c index 037163472d..7db053a39d 100644 --- a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c +++ b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c @@ -37,7 +37,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/audiocore/__init__.h" #include "bindings/rp2pio/StateMachine.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" const uint16_t i2s_program[] = { // ; Load the next set of samples diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index 8301f9fde4..c3aadd2bbe 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "shared-bindings/audiobusio/PDMIn.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "audio_dma.h" diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 2f09124f4b..8b5c3accec 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -39,7 +39,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "src/rp2040/hardware_structs/include/hardware/structs/dma.h" #include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" diff --git a/ports/raspberrypi/common-hal/countio/Counter.c b/ports/raspberrypi/common-hal/countio/Counter.c index 0ae773bdf3..44db126656 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.c +++ b/ports/raspberrypi/common-hal/countio/Counter.c @@ -2,7 +2,7 @@ #include "py/runtime.h" #include "py/mpstate.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/countio/Edge.h" #include "shared-bindings/digitalio/Pull.h" diff --git a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c index a8a5a6b4d9..ef431d8506 100644 --- a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c +++ b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c @@ -32,7 +32,7 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" diff --git a/ports/raspberrypi/common-hal/microcontroller/__init__.c b/ports/raspberrypi/common-hal/microcontroller/__init__.c index ed68835e71..3b656edc07 100644 --- a/ports/raspberrypi/common-hal/microcontroller/__init__.c +++ b/ports/raspberrypi/common-hal/microcontroller/__init__.c @@ -38,7 +38,7 @@ #include "supervisor/filesystem.h" #include "supervisor/port.h" #include "supervisor/shared/safe_mode.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "src/rp2040/hardware_structs/include/hardware/structs/sio.h" #include "src/rp2_common/hardware_sync/include/hardware/sync.h" diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index 71633fcef7..33e6b0d89c 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -32,7 +32,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/pulseio/PulseIn.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "bindings/rp2pio/StateMachine.h" #include "common-hal/pulseio/PulseIn.h" diff --git a/ports/raspberrypi/common-hal/pulseio/PulseOut.c b/ports/raspberrypi/common-hal/pulseio/PulseOut.c index 7704fdff6f..881e003579 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseOut.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/microcontroller/__init__.h" #include "common-hal/pwmio/PWMOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "src/rp2040/hardware_structs/include/hardware/structs/pwm.h" #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" diff --git a/ports/raspberrypi/common-hal/pwmio/PWMOut.c b/ports/raspberrypi/common-hal/pwmio/PWMOut.c index 958e848b9f..e6f88f8894 100644 --- a/ports/raspberrypi/common-hal/pwmio/PWMOut.c +++ b/ports/raspberrypi/common-hal/pwmio/PWMOut.c @@ -32,7 +32,7 @@ #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/microcontroller/Processor.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "src/rp2040/hardware_regs/include/hardware/platform_defs.h" #include "src/rp2_common/hardware_clocks/include/hardware/clocks.h" diff --git a/ports/stm/Makefile b/ports/stm/Makefile index 5eeff2c80a..afde51bdc0 100755 --- a/ports/stm/Makefile +++ b/ports/stm/Makefile @@ -88,8 +88,6 @@ else CFLAGS += -DNDEBUG OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions CFLAGS += -ggdb3 - # TODO: Test with -flto - # CFLAGS += -flto endif # to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk diff --git a/ports/stm/common-hal/analogio/AnalogIn.c b/ports/stm/common-hal/analogio/AnalogIn.c index 9ec93ccc84..7bed932c71 100644 --- a/ports/stm/common-hal/analogio/AnalogIn.c +++ b/ports/stm/common-hal/analogio/AnalogIn.c @@ -27,7 +27,7 @@ #include "common-hal/analogio/AnalogIn.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/common-hal/analogio/AnalogOut.c b/ports/stm/common-hal/analogio/AnalogOut.c index b2cdd50153..3c2860c9ad 100644 --- a/ports/stm/common-hal/analogio/AnalogOut.c +++ b/ports/stm/common-hal/analogio/AnalogOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/microcontroller/Pin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index 3ff437c803..4faa5ca2ef 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/microcontroller/Pin.h" // I2C timing specs for the H7 and F7 diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index f772cdeec0..1daa29a923 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "supervisor/board.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/microcontroller/Pin.h" // Note that any bugs introduced in this file can cause crashes at startup diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index d3fdb83c88..171e915dd9 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -35,7 +35,7 @@ #include "py/mperrno.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define ALL_UARTS 0xFFFF diff --git a/ports/stm/common-hal/digitalio/DigitalInOut.c b/ports/stm/common-hal/digitalio/DigitalInOut.c index 39c72b73c9..3a0e27943b 100644 --- a/ports/stm/common-hal/digitalio/DigitalInOut.c +++ b/ports/stm/common-hal/digitalio/DigitalInOut.c @@ -28,7 +28,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/Pin.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // The HAL is sparse on obtaining register information, so we use the LLs here. #if (CPY_STM32H7) diff --git a/ports/stm/common-hal/microcontroller/Processor.c b/ports/stm/common-hal/microcontroller/Processor.c index 13c661a60a..67cf9a73e4 100644 --- a/ports/stm/common-hal/microcontroller/Processor.c +++ b/ports/stm/common-hal/microcontroller/Processor.c @@ -32,7 +32,7 @@ #endif #include "common-hal/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include STM32_HAL_H diff --git a/ports/stm/common-hal/pulseio/PulseOut.c b/ports/stm/common-hal/pulseio/PulseOut.c index fe3caa08b2..7725d8cdde 100644 --- a/ports/stm/common-hal/pulseio/PulseOut.c +++ b/ports/stm/common-hal/pulseio/PulseOut.c @@ -33,7 +33,7 @@ #include "py/runtime.h" #include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pwmio/PWMOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include STM32_HAL_H #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/common-hal/pwmio/PWMOut.c b/ports/stm/common-hal/pwmio/PWMOut.c index 6710f43f7d..45f00b901b 100644 --- a/ports/stm/common-hal/pwmio/PWMOut.c +++ b/ports/stm/common-hal/pwmio/PWMOut.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #include "common-hal/pwmio/PWMOut.h" #include "shared-bindings/pwmio/PWMOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/microcontroller/__init__.h" #include STM32_HAL_H diff --git a/ports/stm/common-hal/sdioio/SDCard.c b/ports/stm/common-hal/sdioio/SDCard.c index 40e6eddae1..8eeae2781d 100644 --- a/ports/stm/common-hal/sdioio/SDCard.c +++ b/ports/stm/common-hal/sdioio/SDCard.c @@ -32,7 +32,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/util.h" #include "supervisor/board.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/peripherals/timers.c b/ports/stm/peripherals/timers.c index f0054648fc..371b8f414b 100644 --- a/ports/stm/peripherals/timers.c +++ b/ports/stm/peripherals/timers.c @@ -29,7 +29,7 @@ #include "py/gc.h" #include "py/obj.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/unix/modffi.c b/ports/unix/modffi.c index d1966c51f0..d8b63b571e 100644 --- a/ports/unix/modffi.c +++ b/ports/unix/modffi.c @@ -38,7 +38,7 @@ #include "py/objint.h" #include "py/gc.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" /* * modffi uses character codes to encode a value type, based on "struct" diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c index 04ff325eef..987c70b26e 100644 --- a/ports/unix/modmachine.c +++ b/ports/unix/modmachine.c @@ -36,7 +36,7 @@ #include "extmod/machine_signal.h" #include "extmod/machine_pulse.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PLAT_DEV_MEM #include diff --git a/py/argcheck.c b/py/argcheck.c index 592b35940e..cabfaeeaae 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -29,7 +29,7 @@ #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) { // TODO maybe take the function name as an argument so we can print nicer error messages diff --git a/py/bc.c b/py/bc.c index 33b94c4a9f..e1645dbff0 100644 --- a/py/bc.c +++ b/py/bc.c @@ -33,7 +33,7 @@ #include "py/bc0.h" #include "py/bc.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) diff --git a/py/binary.c b/py/binary.c index 06f0157567..439993c0f7 100644 --- a/py/binary.c +++ b/py/binary.c @@ -36,7 +36,7 @@ #include "py/objint.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Helpers to work with binary-encoded data diff --git a/py/builtinevex.c b/py/builtinevex.c index a96a3a5344..46d4a1277a 100644 --- a/py/builtinevex.c +++ b/py/builtinevex.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "py/builtin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_COMPILE diff --git a/py/builtinhelp.c b/py/builtinhelp.c index 7411c57aae..86632f6dde 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -32,6 +32,8 @@ #include "py/mpconfig.h" #include "py/objmodule.h" +#include "supervisor/shared/translate/translate.h" + #if MICROPY_PY_BUILTINS_HELP const char mp_help_default_text[] = diff --git a/py/builtinimport.c b/py/builtinimport.c index d938cde7ea..92f3150306 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -39,7 +39,7 @@ #include "py/builtin.h" #include "py/frozenmod.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 2514cbaa2b..681eae779b 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -51,8 +51,7 @@ BASE_CFLAGS = \ -DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \ -DCIRCUITPY_CANARY_WORD=0xADAF00 \ -DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \ - -DCIRCUITPY_BOARD_ID="\"$(BOARD)\"" \ - --param max-inline-insns-single=500 + -DCIRCUITPY_BOARD_ID="\"$(BOARD)\"" # Use these flags to debug build times and header includes. # -ftime-report @@ -67,6 +66,13 @@ else CFLAGS += -DCIRCUITPY_DEBUG=0 endif +CIRCUITPY_LTO ?= 0 +ifneq ($(CIRCUITPY_LTO),0) +CFLAGS += -DCIRCUITPY_LTO=1 -flto=auto -flto-partition=$(CIRCUITPY_LTO) +else +CFLAGS += -DCIRCUITPY_LTO=0 +endif + ### # Handle frozen modules. @@ -756,3 +762,6 @@ endif check-release-needs-clean-build: @echo "RELEASE_NEEDS_CLEAN_BUILD = $(RELEASE_NEEDS_CLEAN_BUILD)" + +# Ignore these errors +$(BUILD)/lib/libm/kf_rem_pio2.o: CFLAGS += -Wno-maybe-uninitialized diff --git a/py/compile.c b/py/compile.c index e5f341a656..63f96f6085 100644 --- a/py/compile.c +++ b/py/compile.c @@ -37,7 +37,7 @@ #include "py/asmbase.h" #include "py/persistentcode.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_ENABLE_COMPILER @@ -92,7 +92,7 @@ typedef enum { #define NATIVE_EMITTER(f) emit_native_table[mp_dynamic_compiler.native_arch]->emit_##f #define NATIVE_EMITTER_TABLE emit_native_table[mp_dynamic_compiler.native_arch] -STATIC const emit_method_table_t *emit_native_table[] = { +STATIC const emit_method_table_t * emit_native_table[] = { NULL, &emit_native_x86_method_table, &emit_native_x64_method_table, @@ -131,7 +131,7 @@ STATIC const emit_method_table_t *emit_native_table[] = { #define ASM_EMITTER(f) emit_asm_table[mp_dynamic_compiler.native_arch]->asm_##f #define ASM_EMITTER_TABLE emit_asm_table[mp_dynamic_compiler.native_arch] -STATIC const emit_inline_asm_method_table_t *emit_asm_table[] = { +STATIC const emit_inline_asm_method_table_t * emit_asm_table[] = { NULL, NULL, NULL, @@ -3527,7 +3527,7 @@ mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_f switch (s->emit_options) { - #if MICROPY_EMIT_NATIVE + #if MICROPY_EMIT_NATIVE case MP_EMIT_OPT_NATIVE_PYTHON: case MP_EMIT_OPT_VIPER: if (emit_native == NULL) { @@ -3536,7 +3536,7 @@ mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_f comp->emit_method_table = NATIVE_EMITTER_TABLE; comp->emit = emit_native; break; - #endif // MICROPY_EMIT_NATIVE + #endif // MICROPY_EMIT_NATIVE default: comp->emit = emit_bc; diff --git a/py/enum.c b/py/enum.c index 4728c7f11d..681c3b3103 100644 --- a/py/enum.c +++ b/py/enum.c @@ -27,6 +27,8 @@ #include "py/enum.h" #include "py/runtime.h" +#include "supervisor/shared/translate/translate.h" + mp_obj_t cp_enum_find(const mp_obj_type_t *type, int value) { const mp_obj_dict_t *dict = type->locals_dict; for (size_t i = 0; i < dict->map.used; i++) { diff --git a/py/lexer.c b/py/lexer.c index 196f9a2644..0d6de0d522 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -32,7 +32,7 @@ #include "py/lexer.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_ENABLE_COMPILER diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 74ad78c47d..dada7e8e59 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -4,7 +4,7 @@ Process raw qstr file and output qstr data with length, hash and data bytes. This script works with Python 2.7, 3.3 and 3.4. For documentation about the format of compressed translated strings, see -supervisor/shared/translate.h +supervisor/shared/translate/translate.h """ from __future__ import print_function diff --git a/py/modbuiltins.c b/py/modbuiltins.c index ebdbd52dff..91712812bc 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -35,7 +35,7 @@ #include "py/builtin.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT #include diff --git a/py/modmath.c b/py/modmath.c index 103310db5e..167d46d02b 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -27,7 +27,7 @@ #include "py/builtin.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/py/modmicropython.c b/py/modmicropython.c index 0465a4eef8..42c84e5292 100644 --- a/py/modmicropython.c +++ b/py/modmicropython.c @@ -32,7 +32,7 @@ #include "py/gc.h" #include "py/mphal.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Various builtins specific to MicroPython runtime, // living in micropython module diff --git a/py/modstruct.c b/py/modstruct.c index c0b0fb7890..17dfc548ab 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -33,7 +33,7 @@ #include "py/objtuple.h" #include "py/binary.h" #include "py/parsenum.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_STRUCT diff --git a/py/modthread.c b/py/modthread.c index 333d750a36..a3960cddcb 100644 --- a/py/modthread.c +++ b/py/modthread.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "py/stackctrl.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_THREAD diff --git a/py/moduerrno.c b/py/moduerrno.c index 743be0b85d..0ac0503ccc 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -30,7 +30,7 @@ #include "py/obj.h" #include "py/mperrno.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // This list can be defined per port in mpconfigport.h to tailor it to a // specific port's needs. If it's not defined then we provide a default. diff --git a/py/obj.c b/py/obj.c index cc7f9006e8..da609aa8ce 100644 --- a/py/obj.c +++ b/py/obj.c @@ -41,7 +41,7 @@ #include "supervisor/linker.h" #include "supervisor/shared/stack.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_t o_in) { #if MICROPY_OBJ_IMMEDIATE_OBJS && MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A diff --git a/py/obj.h b/py/obj.h index 5f8f71ba0b..8f38a4c7c0 100644 --- a/py/obj.h +++ b/py/obj.h @@ -34,7 +34,7 @@ #include "py/mpprint.h" #include "py/runtime0.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/compressed_string.h" // This is the definition of the opaque MicroPython object type. // All concrete objects have an encoding within this type and the diff --git a/py/objarray.c b/py/objarray.c index b71687fb35..a66a73a5ac 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -34,7 +34,7 @@ #include "py/objstr.h" #include "py/objarray.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW diff --git a/py/objcomplex.c b/py/objcomplex.c index b37b059d59..f205249bb4 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -31,7 +31,7 @@ #include "py/parsenum.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_COMPLEX diff --git a/py/objdeque.c b/py/objdeque.c index 2d29d71e3b..59c4c709fc 100644 --- a/py/objdeque.c +++ b/py/objdeque.c @@ -28,7 +28,7 @@ #include #include "py/mpconfig.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_COLLECTIONS_DEQUE diff --git a/py/objdict.c b/py/objdict.c index 5f233741fa..306205d12f 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -34,7 +34,7 @@ #include "py/objstr.h" #include "supervisor/linker.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" const mp_obj_dict_t mp_const_empty_dict_obj = { .base = { .type = &mp_type_dict }, diff --git a/py/objexcept.c b/py/objexcept.c index fc0787631f..230f9d11ba 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -39,7 +39,7 @@ #include "py/gc.h" #include "py/mperrno.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Number of items per traceback entry (file, line, block) #define TRACEBACK_ENTRY_LEN (3) diff --git a/py/objfloat.c b/py/objfloat.c index 6d1d10188c..f8261df933 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -32,7 +32,7 @@ #include "py/parsenum.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT diff --git a/py/objgenerator.c b/py/objgenerator.c index c63ea6b816..b18101cfa1 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -35,7 +35,7 @@ #include "py/objfun.h" #include "py/stackctrl.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Instance of GeneratorExit exception - needed by generator.close() const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, (mp_obj_traceback_t *)&mp_const_empty_traceback_obj}; diff --git a/py/objint.c b/py/objint.c index 50bcbf56f8..98178e7ffa 100644 --- a/py/objint.c +++ b/py/objint.c @@ -35,7 +35,7 @@ #include "py/runtime.h" #include "py/binary.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT #include diff --git a/py/objint_longlong.c b/py/objint_longlong.c index 368c74ec1d..67ec844f47 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -32,7 +32,7 @@ #include "py/objint.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT #include diff --git a/py/objint_mpz.c b/py/objint_mpz.c index b804ce28af..fd74803fe7 100644 --- a/py/objint_mpz.c +++ b/py/objint_mpz.c @@ -33,7 +33,7 @@ #include "py/objint.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT #include diff --git a/py/objlist.c b/py/objlist.c index 9d1949b7dc..434bca7d0a 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "py/stackctrl.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf); STATIC mp_obj_list_t *list_new(size_t n); diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index c970d1afba..60a0a31847 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -33,7 +33,7 @@ #include "py/objnamedtuple.h" #include "py/objtype.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_COLLECTIONS diff --git a/py/objobject.c b/py/objobject.c index d9c75faff9..b32e5fac0d 100644 --- a/py/objobject.c +++ b/py/objobject.c @@ -29,7 +29,7 @@ #include "py/objtype.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" typedef struct _mp_obj_object_t { mp_obj_base_t base; diff --git a/py/objrange.c b/py/objrange.c index b23ab23bd7..b0c74815dc 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -28,7 +28,7 @@ #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" /******************************************************************************/ /* range iterator */ diff --git a/py/objset.c b/py/objset.c index d7dda6ba59..237e4c2471 100644 --- a/py/objset.c +++ b/py/objset.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "py/builtin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_SET diff --git a/py/objslice.c b/py/objslice.c index 142f62fdac..3172f798c0 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -30,7 +30,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" /******************************************************************************/ /* slice object */ diff --git a/py/objstr.c b/py/objstr.c index 3d45383bb3..df735a45cd 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -35,7 +35,7 @@ #include "py/runtime.h" #include "py/stackctrl.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_STR_OP_MODULO STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_t *args, mp_obj_t dict); diff --git a/py/objstringio.c b/py/objstringio.c index 336a041baf..c6d22d6c89 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -33,7 +33,7 @@ #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_IO diff --git a/py/objstrunicode.c b/py/objstrunicode.c index eb79d54991..0f26da62cf 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -32,7 +32,7 @@ #include "py/objlist.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_STR_UNICODE diff --git a/py/objtuple.c b/py/objtuple.c index 90b0773bb4..87d16905df 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "py/objtype.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" /******************************************************************************/ diff --git a/py/objtype.c b/py/objtype.c index 62ea1ed602..071065041f 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -35,7 +35,7 @@ #include "py/runtime.h" #include "supervisor/shared/stack.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) diff --git a/py/parse.c b/py/parse.c index dee662b4ec..b3be279c5b 100644 --- a/py/parse.c +++ b/py/parse.c @@ -39,7 +39,7 @@ #include "py/objstr.h" #include "py/builtin.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_ENABLE_COMPILER diff --git a/py/parsenum.c b/py/parsenum.c index bd41488204..adf2a4d84d 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -32,7 +32,7 @@ #include "py/parsenum.h" #include "py/smallint.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT #include diff --git a/py/persistentcode.c b/py/persistentcode.c index e604569fe2..787f724bf6 100644 --- a/py/persistentcode.c +++ b/py/persistentcode.c @@ -36,7 +36,7 @@ #include "py/objstr.h" #include "py/mpthread.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE diff --git a/py/proto.c b/py/proto.c index 9f110b9f9a..d70a9d2aac 100644 --- a/py/proto.c +++ b/py/proto.c @@ -28,6 +28,8 @@ #include "py/proto.h" #include "py/runtime.h" +#include "supervisor/shared/translate/translate.h" + #ifndef MICROPY_UNSAFE_PROTO const void *mp_proto_get(uint16_t name, mp_const_obj_t obj) { const mp_obj_type_t *type = mp_obj_get_type(obj); diff --git a/py/qstr.c b/py/qstr.c index 41176ec5ab..083e12d6f0 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -35,6 +35,7 @@ #include "py/runtime.h" #include "supervisor/linker.h" +#include "supervisor/shared/translate/translate.h" // NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings) // ultimately we will replace this with a static hash table of some kind diff --git a/py/runtime.c b/py/runtime.c index f2ad8728a5..7fcad7366a 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -45,7 +45,7 @@ #include "py/stackctrl.h" #include "py/gc.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) diff --git a/py/runtime.h b/py/runtime.h index dccdc2feed..a78969780b 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -33,6 +33,8 @@ #include "supervisor/linker.h" +#include "supervisor/shared/translate/translate.h" + typedef enum { MP_VM_RETURN_NORMAL, MP_VM_RETURN_YIELD, diff --git a/py/sequence.c b/py/sequence.c index ee400ccd8d..7befc85763 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -28,7 +28,7 @@ #include #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Helpers for sequence types diff --git a/py/stream.c b/py/stream.c index b12d693c62..27609043fc 100644 --- a/py/stream.c +++ b/py/stream.c @@ -31,7 +31,7 @@ #include "py/objstr.h" #include "py/stream.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // This file defines generic Python stream read/write methods which // dispatch to the underlying stream interface of an object. diff --git a/py/vm.c b/py/vm.c index 8cb01d3552..12a0f2d445 100644 --- a/py/vm.c +++ b/py/vm.c @@ -37,6 +37,7 @@ #include "py/profile.h" #include "supervisor/linker.h" +#include "supervisor/shared/translate/translate.h" // *FORMAT-OFF* diff --git a/runtime.py b/runtime.py new file mode 100644 index 0000000000..28bf98962e --- /dev/null +++ b/runtime.py @@ -0,0 +1,10 @@ +import pathlib +paths = pathlib.Path(".").glob("**/*.c") +translate_h = "#include \"supervisor/shared/translate/translate.h\"" +for p in paths: + if "esp-idf" in p: + continue + lines = p.read_text().split("\n") + if "#include \"py/runtime.h\"" in lines and translate_h in lines: + lines.remove(translate_h) + p.write_text("\n".join(lines)) diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 4015d31161..1a4356c719 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -32,7 +32,7 @@ #include "shared-bindings/util.h" #include "PewPew.h" #include "common-hal/_pew/PewPew.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PewPew: //| """This is an internal module to be used by the ``pew.py`` library from diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index c3c0aa1801..9e64a252db 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -28,7 +28,7 @@ #include "__init__.h" #include "Layer.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Layer: //| """Keep information about a single layer of graphics""" diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index d6b22171d6..48747bfd67 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -28,7 +28,7 @@ #include "__init__.h" #include "Text.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Text: //| """Keep information about a single grid of text""" diff --git a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c index 327e8e72b4..3ae5fc2a2f 100644 --- a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c @@ -36,7 +36,7 @@ #include "shared/runtime/context_manager_helpers.h" #include "py/runtime.h" #include "py/smallint.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class I2CDevice: diff --git a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c index 2c5708b831..f7cc357e91 100644 --- a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c @@ -35,7 +35,7 @@ #include "shared/runtime/buffer_helper.h" #include "shared/runtime/context_manager_helpers.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class SPIDevice: diff --git a/shared-bindings/alarm/SleepMemory.c b/shared-bindings/alarm/SleepMemory.c index 37223f1f35..b4e68c964c 100644 --- a/shared-bindings/alarm/SleepMemory.c +++ b/shared-bindings/alarm/SleepMemory.c @@ -31,7 +31,7 @@ #include "py/runtime0.h" #include "shared-bindings/alarm/SleepMemory.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class SleepMemory: //| """Store raw bytes in RAM that persists during deep sleep. diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index ff34716786..06ad77c56d 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -33,7 +33,7 @@ #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PinAlarm: //| """Trigger an alarm when a pin changes state.""" diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index ab0274afa9..0b77913c9b 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -33,7 +33,7 @@ #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE mp_obj_t MP_WEAK rtc_get_time_source_time(void) { diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 2f171c5a0f..41c9b053eb 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -34,7 +34,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class AnalogOut: //| """Output analog values (a specific voltage). diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 93c316d374..7c660abc4a 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class I2SOut: //| """Output an I2S audio signal""" diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index aa810f2930..29752a442c 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -34,7 +34,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiobusio/PDMIn.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PDMIn: //| """Record an input PDM audio stream""" diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 82c02450ba..02d4bbaa2f 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "shared-bindings/util.h" #include "shared-bindings/audiocore/RawSample.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class RawSample: //| """A raw audio sample buffer in memory""" diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 285bd7cbbe..b1c51a9746 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "shared-bindings/audiocore/WaveFile.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class WaveFile: //| """Load a wave file for audio playback diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 0b4ed7b975..75ba7b5ec5 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -34,7 +34,7 @@ #include "shared-bindings/audioio/AudioOut.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class AudioOut: //| """Output an analog audio signal""" diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 3ca6ccd5e3..47dbd94f19 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -36,7 +36,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Mixer: //| """Mixes one or more audio samples together into one sample.""" diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index f02b9521af..f7bf16fb49 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -35,7 +35,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class MixerVoice: //| """Voice objects used with Mixer diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 16efa361b8..8251b26c73 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "shared-bindings/audiomp3/MP3Decoder.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class MP3Decoder: //| """Load a mp3 file for audio playback diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 8118eb47f2..f4f3675750 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -34,7 +34,7 @@ #include "shared-bindings/audiopwmio/PWMAudioOut.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PWMAudioOut: //| """Output an analog audio signal by varying the PWM duty cycle.""" diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 67c411120b..9c0555dd5a 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -35,7 +35,7 @@ #include "shared/runtime/context_manager_helpers.h" #include "py/mperrno.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class I2C: //| """Two wire serial protocol""" diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 1f19f8c939..103dd9fbaa 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -37,7 +37,7 @@ #include "shared/runtime/context_manager_helpers.h" #include "py/mperrno.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class SPI: //| """A 3-4 wire serial protocol diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index e05e4e0546..b3afd9801d 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -34,7 +34,7 @@ #include "shared/runtime/buffer_helper.h" #include "shared/runtime/context_manager_helpers.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class I2C: //| """Two wire serial protocol""" diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index af853b84ac..eb89746d05 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -38,7 +38,7 @@ #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class SPI: diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 7a27b04aec..baa7f2cdba 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -38,7 +38,7 @@ #include "py/objtype.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define STREAM_DEBUG(...) (void)0 // #define STREAM_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index a9026fbd59..ae72b5cb55 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -41,7 +41,7 @@ #include "shared-bindings/digitalio/DriveMode.h" #include "shared-bindings/digitalio/Pull.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class DigitalInOut: //| """Digital input and output diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 4db68dda10..364be05de0 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -26,6 +26,7 @@ #include "py/runtime.h" #include "shared-bindings/digitalio/Pull.h" +#include "supervisor/shared/translate/translate.h" //| class Pull: //| """Defines the pull of a digital input pin""" diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 3af152ffdc..ef5727261c 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -34,7 +34,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Bitmap: //| """Stores values of a certain size in a 2D array diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 18b88664c0..7b33b1ec8f 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -34,7 +34,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class ColorConverter: //| """Converts one color format to another.""" diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index b19c0bac53..4b5db33928 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -37,7 +37,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| _DisplayBus = Union['FourWire', 'paralleldisplay.ParallelBus', 'I2CDisplay'] //| """:py:class:`FourWire`, :py:class:`paralleldisplay.ParallelBus` or :py:class:`I2CDisplay`""" diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 94d2978cef..81863b2a7a 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -37,7 +37,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class EPaperDisplay: //| """Manage updating an epaper display over a display bus diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 2aa80df61d..7e72169230 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -37,7 +37,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class FourWire: //| """Manage updating a display over SPI four wire protocol in the background while Python code runs. diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 75cc217af3..4a57b4a5f1 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -33,7 +33,7 @@ #include "py/objproperty.h" #include "py/objtype.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Group: //| """Manage a group of sprites and groups and how they are inter-related.""" diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index a637fc5071..86138d8a36 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -37,7 +37,7 @@ #include "shared-bindings/busio/I2C.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class I2CDisplay: //| """Manage updating a display over I2C in the background while Python code runs. diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index aa749bf7f7..02c370c3c4 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "py/objproperty.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/displayio/OnDiskBitmap.h" //| class OnDiskBitmap: diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index ad6d7c319a..171a243a95 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -34,7 +34,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Palette: //| """Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index cbfe12d551..30a51dadce 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -32,7 +32,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Shape: //| """Represents a shape made by defining boundaries that may be mirrored.""" diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index b1557a1777..d084d94be2 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -38,7 +38,7 @@ #include "shared-bindings/displayio/OnDiskBitmap.h" #include "shared-bindings/displayio/Palette.h" #include "shared-bindings/displayio/Shape.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class TileGrid: //| """A grid of tiles sourced out of one bitmap diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 5c1b976e81..02d3373797 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -34,7 +34,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| from typing_extensions import Protocol # for compat with python < 3.8 //| diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index daff2174fa..6af8f16ce8 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -38,7 +38,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class FramebufferDisplay: //| """Manage updating a display with framebuffer in RAM diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 2f6ebd06c2..b72627b19f 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/frequencyio/FrequencyIn.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class FrequencyIn: //| """Read a frequency signal diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 54dbf004ad..f5fb45cb4d 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -27,7 +27,7 @@ #include "py/builtin.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #if MICROPY_PY_BUILTINS_FLOAT diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c index fe25a1a230..45e7019912 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.c +++ b/shared-bindings/memorymonitor/AllocationAlarm.c @@ -31,7 +31,7 @@ #include "py/runtime0.h" #include "shared-bindings/memorymonitor/AllocationAlarm.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class AllocationAlarm: //| diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index 1c39fdcd92..ed8252b67a 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -31,7 +31,7 @@ #include "py/runtime0.h" #include "shared-bindings/memorymonitor/AllocationSize.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class AllocationSize: //| diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index db96519dc7..840f468e2a 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -31,7 +31,7 @@ #include "py/nlr.h" #include "py/obj.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Pin: //| """Identifies an IO pin on the microcontroller.""" diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index ff1b52eecd..067d6b0097 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -38,7 +38,7 @@ #include "py/objtype.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Processor: diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 1b14b32934..46382dc3e6 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -39,7 +39,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """Pin references and cpu functionality //| diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c index f3f8d1ab6c..8726e9a655 100644 --- a/shared-bindings/multiterminal/__init__.c +++ b/shared-bindings/multiterminal/__init__.c @@ -28,7 +28,7 @@ #include "py/obj.h" #include "py/mphal.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """Manage additional terminal sources //| diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index d0234fe451..e45e970179 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // RGB LED timing information: diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index b01430c078..936e3bcee5 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #include "py/runtime0.h" #include "shared-bindings/nvm/ByteArray.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class ByteArray: //| r"""Presents a stretch of non-volatile memory as a bytearray. diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index a8545d9079..4c249c368e 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -36,6 +36,7 @@ #include "py/objstr.h" #include "py/runtime.h" #include "shared-bindings/os/__init__.h" +#include "supervisor/shared/translate/translate.h" //| """functions that an OS normally provides //| diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c index c93f363d1a..a8b37fa956 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -35,7 +35,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class ParallelBus: //| """Manage updating a display over 8-bit parallel bus in the background while Python code runs. This diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 2ceca6b044..d84e788de5 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -34,7 +34,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/ps2io/Ps2.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Ps2: //| """Communicate with a PS/2 keyboard or mouse diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 21dfdae42c..1769f5c7a8 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/pulseio/PulseIn.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PulseIn: //| """Measure a series of active and idle pulses. This is commonly used in infrared receivers diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index ac568231b9..3de2176ffc 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -34,7 +34,7 @@ #include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PulseOut: //| """Pulse PWM "carrier" output on and off. This is commonly used in infrared remotes. The diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 524a857e64..4acb2a6a8a 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 63570fe7e7..eee574d29e 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -31,7 +31,7 @@ #include "py/obj.h" #include "py/runtime.h" #include "shared-bindings/random/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """pseudo-random numbers and choices //| diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index b07f90bd01..9e75576487 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -34,7 +34,7 @@ #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index c06ce18826..dbeb50ddf3 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -38,7 +38,7 @@ #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class SDCard: //| """SD Card Block Interface with SDIO diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 277c8343e0..baf91a35c1 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -33,7 +33,7 @@ #include "py/objnamedtuple.h" #include "py/runtime.h" #include "shared-bindings/storage/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """Storage management //| diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index c29c33c1c0..5b63a15f15 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -36,7 +36,7 @@ #include "py/parsenum.h" #include "shared-bindings/struct/__init__.h" #include "shared-module/struct/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """Manipulation of c-style data //| diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 6fcff963a6..cad8ccdeec 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -36,7 +36,7 @@ #include "supervisor/shared/reload.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/traceback.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/workflow.h" #include "shared-bindings/microcontroller/__init__.h" diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 7805c1a6a0..e27ff903c6 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "shared-bindings/util.h" #include "shared-bindings/synthio/MidiTrack.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class MidiTrack: //| """Simple square-wave MIDI synth""" diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index cdeca59164..c6fd389b12 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -35,7 +35,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "shared-bindings/fontio/BuiltinFont.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Terminal: //| """Display a character stream with a TileGrid""" diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 5b16ded0e4..096c80d382 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -34,7 +34,7 @@ #include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """time and timing related functions //| diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 23b35253cb..729cf94d5d 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -36,7 +36,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/touchio/TouchIn.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class TouchIn: //| """Read the state of a capacitive touch sensor diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 760efb6278..8a74380be3 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -33,7 +33,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Serial: //| """Receives cdc commands over USB""" diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index eabe26ad07..e23e289309 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -31,6 +31,7 @@ #include "shared-bindings/usb_cdc/__init__.h" #include "shared-bindings/usb_cdc/Serial.h" +#include "supervisor/shared/translate/translate.h" #include "py/runtime.h" diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index 3f30a6264c..f0074f9cac 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -27,6 +27,7 @@ #include "py/objproperty.h" #include "shared-bindings/usb_hid/Device.h" #include "py/runtime.h" +#include "supervisor/shared/translate/translate.h" //| class Device: //| """HID Device specification""" diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 3922ded03c..dcdf6933f7 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -31,6 +31,8 @@ #include "shared-bindings/usb_hid/__init__.h" #include "shared-bindings/usb_hid/Device.h" +#include "supervisor/shared/translate/translate.h" + //| """USB Human Interface Device //| //| The `usb_hid` module allows you to output data as a HID device.""" diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index 0056a0818a..273fa77b35 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -33,7 +33,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PortIn: //| """Receives midi commands over USB""" diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index c468401924..d5652be5d4 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -33,7 +33,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class PortOut: //| """Sends midi messages to a computer over USB""" diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index ec065d1e18..d3d5cf2626 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -32,6 +32,7 @@ #include "shared-bindings/usb_midi/__init__.h" #include "shared-bindings/usb_midi/PortIn.h" #include "shared-bindings/usb_midi/PortOut.h" +#include "supervisor/shared/translate/translate.h" #include "py/runtime.h" diff --git a/shared-bindings/util.c b/shared-bindings/util.c index c1ca01e0ad..5c5eafad4a 100644 --- a/shared-bindings/util.c +++ b/shared-bindings/util.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "shared-bindings/util.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // If so, deinit() has already been called on the object, so complain. void raise_deinited_error(void) { diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index ded1861896..f955cd2afe 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -8,7 +8,7 @@ #include "py/objproperty.h" #include "py/objtype.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Circle: //| diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index ae9d7a01ca..60a4582e5a 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -9,7 +9,7 @@ #include "py/objproperty.h" #include "py/objtype.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define VECTORIO_POLYGON_DEBUG(...) (void)0 diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 739a1ba9d1..34b9e1eabe 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -7,7 +7,7 @@ #include "py/objtype.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| class Rectangle: //| def __init__(self, pixel_shader: Union[displayio.ColorConverter, displayio.Palette], width: int, height: int, x: int, y: int) -> None: diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 6a3e192cb9..ba55cfb851 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -16,7 +16,7 @@ #include "py/objproperty.h" #include "py/objtype.h" #include "py/runtime.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // shape: The shape implementation to draw. diff --git a/shared-bindings/zlib/__init__.c b/shared-bindings/zlib/__init__.c index 65bec244e3..e3858d008d 100644 --- a/shared-bindings/zlib/__init__.c +++ b/shared-bindings/zlib/__init__.c @@ -39,7 +39,7 @@ #include "shared-bindings/zlib/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" //| """zlib decompression functionality //| diff --git a/shared-module/audiocore/WaveFile.c b/shared-module/audiocore/WaveFile.c index b4056e3f29..1b87532551 100644 --- a/shared-module/audiocore/WaveFile.c +++ b/shared-module/audiocore/WaveFile.c @@ -33,7 +33,7 @@ #include "py/runtime.h" #include "shared-module/audiocore/WaveFile.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" struct wave_format_chunk { uint16_t audio_format; diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index d0b5428a11..506ed5eff2 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -35,7 +35,7 @@ #include "py/runtime.h" #include "shared-module/audiomp3/MP3Decoder.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/background_callback.h" #include "lib/mp3/src/mp3common.h" diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c index eb897e122f..65926b8c07 100644 --- a/shared-module/bitbangio/I2C.c +++ b/shared-module/bitbangio/I2C.c @@ -32,7 +32,7 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" STATIC void delay(bitbangio_i2c_obj_t *self) { // We need to use an accurate delay to get acceptable I2C diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c index 972b085978..d740a214e7 100644 --- a/shared-module/bitbangio/SPI.c +++ b/shared-module/bitbangio/SPI.c @@ -32,7 +32,7 @@ #include "shared-bindings/bitbangio/SPI.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #define MAX_BAUDRATE (common_hal_mcu_get_clock_frequency() / 48) diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 7bd0d42339..5d08c368b5 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -27,7 +27,7 @@ #include "shared-bindings/board/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/board/__init__.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "mpconfigboard.h" #include "py/runtime.h" diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index e1b98a9f93..d32550722c 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -36,7 +36,7 @@ #include "py/runtime.h" #include "py/stream.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/msgpack/ExtType.h" #include "shared-bindings/msgpack/__init__.h" #include "shared-module/msgpack/__init__.h" diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index e36d3ec21e..8806b7c8c6 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -38,6 +38,7 @@ #include "shared-bindings/storage/__init__.h" #include "supervisor/filesystem.h" #include "supervisor/flash.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/usb.h" #if CIRCUITPY_USB_MSC diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index a0abd16408..e87321ae79 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "py/binary.h" #include "py/parsenum.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "shared-bindings/struct/__init__.h" STATIC void struct_validate_format(char fmt) { diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 13e66058c2..f92c93baa3 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -31,7 +31,7 @@ #include "shared-bindings/usb_hid/Device.h" #include "shared-module/usb_hid/__init__.h" #include "shared-module/usb_hid/Device.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/tick.h" #include "tusb.h" diff --git a/shared-module/usb_hid/__init__.c b/shared-module/usb_hid/__init__.c index 89a05c77b3..99be84542f 100644 --- a/shared-module/usb_hid/__init__.c +++ b/shared-module/usb_hid/__init__.c @@ -33,6 +33,7 @@ #include "shared-bindings/usb_hid/__init__.h" #include "shared-bindings/usb_hid/Device.h" #include "supervisor/memory.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/usb.h" static const uint8_t usb_hid_descriptor_template[] = { diff --git a/shared-module/usb_midi/PortIn.c b/shared-module/usb_midi/PortIn.c index b16b77cf97..a5c73aa256 100644 --- a/shared-module/usb_midi/PortIn.c +++ b/shared-module/usb_midi/PortIn.c @@ -26,7 +26,7 @@ #include "shared-bindings/usb_midi/PortIn.h" #include "shared-module/usb_midi/PortIn.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "tusb.h" size_t common_hal_usb_midi_portin_read(usb_midi_portin_obj_t *self, uint8_t *data, size_t len, int *errcode) { diff --git a/shared-module/usb_midi/PortOut.c b/shared-module/usb_midi/PortOut.c index 4005d8b77d..c9d229635e 100644 --- a/shared-module/usb_midi/PortOut.c +++ b/shared-module/usb_midi/PortOut.c @@ -26,7 +26,7 @@ #include "shared-bindings/usb_midi/PortOut.h" #include "shared-module/usb_midi/PortOut.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "tusb.h" size_t common_hal_usb_midi_portout_write(usb_midi_portout_obj_t *self, const uint8_t *data, size_t len, int *errcode) { diff --git a/shared-module/usb_midi/__init__.c b/shared-module/usb_midi/__init__.c index 8cac2ba8af..ed1b8a0518 100644 --- a/shared-module/usb_midi/__init__.c +++ b/shared-module/usb_midi/__init__.c @@ -34,6 +34,7 @@ #include "shared-bindings/usb_midi/PortIn.h" #include "shared-bindings/usb_midi/PortOut.h" #include "supervisor/memory.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/usb.h" #include "tusb.h" diff --git a/shared/libc/abort_.c b/shared/libc/abort_.c index 45a2e0dedd..0c1d860aef 100644 --- a/shared/libc/abort_.c +++ b/shared/libc/abort_.c @@ -1,6 +1,6 @@ #include -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" NORETURN void abort_(void); diff --git a/shared/netutils/netutils.c b/shared/netutils/netutils.c index fe92e8bafb..030b1535cd 100644 --- a/shared/netutils/netutils.c +++ b/shared/netutils/netutils.c @@ -31,7 +31,7 @@ #include "py/runtime.h" #include "shared/netutils/netutils.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" // Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian) { diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 7922cffc2b..875a1a0220 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -37,7 +37,7 @@ #include "supervisor/serial.h" #include "supervisor/shared/rgb_led_colors.h" #include "supervisor/shared/status_leds.h" -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include "supervisor/shared/tick.h" #define SAFE_MODE_DATA_GUARD 0xad0000af diff --git a/supervisor/shared/translate.h b/supervisor/shared/translate/compressed_string.h similarity index 81% rename from supervisor/shared/translate.h rename to supervisor/shared/translate/compressed_string.h index 1963c6fe65..e331a5866f 100644 --- a/supervisor/shared/translate.h +++ b/supervisor/shared/translate/compressed_string.h @@ -24,8 +24,7 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H -#define MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H +#pragma once #include #include @@ -83,29 +82,3 @@ typedef struct compressed_string { void serial_write_compressed(const compressed_string_t *compressed); char *decompress(const compressed_string_t *compressed, char *decompressed); uint16_t decompress_length(const compressed_string_t *compressed); - - -// Map MicroPython's error messages to our translations. -#if defined(MICROPY_ENABLE_DYNRUNTIME) && MICROPY_ENABLE_DYNRUNTIME -#define MP_ERROR_TEXT(x) (x) -#else -#define MP_ERROR_TEXT(x) translate(x) -#endif - -static inline -// gcc10 -flto has issues with this being always_inline for debug builds. -#if CIRCUITPY_DEBUG < 1 -__attribute__((always_inline)) -#endif -const compressed_string_t *translate(const char *original) { - #ifndef NO_QSTR - #define QDEF(id, hash, len, str) - #define TRANSLATION(id, firstbyte, ...) if (strcmp(original, id) == 0) { static const compressed_string_t v = { .data = firstbyte, .tail = { __VA_ARGS__ } }; return &v; } else - #include "genhdr/qstrdefs.generated.h" -#undef TRANSLATION -#undef QDEF - #endif - return NULL; -} - -#endif // MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate/translate.c similarity index 97% rename from supervisor/shared/translate.c rename to supervisor/shared/translate/translate.c index 55cc7d5d1e..cde3b90a1d 100644 --- a/supervisor/shared/translate.c +++ b/supervisor/shared/translate/translate.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "supervisor/shared/translate.h" +#include "supervisor/shared/translate/translate.h" #include #include @@ -134,3 +134,7 @@ char *decompress(const compressed_string_t *compressed, char *decompressed) { decompressed[length - 1] = '\0'; return decompressed; } + +#if CIRCUITPY_LTO == 1 +#include "supervisor/shared/translate/translate_impl.h" +#endif diff --git a/supervisor/shared/translate/translate.h b/supervisor/shared/translate/translate.h new file mode 100644 index 0000000000..d87fce8746 --- /dev/null +++ b/supervisor/shared/translate/translate.h @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include +#include +#include + +#include "supervisor/shared/translate/compressed_string.h" + +// Map MicroPython's error messages to our translations. +#if defined(MICROPY_ENABLE_DYNRUNTIME) && MICROPY_ENABLE_DYNRUNTIME +#define MP_ERROR_TEXT(x) (x) +#else +#define MP_ERROR_TEXT(x) translate(x) +#endif + +// translate() is a giant function with many strcmp calls. The assumption is +// that the build process will optimize this away and replace it with the +// appropriate compressed data for each call site. + +#if CIRCUITPY_LTO == 0 +// Without LTO, we need to include a copy of this function in each compilation +// unit so that the compile stage can do the optimization. Otherwise the linker +// will leave this as a giant function and have each call site call into it. +#include "supervisor/shared/translate/translate_impl.h" +#else +// In link time optimized (LTO) builds, we can compile this once into a .o and +// at link time the calls will be optimized. +const compressed_string_t *translate(const char *c); +#endif diff --git a/supervisor/shared/translate/translate_impl.h b/supervisor/shared/translate/translate_impl.h new file mode 100644 index 0000000000..48dea90d6b --- /dev/null +++ b/supervisor/shared/translate/translate_impl.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include +#include +#include + +#include "supervisor/shared/translate/compressed_string.h" + +#if CIRCUITPY_LTO == 0 +static +#endif +inline +// gcc10 -flto has issues with this being always_inline for debug builds. +#if CIRCUITPY_DEBUG < 1 +__attribute__((always_inline)) +#endif +const compressed_string_t *translate(const char *original) { + #ifndef NO_QSTR + #define QDEF(id, hash, len, str) + #define TRANSLATION(id, firstbyte, ...) if (strcmp(original, id) == 0) { static const compressed_string_t v = { .data = firstbyte, .tail = { __VA_ARGS__ } }; return &v; } else + #include "genhdr/qstrdefs.generated.h" +#undef TRANSLATION +#undef QDEF + #endif + return NULL; +} diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index f4ca11db43..5f4a65623f 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -15,7 +15,7 @@ SRC_SUPERVISOR = \ supervisor/shared/status_leds.c \ supervisor/shared/tick.c \ supervisor/shared/traceback.c \ - supervisor/shared/translate.c \ + supervisor/shared/translate/translate.c \ supervisor/shared/workflow.c ifeq ($(DISABLE_FILESYSTEM),1)