-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] rimage: Add support for multiple toml file #179
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,14 @@ int main(int argc, char *argv[]) | |
{ | ||
struct image image; | ||
struct adsp *heap_adsp; | ||
const char *adsp_config = NULL; | ||
int opt, ret, i, first_non_opt; | ||
struct adsp_conf_files files; | ||
int opt, ret, first_non_opt; | ||
int use_ext_man = 0; | ||
unsigned int pv_bit = 0; | ||
const char *adsp_desc_suffix = ".toml"; | ||
bool imr_type_override = false; | ||
int i = 0; | ||
size_t len; | ||
|
||
memset(&image, 0, sizeof(image)); | ||
|
||
|
@@ -84,7 +87,8 @@ int main(int argc, char *argv[]) | |
use_ext_man = 1; | ||
break; | ||
case 'c': | ||
adsp_config = optarg; | ||
files.file[i] = optarg; | ||
i++; | ||
break; | ||
case 'y': | ||
image.verify_file = optarg; | ||
|
@@ -110,24 +114,38 @@ int main(int argc, char *argv[]) | |
first_non_opt = optind; | ||
|
||
/* we must have config */ | ||
if (!adsp_config) { | ||
if (i == 0 || i >= MAX_SUPPORTED_CONF_FILES) { | ||
usage(argv[0]); | ||
fprintf(stderr, "error: must have adsp desc\n"); | ||
fprintf(stderr, "error: invalid number of adsp_desc provided\n"); | ||
return -EINVAL; | ||
} | ||
files.file_count = i; | ||
|
||
/* requires private key */ | ||
if (!image.key_name) { | ||
fprintf(stderr, "error: requires private key\n"); | ||
return -EINVAL; | ||
} | ||
|
||
/* make sure we have an outfile if not verifying */ | ||
if ((!image.out_file && !image.verify_file)) { | ||
/* We are either signing or verifying an image, not both or neither */ | ||
if (!(!!image.out_file ^ !!image.verify_file)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possible to figure out a more easier expression for better understanding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. " not both or neither " would this not imply to fail if |
||
usage(argv[0]); | ||
return -EINVAL; | ||
} | ||
|
||
/* Construct the output path for the final adsp_desc toml */ | ||
files.out_file = NULL; | ||
if (image.out_file){ | ||
len = strlen(image.out_file); | ||
files.out_file = malloc(len + strlen(adsp_desc_suffix) + 1); | ||
strcpy(files.out_file, image.out_file); | ||
} else { | ||
len = strlen(image.verify_file); | ||
files.out_file = malloc(len + strlen(adsp_desc_suffix) + 1); | ||
strcpy(files.out_file, image.verify_file); | ||
} | ||
strcpy(files.out_file + len, adsp_desc_suffix); | ||
|
||
/* firmware version: major.minor.micro */ | ||
if (image.fw_ver_string) { | ||
ret = sscanf(image.fw_ver_string, "%hu.%hu.%hu", | ||
|
@@ -161,7 +179,7 @@ int main(int argc, char *argv[]) | |
} | ||
image.adsp = heap_adsp; | ||
memset(heap_adsp, 0, sizeof(*heap_adsp)); | ||
ret = adsp_parse_config(adsp_config, &image); | ||
ret = adsp_parse_config(&files, &image); | ||
if (ret < 0) | ||
goto out; | ||
|
||
|
@@ -272,5 +290,7 @@ int main(int argc, char *argv[]) | |
if (image.out_fd) | ||
fclose(image.out_fd); | ||
|
||
free(files.out_file); | ||
|
||
return ret; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use file pointer as parameter is not always proposed, directly read and write is also very simple.
btw, how about fread/fwrite? since toml file is not big.