Skip to content

Commit 0a2d795

Browse files
author
Andrew Boie
committed
Revert "sys_log: replace old debug macros at USB DFU sample"
This reverts commit 573b742. Change-Id: Ifc6d079cf49254472ec381a6dd25d642c2d29b88 Signed-off-by: Andrew Boie <[email protected]>
1 parent 2599c60 commit 0a2d795

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

samples/usb/dfu/prj.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ CONFIG_ARC_INIT=n
44
CONFIG_USB=y
55
CONFIG_USB_DW=y
66
CONFIG_USB_DEVICE_STACK=y
7-
#Un comment to enable logging
8-
#CONFIG_SYS_LOG=y
9-
CONFIG_SYS_LOG_USB_DFU_LEVEL=0
107
CONFIG_SYS_LOG_USB_DW_LEVEL=0
118
CONFIG_SYS_LOG_USB_LEVEL=0
129
CONFIG_FLASH=y

samples/usb/dfu/src/usb_dfu.c

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@
4545
#include "usb_dfu.h"
4646

4747

48-
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_USB_DFU_LEVEL
49-
#include <misc/sys_log.h>
48+
#ifndef CONFIG_USB_DFU_DEBUG
49+
#define DBG(...) { ; }
50+
#else
51+
#if defined(CONFIG_STDOUT_CONSOLE)
52+
#include <stdio.h>
53+
#define DBG printf
54+
#else
55+
#define DBG printk
56+
#endif /* CONFIG_STDOUT_CONSOLE */
57+
#endif /* CONFIG_USB_DFU_DEBUG */
5058

5159
/* Alternate settings are used to access additional memory segments.
5260
* This example uses the alternate settings as an offset into flash.
@@ -338,7 +346,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
338346

339347
switch (pSetup->bRequest) {
340348
case DFU_GETSTATUS:
341-
SYS_LOG_DBG("DFU_GETSTATUS: status %d, state %d",
349+
DBG("DFU_GETSTATUS: status %d, state %d\n",
342350
dfu_data.status, dfu_data.state);
343351

344352
if (dfu_data.state == dfuMANIFEST_SYNC)
@@ -354,13 +362,13 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
354362
break;
355363

356364
case DFU_GETSTATE:
357-
SYS_LOG_DBG("DFU_GETSTATE");
365+
DBG("DFU_GETSTATE\n");
358366
(*data)[0] = dfu_data.state;
359367
*data_len = 1;
360368
break;
361369

362370
case DFU_ABORT:
363-
SYS_LOG_DBG("DFU_ABORT");
371+
DBG("DFU_ABORT\n");
364372

365373
if (dfu_check_app_state())
366374
return -EINVAL;
@@ -371,7 +379,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
371379
break;
372380

373381
case DFU_CLRSTATUS:
374-
SYS_LOG_DBG("DFU_CLRSTATUS");
382+
DBG("DFU_CLRSTATUS\n");
375383

376384
if (dfu_check_app_state())
377385
return -EINVAL;
@@ -381,7 +389,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
381389
break;
382390

383391
case DFU_DNLOAD:
384-
SYS_LOG_DBG("DFU_DNLOAD block %d, len %d, state %d",
392+
DBG("DFU_DNLOAD block %d, len %d, state %d\n",
385393
pSetup->wValue, pSetup->wLength, dfu_data.state);
386394

387395
if (dfu_check_app_state())
@@ -390,7 +398,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
390398
switch (dfu_data.state) {
391399
case dfuIDLE:
392400
dfu_reset_counters();
393-
SYS_LOG_DBG("DFU_DNLOAD start");
401+
DBG("DFU_DNLOAD start\n");
394402
case dfuDNLOAD_IDLE:
395403
if (pSetup->wLength != 0) {
396404
/* Download has started */
@@ -402,13 +410,12 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
402410
DFU_FLASH_ADDR +
403411
dfu_data.bytes_rcvd,
404412
dfu_data.flash_page_size);
405-
SYS_LOG_DBG("Flash erase");
413+
DBG("Flash erase\n");
406414
if (ret) {
407415
dfu_data.state = dfuERROR;
408416
dfu_data.status = errERASE;
409-
SYS_LOG_ERR("DFU flash erase "
410-
"error, ret %d",
411-
ret);
417+
DBG("DFU flash erase error, "
418+
"ret %d\n", ret);
412419
}
413420
}
414421

