Skip to content
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

Add NOR image support and support non boot-resource image #39

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/OpenixCard/FEX2CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ void FEX2CFG::parse_fex() {
fex_classed = inicpp::parser::load(awImgFexClassed);
} catch(const inicpp::ambiguity_exception &e) {
LOG::ERROR(std::string("Partition table error, bad format. ") + std::string(e.what()));
return;
LOG::ERROR(std::string("Your Partition table: "));
std::cout << awImgFexClassed << std::endl;
LOG::ERROR(std::string("Please fix in `sys_partition.fex` and re-pack with Allwinner BSP"));
std::exit(-1);
}
}

Expand All @@ -123,7 +126,6 @@ void FEX2CFG::parse_fex() {
return awImgCfg;
}


uint FEX2CFG::get_image_real_size(bool print) {
get_partition_real_size();
uint total_size = 0;
Expand All @@ -144,7 +146,7 @@ void FEX2CFG::gen_cfg() {
awImgCfg += ".img {\n";

// For Debug
// print_partition_table();
print_partition_table();

// Generate file from FEX
awImgCfg += gen_linux_cfg_from_fex_map(fex_classed, type);
Expand Down
2 changes: 1 addition & 1 deletion src/OpenixCard/FEX2CFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FEX2CFG {
std::string awImgFex = {};
std::string awImgCfg = {};
std::string awImgFexClassed = {};
partition_table_type type = partition_table_type::hybrid;
partition_table_type type = partition_table_type::gpt;

void open_file(const std::string &file_path);

Expand Down
26 changes: 25 additions & 1 deletion src/OpenixCard/payloads/linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ std::string gen_linux_cfg_from_fex_map(const inicpp::config &fex, partition_tabl
partition_table_struct patab;
linux_compensate compensate;
std::string cfg_data;

// check type
for (auto &sect: fex) {
patab = {}; // reflash struce
for (auto &opt: sect) {
if (opt.get_name() == "name") {
patab.name = opt.get<inicpp::string_ini_t>();
} else if (opt.get_name() == "size") {
patab.size = opt.get<inicpp::unsigned_ini_t>();
} else if (opt.get_name() == "downloadfile") {
patab.downloadfile = opt.get<inicpp::string_ini_t>();
} else if (opt.get_name() == "user_type") {
patab.user_type = opt.get<inicpp::unsigned_ini_t>();
} else {
// Droped.
}
}
if (patab.name == "boot-resource") {
type = partition_table_type::hybrid;
} else if (patab.downloadfile == "\"boot-resource.fex\"") {
type = partition_table_type::hybrid;
}
}

cfg_data += "\thdimage{\n";

switch(type){
Expand All @@ -31,7 +55,7 @@ std::string gen_linux_cfg_from_fex_map(const inicpp::config &fex, partition_tabl
cfg_data += "\t\tpartition-table-type = \"mbr\"\n";
break;
default:
cfg_data += "\t\tpartition-table-type = \"hybrid\"\n";
cfg_data += "\t\tpartition-table-type = \"gpt\"\n";
break;
}

Expand Down