diff --git a/Makefile.standard_app b/Makefile.standard_app index a880033f0..a0be83a3d 100644 --- a/Makefile.standard_app +++ b/Makefile.standard_app @@ -124,6 +124,12 @@ ifneq ($(DISABLE_STANDARD_APP_FILES), 1) SDK_SOURCE_PATH += lib_standard_app endif +ifneq ($(DISABLE_STANDARD_APP_SYNC_RAPDU), 1) +ifneq ($(TARGET_NAME),TARGET_NANOS) +DEFINES += STANDARD_APP_SYNC_RAPDU +endif +endif + ##################################################################### # NBGL # ##################################################################### diff --git a/lib_standard_app/io.c b/lib_standard_app/io.c index 57016ea75..27581c4fb 100644 --- a/lib_standard_app/io.c +++ b/lib_standard_app/io.c @@ -134,8 +134,8 @@ WEAK int io_recv_command() switch (G_io_state) { case READY: + ret = io_exchange(CHANNEL_APDU | IO_CONTINUE_RX, G_output_len); G_io_state = RECEIVED; - ret = io_exchange(CHANNEL_APDU, G_output_len); break; case RECEIVED: G_io_state = WAITING; @@ -198,9 +198,17 @@ WEAK int io_send_response_buffers(const buffer_t *rdatalist, size_t count, uint1 ret = -1; break; case RECEIVED: +#ifdef STANDARD_APP_SYNC_RAPDU + // Send synchronously the APDU response. + // This is needed to send the response before displaying synchronous + // status message on the screen. + // This is not always done to spare the RAM (stack) on LNS. + __attribute__((fallthrough)); +#else G_io_state = READY; ret = 0; break; +#endif case WAITING: ret = io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_output_len); G_output_len = 0;