Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers target_reset_mimxrt.c Source File

target_reset_mimxrt.c

Go to the documentation of this file.
00001 /**
00002  * @file    target_reset_mimxrt.c
00003  * @brief   Target reset for the i.MX RT series
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include "swd_host.h"
00023 #include "info.h"
00024 #include "target_family.h"
00025 #include "cmsis_os2.h"
00026 
00027 static void target_before_init_debug(void)
00028 {
00029     // This is for the hardware conflict (the EVK are not consider >2 debugger connection
00030     // situation) with another external debugger(such as JLINK). Before drag&pull, issue a
00031     // hardware reset to bring the platform to a known state and also force
00032     // RESET pin to high state ensure a successfully access.
00033     swd_set_target_reset(1);
00034     osDelay(5);
00035     swd_set_target_reset(0);
00036     osDelay(5);
00037 }
00038 
00039 static void prerun_target_config(void)
00040 {
00041     // In some case the CPU will enter "cannot debug" state (low power, SWD pin mux changed, etc.).
00042     // Doing a hardware reset will clear those states (probably, depends on app). Also, if the
00043     // external flash's data is not a valid bootable image, DAPLink cannot attached to target. A
00044     // hardware reset will increase the chance to connect in this situation.
00045     target_set_state(RESET_RUN);
00046 }
00047 
00048 static uint8_t validate_bin_nvic(const uint8_t *buf)
00049 {
00050     if(buf[0] == 'F' && buf[1] == 'C' && buf[2] == 'F' && buf[3] == 'B')
00051     {
00052         return 1;
00053     }
00054     else
00055     {
00056         return 0;
00057     }
00058 }
00059 
00060 const target_family_descriptor_t g_nxp_mimxrt = {
00061     .family_id  = kNXP_Mimxrt_FamilyID,
00062     .default_reset_type = kSoftwareReset,
00063     .soft_reset_type = VECTRESET,
00064     .target_before_init_debug = target_before_init_debug,
00065     .prerun_target_config = prerun_target_config,
00066     .validate_bin_nvic = validate_bin_nvic,
00067 };