# Asserts the autobaud loader's measured unit sits where the host will read # it (--info's measured clock - the address is wire contract). Two homes: on # a chip with the GPIOR pair the unit lives there and the image must carry no # RAM word for it at all; elsewhere it is the first RAM object at SRAM start. # Run as # cmake -DOBJDUMP=... -DELF=... -DRAM_START= [-DGPIOR=] # -P check_unit.cmake execute_process(COMMAND ${OBJDUMP} -t ${ELF} OUTPUT_VARIABLE _syms RESULT_VARIABLE _res) if(NOT _res EQUAL 0) message(FATAL_ERROR "${OBJDUMP} -t ${ELF} failed") endif() # The symbol line: "00800100 l O .noinit 00000002 6m_unitE". string(REGEX MATCH "\n0*([0-9a-f]+)[^\n]+[ \t][^ \t\n]*6m_unitE\n" _line "${_syms}") if(GPIOR) if(_line) message(FATAL_ERROR "m_unit RAM symbol present although the unit's home is GPIOR ${GPIOR} - " "the host peeks the pair, and a RAM copy would be dead weight") endif() message(STATUS "no m_unit RAM object - the unit lives in the GPIOR pair at ${GPIOR}") return() endif() if(NOT _line) message(FATAL_ERROR "no m_unit symbol in ${ELF} - is this the autobaud loader?") endif() # AVR data-space symbols carry the 0x800000 VMA offset. math(EXPR _want "0x800000 + ${RAM_START}" OUTPUT_FORMAT HEXADECIMAL) math(EXPR _have "0x${CMAKE_MATCH_1}" OUTPUT_FORMAT HEXADECIMAL) if(NOT _have STREQUAL _want) message(FATAL_ERROR "m_unit sits at ${_have}, ram_start is ${_want} - the host peeks ram_start") endif() message(STATUS "m_unit at ${_have} == ram_start")