test: the exhaustive clock x baud x backend size matrix
Every plausible oscillator against every rate it reaches against every backend, on one chip per size-bearing class, under --full only. The baud ladder becomes a reachability predicate the enumeration filters on, so an unreachable point drops out instead of aborting the configure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -146,36 +146,51 @@ set(PUREBOOT_HAS_USART ${_pb_has_usart} PARENT_SCOPE)
|
||||
set(PUREBOOT_HAS_USART1 ${_pb_has_usart1} PARENT_SCOPE)
|
||||
set(PUREBOOT_SIM_MCU ${_pb_sim_mcu} PARENT_SCOPE)
|
||||
|
||||
# The fastest standard rate the clock reaches within 2.5 %, by the same
|
||||
# best-of-U2X-and-plain divisor search libavr's solve_baud runs, so a default
|
||||
# The rates a default may pick, fastest first.
|
||||
set_property(GLOBAL PROPERTY PUREBOOT_BAUD_LADDER 115200 57600 38400 19200 9600)
|
||||
|
||||
# Whether <baud> is reachable from <clock> within 2.5 %, by the same
|
||||
# best-of-U2X-and-plain divisor search libavr's solve_baud runs, so a build
|
||||
# never trips the compile-time error it is checked against. A software build
|
||||
# also needs the polled receiver's 100-cycles-a-bit floor: at low clocks the
|
||||
# U2X divisor reaches rates the bit-banged sampler cannot.
|
||||
function(pureboot_default_baud clock software outvar)
|
||||
foreach(baud 115200 57600 38400 19200 9600)
|
||||
math(EXPR _cycles "${clock} / ${baud}")
|
||||
if(software AND _cycles LESS 100)
|
||||
function(pureboot_baud_feasible clock baud software outvar)
|
||||
set(${outvar} 0 PARENT_SCOPE)
|
||||
math(EXPR _cycles "${clock} / ${baud}")
|
||||
if(software AND _cycles LESS 100)
|
||||
return()
|
||||
endif()
|
||||
foreach(divisor 8 16)
|
||||
math(EXPR _step "${divisor} * ${baud}")
|
||||
math(EXPR _n "(${clock} + ${_step} / 2) / ${_step}")
|
||||
if(_n LESS 1 OR _n GREATER 4096)
|
||||
continue()
|
||||
endif()
|
||||
foreach(divisor 8 16)
|
||||
math(EXPR _step "${divisor} * ${baud}")
|
||||
math(EXPR _n "(${clock} + ${_step} / 2) / ${_step}")
|
||||
if(_n LESS 1 OR _n GREATER 4096)
|
||||
continue()
|
||||
endif()
|
||||
math(EXPR _actual "${clock} / (${divisor} * ${_n})")
|
||||
math(EXPR _delta "${_actual} - ${baud}")
|
||||
if(_delta LESS 0)
|
||||
math(EXPR _delta "-(${_delta})")
|
||||
endif()
|
||||
math(EXPR _error_bp "${_delta} * 10000 / ${baud}")
|
||||
if(_error_bp LESS_EQUAL 250)
|
||||
set(${outvar} ${baud} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
math(EXPR _actual "${clock} / (${divisor} * ${_n})")
|
||||
math(EXPR _delta "${_actual} - ${baud}")
|
||||
if(_delta LESS 0)
|
||||
math(EXPR _delta "-(${_delta})")
|
||||
endif()
|
||||
math(EXPR _error_bp "${_delta} * 10000 / ${baud}")
|
||||
if(_error_bp LESS_EQUAL 250)
|
||||
set(${outvar} 1 PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
message(FATAL_ERROR "pureboot: no standard baud rate fits a ${clock} Hz clock within 2.5 %")
|
||||
endfunction()
|
||||
|
||||
# The fastest ladder rate the clock reaches.
|
||||
function(pureboot_default_baud clock software outvar)
|
||||
get_property(_ladder GLOBAL PROPERTY PUREBOOT_BAUD_LADDER)
|
||||
foreach(baud ${_ladder})
|
||||
pureboot_baud_feasible(${clock} ${baud} ${software} _ok)
|
||||
if(_ok)
|
||||
set(${outvar} ${baud} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
message(FATAL_ERROR "pureboot: no standard baud rate fits a ${clock} Hz clock within 2.5 % "
|
||||
"— pass BAUD <rate> to deploy a non-standard one")
|
||||
endfunction()
|
||||
|
||||
# pureboot_add_loader(<name> [CLOCK <hz>] [BAUD <bd>]
|
||||
|
||||
Reference in New Issue
Block a user