Esempio n. 1
0
void target_before_init_debug(void) {
    swd_set_target_reset(1);
    os_dly_wait(2);
    swd_set_target_reset(0);
    os_dly_wait(2);
    return;
}
Esempio n. 2
0
static uint8_t target_set_state_by_board(TARGET_RESET_STATE state)
{
    if( state == RESET_PROGRAM )
    {
        do
        {
            swd_set_target_reset(1);
            osDelay(2);

            swd_set_target_reset(0);
            osDelay(2);
        } while(!swd_init_debug());
    }
    return 1;
}
Esempio n. 3
0
uint8_t target_unlock_sequence(void)
{
    uint32_t val;

    // read the device ID
    if (!swd_read_ap(MDM_IDR, &val)) {
        return 0;
    }

    // verify the result
    if (val != MDM_ID) {
        return 0;
    }

    if (!swd_read_ap(MDM_STATUS, &val)) {
        return 0;
    }

    // flash in secured mode
    if (val & (1 << 2)) {
        // hold the device in reset
        swd_set_target_reset(1);

        // write the mass-erase enable bit
        if (!swd_write_ap(MDM_CTRL, 1)) {
            return 0;
        }

        while (1) {
            // wait until mass erase is started
            if (!swd_read_ap(MDM_STATUS, &val)) {
                return 0;
            }

            if (val & 1) {
                break;
            }
        }

        // mass erase in progress
        while (1) {
            // keep reading until procedure is complete
            if (!swd_read_ap(MDM_CTRL, &val)) {
                return 0;
            }

            if (val == 0) {
                break;
            }
        }
    }

    return 1;
}
Esempio n. 4
0
static void target_before_init_debug(void)
{
    // This is for the hardware conflict (the EVK are not consider >2 debugger connection
    // situation) with another external debugger(such as JLINK). Before drag&pull, to force
    // RESET pin to high state ensure a successfully access. If external debugger not
    // connected. It's not necessary for doing that.
    swd_set_target_reset(0);

    // In some case the CPU will enter "cannot debug" state (low power, SWD pin mux changed, etc.).
    // Doing a hardware reset will clear those states (probably, depends on app). Also, if the
    // external flash's data is not a valid bootable image, DAPLink cannot attached to target. A
    // hardware reset will increase the chance to connect in this situation.
    target_set_state(RESET_RUN);
}
Esempio n. 5
0
void target_before_init_debug(void)
{
    swd_set_target_reset(1);
}