Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rp2350 target drag and drop #129

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ target_sources(${PROJECT} PRIVATE
src/lib/daplink/target/target_board.c
src/lib/daplink/target/target_family.c

src/daplink-pico/board/rp2040/pico.c
src/daplink-pico/board/rp2040/pico_target_utils.c
src/daplink-pico/board/rp2040/program_flash_generic.c
src/daplink-pico/detect_target.c
src/daplink-pico/family/raspberry/target_utils_raspberry.c
src/daplink-pico/board/rp2040/target_utils_rp2040.c
src/daplink-pico/board/rp2040/program_flash_generic_rp2040.c
src/daplink-pico/family/raspberry/rp2040/target_reset_rp2040.c

src/daplink-pico/family/raspberry/rp2350/target_reset_rp2350.c
)

Expand Down
2 changes: 2 additions & 0 deletions src/daplink-pico/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
# DAPLink adoptions for the probe

These modules fit the probe into the DAPLink infrastructure.

link:detect_target.c[] contains the auto-detect me3chanism.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "swd_host.h"

#include "pico_target_utils.h"
#include "target_utils_rp2040.h"

extern char __start_for_target_connect[];
extern char __stop_for_target_connect[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

#include <stdio.h>

#include "pico_target_utils.h"
#include "target_utils_rp2040.h"

#include "swd_host.h"
#include "target_rpXXXX.h"
#include "target_utils_raspberry.h"



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

#include "target_family.h"
#include "target_board.h"
#include "target_rpXXXX.h"
#include "program_flash_generic.h"
#include "target_utils_raspberry.h"
#include "program_flash_generic_rp2040.h"

#include "probe.h"
#include "minIni/minIni.h"
Expand Down Expand Up @@ -243,7 +243,6 @@ void pico_prerun_board_config(void)
uint32_t chip_id;

r = swd_read_word(0x40000000, &chip_id);
printf("!!!!!!!!!!!!!!!!!! chip_id: 0x%lx\n", chip_id);
if (r && (chip_id & 0x0fffffff) == swd_id_rp2350) {
target_found = true;
strcpy(board_vendor, "RaspberryPi");
Expand Down
55 changes: 2 additions & 53 deletions src/daplink-pico/family/raspberry/rp2040/target_reset_rp2040.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2015-2019 Realtek Semiconductor Corp.
* Copyright (c) 2024 Hardy Griech
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,11 +16,11 @@

#include <string.h>
#include <stdio.h>
#include <target_rpXXXX.h>
#include "DAP_config.h"
#include "target_family.h"
#include "swd_host.h"

#include "target_utils_raspberry.h"

#include "FreeRTOS.h"
#include "task.h"
Expand Down Expand Up @@ -532,57 +532,6 @@ static uint8_t rp2040_target_set_state(target_state_t state)
} // rp2040_target_set_state


//----------------------------------------------------------------------------------------------------------------------
//
// some utility functions
//


bool target_core_is_halted(void)
{
uint32_t value;

if ( !swd_read_word(DBG_HCSR, &value))
return false;
if (value & S_HALT)
return true;
return false;
} // target_core_is_halted



bool target_core_halt(void)
{
if ( !swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_MASKINTS | C_HALT)) {
return false;
}

while ( !target_core_is_halted())
;
return true;
} // target_core_halt



bool target_core_unhalt(void)
{
if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN)) {
return false;
}
return true;
} // target_core_unhalt



bool target_core_unhalt_with_masked_ints(void)
{
if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_MASKINTS)) {
return false;
}
return true;
} // target_core_unhalt_with_masked_ints


//----------------------------------------------------------------------------------------------------------------------

const target_family_descriptor_t g_raspberry_rp2040_family = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2015-2019 Realtek Semiconductor Corp.
* Copyright (c) 2024 Hardy Griech
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,11 +16,11 @@

#include <string.h>
#include <stdio.h>
#include <target_rpXXXX.h>
#include "DAP_config.h"
#include "target_family.h"
#include "swd_host.h"

#include "target_utils_raspberry.h"

#include "FreeRTOS.h"
#include "task.h"
Expand Down
81 changes: 81 additions & 0 deletions src/daplink-pico/family/raspberry/target_utils_raspberry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* CMSIS-DAP Interface Firmware
* Copyright (c) 2024 Hardy Griech
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <string.h>
#include <stdio.h>
#include "DAP_config.h"
#include "target_family.h"
#include "swd_host.h"

#include "target_utils_raspberry.h"

#include "FreeRTOS.h"
#include "task.h"


#define DBG_Addr (0xe000edf0)
#include "debug_cm.h"


//----------------------------------------------------------------------------------------------------------------------
//
// some utility functions
//


bool target_core_is_halted(void)
{
uint32_t value;

if ( !swd_read_word(DBG_HCSR, &value))
return false;
if (value & S_HALT)
return true;
return false;
} // target_core_is_halted



bool target_core_halt(void)
{
if ( !swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_MASKINTS | C_HALT)) {
return false;
}

while ( !target_core_is_halted())
;
return true;
} // target_core_halt



bool target_core_unhalt(void)
{
if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN)) {
return false;
}
return true;
} // target_core_unhalt



bool target_core_unhalt_with_masked_ints(void)
{
if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_MASKINTS)) {
return false;
}
return true;
} // target_core_unhalt_with_masked_ints
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
* Copyright (c) 2024 Hardy Griech
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions src/msc/msc_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <stdio.h>

#include <pico/stdlib.h>
#include <target_rpXXXX.h>

#include "boot/uf2.h" // this is the Pico variant of the UF2 header

Expand All @@ -49,7 +48,8 @@
#include "error.h"
#include "flash_intf.h"
#include "flash_manager.h"
#include "pico_target_utils.h"
#include "target_utils_rp2040.h"
#include "target_utils_raspberry.h"


#define DEBUG_MODULE 0
Expand Down