Jassi Brar | 6b403ca | 2023-05-31 00:29:56 -0500 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | /* |
| 3 | * Copyright (c) 2023, Linaro Limited |
| 4 | */ |
| 5 | |
| 6 | #include <efi_loader.h> |
| 7 | #include <fwu.h> |
| 8 | #include <fwu_mdata.h> |
| 9 | #include <memalign.h> |
| 10 | #include <mtd.h> |
| 11 | |
| 12 | #define DFU_ALT_BUF_LEN 256 |
| 13 | |
| 14 | /* Generate dfu_alt_info from partitions */ |
| 15 | void set_dfu_alt_info(char *interface, char *devstr) |
| 16 | { |
| 17 | ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); |
| 18 | struct mtd_info *mtd; |
| 19 | int ret; |
| 20 | |
| 21 | memset(buf, 0, sizeof(buf)); |
| 22 | |
| 23 | mtd_probe_devices(); |
| 24 | |
| 25 | mtd = get_mtd_device_nm("nor1"); |
| 26 | if (IS_ERR_OR_NULL(mtd)) |
| 27 | return; |
| 28 | |
| 29 | ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd); |
| 30 | if (ret < 0) { |
| 31 | log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret); |
| 32 | return; |
| 33 | } |
| 34 | log_debug("Make dfu_alt_info: '%s'\n", buf); |
| 35 | |
| 36 | env_set("dfu_alt_info", buf); |
| 37 | } |