| /* |
| * Copyright (c) 2019 The Fuchsia Authors |
| */ |
| |
| #include <config.h> |
| #include <common.h> |
| |
| /* #include <fastboot.h> */ |
| #include <aboot.h> |
| #include <fb_fastboot.h> |
| #include <zircon-estelle/partition.h> |
| |
| void fb_zircon_flash_write(const char *cmd, void *download_buffer, |
| unsigned int download_bytes) |
| { |
| int ret; |
| uint64_t ptn_size; |
| |
| ret = zircon_get_partititon_size(cmd, &ptn_size); |
| if (ret) { |
| error(" invalid NAND device"); |
| fastboot_fail(" invalid NAND device"); |
| return; |
| } |
| |
| printf("Flashing raw image to %s partition\n", cmd); |
| |
| ret = zircon_partition_write(cmd, 0, download_buffer, download_bytes); |
| |
| printf("........ wrote %u bytes\n", download_bytes); |
| |
| if (ret) { |
| fastboot_fail("error writing the image"); |
| return; |
| } |
| |
| fastboot_okay(""); |
| } |
| |
| void fb_zircon_erase(const char *cmd) |
| { |
| int ret; |
| uint64_t ptn_size; |
| |
| ret = zircon_get_partititon_size(cmd, &ptn_size); |
| if (ret) { |
| error(" invalid NAND device"); |
| fastboot_fail(" invalid NAND device"); |
| return; |
| } |
| |
| ret = zircon_partition_erase(cmd); |
| if (ret) { |
| fastboot_fail("failed erasing from device"); |
| return; |
| } |
| fastboot_okay(NULL); |
| } |