firestarter 3.2.7b3__tar.gz → 3.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. {firestarter-3.2.7b3/firestarter.egg-info → firestarter-3.3.0}/PKG-INFO +1 -1
  2. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/_version.py +3 -3
  3. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/chip_resolver.py +27 -2
  4. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/cli_handlers.py +65 -16
  5. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/codec.py +73 -33
  6. firestarter-3.3.0/firestarter/command_codec.py +188 -0
  7. firestarter-3.3.0/firestarter/command_frame.py +105 -0
  8. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/constants.py +21 -28
  9. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/data/chip_database.json +383 -262
  10. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/data/pinouts.json +11 -1
  11. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/database.py +2 -2
  12. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/diagnostic_report.py +1 -1
  13. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/eprom_info.py +2 -1
  14. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/eprom_operations.py +54 -91
  15. firestarter-3.3.0/firestarter/eprom_rows.py +12 -0
  16. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/exceptions.py +19 -0
  17. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/firmware.py +11 -0
  18. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/frame_parser.py +7 -2
  19. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/fw_release_gate.py +49 -12
  20. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/hardware.py +120 -85
  21. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/ic_layout.py +3 -1
  22. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/jumper_table.py +10 -0
  23. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/messages.py +102 -10
  24. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/page_size_gate.py +4 -4
  25. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/serial_comm.py +135 -80
  26. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/vpp_display.py +8 -1
  27. firestarter-3.3.0/firestarter/write_budget.py +74 -0
  28. {firestarter-3.2.7b3 → firestarter-3.3.0/firestarter.egg-info}/PKG-INFO +1 -1
  29. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter.egg-info/SOURCES.txt +14 -2
  30. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter.egg-info/scm_file_list.json +14 -4
  31. firestarter-3.3.0/firestarter.egg-info/scm_version.json +8 -0
  32. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/__snapshots__/test_characterization.ambr +2 -2
  33. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/conftest.py +221 -95
  34. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fake_chip.py +4 -33
  35. firestarter-3.3.0/tests/fixtures/operator_doubles.py +114 -0
  36. firestarter-3.3.0/tests/fixtures/ready_ack.py +46 -0
  37. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/report_shapes.py +24 -126
  38. firestarter-3.3.0/tests/fresh_cli.py +116 -0
  39. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/golden/chip_database_field_inventory.json +5 -32
  40. firestarter-3.3.0/tests/golden/command_vectors.json +435 -0
  41. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/golden/wire_dict.json +41 -4
  42. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/plan_corpus.py +29 -49
  43. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_b15_page_size_corroboration.py +0 -55
  44. firestarter-3.3.0/tests/test_bandgap_back_solve.py +64 -0
  45. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_blast_radius_invariance.py +4 -177
  46. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_boot_block_hint.py +7 -20
  47. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_budget_failure_render.py +32 -89
  48. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_bug_characterization.py +17 -24
  49. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_build_db_inclusion.py +111 -5
  50. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_canonical_part_number.py +5 -46
  51. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_characterization.py +7 -31
  52. firestarter-3.3.0/tests/test_chip_database_field_inventory.py +220 -0
  53. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_name_resolution.py +38 -46
  54. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_resolver.py +142 -1
  55. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_test.py +309 -460
  56. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_test_blank_check_order.py +7 -12
  57. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_test_cycle.py +17 -40
  58. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_test_sdp_leg.py +93 -336
  59. firestarter-3.3.0/tests/test_chip_test_timing.py +145 -0
  60. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_chip_test_uv_slot_write.py +35 -122
  61. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_cli_handlers.py +72 -238
  62. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_cobs.py +2 -57
  63. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_codec.py +7 -9
  64. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_codec_format_message.py +81 -47
  65. firestarter-3.3.0/tests/test_command_codec.py +314 -0
  66. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_compare.py +86 -166
  67. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_config.py +11 -20
  68. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_config_band_refusal.py +96 -19
  69. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_connect_cost_harness.py +1 -7
  70. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_consistency_check.py +153 -210
  71. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_coverage_floor_v18.py +6 -17
  72. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_database_conversion.py +3 -1
  73. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_datasheet_overrides.py +5 -18
  74. firestarter-3.3.0/tests/test_decoder.py +475 -0
  75. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_derive_plan_no_drop_sweep.py +3 -109
  76. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_derive_plan_structural_sentinel.py +53 -319
  77. firestarter-3.3.0/tests/test_dev_group_channel_gating.py +187 -0
  78. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_dev_test_cmd.py +40 -150
  79. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_dev_tools_channel_gate.py +23 -7
  80. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_devtest_firmware_error_propagation.py +4 -15
  81. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_diagnostic_report.py +213 -384
  82. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_dip24_2816_erase_gate.py +12 -13
  83. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_eprom_info.py +3 -1
  84. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_eprom_operations.py +256 -794
  85. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_erase_blank_step_nonregression.py +4 -27
  86. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_erase_flag_invariants.py +15 -25
  87. firestarter-3.3.0/tests/test_even_block.py +132 -0
  88. firestarter-3.3.0/tests/test_every_row_encodes.py +41 -0
  89. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_firmware_install.py +32 -54
  90. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_flash4_erase_gate.py +10 -22
  91. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fw_list_failure_vs_empty.py +0 -9
  92. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fw_port_targeting_and_blind_install.py +10 -18
  93. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fw_release_gate.py +142 -101
  94. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fw_update_dead_endpoint.py +4 -3
  95. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fw_update_path_gate.py +24 -47
  96. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fw_version_guard.py +5 -16
  97. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_fwguard.py +13 -32
  98. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_hardware.py +143 -194
  99. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_hw_revision_gate.py +12 -151
  100. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_ic_layout.py +3 -17
  101. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_info_vpp_and_erase.py +37 -15
  102. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_jp5_gate.py +23 -22
  103. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_jumper_table.py +9 -4
  104. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_lock_status_class_partition.py +12 -14
  105. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_lock_status_cli.py +0 -5
  106. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_lock_status_wire.py +36 -41
  107. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_logging_utils.py +9 -9
  108. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_matrix_artifact.py +3 -36
  109. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_page_size_alignment_refusal.py +37 -41
  110. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_page_size_invariants.py +29 -65
  111. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_page_size_write_refusal.py +29 -31
  112. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_parse_devtest_issue.py +3 -4
  113. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_probe_spurious_setup_ack.py +17 -30
  114. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_programming_vcc_census.py +8 -108
  115. firestarter-3.3.0/tests/test_protect_flags_doc_measurements.py +32 -0
  116. firestarter-3.3.0/tests/test_protection_table_citations.py +56 -0
  117. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_protocol_not_implemented.py +2 -45
  118. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_protocol_not_implemented_production_path.py +24 -152
  119. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_provenance.py +0 -17
  120. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_pulse_us_override.py +38 -118
  121. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_py32_channel_gating.py +20 -114
  122. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_py32_dfu.py +7 -9
  123. firestarter-3.3.0/tests/test_pyusb_api_surface.py +155 -0
  124. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_sdp_capability.py +0 -3
  125. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_sdp_db_invariant.py +1 -41
  126. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_serial_characterization.py +27 -20
  127. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_serial_comm.py +52 -129
  128. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_session_lease.py +7 -14
  129. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_setup_refusals.py +13 -14
  130. firestarter-3.3.0/tests/test_setup_typed_refusals.py +109 -0
  131. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_submit.py +265 -897
  132. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_transport_counters.py +38 -31
  133. firestarter-3.3.0/tests/test_unsupported_frame_fallback.py +252 -0
  134. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_utils.py +8 -9
  135. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_validate_family_cmd.py +0 -6
  136. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_validate_oracle.py +27 -137
  137. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_validated_parts_regression_surface.py +51 -43
  138. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_vcc_margin_rail.py +35 -49
  139. firestarter-3.3.0/tests/test_vpp_decode_table.py +50 -0
  140. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_vpp_rail_classification.py +3 -211
  141. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_wire_dict_equivalence.py +11 -26
  142. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_blank_guard.py +107 -275
  143. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_blank_guard_pinning.py +20 -18
  144. firestarter-3.3.0/tests/test_write_budget.py +52 -0
  145. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_guard_port_pinning.py +18 -52
  146. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_progress.py +56 -129
  147. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_response_budget.py +164 -267
  148. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_skip_erase_0x0d.py +2 -8
  149. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_skip_sdp_unlock.py +34 -86
  150. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_write_verify.py +77 -213
  151. firestarter-3.2.7b3/firestarter.egg-info/scm_version.json +0 -8
  152. firestarter-3.2.7b3/tests/golden/build_db_part_specific_constants.json +0 -19
  153. firestarter-3.2.7b3/tests/test_build_db_constant_census.py +0 -138
  154. firestarter-3.2.7b3/tests/test_chip_database_field_inventory.py +0 -401
  155. firestarter-3.2.7b3/tests/test_chip_test_timing.py +0 -243
  156. firestarter-3.2.7b3/tests/test_decoder.py +0 -668
  157. firestarter-3.2.7b3/tests/test_dev_group_channel_gating.py +0 -331
  158. firestarter-3.2.7b3/tests/test_even_block.py +0 -198
  159. firestarter-3.2.7b3/tests/test_protect_flags_doc_measurements.py +0 -298
  160. firestarter-3.2.7b3/tests/test_protection_table_citations.py +0 -141
  161. firestarter-3.2.7b3/tests/test_pyusb_api_surface.py +0 -209
  162. firestarter-3.2.7b3/tests/test_vpp_decode_table.py +0 -59
  163. {firestarter-3.2.7b3 → firestarter-3.3.0}/LICENSE +0 -0
  164. {firestarter-3.2.7b3 → firestarter-3.3.0}/MANIFEST.in +0 -0
  165. {firestarter-3.2.7b3 → firestarter-3.3.0}/README.md +0 -0
  166. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/__init__.py +0 -0
  167. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/address_parser.py +0 -0
  168. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/avr_tool.py +0 -0
  169. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/channel.py +0 -0
  170. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/chip_test.py +0 -0
  171. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/compare.py +0 -0
  172. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/config.py +0 -0
  173. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/dip24_2816_erase_gate.py +0 -0
  174. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/erase_support.py +0 -0
  175. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/flash4_erase_gate.py +0 -0
  176. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/jp5_gate.py +0 -0
  177. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/lock_status.py +0 -0
  178. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/log_capture.py +0 -0
  179. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/logging_utils.py +0 -0
  180. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/main.py +0 -0
  181. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/protection_readability.py +0 -0
  182. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/py32_dfu.py +0 -0
  183. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/sdp_capability.py +0 -0
  184. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/sdp_honesty.py +0 -0
  185. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/submit.py +0 -0
  186. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/timestamps.py +0 -0
  187. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/transport_counters.py +0 -0
  188. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/utils.py +0 -0
  189. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter/write_blank_guard.py +0 -0
  190. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter.egg-info/dependency_links.txt +0 -0
  191. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter.egg-info/entry_points.txt +0 -0
  192. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter.egg-info/requires.txt +0 -0
  193. {firestarter-3.2.7b3 → firestarter-3.3.0}/firestarter.egg-info/top_level.txt +0 -0
  194. {firestarter-3.2.7b3 → firestarter-3.3.0}/pyproject.toml +0 -0
  195. {firestarter-3.2.7b3 → firestarter-3.3.0}/setup.cfg +0 -0
  196. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/__init__.py +0 -0
  197. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/part_number_delta.json +0 -0
  198. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/at28c256-full-all-ok-sdp.json +0 -0
  199. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/attr01-status-axis-transport-fault.json +0 -0
  200. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/gh20-at28c256-fail.json +0 -0
  201. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/gh23-w27e257-fail.json +0 -0
  202. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/gh28-m27c512-fail.json +0 -0
  203. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/gh47-sst27sf512-pass.json +0 -0
  204. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/m27c512-full-all-ok.json +0 -0
  205. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/m27c512-full-blank-check-bad.json +0 -0
  206. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/m27c512-full-canonical-name.json +0 -0
  207. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/m27c512-full-comma-joined-name.json +0 -0
  208. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/m27c512-full-runs-1.json +0 -0
  209. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/prune03-synthesized-fingerprint-match.json +0 -0
  210. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/sst27sf512-full-all-ok.json +0 -0
  211. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/sst27sf512-six-step-readback-gated.json +0 -0
  212. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/sst27sf512-six-step.json +0 -0
  213. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/synthetic-arm4-empty-results.json +0 -0
  214. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/synthetic-arm4-no-ok.json +0 -0
  215. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/uv-slot-write-pass.json +0 -0
  216. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/reports/w27e257-full-all-ok.json +0 -0
  217. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/shape_ids.json +0 -0
  218. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/fixtures/synthetic_nonzero_chip_id.py +0 -0
  219. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_address_parser.py +0 -0
  220. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_build_db_interpret_timing.py +0 -0
  221. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_build_db_pinout_fork.py +0 -0
  222. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_build_db_sram_non_volatile.py +0 -0
  223. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_click_group_gate_hook.py +0 -0
  224. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_dfu_opcode_anchors.py +0 -0
  225. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_endpoint_constants.py +0 -0
  226. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_eprom_database.py +0 -0
  227. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_error_code_seam.py +0 -0
  228. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_extra_chips_supplement.py +0 -0
  229. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_log_capture.py +0 -0
  230. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_protection_resolution.py +0 -0
  231. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_protection_status_catalog.py +0 -0
  232. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_py32_flash_map_host.py +0 -0
  233. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_py32_pyusb_absent.py +0 -0
  234. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_sdp_honesty.py +0 -0
  235. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_timestamps.py +0 -0
  236. {firestarter-3.2.7b3 → firestarter-3.3.0}/tests/test_uv_mask.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: firestarter
