Skip to content

Commit 5f39316

Browse files
committed
fix side-effect prevent dfu when disable timeout
1 parent 11572aa commit 5f39316

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

Makefile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ IPATH += $(SD_PATH)/$(SD_FILENAME)_API/include/nrf52
232232
ifeq ($(DEBUG), 1)
233233
RTT_SRC = lib/SEGGER_RTT
234234

235-
CFLAGS += -ggdb -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
235+
CFLAGS += -DCFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
236236
IPATH += $(RTT_SRC)/RTT
237237
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
238238
endif
@@ -263,7 +263,8 @@ CFLAGS += \
263263
-Wsign-compare \
264264
-Wmissing-format-attribute \
265265
-Wno-endif-labels \
266-
-Wunreachable-code
266+
-Wunreachable-code \
267+
-ggdb
267268

268269
# Suppress warning caused by SDK
269270
CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
@@ -306,7 +307,6 @@ LIBS += -lm -lc
306307
#------------------------------------------------------------------------------
307308
ASFLAGS += $(CFLAGS)
308309

309-
310310
#function for removing duplicates in a list
311311
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
312312

@@ -329,16 +329,6 @@ INC_PATHS = $(addprefix -I,$(IPATH))
329329
# BUILD TARGETS
330330
#------------------------------------------------------------------------------
331331

332-
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
333-
ifeq ("$(V)","1")
334-
$(info CFLAGS $(CFLAGS))
335-
$(info )
336-
$(info LDFLAGS $(LDFLAGS))
337-
$(info )
338-
$(info ASFLAGS $(ASFLAGS))
339-
$(info )
340-
endif
341-
342332
.PHONY: all clean flash dfu-flash sd gdbflash gdb
343333

344334
# default target to build

lib/sdk11/components/libraries/bootloader_dfu/dfu_single_bank.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ void dfu_register_callback(dfu_callback_t callback_handler)
260260

261261
uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
262262
{
263-
uint32_t err_code;
264-
265263
m_start_packet = *(p_packet->params.start_packet);
266264

267265
// Check that the requested update procedure is supported.
@@ -313,18 +311,11 @@ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet)
313311
m_functions.activate = dfu_activate_app;
314312
}
315313

316-
switch (m_dfu_state)
317-
{
318-
case DFU_STATE_IDLE:
319-
m_functions.prepare(m_image_size);
320-
break;
314+
if ( DFU_STATE_IDLE != m_dfu_state ) return NRF_ERROR_INVALID_STATE;
321315

322-
default:
323-
err_code = NRF_ERROR_INVALID_STATE;
324-
break;
325-
}
316+
m_functions.prepare(m_image_size);
326317

327-
return err_code;
318+
return NRF_SUCCESS;
328319
}
329320

330321

@@ -431,7 +422,6 @@ uint32_t dfu_init_pkt_complete(void)
431422

432423
uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
433424
{
434-
uint32_t err_code = NRF_SUCCESS;
435425
uint32_t length;
436426

437427
switch (m_dfu_state)
@@ -463,11 +453,10 @@ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet)
463453

464454
default:
465455
// Either the start packet was not received or dfu_init function was not called before.
466-
err_code = NRF_ERROR_INVALID_STATE;
467-
break;
456+
return NRF_ERROR_INVALID_STATE;
468457
}
469458

470-
return err_code;
459+
return NRF_SUCCESS;
471460
}
472461

473462

0 commit comments

Comments
 (0)