mirror of
https://github.com/pine64/blisp.git
synced 2024-12-22 06:20:12 +00:00
Added error-number printing to common.c
This commit is contained in:
parent
04916cf5a4
commit
aa79ad3601
@ -42,15 +42,17 @@ blisp_return_t blisp_common_init_device(struct blisp_device* device,
|
|||||||
blisp_return_t ret;
|
blisp_return_t ret;
|
||||||
ret = blisp_device_init(device, chip);
|
ret = blisp_device_init(device, chip);
|
||||||
if (ret != BLISP_OK) {
|
if (ret != BLISP_OK) {
|
||||||
fprintf(stderr, "Failed to init device.\n");
|
fprintf(stderr, "Failed to init device, ret: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = blisp_device_open(device,
|
ret = blisp_device_open(device,
|
||||||
port_name->count == 1 ? port_name->sval[0] : NULL);
|
port_name->count == 1 ? port_name->sval[0] : NULL);
|
||||||
if (ret != BLISP_OK) {
|
if (ret != BLISP_OK) {
|
||||||
fprintf(stderr, ret == BLISP_ERR_DEVICE_NOT_FOUND
|
if (ret == BLISP_ERR_DEVICE_NOT_FOUND) {
|
||||||
? "Device not found\n"
|
fprintf(stderr, "Device not found\n");
|
||||||
: "Failed to open device.\n");
|
} else {
|
||||||
|
fprintf(stderr, "Failed to open device, ret: %d\n", ret);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,14 +69,14 @@ blisp_return_t blisp_common_prepare_flash(struct blisp_device* device) {
|
|||||||
printf("Sending a handshake...\n");
|
printf("Sending a handshake...\n");
|
||||||
ret = blisp_device_handshake(device, false);
|
ret = blisp_device_handshake(device, false);
|
||||||
if (ret != BLISP_OK) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
printf("Handshake successful!\nGetting chip info...\n");
|
printf("Handshake successful!\nGetting chip info...\n");
|
||||||
struct blisp_boot_info boot_info;
|
struct blisp_boot_info boot_info;
|
||||||
ret = blisp_device_get_boot_info(device, &boot_info);
|
ret = blisp_device_get_boot_info(device, &boot_info);
|
||||||
if (ret != BLISP_OK) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,13 +105,13 @@ blisp_return_t blisp_common_prepare_flash(struct blisp_device* device) {
|
|||||||
printf("Setting clock parameters ...\n");
|
printf("Setting clock parameters ...\n");
|
||||||
ret = bl808_load_clock_para(device, true, device->current_baud_rate);
|
ret = bl808_load_clock_para(device, true, device->current_baud_rate);
|
||||||
if (ret != BLISP_OK) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
printf("Setting flash parameters...\n");
|
printf("Setting flash parameters...\n");
|
||||||
ret = bl808_load_flash_para(device);
|
ret = bl808_load_flash_para(device);
|
||||||
if (ret != BLISP_OK) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,20 +151,20 @@ blisp_return_t blisp_common_prepare_flash(struct blisp_device* device) {
|
|||||||
|
|
||||||
ret = blisp_device_check_image(device);
|
ret = blisp_device_check_image(device);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
fprintf(stderr, "Failed to check image.\n");
|
fprintf(stderr, "Failed to check image, ret: %d\n", ret);
|
||||||
goto exit1;
|
goto exit1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = blisp_device_run_image(device);
|
ret = blisp_device_run_image(device);
|
||||||
if (ret != BLISP_OK) {
|
if (ret != BLISP_OK) {
|
||||||
fprintf(stderr, "Failed to run image.\n");
|
fprintf(stderr, "Failed to run image, ret: %d\n", ret);
|
||||||
goto exit1;
|
goto exit1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Sending a handshake...\n");
|
printf("Sending a handshake...\n");
|
||||||
ret = blisp_device_handshake(device, true);
|
ret = blisp_device_handshake(device, true);
|
||||||
if (ret != BLISP_OK) {
|
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;
|
goto exit1;
|
||||||
}
|
}
|
||||||
printf("Handshake with eflash_loader successful.\n");
|
printf("Handshake with eflash_loader successful.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user