Skip to content

Commit

Permalink
IO revamping
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Portron committed Dec 18, 2024
1 parent b1727b3 commit 4dac6ad
Show file tree
Hide file tree
Showing 179 changed files with 12,700 additions and 38,480 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ repos:
rev: v2.2.5
hooks:
- id: codespell
args: [--ignore-words-list=aci]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
Expand Down
2 changes: 2 additions & 0 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ DEFINES += SCREEN_SIZE_NANO
DEFINES += HAVE_BAGL
endif # TARGET_NANOS

DEFINES += OS_IO_SEPH_BUFFER_SIZE=352

ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_NANOS2))
# Screen is directly connected to the SE
DEFINES += HAVE_SE_SCREEN
Expand Down
2 changes: 2 additions & 0 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ define check_duplicate =
$(if $(LIST), $(info [WARNING] Found duplicate files in SDK and APP: ${LIST}))
endef

SDK_SOURCE_PATH += io io_legacy protocol lib_u2f_legacy

# adding the correct target header to sources
SDK_SOURCE_PATH += target/$(TARGET)/include

Expand Down
38 changes: 22 additions & 16 deletions Makefile.standard_app
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX TARGET_FLE
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000 HAVE_BLE_APDU
DEFINES += BLE_SEGMENT_SIZE=32
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
SDK_SOURCE_PATH += lib_blewbxx
endif
endif

Expand All @@ -36,6 +36,7 @@ ifeq ($(ENABLE_NFC), 1)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME), TARGET_STAX TARGET_FLEX))
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
DEFINES += HAVE_NFC
SDK_SOURCE_PATH += lib_nfc
endif
endif

Expand Down Expand Up @@ -82,17 +83,6 @@ else
DEFINES += PRINTF\(...\)=
endif

#####################################################################
# IO SEPROXY BUFFER SIZE #
#####################################################################
ifneq ($(DISABLE_DEFAULT_IO_SEPROXY_BUFFER_SIZE), 1)
ifeq ($(TARGET_NAME), TARGET_NANOS)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
endif
endif

#####################################################################
# NBGL #
#####################################################################
Expand Down Expand Up @@ -121,19 +111,30 @@ ifeq ($(ENABLE_NBGL_KEYPAD), 1)
DEFINES += NBGL_KEYPAD
endif

#####################################################################
# OS IO STACK USE #
#####################################################################
ifneq ($(DISABLE_OS_IO_STACK_USE), 1)
DEFINES += USE_OS_IO_STACK
endif

#####################################################################
# STANDARD DEFINES #
#####################################################################
DEFINES += $(DEFINES_LIB)
DEFINES += MAJOR_VERSION=$(APPVERSION_M) MINOR_VERSION=$(APPVERSION_N) PATCH_VERSION=$(APPVERSION_P)
DEFINES += IO_HID_EP_LENGTH=64
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=OS_IO_SEPH_BUFFER_SIZE


SDK_SOURCE_PATH += io
SDK_SOURCE_PATH += protocol

ifeq ($(DISABLE_STANDARD_APP_DEFINES), 1)
DISABLE_STANDARD_SNPRINTF = 1
DISABLE_STANDARD_USB = 1
DISABLE_STANDARD_WEBUSB = 1
DISABLE_STANDARD_BAGL_UX_FLOW = 1
DISABLE_STANDARD_SEPROXYHAL = 1
endif

ifneq ($(DISABLE_STANDARD_SNPRINTF), 1)
Expand All @@ -143,7 +144,7 @@ endif
ifneq ($(DISABLE_STANDARD_USB), 1)
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=4 HAVE_USB_APDU
DEFINES += USB_SEGMENT_SIZE=64
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
SDK_SOURCE_PATH += lib_stusb
endif

ifneq ($(DISABLE_STANDARD_WEBUSB), 1)
Expand All @@ -153,8 +154,13 @@ ifneq ($(DISABLE_STANDARD_WEBUSB), 1)
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=$(WEBUSB_URL_SIZE_B) WEBUSB_URL=$(WEBUSB_URL)
endif