3
- Version: 3.2.7b3
3
+ Version: 3.3.0
4
4
  Summary: EPROM programmer software for the Relatively Universal ROM Programmer
5
5
  Author-email: Henrik Olsson <henols@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/henols/firestarter_app
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '3.2.7b3'
22
- __version_tuple__ = version_tuple = (3, 2, 7, 'b3')
21
+ __version__ = version = '3.3.0'
22
+ __version_tuple__ = version_tuple = (3, 3, 0)
23
23
 
24
- __commit_id__ = commit_id = 'g85b7152'
24
+ __commit_id__ = commit_id = 'g927ad2b'
@@ -9,7 +9,7 @@ Single chokepoint between CLI dispatch and the EPROM database lookup/conversion.
9
9
 
10
10
  from typing import Any
11
11
 
12
- from firestarter.database import ROM_CE, ROM_OE, EpromDatabase
12
+ from firestarter.database import ROM_CE, ROM_OE, EpromDatabase, pin_conversions
13
13
  from firestarter.exceptions import (
14
14
  AmbiguousChipNameError,
15
15
  ChipNotFoundError,
@@ -18,6 +18,13 @@ from firestarter.exceptions import (
18
18
 
19
19
  _NON_ZERO_WIRE_FIELDS = ("memory-size", "pin-count", "vpp_mv")
20
20
 
21
+ # The 0x10 (Intel 28F) handler routes 12V to socket pin 1 (CTRL_VPP_P1_ENABLE).
22
+ _INTEL_28F_ALGORITHM = 0x10
23
+
24
+ # The shield supplies a fixed 5V VCC. Must agree with SHIELD_MIN_VCC_MV in
25
+ # tools/build_db.py.
26
+ _SHIELD_MIN_VCC_MV = 4500
27
+
21
28
 
22
29
  def _qualified_choices(name: str, db: EpromDatabase) -> list[str]:
23
30
  """The row `name` selects first, then each other row it selects that
@@ -115,13 +122,22 @@ def resolve_chip(name: str, db: EpromDatabase | None = None) -> dict[str, Any]:
115
122
  "a chip entry must specify a non-zero 'algorithm' to be programmed"
116
123
  )
117
124
 
125
+ # A 3V part runs out of its rating on the shield's 5V supply. A user
126
+ # override that marks such a row supported is refused here, before any wire.
127
+ vcc_mv = raw_config.get("electrical", {}).get("vcc_mv")
128
+ if isinstance(vcc_mv, int) and 0 < vcc_mv < _SHIELD_MIN_VCC_MV:
129
+ raise ChipNotImplementedError(
130
+ f"{name}: the chip's operating VCC is {vcc_mv / 1000:g}V, but the "
131
+ "shield supplies 5V. The programmer refuses the chip."
132
+ )
133
+
118
134
  full = db.get_eprom(name)
119
135
  data = db.convert_to_programmer(full) if full else None
120
136
  if not data:
121
137
  raise ChipNotFoundError(name)
122
138
 
123
139
  # The firmware refuses a memory command whose memory-size, pin-count or
124
- # vpp_mv is 0, with the same 'Bad JSON' answer that old firmware gives.
140
+ # vpp_mv is 0 (MSG_ERR_BAD_COMMAND), so the port walk sees no programmer.
125
141
  # No shipped row has a 0 here; a user database override can.
126
142
  zero_fields = [key for key in _NON_ZERO_WIRE_FIELDS if not data.get(key)]
127
143
  if zero_fields:
@@ -148,4 +164,13 @@ def resolve_chip(name: str, db: EpromDatabase | None = None) -> dict[str, Any]:
148
164
  f"{1 << len(bus)} of its {data['memory-size']} bytes. The programmer "
149
165
  "cannot address the rest of the chip."
150
166
  )
167
+ # The 0x10 handler puts 12V on socket pin 1, so a 0x10 chip whose bus uses
168
+ # that pin (A18 on the SST28SF040 family) would take 12V on an address
169
+ # line. Only a 32-pin chip has a pin there: a smaller chip sits
170
+ # bottom-aligned, and none of its pins converts to the socket pin 1 line.
171
+ if bus and algorithm == _INTEL_28F_ALGORITHM and pin_conversions[32][1] in bus:
172
+ raise ChipNotImplementedError(
173
+ f"{name}: algorithm 0x10 puts 12V on socket pin 1, but the chip's pin "
174
+ "map uses pin 1 as an address line. The programmer refuses the chip."
175
+ )
151
176
  return data
@@ -21,6 +21,7 @@ import click.shell_completion
21
21
  from rich.console import Console
22
22
 
23
23
  from firestarter import __version__ as version
24
+ from firestarter import command_frame as cf
24
25
  from firestarter import (
25
26
  dip24_2816_erase_gate,
26
27
  flash4_erase_gate,
@@ -62,6 +63,7 @@ from firestarter.chip_test import (
62
63
  sdp_hold_state,
63
64
  sdp_oracle_applicable,
64
65
  )
66
+ from firestarter.command_codec import CommandEncodeError
65
67
  from firestarter.config import ConfigManager, get_config_dir
66
68
  from firestarter.constants import (
67
69
  CONFIG_R1_MAX,
@@ -85,6 +87,7 @@ from firestarter.exceptions import (
85
87
  ChipNotFoundError,
86
88
  ChipNotImplementedError,
87
89
  EpromOperationError,
90
+ FirmwareFrameVersionError,
88
91
  FirmwareOperationError,
89
92
  FirmwareOutdatedError,
90
93
  HardwareOperationError,
@@ -98,7 +101,7 @@ from firestarter.exceptions import (
98
101
  )
99
102
  from firestarter.firmware import FIRMWARE_VERSION_RE, FirmwareManager
100
103
  from firestarter.fw_release_gate import require_installable_release
101
- from firestarter.hardware import HardwareManager
104
+ from firestarter.hardware import HardwareManager, bandgap_from_measured_vcc
102
105
  from firestarter.lock_status import (
103
106
  classify_protection_response,
104
107
  exit_code_for_class,
@@ -238,6 +241,8 @@ def map_typed_errors(f: Callable[..., Any]) -> Callable[..., Any]:
238
241
  return f(*args, **kwargs)
239
242
  except ChipNotFoundError as e:
240
243
  raise click.ClickException(str(e)) from e
244
+ except FirmwareFrameVersionError as e:
245
+ raise click.ClickException(f"Command frame version mismatch: {e}") from e
241
246
  except FirmwareOutdatedError as e:
242
247
  raise click.ClickException(f"Firmware outdated: {e}") from e
243
248
  except (SerialError, SerialTimeoutError) as e:
@@ -269,6 +274,11 @@ def map_typed_errors(f: Callable[..., Any]) -> Callable[..., Any]:
269
274
  # make this host-voiced refusal (write_blank_guard.py) read as a
270
275
  # hardware fault instead of an input-validation refusal.
271
276
  raise click.ClickException(str(e)) from e
277
+ except CommandEncodeError as e:
278
+ # The host refused the command before any byte reached the port.
279
+ # Above the EpromOperationError arm: "Programmer error" would read
280
+ # as a hardware fault for an input the frame cannot carry.
281
+ raise click.ClickException(f"Refused before sending: {e}") from e
272
282
  except EpromOperationError as e:
273
283
  raise click.ClickException(f"Programmer error: {e}") from e
274
284
  except Pin1HazardRefusedError as e:
@@ -367,6 +377,7 @@ def _build_op_flags(
367
377
  # SDP auto-set condition inside write() below -- flipping this default
368
378
  # invalidates the removal-safety argument the `dev sdp` removal rests on.
369
379
  skip_sdp_unlock: bool = False,
380
+ skip_final_verify: bool = False,
370
381
  input_enable: bool | None = None,
371
382
  chip_disable: bool | None = None,
372
383
  ) -> int:
@@ -396,6 +407,7 @@ def _build_op_flags(
396
407
  verbose,
397
408
  skip_erase=skip_erase,
398
409
  skip_sdp_unlock=skip_sdp_unlock,
410
+ skip_final_verify=skip_final_verify,
399
411
  )
400
412
  if input_enable is not None:
401
413
  flags |= 0 if input_enable else FLAG_OUTPUT_ENABLE
@@ -933,6 +945,9 @@ def write(
933
945
  vpe_as_vpp=vpe_as_vpp,
934
946
  skip_erase=skip_erase,
935
947
  skip_sdp_unlock=skip_sdp_unlock,
948
+ # The read-back below compares every byte, so the board's own
949
+ # final verify pass would only repeat it.
950
+ skip_final_verify=verify,
936
951
  ),
937
952
  # Translate Click's `None` ("--pulse-us not supplied") into
938
953
  # write_eprom's own integer sentinel (0 means "use the database
@@ -1048,8 +1063,7 @@ def _address_size_refusal_exit_code(
1048
1063
  """Refuse a negative start address or a size below 1 byte before the
1049
1064
  serial port opens.
1050
1065
 
1051
- The firmware refuses both at setup, with the same 'Bad JSON' answer that
1052
- firmware too old for this CLI gives, so without this check the operator
1066
+ The firmware refuses both at setup, so without this check the operator
1053
1067
  sees only "no programmer found". Returns 2 to refuse with, or `None`.
1054
1068
  A malformed string is not refused here: `_setup_operation`'s own parse
1055
1069
  handling still owns that error.
@@ -1592,15 +1606,22 @@ def hw(app: AppContext) -> None:
1592
1606
 
1593
1607
 
1594
1608
  _BANDGAP_NOMINAL_MV = 1100
1609
+ # A plausibility bound for a 5 V supply pin, not a wire limit: the host sends
1610
+ # the bandgap, not the reading. A reading above it is a typo, refused before
1611
+ # any port opens.
1612
+ _CAL_VCC_MAX_V = 10.0
1595
1613
 
1596
1614
 
1597
1615
  @cli.command(name="cal")
1598
1616
  @click.option(
1599
1617
  "--vcc",
1600
- type=click.FloatRange(min=0, min_open=True),
1618
+ type=click.FloatRange(min=0, min_open=True, max=_CAL_VCC_MAX_V),
1601
1619
  default=None,
1602
1620
  metavar="VOLTS",
1603
- help="Calibrate using a multimeter reading of the 5V pin, e.g. --vcc 5.09",
1621
+ help=(
1622
+ "Calibrate using a multimeter reading of the 5V pin, e.g. --vcc 5.09. "
1623
+ f"At most {_CAL_VCC_MAX_V:g} V."
1624
+ ),
1604
1625
  )
1605
1626
  @click.option(
1606
1627
  "--reset",
@@ -1640,21 +1661,43 @@ def cal(app: AppContext, vcc: float | None, reset: bool) -> None:
1640
1661
  if vcc is not None:
1641
1662
  measured_mv = int(round(vcc * 1000))
1642
1663
  before = app.hardware_manager.read_calibration()
1643
- if not app.hardware_manager.calibrate_bandgap(measured_mv):
1664
+ if before is None:
1665
+ click.echo(
1666
+ "Could not read the calibration. The firmware may be older than "
1667
+ "this CLI."
1668
+ )
1669
+ sys.exit(1)
1670
+ bandgap_adc = before["bandgap_adc"]
1671
+ if bandgap_adc == 0:
1672
+ click.echo("This board has no bandgap calibration (py32f071).")
1673
+ sys.exit(1)
1674
+ bandgap_mv = bandgap_from_measured_vcc(measured_mv, bandgap_adc)
1675
+ if bandgap_mv is None:
1644
1676
  click.echo(
1645
1677
  "Calibration refused. The result was outside 1000-1200 mV, which "
1646
1678
  "means the reading does not match this board. Check that the "
1647
- "multimeter is on the 5V pin and that the value is in volts. "
1648
- "A py32f071 board has no bandgap calibration and always "
1649
- "refuses it."
1679
+ "multimeter is on the 5V pin and that the value is in volts."
1650
1680
  )
1651
1681
  sys.exit(1)
1682
+ if not app.hardware_manager.set_bandgap_mv(bandgap_mv):
1683
+ sys.exit(1)
1684
+ # Read the value back over a new connection, so the report is what the
1685
+ # board stored, not what this host sent.
1652
1686
  after = app.hardware_manager.read_calibration()
1653
- if before is not None and after is not None:
1687
+ if after is None:
1654
1688
  click.echo(
1655
- f"Reference: {before['bandgap_mv']} mV -> {after['bandgap_mv']} mV"
1689
+ f"Sent {bandgap_mv} mV, but could not read the calibration back. "
1690
+ "Run 'firestarter cal' to check it."
1656
1691
  )
1657
- _echo_calibration_effect(after["bandgap_mv"])
1692
+ sys.exit(1)
1693
+ if after["bandgap_mv"] != bandgap_mv:
1694
+ click.echo(
1695
+ f"Calibration not stored: the board reports {after['bandgap_mv']} "
1696
+ f"mV, expected {bandgap_mv} mV."
1697
+ )
1698
+ sys.exit(1)
1699
+ click.echo(f"Reference: {before['bandgap_mv']} mV -> {after['bandgap_mv']} mV")
1700
+ _echo_calibration_effect(after["bandgap_mv"])
1658
1701
  sys.exit(0)
1659
1702
 
1660
1703
  current = app.hardware_manager.read_calibration()
@@ -2271,16 +2314,22 @@ if _DEV_TOOLS_ENABLED:
2271
2314
  @click.option(
2272
2315
  "--read-settling",
2273
2316
  "read_settling_us",
2274
- type=int,
2317
+ type=click.IntRange(0, cf.READ_TIMING_MAX_US),
2275
2318
  default=0,
2276
- help="Address-settling delay before /CE assert (µs; 0=firmware default 0µs).",
2319
+ help=(
2320
+ "Address-settling delay before /CE assert "
2321
+ f"(µs, 0..{cf.READ_TIMING_MAX_US}; 0=firmware default 0µs)."
2322
+ ),
2277
2323
  )
2278
2324
  @click.option(
2279
2325
  "--read-strobe",
2280
2326
  "read_strobe_us",
2281
- type=int,
2327
+ type=click.IntRange(0, cf.READ_TIMING_MAX_US),
2282
2328
  default=0,
2283
- help="/CE read-strobe pulse width (µs; 0=firmware default 3µs).",
2329
+ help=(
2330
+ "/CE read-strobe pulse width "
2331
+ f"(µs, 0..{cf.READ_TIMING_MAX_US}; 0=firmware default 3µs)."
2332
+ ),
2284
2333
  )
2285
2334
  @click.pass_obj
2286
2335
  @map_typed_errors
@@ -12,6 +12,7 @@ import logging
12
12
  import struct
13
13
  from typing import Any, List # noqa: UP035
14
14
 
15
+ from firestarter.command_frame import REFUSALS
15
16
  from firestarter.constants import (
16
17
  COMMAND_NAMES,
17
18
  REVISION_0,
@@ -29,22 +30,58 @@ from firestarter.messages import (
29
30
  DEBUG_CATALOG,
30
31
  MSG_DATA_CHUNK,
31
32
  MSG_DEBUG,
33
+ MSG_ERR_BAD_COMMAND,
34
+ MSG_ERR_VPP_HIGH_MV,
32
35
  MSG_INFO_CMD,
33
36
  MSG_INFO_HW,
34
37
  MSG_INFO_PHYSICAL_HW,
38
+ MSG_INFO_REGISTERS,
35
39
  MSG_OK_CFG,
36
40
  MSG_OK_REV,
41
+ MSG_WARN_VPP_HIGH_MV,
42
+ MSG_WARN_VPP_LOW_MV,
37
43
  SEVERITY_LABEL,
38
44
  MessageDef,
39
45
  )
40
46
 
41
47
  logger = logging.getLogger("Codec")
42
48
 
43
- # Older, shorter forms of fixed-width acks that the host still accepts. The
44
- # value is the legacy param-region length; the decoder reads only the leading
45
- # catalog params that fit in it. MSG_OK_CFG gained the trailing u16 bandgap in
46
- # 3.1.0b4, so the 3.1.0 stable firmware still sends the 9-byte form.
47
- _LEGACY_PARAM_BYTES = {MSG_OK_CFG: 9}
49
+ # MSG_INFO_REGISTERS views (firmware sync: dev_tools.cpp DT_VIEW_*).
50
+ _REGISTER_VIEW_REG_FIRESTARTER = 1
51
+ _REGISTER_VIEW_ADDR = 2
52
+
53
+
54
+ def volts(mv: int) -> str:
55
+ """`'12.449 V'` for a millivolt value: every millivolt the firmware sent."""
56
+ return f"{mv / 1000:.3f} V"
57
+
58
+
59
+ def _register_table(name: str, value: int, bits: int) -> list[str]:
60
+ """One register as the three lines `dev reg` / `dev addr` print: the
61
+ value, the bit header and the bit row, D(bits-1) first."""
62
+ header = "|D8" if bits == 9 else ""
63
+ row = "".join(f"| {(value >> i) & 1}" for i in range(bits - 1, -1, -1))
64
+ return [
65
+ f"{name}: 0x{value:02X}",
66
+ f"{header}|D7|D6|D5|D4|D3|D2|D1|D0|",
67
+ f"{row}|",
68
+ ]
69
+
70
+
71
+ def _render_registers(msb: int, lsb: int, ctrl: int, remapped: int, view: int) -> str:
72
+ """The bit tables for MSG_INFO_REGISTERS. The firmware sends raw values;
73
+ the table layout is the one the firmware used to print."""
74
+ lines = _register_table("MSB", msb, 8) + _register_table("LSB", lsb, 8)
75
+ if view == _REGISTER_VIEW_ADDR:
76
+ lines += _register_table("TOP addr", ctrl, 8)
77
+ lines += _register_table("CTRL remapped", remapped, 8)
78
+ elif view == _REGISTER_VIEW_REG_FIRESTARTER:
79
+ lines += _register_table("CTRL", ctrl, 9)
80
+ lines += _register_table("CTRL remapped", remapped, 8)
81
+ else:
82
+ lines += _register_table("CTRL", ctrl & 0xFF, 8)
83
+ return "\n".join(lines)
84
+
48
85
 
49
86
  # REVISION_* byte → silkscreen-string mapping for MSG_OK_REV rendering.
50
87
  # Mirrors firmware enum at firestarter/include/rurp_shield.h. Lookup-via-dict.get()
@@ -78,13 +115,10 @@ def format_message(msg_id: int, params: List[Any], entry: MessageDef) -> str | N
78
115
  (the override is in effect; the second field is what the board detected)
79
116
 
80
117
  P-03 MSG_OK_CFG — params[0]=r1 u32, params[1]=r2 u32, params[2]=override u8,
81
- params[3]=bandgap_mv u16 (absent on firmware before 3.1.0b4)
82
- override==0xFF → "R1: {r1}, R2: {r2}, Bandgap: {n} mV"
83
- override!=0xFF → "R1: {r1}, R2: {r2}, Override HW: {silkscreen_str}, Bandgap: {n} mV"
84
- The Bandgap clause is always present when the ack carries the field:
85
- HardwareManager.read_calibration keys on it. The 9-byte form from older
86
- firmware has no bandgap, so it renders without the Bandgap clause, and
87
- read_calibration reports that firmware as too old.
118
+ params[3]=bandgap_mv u16, params[4]=bandgap_adc u16
119
+ override==0xFF → "R1: {r1}, R2: {r2}, Bandgap: {n} mV, Bandgap count: {c}"
120
+ override!=0xFF → "R1: {r1}, R2: {r2}, Override HW: {silkscreen_str},
121
+ Bandgap: {n} mV, Bandgap count: {c}"
88
122
  Override clause now routes through
89
123
  _REVISION_SILKSCREEN so the same byte that surfaces as "Rev 2.0-class"
90
124
  via MSG_OK_REV no longer surfaces as "Rev2" on the adjacent ack line.
@@ -107,7 +141,7 @@ def format_message(msg_id: int, params: List[Any], entry: MessageDef) -> str | N
107
141
  eff_str = _REVISION_SILKSCREEN.get(effective, f"Rev{effective}")
108
142
  return f"{eff_str}, Detected HW: {phys_str}"
109
143
 
110
- if msg_id == MSG_OK_CFG and len(params) in (3, 4):
144
+ if msg_id == MSG_OK_CFG and len(params) == 5:
111
145
  r1, r2, override = params[0], params[1], params[2]
112
146
  head = f"R1: {r1}, R2: {r2}"
113
147
  if override != 0xFF:
@@ -117,12 +151,7 @@ def format_message(msg_id: int, params: List[Any], entry: MessageDef) -> str | N
117
151
  # No-space "Rev{n}" fallback mirrors the MSG_OK_REV branch shape.
118
152
  override_str = _REVISION_SILKSCREEN.get(override, f"Rev{override}")
119
153
  head += f", Override HW: {override_str}"
120
- if len(params) == 3:
121
- # Firmware before 3.1.0b4 sends no bandgap field.
122
- return head
123
- # v1.43 appended the calibrated reference. Rendered last so the
124
- # override clause keeps the position every prior release put it in.
125
- return f"{head}, Bandgap: {params[3]} mV"
154
+ return f"{head}, Bandgap: {params[3]} mV, Bandgap count: {params[4]}"
126
155
 
127
156
  # Silkscreen-aware rendering for the two
128
157
  # boot-time INFO surfaces that carry the same revision byte as
@@ -136,6 +165,22 @@ def format_message(msg_id: int, params: List[Any], entry: MessageDef) -> str | N
136
165
  byte = params[0]
137
166
  return f"Physical HW: {_REVISION_SILKSCREEN.get(byte, f'Rev{byte}')}"
138
167
 
168
+ if msg_id == MSG_ERR_BAD_COMMAND and len(params) == 1:
169
+ code = params[0]
170
+ return f"Command refused: {REFUSALS.get(code, f'reason {code}')}"
171
+
172
+ if msg_id == MSG_INFO_REGISTERS and len(params) == 5:
173
+ return _render_registers(*params)
174
+
175
+ # The firmware sends millivolts; show volts. The catalog text (mV) is the
176
+ # fallback for any other shape.
177
+ if msg_id in (MSG_WARN_VPP_LOW_MV, MSG_WARN_VPP_HIGH_MV, MSG_ERR_VPP_HIGH_MV):
178
+ if len(params) == 2:
179
+ measured, expected = params
180
+ relation = "<" if msg_id == MSG_WARN_VPP_LOW_MV else ">"
181
+ state = "low" if msg_id == MSG_WARN_VPP_LOW_MV else "high"
182
+ return f"VPP is {state}: {volts(measured)} {relation} {volts(expected)}"
183
+
139
184
  if msg_id == MSG_INFO_CMD and len(params) == 1:
140
185
  cmd = params[0]
141
186
  name = COMMAND_NAMES.get(cmd)
@@ -244,27 +289,18 @@ def decode_id_frame(frame_len: int, body: bytes) -> LogMessage | None:
244
289
  # entries carry param_bytes == -1 in the catalog; for those we
245
290
  # cannot pre-validate, but _decode_param will surface any overrun
246
291
  # via IndexError below.
247
- legacy_len = _LEGACY_PARAM_BYTES.get(msg_id)
248
- is_legacy = legacy_len is not None and len(params_bytes) == legacy_len
249
- if (
250
- entry.param_bytes >= 0
251
- and len(params_bytes) != entry.param_bytes
252
- and not is_legacy
253
- ):
292
+ if entry.param_bytes >= 0 and len(params_bytes) != entry.param_bytes:
254
293
  logger.warning(
255
294
  f"Param shape mismatch for ID 0x{msg_id:02x} ({entry.name}): "
256
295
  f"expected {entry.param_bytes} bytes, got {len(params_bytes)}"
257
296
  )
258
297
  return None
259
298
 
260
- # Decode each param per the catalog grammar. A legacy short form stops
261
- # at the end of its shorter param region.
299
+ # Decode each param per the catalog grammar.
262
300
  values: List[Any] = [] # noqa: UP006
263
301
  cursor = 0
264
302
  try:
265
303
  for ptype, _prender in entry.params:
266
- if is_legacy and cursor >= len(params_bytes):
267
- break
268
304
  value, cursor = _decode_param(ptype, params_bytes, cursor)
269
305
  values.append(value)
270
306
  except (IndexError, struct.error, ValueError) as exc:
@@ -295,15 +331,19 @@ def decode_id_frame(frame_len: int, body: bytes) -> LogMessage | None:
295
331
 
296
332
  # Extract raw-bytes payload for MSG_DATA_CHUNK (W-04) so the chip-read
297
333
  # loop can obtain the chip data without a second read call.
298
- chunk_payload = None
334
+ payload = None
299
335
  if (
300
336
  msg_id == MSG_DATA_CHUNK
301
337
  and values
302
338
  and isinstance(values[0], (bytes, bytearray))
303
339
  ):
304
- chunk_payload = bytes(values[0])
340
+ payload = bytes(values[0])
305
341
 
306
342
  severity_label = SEVERITY_LABEL.get(entry.severity, f"SEV{entry.severity}")
307
343
  return LogMessage(
308
- severity=severity_label, text=text, id=msg_id, payload=chunk_payload
344
+ severity=severity_label,
345
+ text=text,
346
+ id=msg_id,
347
+ payload=payload,
348
+ params=tuple(values),
309
349
  )
@@ -0,0 +1,188 @@
1
+ """
2
+ Project Name: Firestarter
3
+ Copyright (c) 2024 Henrik Olsson
4
+
5
+ Permission is hereby granted under MIT license.
6
+
7
+ Binary command frame encoder.
8
+
9
+ Turns the host's command dict (the dict that `database.convert_to_programmer`
10
+ and `EpromOperator._setup_operation` build) into the binary frame the
11
+ firmware decodes. The layout comes from `firestarter.command_frame`, which is
12
+ generated in the meta repo from `tools/protocol/command_frame.toml`.
13
+
14
+ The encoder refuses every value the frame cannot carry, and every key it does
15
+ not know. The JSON firmware ignored unknown keys; a binary frame has no slot
16
+ for one, so dropping it silently would hide a host bug.
17
+ """
18
+
19
+ import json
20
+ import struct
21
+ from typing import Any
22
+
23
+ from firestarter import command_frame as cf
24
+ from firestarter.exceptions import EpromOperationError
25
+
26
+ COMMAND_KEYS = ("cmd", "state")
27
+ BUS_CONFIG_KEY = "bus-config"
28
+
29
+ _FORMAT_MAX = {"B": 0xFF, "H": 0xFFFF, "I": 0xFFFFFFFF}
30
+ _MEMORY_KEYS = frozenset(key for _, key, _, _, bus in cf.MEMORY_FIELDS if not bus)
31
+ _BUS_KEYS = frozenset(key for _, key, _, _, bus in cf.MEMORY_FIELDS if bus)
32
+ # A retired config field has no key: it keeps its offset and is never sent.
33
+ _CONFIG_KEYS = frozenset(key for _, key, _, _ in cf.CONFIG_FIELDS if key)
34
+ _HEADER_KEYS = frozenset(COMMAND_KEYS + ("flags",))
35
+
36
+
37
+ class CommandEncodeError(EpromOperationError, ValueError):
38
+ """The command dict cannot be expressed as a binary command frame.
39
+
40
+ Raised before anything reaches the port. The JSON firmware accepted such
41
+ values and then shifted by them or truncated them, so a value the frame
42
+ cannot carry was never a value the firmware handled correctly.
43
+ """
44
+
45
+
46
+ def _is_int(value: Any) -> bool:
47
+ # bool is an int subclass; True must not encode as 1.
48
+ return isinstance(value, int) and not isinstance(value, bool)
49
+
50
+
51
+ def _int(key: str, value: Any, fmt: str) -> int:
52
+ if not _is_int(value) or not 0 <= value <= _FORMAT_MAX[fmt]:
53
+ raise CommandEncodeError(
54
+ f"'{key}' must be an integer in 0..{_FORMAT_MAX[fmt]}, got {value!r}"
55
+ )
56
+ return value
57
+
58
+
59
+ def _line(key: str, value: Any) -> int:
60
+ if not _is_int(value) or not 0 <= value < cf.BUS_LINES:
61
+ raise CommandEncodeError(
62
+ f"'{key}' line {value!r} is outside bus lines 0..{cf.BUS_LINES - 1}; "
63
+ f"the shield cannot drive this pin of the chip's pin map as a bus line"
64
+ )
65
+ return value
66
+
67
+
68
+ def _refuse_unknown(keys: Any, known: frozenset, where: str) -> None:
69
+ unknown = sorted(set(keys) - known)
70
+ if unknown:
71
+ raise CommandEncodeError(
72
+ f"{where} has keys the command frame cannot carry: {unknown}"
73
+ )
74
+
75
+
76
+ def _memory_field(
77
+ name: str, key: str, fmt: str, command: dict, bus_config: dict
78
+ ) -> bytes:
79
+ if name == "address_lines":
80
+ lines = bus_config.get(key, [])
81
+ if len(lines) > cf.ADDRESS_LINES:
82
+ raise CommandEncodeError(
83
+ f"'{key}' has {len(lines)} address lines; the frame carries {cf.ADDRESS_LINES}"
84
+ )
85
+ checked = [_line(key, line) for line in lines]
86
+ if len(set(checked)) != len(checked):
87
+ raise CommandEncodeError(f"'{key}' names a bus line twice: {checked}")
88
+ return bytes(checked + [cf.LINE_ABSENT] * (cf.ADDRESS_LINES - len(checked)))
89
+ if name in ("rw_line", "vpp_line"):
90
+ value = _line(key, bus_config[key]) if key in bus_config else cf.LINE_ABSENT
91
+ return struct.pack(">B", value)
92
+ if name == "static_high_mask":
93
+ mask = 0
94
+ for line in bus_config.get(key, []):
95
+ mask |= 1 << _line(key, line)
96
+ return struct.pack(">I", mask)
97
+ value = _int(key, command.get(key, 0), fmt)
98
+ if name in ("read_settling_us", "read_strobe_us") and value > cf.READ_TIMING_MAX_US:
99
+ raise CommandEncodeError(
100
+ f"'{key}' must be at most {cf.READ_TIMING_MAX_US} us, got {value}"
101
+ )
102
+ if name == "vpp_mv" and value > cf.VPP_MAX_MV:
103
+ raise CommandEncodeError(
104
+ f"'{key}' must be at most {cf.VPP_MAX_MV} mV, got {value}"
105
+ )
106
+ return struct.pack(">" + fmt, value)
107
+
108
+
109
+ def _config_value(name: str, key: str, fmt: str, raw: Any) -> int:
110
+ value = _int(key, raw, fmt)
111
+ if name == "rev" and value != 0xFF and value > cf.REVISION_MAX:
112
+ raise CommandEncodeError(
113
+ f"'{key}' must be 0..{cf.REVISION_MAX}, or 255 to clear it, got {value}"
114
+ )
115
+ return value
116
+
117
+
118
+ def _encode_memory(command: dict) -> bytes:
119
+ _refuse_unknown(
120
+ command, _HEADER_KEYS | _MEMORY_KEYS | {BUS_CONFIG_KEY}, "memory command"
121
+ )
122
+ bus_config = command.get(BUS_CONFIG_KEY) or {}
123
+ _refuse_unknown(bus_config, _BUS_KEYS, f"'{BUS_CONFIG_KEY}'")
124
+ payload = b"".join(
125
+ _memory_field(name, key, fmt, command, bus_config)
126
+ for name, key, fmt, _, _ in cf.MEMORY_FIELDS
127
+ )
128
+ assert len(payload) == cf.MEMORY_SIZE
129
+ return payload
130
+
131
+
132
+ def _encode_config(command: dict) -> bytes:
133
+ _refuse_unknown(command, _HEADER_KEYS | _CONFIG_KEYS, "config command")
134
+ present = 0
135
+ fields = b""
136
+ for name, key, fmt, bit in cf.CONFIG_FIELDS:
137
+ value = 0
138
+ if key and key in command:
139
+ present |= bit
140
+ value = _config_value(name, key, fmt, command[key])
141
+ fields += struct.pack(">" + fmt, value)
142
+ payload = struct.pack(">B", present) + fields
143
+ assert len(payload) == cf.CONFIG_SIZE
144
+ return payload
145
+
146
+
147
+ def command_ordinal(command: dict) -> int:
148
+ """Return the command ordinal from a dict's `cmd` or `state` key."""
149
+ for key in COMMAND_KEYS:
150
+ if key in command:
151
+ return _int(key, command[key], "B")
152
+ raise CommandEncodeError("command dict has neither 'cmd' nor 'state'")
153
+
154
+
155
+ def encode_command(command: dict) -> bytes:
156
+ """Encode a host command dict as one binary command frame (no COBS, no CRC)."""
157
+ cmd = command_ordinal(command)
158
+ flags = _int("flags", command.get("flags", 0), "H")
159
+ if flags & ~cf.FLAGS_MASK:
160
+ raise CommandEncodeError(
161
+ f"'flags' 0x{flags:04X} sets bits outside 0x{cf.FLAGS_MASK:04X}"
162
+ )
163
+ kind = cf.PAYLOAD_KIND.get(cmd, "none")
164
+ if kind == "memory":
165
+ payload = _encode_memory(command)
166
+ elif kind == "config":
167
+ payload = _encode_config(command)
168
+ else:
169
+ _refuse_unknown(command, _HEADER_KEYS, f"command {cmd}")
170
+ payload = b""
171
+ return (
172
+ struct.pack(cf.HEADER_FORMAT, cf.MAGIC, cf.VERSION, cmd, flags, len(payload))
173
+ + payload
174
+ )
175
+
176
+
177
+ def encode_legacy_fw_version_query(command: dict) -> bytes:
178
+ """The JSON firmware-version query a JSON-era firmware understands.
179
+
180
+ The firmware-update path sends this only after the firmware has refused
181
+ the binary query as an unsupported frame, so that `fw` can still read the
182
+ version and board of a board it is about to replace. No other path may
183
+ send JSON.
184
+ """
185
+ legacy = {"state": command_ordinal(command)}
186
+ if command.get("flags"):
187
+ legacy["flags"] = command["flags"]
188
+ return json.dumps(legacy, separators=(",", ":")).encode("ascii")