@@ -1939,6 +1939,15 @@ bool get_json_int(json value, T& out) {
19391939 }
19401940}
19411941
1942+ bool get_json_bool (json value, bool & out) {
1943+ if (value.is_boolean ()) {
1944+ out = value;
1945+ return true ;
1946+ } else {
1947+ return false ;
1948+ }
1949+ }
1950+
19421951uint32_t bootrom_func_lookup_rp2040 (memory_access& access, uint16_t tag) {
19431952 model_t model = access.get_model ();
19441953 // we are only used on RP2040
@@ -6587,10 +6596,23 @@ bool partition_create_command::execute(device_map &devices) {
65876596 else {string p_id = p[" id" ]; fail (ERROR_INCOMPATIBLE, " Partition ID \" %s\" is not a valid 64bit integer\n " , p_id.c_str ());}
65886597 }
65896598
6590- if (p.contains (" no_reboot_on_uf2_download" )) new_p.flags |= PICOBIN_PARTITION_FLAGS_UF2_DOWNLOAD_NO_REBOOT_BITS;
6591- if (p.contains (" ab_non_bootable_owner_affinity" )) new_p.flags |= PICOBIN_PARTITION_FLAGS_UF2_DOWNLOAD_AB_NON_BOOTABLE_OWNER_AFFINITY;
6592- if (p.contains (" ignored_during_riscv_boot" )) new_p.flags |= PICOBIN_PARTITION_FLAGS_IGNORED_DURING_RISCV_BOOT_BITS;
6593- if (p.contains (" ignored_during_arm_boot" )) new_p.flags |= PICOBIN_PARTITION_FLAGS_IGNORED_DURING_ARM_BOOT_BITS;
6599+ bool tmp_bool;
6600+ for (const auto & pair : std::vector<std::pair<std::string, uint32_t >>{
6601+ {" no_reboot_on_uf2_download" , PICOBIN_PARTITION_FLAGS_UF2_DOWNLOAD_NO_REBOOT_BITS},
6602+ {" ab_non_bootable_owner_affinity" , PICOBIN_PARTITION_FLAGS_UF2_DOWNLOAD_AB_NON_BOOTABLE_OWNER_AFFINITY},
6603+ {" ignored_during_riscv_boot" , PICOBIN_PARTITION_FLAGS_IGNORED_DURING_RISCV_BOOT_BITS},
6604+ {" ignored_during_arm_boot" , PICOBIN_PARTITION_FLAGS_IGNORED_DURING_ARM_BOOT_BITS},
6605+ }) {
6606+ const std::string json_flag = pair.first ;
6607+ const uint32_t FLAG_BITS = pair.second ;
6608+ if (p.contains (json_flag)) {
6609+ if (get_json_bool (p[json_flag], tmp_bool)) {
6610+ new_p.flags |= (tmp_bool ? FLAG_BITS : 0 );
6611+ } else {
6612+ fail (ERROR_INCOMPATIBLE, " Partition %d %s value is not a valid boolean\n " , pt.partitions .size (), json_flag.c_str ());
6613+ }
6614+ }
6615+ }
65946616 pt.partitions .push_back (new_p);
65956617 }
65966618
0 commit comments