ataradov / free-dap Goto Github PK
View Code? Open in Web Editor NEWFree and open implementation of the CMSIS-DAP debugger firmware
License: BSD 3-Clause "New" or "Revised" License
Free and open implementation of the CMSIS-DAP debugger firmware
License: BSD 3-Clause "New" or "Revised" License
I tried looking at the sources and it seems like the vcp platform is using a more modular approach while also implementing cbc (serial console?) next to hid.
Is samd11_vcp intended to replace the samd11 platform? If so, why keep the old source around?
dap_process_request
doesn't return the number of bytes written to resp
, which forces the underlying transport to always transmit full size packets.
Make a "rp2040 dap" with this , and use it to debug another rp2040 is very cool, debug is OK, but download shows error.
This is my platform.ini:
[env:upstream_develop]
platform = https://github.sunflyer.cn/platformio/platform-raspberrypi.git
framework = arduino
board = pico
board_build.f_cpu = 120000000L
debug_tool = cmsis-dap
upload_protocol = cmsis-dap
debug_speed = 1000000
This is the upload log:
> Executing task in folder 220428-141324-arduino-blink: C:\Users\THINKPAD\.platformio\penv\Scripts\platformio.exe run --target upload <
Processing upstream_develop (platform: https://github.sunflyer.cn/platformio/platform-raspberrypi.git; framework: arduino; board: pico)
----------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/pico.html
PLATFORM: Raspberry Pi RP2040 (1.6.0+sha.e08da69) > Raspberry Pi Pico
HARDWARE: RP2040 120MHz, 264KB RAM, 2MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink, raspberrypi-swd)
PACKAGES:
- framework-arduino-mbed 3.0.1
- tool-openocd-raspberrypi 2.1100.0 (11.0)
- tool-rp2040tools 1.0.2
- toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SPI>
Building in release mode
Checking size .pio\build\upstream_develop\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [== ] 17.0% (used 45844 bytes from 270336 bytes)
Flash: [ ] 0.2% (used 4322 bytes from 2097152 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, picotool, raspberrypi-swd
CURRENT: upload_protocol = cmsis-dap
Uploading .pio\build\upstream_develop\firmware.elf
Open On-Chip Debugger 0.11.0+dev-gec0240e6a-dirty (2021-03-09-09:44)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
adapter speed: 1000000 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
** Programming Started **
Warn : no flash bank found for address 0x10000000
Warn : no flash bank found for address 0x10013fa0
** Programming Finished **
** Verify Started **
Warn : target was in unknown state when halt was requested
Error: timed out while waiting for target halted
Error: error executing cortex_m crc algorithm
Error: checksum mismatch - attempting binary compare
embedded:startup.tcl:530: Error: ** Verify Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 591
at file "embedded:startup.tcl", line 530
*** [upload] Error 1
========================================================= [FAILED] Took 5.58 seconds =========================================================
I'm trying to compile free-dap on Ubuntu 17.10 for samd11. However when trying to make
Makefile_std, I'm getting the following error:
$ make -f Makefile_std
make: gmkdir: Command not found
Makefile_std:64: recipe for target 'directory' failed
make: *** [directory] Error 127
Replacing @gmkdir
with @mkdir
fixes the problem.
What is @gmkdir
, why is it used instead of @mkdir
and how can I provide @gmkdir
on Ubuntu?
Hi,
I see free-dap declares support for CMSIS-DAP 1.0, though it already implements the DAP__SWD__Sequence command introduced, along a number of optional features, in version 1.2.
In pyocd, the CMSIS-DAP version is used to determine SWD_Sequence support, and the latter is needed to debug RP2040 targets - due to their DP structure. Currently an error message to that effect is displayed when using pycod --target rp2040
.
Since the capabilities bits returned by DAP_Info declare no support for other 1.2 optional features, it would seem that free-dap is actually 1.2 complaint already.
So, changing the supported version string to "v1.2" might be enough to enable the use of free-dap for RP2040 targets through pyocd.
I'll be trying this update in the coming days/weekend and in case submit a PR.
Thanks for this useful tool!
Problem:
When trying to load free_dap_rp2040.elf via GDB, GDB reports the file was written to the target but the target remains in BOOTSEL mode.
Tested loading picoprobe.elf onto the target and the target is flashed successfully.
Setup:
Debugger: RPi Pico running picoprobe
Target: RPi Pico
OpenOCD Config:
Version: 0.12.0
Config File:
source [find interface/cmsis-dap.cfg]
transport select swd
adapter speed 1000
set USE_CORE 0
source [find target/rp2040.cfg]
Steps to reproduce:
openocd -f <config listed above>
arm-none-eabi-gdb free-dap-rp2040.elf
In GDB terminal
target remote :3333
load
monitor reset init
continue
GDB output:
(gdb) target remote :3333
Remote debugging using :3333
0x000020e0 in ?? ()
(gdb) load
Loading section .boot, size 0x100 lma 0x10000000
Loading section .text, size 0x2bdc lma 0x10000200
Loading section .data, size 0x24 lma 0x10002ddc
Start address 0x10000000, load size 11520
Transfer rate: 5 KB/sec, 3840 bytes/write.
(gdb) monitor reset init
[rp2040.core0] halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
(gdb) continue
Continuing.
lsusb
output
Bus 000 Device 008: ID 2e8a:000c 2e8a Picoprobe CMSIS-DAP Serial: E66118604B644623
Bus 000 Device 010: ID 2e8a:0003 2e8a RP2 Boot Serial: E0C9125B0D9B
Hi Alex,
I'm trying to port free-dap on the Tau. I would like to keep the bootloader installed. I've modified the linker script you provide to take care not override the bootloader region and matched the memory map as follow :
MEMORY
{
flash (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x20000-0x2000 /* 128k-bootloader */
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00004000-4 /* 16k */
}
__top_flash = 0x40000;
__top_ram = 0x20000000 + 0x4000;
ENTRY(irq_handler_reset)
I modified the dap_config.h header to match the pinout as follow :
HAL_GPIO_PIN(SWCLK_TCK, A, 19)
HAL_GPIO_PIN(SWDIO_TMS, A, 18)
HAL_GPIO_PIN(TDI, A, 17)
HAL_GPIO_PIN(TDO, A, 16)
HAL_GPIO_PIN(nTRST, A, 7)
HAL_GPIO_PIN(nRESET, A, 6)
HAL_GPIO_PIN(LED, A, 27)
And the makefile as follow :
...
LDFLAGS += -Wl,--script=../linker/samd21e17_boot.ld
...
DEFINES += \
-D__SAMD21E17A__ \
-DDONT_USE_CMSIS_INIT \
-DF_CPU=48000000
...
Build is succesfull and I flash using the Tau Arduino package Bossac :
bossac.exe -e -w -v -b free_dap.bin
Which seems succesfull too:
Device found on COM15
Atmel SMART device 0x1001000b found
Erase flash
done in 0.405 seconds
Write 7568 bytes to flash (119 pages)
[==============================] 100% (119/119 pages)
done in 0.107 seconds
Verify 7568 bytes of flash with checksum.
Verify successful
done in 0.017 seconds
Set boot flash true
Ignoring set boot from flash flag.
But when I reset the board, the USB peripheral does not enumerate...
I'm able to re-enter bootloader using the double-tap magic (double press on reset in less than 500ms) from the Tau's bootloader.
I made blink code from the main which works as expected :
int main(void)
{
sys_init();
//dap_init();
//usb_init();
HAL_GPIO_LED_out();
uint16_t tempo = 0xFFFF;
while (1)
{
HAL_GPIO_LED_toggle();
tempo = 0xFFFF;
while(tempo--);
};
return 0;
}
Do you know if I'm missing something to make it work on this platform? Could the USB code from the bootloader somehow screw free-dap initialisation?
Thanks for your help :)
Hi Alex!
I'm trying to run this on a SAMV71, but when I connect to my win11 PC the device enumeration fails due to an invalid configuration descriptor. However, connecting to a linux host seems to be working fine. I haven't changed any of the descriptors in the project. Any ideas what might be the issue?
A small off by one error in dap_info:
Line 833 in 0644042
The correct value to use is dap_resp_ptr - 2
, as the packet already contains the DAP_Info code (0x00) and the length.
E.g.: with the version string "1.3.0", dap_resp_ptr
would be 1 (code) + 1 (length) + 5 (string) + 1 (appended 0) = 8 in line 833, the value we need is 6 (i.e. string length including final NUL).
I'm using free-dap on a SAMD11 in order to flash microcontrollers and it works remarkably well except for the speed. The process of programming and verifying a 128K ROM takes about 20 seconds.
I'm wondering what's the limit here:
Before investing in any solution I wanted to make sure I'm not missing something obvious here. Is 20s a reasonable speed for 128K program + verify or should it be much faster anyhow?
According to silabs, the target will both sample and put data on the line on a rising clock edge.
However to my understanding free-dap reads from the target on the falling clock edge e.g. dap_swd_read_fast:
DAP_CONFIG_SWCLK_TCK_clr();
bit = DAP_CONFIG_SWDIO_TMS_read();
DAP_CONFIG_SWCLK_TCK_set();
Obviously free-dap works, thus I'm wondering whether my understanding of raising/falling edge or the documentation is wrong. Could you maybe point me in the right direction?
Moreover which documentation did you use when implementing SWD big banging?
in dap.c I find:
if (select & DAP_SWJ_TDI)
DAP_CONFIG_TDO_write(value & DAP_SWJ_TDI);
but I do not find a HAL_GPIO_TDO_out()
This is strange.
I think they are totally different projects with different implementation, but only using same cmsis-dap protocol. Right? Thanks
Will this CMSIS-DAP programmer/debugger work on the D51 (M4) or just the D11/D21 (M0+) MCUS?
We have been able to successfully flash D11/D21 with your codebase (using Keil).
In Keil, the DAP debugger is not recognizing the D51 (custom dev board).
Thoughts?
heya i did a quick build onto an atsamd21, but don't have a target attached. connecting with atmel studio 7 gives:
Unable to connect to tool EDBG (123456)
Timestamp: 2016-09-08 00:07:32.092
Severity: ERROR
ComponentId: 20000
StatusCode: 0Failed to set-up tool (no context id returned).
do you know if it definitely does or does not work with AS7?
normally if you dont have a target you can still connect to EDBG so i dont /think/ that's an issue. if it doesn't work as-is with atmel studio 7 thats ok i can hack on making that work. just checking before i pull out the usb analyser and go down that path 😄
thx!
Hi,
I've been running into trouble when connecting my free-dap hardware (based upon d11_usb_mini) with the target but not powering the free-dap hardware.
The symptom looks like the target does not work since the target's nRST
voltage drops from 3,3 V to 1,3 V. Since the target tries to hold 3,3 V on nRST
, the Atmel SAMD 11 on the free-dap hardware is subject to a voltage between PA09 and GND (connected via J7/J8 to the target).
Together with a pal we came up with the following circuit:
This should disconnect PA09 from J7 unless V_USB
is present. Of cause, the logic will be inverted (PA09 becoming RST instead of ¬RST) but that can be fixed in software fairly easy. When V_USB
is not present, the pulldown will make sure that T2 is disconnected (GND is present since it's connected to the target via J8).
I have a couple of questions:
-- ooxi
Just wondering how feasible it would be to run this on an ESP32, and provide access via a TCP connection instead of HID. I see there is https://github.com/windowsair/wireless-esp8266-dap, which uses USBIP to emulate a USB connection over TCP.
The free-dap platform directories contain a lot of infrastructure code e.g. usart.c. Was this code specifically written for free-dap, or do you keep souce code somewhere else?
I looked at your mcu-starter-projects repository but couldn't find it anywhere else.
Reason I'm asking is, I want to extend samd21 platform with USART functionality and don't want to reinvent the wheel.
I have one suggestion for the new hardware board I noticed today. Would it be possible to provide a jumper so that it is possible to connect nRESET to Pin 3? Doing so would allow the use of a 1.27mm 6 pin header on the target.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.