@@ -421,8 +428,8 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
421428
if (ret) {
422429
dfu_data.state = dfuERROR;
423430
dfu_data.status = errWRITE;
424-
SYS_LOG_ERR("DFU flash write error, "
425-
"ret %d", ret);
431+
DBG("DFU flash write error, ret %d\n",
432+
ret);
426433
} else
427434
dfu_data.bytes_rcvd += pSetup->wLength;
428435
} else {
@@ -432,16 +439,15 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
432439
}
433440
break;
434441
default:
435-
SYS_LOG_ERR("DFU_DNLOAD wrong state %d",
436-
dfu_data.state);
442+
DBG("DFU_DNLOAD wrong state %d\n", dfu_data.state);
437443
dfu_data.state = dfuERROR;
438444
dfu_data.status = errUNKNOWN;
439445
dfu_reset_counters();
440446
return -EINVAL;
441447
}
442448
break;
443449
case DFU_UPLOAD:
444-
SYS_LOG_DBG("DFU_UPLOAD block %d, len %d, state %d",
450+
DBG("DFU_UPLOAD block %d, len %d, state %d\n",
445451
pSetup->wValue, pSetup->wLength, dfu_data.state);
446452

447453
if (dfu_check_app_state())
@@ -450,12 +456,12 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
450456
switch (dfu_data.state) {
451457
case dfuIDLE:
452458
dfu_reset_counters();
453-
SYS_LOG_DBG("DFU_UPLOAD start");
459+
DBG("DFU_UPLOAD start\n");
454460
case dfuUPLOAD_IDLE:
455461
if (!pSetup->wLength ||
456462
dfu_data.block_nr != pSetup->wValue) {
457-
SYS_LOG_ERR("DFU_UPLOAD block %d, expected "
458-
"%d, len %d", pSetup->wValue,
463+
DBG("DFU_UPLOAD block %d, expected %d, "
464+
"len %d\n", pSetup->wValue,
459465
dfu_data.block_nr, pSetup->wLength);
460466
dfu_data.state = dfuERROR;
461467
dfu_data.status = errUNKNOWN;
@@ -498,16 +504,15 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
498504

499505
break;
500506
default:
501-
SYS_LOG_ERR("DFU_UPLOAD wrong state %d",
502-
dfu_data.state);
507+
DBG("DFU_UPLOAD wrong state %d\n", dfu_data.state);
503508
dfu_data.state = dfuERROR;
504509
dfu_data.status = errUNKNOWN;
505510
dfu_reset_counters();
506511
return -EINVAL;
507512
}
508513
break;
509514
case DFU_DETACH:
510-
SYS_LOG_DBG("DFU_DETACH timeout %d, state %d",
515+
DBG("DFU_DETACH timeout %d, state %d\n",
511516
pSetup->wValue, dfu_data.state);
512517

513518
if (dfu_data.state != appIDLE) {
@@ -528,7 +533,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
528533
usb_set_config(&dfu_config);
529534
break;
530535
default:
531-
SYS_LOG_ERR("DFU UNKNOWN STATE: %d", pSetup->bRequest);
536+
DBG("DFU UNKNOWN STATE: %d\n", pSetup->bRequest);
532537
return -EINVAL;
533538
}
534539

@@ -547,33 +552,32 @@ static void dfu_status_cb(enum usb_dc_status_code status)
547552
/* Check the USB status and do needed action if required */
548553
switch (status) {
549554
case USB_DC_ERROR:
550-
SYS_LOG_ERR("USB device error");
555+
DBG("USB device error\n");
551556
break;
552557
case USB_DC_RESET:
553-
SYS_LOG_DBG("USB device reset detected, state %d",
554-
dfu_data.state);
558+
DBG("USB device reset detected, state %d\n", dfu_data.state);
555559
if (dfu_data.state == appDETACH) {
556560
dfu_data.state = dfuIDLE;
557561
}
558562
break;
559563
case USB_DC_CONNECTED:
560-
SYS_LOG_DBG("USB device connected");
564+
DBG("USB device connected\n");
561565
break;
562566
case USB_DC_CONFIGURED:
563-
SYS_LOG_DBG("USB device configured");
567+
DBG("USB device configured\n");
564568
break;
565569
case USB_DC_DISCONNECTED:
566-
SYS_LOG_DBG("USB device disconnected");
570+
DBG("USB device disconnected\n");
567571
break;
568572
case USB_DC_SUSPEND:
569-
SYS_LOG_DBG("USB device supended");
573+
DBG("USB device supended\n");
570574
break;
571575
case USB_DC_RESUME:
572-
SYS_LOG_DBG("USB device resumed");
576+
DBG("USB device resumed\n");
573577
break;
574578
case USB_DC_UNKNOWN:
575579
default:
576-
SYS_LOG_WRN("USB unknown state");
580+
DBG("USB unknown state\n");
577581
break;
578582
}
579583
}
@@ -596,12 +600,11 @@ static int dfu_custom_handle_req(struct usb_setup_packet *pSetup,
596600
if (REQTYPE_GET_RECIP(pSetup->bmRequestType) ==
597601
REQTYPE_RECIP_INTERFACE) {
598602
if (pSetup->bRequest == REQ_SET_INTERFACE) {
599-
SYS_LOG_DBG("DFU alternate setting %d",
600-
pSetup->wValue);
603+
DBG("DFU alternate setting %d\n", pSetup->wValue);
601604

602605
if (pSetup->wValue >= DFU_MODE_ALTERNATE_SETTINGS) {
603-
SYS_LOG_DBG("Invalid DFU alternate setting "
604-
"(%d)", pSetup->wValue);
606+
DBG("Invalid DFU alternate setting (%d)\n",
607+
pSetup->wValue);
605608
} else {
606609
dfu_data.alt_setting = pSetup->wValue;
607610
}
@@ -652,14 +655,14 @@ int dfu_start(struct device *flash_dev, uint32_t flash_base_addr,
652655
/* Initialize the USB driver with the right configuration */
653656
ret = usb_set_config(&dfu_config);
654657
if (ret < 0) {
655-
SYS_LOG_ERR("Failed to config USB");
658+
DBG("Failed to config USB\n");
656659
return ret;
657660
}
658661

659662
/* Enable USB driver */
660663
ret = usb_enable(&dfu_config);
661664
if (ret < 0) {
662-
SYS_LOG_ERR("Failed to enable USB");
665+
DBG("Failed to enable USB\n");
663666
return ret;
664667
}
665668

0 commit comments

Comments
 (0)