blob: e724e702bdc71aeac6a495061fd5b77c885a8508 [file] [log] [blame]
Jassi Brar6b403ca2023-05-31 00:29:56 -05001// 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 */
15void 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}