Revert "sys_log: replace old debug macros at USB DFU sample"

This reverts commit 573b7420d4.

Change-Id: Ifc6d079cf49254472ec381a6dd25d642c2d29b88
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-08-23 13:26:49 -07:00
commit 0a2d7953e2
2 changed files with 42 additions and 42 deletions

View file

@ -4,9 +4,6 @@ CONFIG_ARC_INIT=n
CONFIG_USB=y CONFIG_USB=y
CONFIG_USB_DW=y CONFIG_USB_DW=y
CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_STACK=y
#Un comment to enable logging
#CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_USB_DFU_LEVEL=0
CONFIG_SYS_LOG_USB_DW_LEVEL=0 CONFIG_SYS_LOG_USB_DW_LEVEL=0
CONFIG_SYS_LOG_USB_LEVEL=0 CONFIG_SYS_LOG_USB_LEVEL=0
CONFIG_FLASH=y CONFIG_FLASH=y

View file

@ -45,8 +45,16 @@
#include "usb_dfu.h" #include "usb_dfu.h"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_USB_DFU_LEVEL #ifndef CONFIG_USB_DFU_DEBUG
#include <misc/sys_log.h> #define DBG(...) { ; }
#else
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define DBG printf
#else
#define DBG printk
#endif /* CONFIG_STDOUT_CONSOLE */
#endif /* CONFIG_USB_DFU_DEBUG */
/* Alternate settings are used to access additional memory segments. /* Alternate settings are used to access additional memory segments.
* This example uses the alternate settings as an offset into flash. * 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,
switch (pSetup->bRequest) { switch (pSetup->bRequest) {
case DFU_GETSTATUS: case DFU_GETSTATUS:
SYS_LOG_DBG("DFU_GETSTATUS: status %d, state %d", DBG("DFU_GETSTATUS: status %d, state %d\n",
dfu_data.status, dfu_data.state); dfu_data.status, dfu_data.state);
if (dfu_data.state == dfuMANIFEST_SYNC) if (dfu_data.state == dfuMANIFEST_SYNC)
@ -354,13 +362,13 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
break; break;
case DFU_GETSTATE: case DFU_GETSTATE:
SYS_LOG_DBG("DFU_GETSTATE"); DBG("DFU_GETSTATE\n");
(*data)[0] = dfu_data.state; (*data)[0] = dfu_data.state;
*data_len = 1; *data_len = 1;
break; break;
case DFU_ABORT: case DFU_ABORT:
SYS_LOG_DBG("DFU_ABORT"); DBG("DFU_ABORT\n");
if (dfu_check_app_state()) if (dfu_check_app_state())
return -EINVAL; return -EINVAL;
@ -371,7 +379,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
break; break;
case DFU_CLRSTATUS: case DFU_CLRSTATUS:
SYS_LOG_DBG("DFU_CLRSTATUS"); DBG("DFU_CLRSTATUS\n");
if (dfu_check_app_state()) if (dfu_check_app_state())
return -EINVAL; return -EINVAL;
@ -381,7 +389,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
break; break;
case DFU_DNLOAD: case DFU_DNLOAD:
SYS_LOG_DBG("DFU_DNLOAD block %d, len %d, state %d", DBG("DFU_DNLOAD block %d, len %d, state %d\n",
pSetup->wValue, pSetup->wLength, dfu_data.state); pSetup->wValue, pSetup->wLength, dfu_data.state);
if (dfu_check_app_state()) if (dfu_check_app_state())
@ -390,7 +398,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
switch (dfu_data.state) { switch (dfu_data.state) {
case dfuIDLE: case dfuIDLE:
dfu_reset_counters(); dfu_reset_counters();
SYS_LOG_DBG("DFU_DNLOAD start"); DBG("DFU_DNLOAD start\n");
case dfuDNLOAD_IDLE: case dfuDNLOAD_IDLE:
if (pSetup->wLength != 0) { if (pSetup->wLength != 0) {
/* Download has started */ /* Download has started */
@ -402,13 +410,12 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
DFU_FLASH_ADDR + DFU_FLASH_ADDR +
dfu_data.bytes_rcvd, dfu_data.bytes_rcvd,
dfu_data.flash_page_size); dfu_data.flash_page_size);
SYS_LOG_DBG("Flash erase"); DBG("Flash erase\n");
if (ret) { if (ret) {
dfu_data.state = dfuERROR; dfu_data.state = dfuERROR;
dfu_data.status = errERASE; dfu_data.status = errERASE;
SYS_LOG_ERR("DFU flash erase " DBG("DFU flash erase error, "
"error, ret %d", "ret %d\n", ret);
ret);
} }
} }
@ -421,8 +428,8 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
if (ret) { if (ret) {
dfu_data.state = dfuERROR; dfu_data.state = dfuERROR;
dfu_data.status = errWRITE; dfu_data.status = errWRITE;
SYS_LOG_ERR("DFU flash write error, " DBG("DFU flash write error, ret %d\n",
"ret %d", ret); ret);
} else } else
dfu_data.bytes_rcvd += pSetup->wLength; dfu_data.bytes_rcvd += pSetup->wLength;
} else { } else {
@ -432,8 +439,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
} }
break; break;
default: default:
SYS_LOG_ERR("DFU_DNLOAD wrong state %d", DBG("DFU_DNLOAD wrong state %d\n", dfu_data.state);
dfu_data.state);
dfu_data.state = dfuERROR; dfu_data.state = dfuERROR;
dfu_data.status = errUNKNOWN; dfu_data.status = errUNKNOWN;
dfu_reset_counters(); dfu_reset_counters();
@ -441,7 +447,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
} }
break; break;
case DFU_UPLOAD: case DFU_UPLOAD:
SYS_LOG_DBG("DFU_UPLOAD block %d, len %d, state %d", DBG("DFU_UPLOAD block %d, len %d, state %d\n",
pSetup->wValue, pSetup->wLength, dfu_data.state); pSetup->wValue, pSetup->wLength, dfu_data.state);
if (dfu_check_app_state()) if (dfu_check_app_state())
@ -450,12 +456,12 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
switch (dfu_data.state) { switch (dfu_data.state) {
case dfuIDLE: case dfuIDLE:
dfu_reset_counters(); dfu_reset_counters();
SYS_LOG_DBG("DFU_UPLOAD start"); DBG("DFU_UPLOAD start\n");
case dfuUPLOAD_IDLE: case dfuUPLOAD_IDLE:
if (!pSetup->wLength || if (!pSetup->wLength ||
dfu_data.block_nr != pSetup->wValue) { dfu_data.block_nr != pSetup->wValue) {
SYS_LOG_ERR("DFU_UPLOAD block %d, expected " DBG("DFU_UPLOAD block %d, expected %d, "
"%d, len %d", pSetup->wValue, "len %d\n", pSetup->wValue,
dfu_data.block_nr, pSetup->wLength); dfu_data.block_nr, pSetup->wLength);
dfu_data.state = dfuERROR; dfu_data.state = dfuERROR;
dfu_data.status = errUNKNOWN; dfu_data.status = errUNKNOWN;
@ -498,8 +504,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
break; break;
default: default:
SYS_LOG_ERR("DFU_UPLOAD wrong state %d", DBG("DFU_UPLOAD wrong state %d\n", dfu_data.state);
dfu_data.state);
dfu_data.state = dfuERROR; dfu_data.state = dfuERROR;
dfu_data.status = errUNKNOWN; dfu_data.status = errUNKNOWN;
dfu_reset_counters(); dfu_reset_counters();
@ -507,7 +512,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
} }
break; break;
case DFU_DETACH: case DFU_DETACH:
SYS_LOG_DBG("DFU_DETACH timeout %d, state %d", DBG("DFU_DETACH timeout %d, state %d\n",
pSetup->wValue, dfu_data.state); pSetup->wValue, dfu_data.state);
if (dfu_data.state != appIDLE) { if (dfu_data.state != appIDLE) {
@ -528,7 +533,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
usb_set_config(&dfu_config); usb_set_config(&dfu_config);
break; break;
default: default:
SYS_LOG_ERR("DFU UNKNOWN STATE: %d", pSetup->bRequest); DBG("DFU UNKNOWN STATE: %d\n", pSetup->bRequest);
return -EINVAL; return -EINVAL;
} }
@ -547,33 +552,32 @@ static void dfu_status_cb(enum usb_dc_status_code status)
/* Check the USB status and do needed action if required */ /* Check the USB status and do needed action if required */
switch (status) { switch (status) {
case USB_DC_ERROR: case USB_DC_ERROR:
SYS_LOG_ERR("USB device error"); DBG("USB device error\n");
break; break;
case USB_DC_RESET: case USB_DC_RESET:
SYS_LOG_DBG("USB device reset detected, state %d", DBG("USB device reset detected, state %d\n", dfu_data.state);
dfu_data.state);
if (dfu_data.state == appDETACH) { if (dfu_data.state == appDETACH) {
dfu_data.state = dfuIDLE; dfu_data.state = dfuIDLE;
} }
break; break;
case USB_DC_CONNECTED: case USB_DC_CONNECTED:
SYS_LOG_DBG("USB device connected"); DBG("USB device connected\n");
break; break;
case USB_DC_CONFIGURED: case USB_DC_CONFIGURED:
SYS_LOG_DBG("USB device configured"); DBG("USB device configured\n");
break; break;
case USB_DC_DISCONNECTED: case USB_DC_DISCONNECTED:
SYS_LOG_DBG("USB device disconnected"); DBG("USB device disconnected\n");
break; break;
case USB_DC_SUSPEND: case USB_DC_SUSPEND:
SYS_LOG_DBG("USB device supended"); DBG("USB device supended\n");
break; break;
case USB_DC_RESUME: case USB_DC_RESUME:
SYS_LOG_DBG("USB device resumed"); DBG("USB device resumed\n");
break; break;
case USB_DC_UNKNOWN: case USB_DC_UNKNOWN:
default: default:
SYS_LOG_WRN("USB unknown state"); DBG("USB unknown state\n");
break; break;
} }
} }
@ -596,12 +600,11 @@ static int dfu_custom_handle_req(struct usb_setup_packet *pSetup,
if (REQTYPE_GET_RECIP(pSetup->bmRequestType) == if (REQTYPE_GET_RECIP(pSetup->bmRequestType) ==
REQTYPE_RECIP_INTERFACE) { REQTYPE_RECIP_INTERFACE) {
if (pSetup->bRequest == REQ_SET_INTERFACE) { if (pSetup->bRequest == REQ_SET_INTERFACE) {
SYS_LOG_DBG("DFU alternate setting %d", DBG("DFU alternate setting %d\n", pSetup->wValue);
pSetup->wValue);
if (pSetup->wValue >= DFU_MODE_ALTERNATE_SETTINGS) { if (pSetup->wValue >= DFU_MODE_ALTERNATE_SETTINGS) {
SYS_LOG_DBG("Invalid DFU alternate setting " DBG("Invalid DFU alternate setting (%d)\n",
"(%d)", pSetup->wValue); pSetup->wValue);
} else { } else {
dfu_data.alt_setting = pSetup->wValue; dfu_data.alt_setting = pSetup->wValue;
} }
@ -652,14 +655,14 @@ int dfu_start(struct device *flash_dev, uint32_t flash_base_addr,
/* Initialize the USB driver with the right configuration */ /* Initialize the USB driver with the right configuration */
ret = usb_set_config(&dfu_config); ret = usb_set_config(&dfu_config);
if (ret < 0) { if (ret < 0) {
SYS_LOG_ERR("Failed to config USB"); DBG("Failed to config USB\n");
return ret; return ret;
} }
/* Enable USB driver */ /* Enable USB driver */
ret = usb_enable(&dfu_config); ret = usb_enable(&dfu_config);
if (ret < 0) { if (ret < 0) {
SYS_LOG_ERR("Failed to enable USB"); DBG("Failed to enable USB\n");
return ret; return ret;
} }