示例#1
0
def probe_system():
    # run-once code to determine what hardware we are running on
    global hw_label, has_608, has_fatram, is_factory_mode

    from sigheader import RAM_BOOT_FLAGS, RBF_FACTORY_MODE
    import ckcc, callgate, stm
    from machine import Pin

    # NOTE: mk1 not supported anymore.
    # PA10 is pulled-down in Mark2, open in previous revs
    #mark2 = (Pin('MARK2', Pin.IN, pull=Pin.PULL_UP).value() == 0)
    #
    #if not mark2:
    #    has_membrane = False
    #    hw_label = 'mk1'

    hw_label = 'mk2'

    has_fatram = ckcc.is_stm32l496()

    if has_fatram:
        hw_label = 'mk3'

    has_608 = callgate.has_608()

    # Boot loader needs to tell us stuff about how we were booted, sometimes:
    # - did we just install a new version, for example
    # - are we running in "factory mode" with flash un-secured?
    is_factory_mode = bool(stm.mem32[RAM_BOOT_FLAGS] & RBF_FACTORY_MODE)
    bn = callgate.get_bag_number()
    if bn:
        # this path supports testing/dev with RDP!=2, which normal production bootroms enforce
        is_factory_mode = False
示例#2
0
async def test_secure_element():

    assert not get_is_bricked()         # bricked already

    # test right chips installed
    is_fat = ckcc.is_stm32l496()
    if is_fat:
        assert version.has_608          # expect 608a
        assert version.hw_label == 'mk3'
    else:
        assert not version.has_608      # expect 508a
        assert version.hw_label != 'mk3'

    if ckcc.is_simulator(): return

    for ph in range(5):
        gg = get_genuine()

        dis.clear()
        if gg:
            dis.text(-1, 8, "Green ON? -->")
        else:
            dis.text(-1,50, "Red ON? -->")

        dis.show()
        k = await ux_wait_keyup('xy')
        assert k == 'y'     # "LED bust"

        if ph and gg:
            # stop once it's on and we've tested both states
            return

        # attempt to switch to other state
        if gg:
            clear_genuine()
        else:
            # very slow!
            dis.text(0,0, "Wait")
            dis.show()
            set_genuine()
            ux_clear_keys()

        ng = get_genuine()
        assert ng != gg     # "Could not invert LED"
示例#3
0
def probe_system():
    # run-once code to determine what hardware we are running on
    global has_membrane, hw_label, has_608

    import ckcc, callgate
    from machine import Pin

    # PA10 is pulled-down in Mark2, open in previous revs
    mark2 = (Pin('MARK2', Pin.IN, pull=Pin.PULL_UP).value() == 0)

    if not mark2:
        has_membrane = False
        hw_label = 'mk1'
    else:
        has_membrane = True
        hw_label = 'mk2'

    if ckcc.is_stm32l496():
        hw_label = 'mk3'

    has_608 = callgate.has_608()
示例#4
0
def probe_system():
    # run-once code to determine what hardware we are running on
    global hw_label, has_608, has_fatram

    import ckcc, callgate
    from machine import Pin

    # NOTE: mk1 not supported anymore.
    # PA10 is pulled-down in Mark2, open in previous revs
    #mark2 = (Pin('MARK2', Pin.IN, pull=Pin.PULL_UP).value() == 0)
    #
    #if not mark2:
    #    has_membrane = False
    #    hw_label = 'mk1'

    hw_label = 'mk2'

    has_fatram = ckcc.is_stm32l496()

    if has_fatram:
        hw_label = 'mk3'

    has_608 = callgate.has_608()