ifneq ($(DISABLE_STANDARD_USB), 1)
DEFINES += HAVE_IO_U2F
SDK_SOURCE_PATH += lib_u2f
endif

ifneq ($(DISABLE_STANDARD_BAGL_UX_FLOW), 1)
ifneq ($(USE_NBGL), 1)
ifndef USE_NBGL
DEFINES += HAVE_UX_FLOW
endif
endif
Expand Down Expand Up @@ -255,7 +261,7 @@ include $(BOLOS_SDK)/Makefile.defines
include $(BOLOS_SDK)/Makefile.glyphs

load: all
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --rootPrivateKey f028458b39af92fea938486ecc49562d0e7731b53d9b25e2701183e4f2adc991

load-offline: all
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline
Expand Down
64 changes: 0 additions & 64 deletions include/ledger_protocol.h

This file was deleted.

59 changes: 0 additions & 59 deletions include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,63 +128,4 @@ int snprintf(char *str, size_t str_size, const char *format, ...);
int compute_address_location(int address);
#endif

// syscall test
// SYSCALL void dummy_1(unsigned int* p PLENGTH(2+len+15+ len + 16 + sizeof(io_send_t) + 1 ),
// unsigned int len);

/* ----------------------------------------------------------------------- */
/* - I/O I2C - */
/* ----------------------------------------------------------------------- */

#ifdef HAVE_IO_I2C

#define IO_I2C_SPEED_STD 0
#define IO_I2C_SPEED_FAST 1
#define IO_I2C_SPEED_FASTPLUS 2
#define IO_I2C_SPEED_HS 3
#define IO_I2C_MASTER 0x80
/**
* Configure the I2C peripheral.
* @param speed_and_master enables to set the bus speed. And to select if the peripheral will act as
* master (issuing Start and Stop condition upon need) or slave mode.
* @param address In master mode, this parameter sets the target I2C device's address. In slave
* mode, the address is the desired I2C bus address for the interface. The address is always a 7bit
* address (excluding the transfer direction bit).
*/
SYSCALL void io_i2c_setmode(unsigned int speed_and_master, unsigned int address);

/**
* Setup the I2C peripheral for:
* - In slave mode, receiving a WRITE transaction of maxlength bytes at most. Upon WRITE transaction
* end, an SEPROXYHAL_TAG_I2C_EVENT is issued with the received data. It has to be received through
* ::io_seph_recv.
* - In master mode, this call is nop.
*/
SYSCALL void io_i2c_prepare(unsigned int maxlength);

#define IO_I2C_FLAGS_READ 0
#define IO_I2C_FLAGS_WRITE 1
#define IO_I2C_FLAGS_START 2
#define IO_I2C_FLAGS_STOP 4
/**
* Request to execute a transfer:
* - In slave mode, this call is non-blocking. It only enables to reply to a READ transaction of at
* most length bytes. After the Stop condition is issued from the master, a SEPROXYHAL_TAG_I2C_EVENT
* event containing the effectively transferred length is issued and can be retrieved through
* ::io_seph_recv. To restart or continue the transfer requires another call to ::io_i2c_xfer.
* - In master mode, this call is blocking and triggers the transaction as requested through the
* flags parameter. The READ or WRITE transaction will place or transmit data from the given buffer
* and length. Depending on the passed start/stop flags, corresponding bus condition are executed.
*/
SYSCALL void io_i2c_xfer(void *buffer PLENGTH(length), unsigned int length, unsigned int flags);

#ifndef BOLOS_RELEASE
#ifdef BOLOS_DEBUG
SYSCALL void io_i2c_dumpstate(void);
SYSCALL void io_debug(char *chars, unsigned int len);
#endif // BOLOS_DEBUG
#endif // BOLOS_RELEASE

#endif // HAVE_IO_I2C

#endif // OS_H
112 changes: 0 additions & 112 deletions include/os_io.h

This file was deleted.

Loading

0 comments on commit 4dac6ad

Please sign in to comment.