Skip to content

Commit

Permalink
Merge pull request #39 from YuzukiTsuru/dev
Browse files Browse the repository at this point in the history
Add NOR image support and support non boot-resource image
  • Loading branch information
YuzukiTsuru authored May 16, 2023
2 parents 9f3f812 + a1a4581 commit 2f1b1c7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
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

0 comments on commit 2f1b1c7

Please sign in to comment.