diff --git a/tools/blisp/src/common.c b/tools/blisp/src/common.c index 451c885..8a5ba54 100644 --- a/tools/blisp/src/common.c +++ b/tools/blisp/src/common.c @@ -42,15 +42,17 @@ blisp_return_t blisp_common_init_device(struct blisp_device* device, blisp_return_t ret; ret = blisp_device_init(device, chip); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to init device.\n"); + fprintf(stderr, "Failed to init device, ret: %d\n", ret); return ret; } ret = blisp_device_open(device, port_name->count == 1 ? port_name->sval[0] : NULL); if (ret != BLISP_OK) { - fprintf(stderr, ret == BLISP_ERR_DEVICE_NOT_FOUND - ? "Device not found\n" - : "Failed to open device.\n"); + if (ret == BLISP_ERR_DEVICE_NOT_FOUND) { + fprintf(stderr, "Device not found\n"); + } else { + fprintf(stderr, "Failed to open device, ret: %d\n", ret); + } return ret; } @@ -67,14 +69,14 @@ blisp_return_t blisp_common_prepare_flash(struct blisp_device* device) { printf("Sending a handshake...\n"); ret = blisp_device_handshake(device, false); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to handshake with device.\n"); + fprintf(stderr, "Failed to handshake with device, ret: %d\n", ret); return ret; } printf("Handshake successful!\nGetting chip info...\n"); struct blisp_boot_info boot_info; ret = blisp_device_get_boot_info(device, &boot_info); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to get boot info.\n"); + fprintf(stderr, "Failed to get boot info, ret: %d\n", ret); return ret; } @@ -103,13 +105,13 @@ blisp_return_t blisp_common_prepare_flash(struct blisp_device* device) { printf("Setting clock parameters ...\n"); ret = bl808_load_clock_para(device, true, device->current_baud_rate); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to set clock parameters.\n"); + fprintf(stderr, "Failed to set clock parameters, ret: %d\n", ret); return ret; } printf("Setting flash parameters...\n"); ret = bl808_load_flash_para(device); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to set flash parameters.\n"); + fprintf(stderr, "Failed to set flash parameters, ret: %d\n", ret); return ret; } } @@ -149,20 +151,20 @@ blisp_return_t blisp_common_prepare_flash(struct blisp_device* device) { ret = blisp_device_check_image(device); if (ret != 0) { - fprintf(stderr, "Failed to check image.\n"); + fprintf(stderr, "Failed to check image, ret: %d\n", ret); goto exit1; } ret = blisp_device_run_image(device); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to run image.\n"); + fprintf(stderr, "Failed to run image, ret: %d\n", ret); goto exit1; } printf("Sending a handshake...\n"); ret = blisp_device_handshake(device, true); if (ret != BLISP_OK) { - fprintf(stderr, "Failed to handshake with device.\n"); + fprintf(stderr, "Failed to handshake with device, ret: %d\n", ret); goto exit1; } printf("Handshake with eflash_loader successful.\n");