Skip to content

Commit

Permalink
Add printing of bootloader info
Browse files Browse the repository at this point in the history
For bootloaders with embedded partition tables, now prints bootloader details before the partitions
  • Loading branch information
will-v-pi committed Nov 15, 2024
1 parent e08e4a2 commit a792948
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3999,21 +3999,35 @@ bool info_command::execute(device_map &devices) {
auto partitions = get_partitions(connection);
vector<uint32_t> starts;
if (partitions) {
// Check if bootloader is present, based on presence of binary info
binary_info_header hdr;
auto bi_access = get_bi_access(access);
bool has_bootloader = find_binary_info(*bi_access, hdr);

// Don't show device, until all partitions done
bool device = settings.info.show_device || settings.info.all;
bool debug = settings.info.show_debug || settings.info.all;
if (settings.info.all) {
settings.info.show_basic = true;
settings.info.show_pins = true;
settings.info.show_build = true;
settings.info.show_metadata = true;
settings.info.all = false;
}
if ((settings.info.show_basic || settings.info.show_pins || settings.info.show_build) || !(settings.info.show_device || settings.info.show_debug)) {
if ((settings.info.show_basic || settings.info.show_pins || settings.info.show_build || settings.info.show_metadata) || !(settings.info.show_device || settings.info.show_debug)) {
settings.info.show_device = false;
settings.info.show_debug = false;
for (auto range : *partitions) {
starts.push_back(std::get<0>(range));
}
if (has_bootloader && std::none_of(starts.cbegin(), starts.cend(), [](int i) { return i == 0; })) {
// Print bootloader info, only if bootloader is present and not in a partition
fos.first_column(0); fos.hanging_indent(0);
fos << "\nBootloader\n";
fos.first_column(1);
partition_memory_access part_access(access, 0);
info_guts(part_access, &connection);
}
for (unsigned int i=0; i < starts.size(); i++) {
uint32_t start = starts[i];
fos.first_column(0); fos.hanging_indent(0);
Expand All @@ -4029,6 +4043,7 @@ bool info_command::execute(device_map &devices) {
settings.info.show_basic = false;
settings.info.show_pins = false;
settings.info.show_build = false;
settings.info.show_metadata = false;
settings.info.show_device = device;
settings.info.show_debug = debug;
info_guts(access, &connection);
Expand Down

0 comments on commit a792948

Please sign in to comment.