Comments (16)
EDBG support on MAC is incomplete, since I don't have any Apple hardware.
It has the report size hard coded:
static int report_size = 512; // TODO: read actual report size
You probably need to change that value to 64 for your device, since it is likely to be a USB FS device.
from edbg.
After Changing the
static int report_size = 64; // TODO: read actual report size
in dbg_mac.c
The error still occurs..
from edbg.
Then you need to print out the values of the hid_buffer before hid_write() and after hid_read(). First byte must match. But more importantly you will know on what command it fails. Do that and provide the output.
int dbg_dap_cmd(uint8_t *data, int resp_size, int req_size)
{
uint8_t cmd = data[0];
int res;
verbose("---\n");
for (int i = 0; i < 16; i++)
verbose("0x%02x ", data[i]);
verbose("\n");
memset(hid_buffer, 0xff, report_size + 1);
hid_buffer[0] = 0x00; // Report ID
memcpy(&hid_buffer[1], data, req_size);
res = write(debugger_fd, hid_buffer, report_size + 1);
if (res < 0)
perror_exit("debugger write()");
res = read(debugger_fd, hid_buffer, report_size + 1);
if (res < 0)
perror_exit("debugger read()");
check(res, "empty response received");
for (int i = 0; i < 16; i++)
verbose("0x%02x ", hid_buffer[i]);
verbose("\n");
check(hid_buffer[0] == cmd, "invalid response received");
res--;
memcpy(data, &hid_buffer[1], (resp_size < res) ? resp_size : res);
return res;
}
from edbg.
In the file dbg_mac.c.. there is "No hid_write() and hid_read()"..
In 2 ways I have applied the following code..
- In this method, I copy pasted the following code in the end of the dbg_mac.c file. Like wise, saved the file and run edbg.
I obtained same result.... of "Error invalid response received"
- In this method, I copy pasted the following code in the end of the dbg_mac.c file. Like wise as mentioned above. This time I have saved the file.. and run "make clean " and "make all".. in the edbg directory.
- After executing make all.. I obtained a message like this...
Moreover, I was not able to find hid_write() and hid_read()..
from edbg.
The code here is for Linux version. Leave the existing mac code as is, just copy the part that prints the data.
And when running make sure to pass the "-b" argument to enable verbose output.
Also, are you sure it is using the newly built version of the edbg? Typically you need to run it like ./edbg ..... to run the version in the current directory and not in the path.
from edbg.
Okay..
I have edited dbg_mac.c
int dbg_dap_cmd(uint8_t *data, int resp_size, int req_size)
{
uint8_t cmd = data[0];
int res;
verbose("---\n");
for (int i = 0; i < 16; i++)
verbose("0x%02x ", data[i]);
verbose("\n");
memset(hid_buffer, 0xff, report_size + 1);
hid_buffer[0] = 0x00; // Report ID
memcpy(&hid_buffer[1], data, req_size);
res = hid_write(handle, hid_buffer, report_size + 1);
if (res < 0)
{
message("Error: %ls\n", hid_error(handle));
perror_exit("debugger write()");
}
res = hid_read(handle, hid_buffer, report_size + 1);
if (res < 0)
perror_exit("debugger read()");
check(res, "empty response received");
for (int i = 0; i < 16; i++)
verbose("0x%02x ", hid_buffer[i]);
verbose("\n");
check(hid_buffer[0] == cmd, "invalid response received");
res--;
memcpy(data, &hid_buffer[1], (resp_size < res) ? resp_size : res);
return res;
}
I have just edited the file by adding the verbose.. in the top and both.. (Please correct me, if I am going it wrong ?)
then, I run "make clean " and "make all"..
This time as you said I run the edbg in the edbg directory..
the code, i have used is
./edbg -bpv -e -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
this time, I got a strange output.. like this??..
sreedhar@Sreedhars-MacBook-Pro edbg % ./edbg -bpv -e -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
---
0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
---
0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
---
0x01 0x00 0x00 0x90 0x01 0xef 0xe9 0xfe 0x7f 0x00 0x00 0x41 0x50 0xd1 0x05 0x01
0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
---
0x03 0x90 0x01 0xef 0xe9 0xfe 0x7f 0x00 0x00 0x46 0x50 0xd1 0x05 0x01 0x00 0x00
0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Error: invalid response received
Can you tell me what this HEX code trying to say..? , how do you decode this ?.. and how to rectify this issue?....
from edbg.
This looks like you have not actually corrected 512 -> 64. Do this change, recompile and try again.
If you did the change, then it looks like the debugger is just not responding to the information requests. This is the firmware issue in the debugger.
The first byte of the request and the response must match. But this could only happen if you send the exact number of bytes the device is expecting.
from edbg.
just forgot to do the change....
Right Now, I did the change from 512 to 64 and ran "make clean", "make all"
After executing "./edbg -bpv -e -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin"
I received
....
0x03 0x00 0x07 0x00 0x00 0x12 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Error: invalid response during transfer (count = 0/2, status = 7)
I got this interesting error.. so, what mistake I have did.. now? I love this debugging!!...
from edbg.
Now you don't have a target connected to the debugger. You can remove the hex print. The debugger now works.
Status = 7 meant that SWDIO line remained high, so there was no active response from the target device (D11 in this case)
from edbg.
Wait, the target got detected. So something else is wrong.
The target did not respond while the flash was erasing. Try to remove the erase command (-e) from the command line and see if the programming succeeds.
from edbg.
I have removed the -e command...
sreedhar@Sreedhars-MacBook-Pro edbg % ./edbg -b -p -v -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
0x03 0x50 0xd2 0x85 0xe9 0xfe 0x7f 0x00 0x00 0x19 0x81 0x3a 0x06 0x01 0x00 0x00
0x03 0x00 0x07 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Error: invalid response during transfer (count = 0/3, status = 7)
Now I am facing.. this error
Error: invalid response during transfer (count = 0/3, status = 7)
from edbg.
Please don't add any more of thew hex stuff. It is no longer relevant.
Something is still wrong with the target device. Do you have a reset asserted by any chance?
from edbg.
I didn't had any
reset asserted by any chance
moreover.. I tried to run. program many times. and I got the result "Error: invalid response received" only..
and I didn't have any indication of reset assert..
I will try to run the code in a new chip and report you..
from edbg.
I meant asserted by some external circuitry. Based on the previous logs, your SWD communication is working, edbg managed to read the device id and recognize the part.
But then programming fails. So double check your power supply to the target and electrical stuff like this.
And yes, a new chip test would be useful too.
from edbg.
Hey..good news it is working.. & thanks
Initially, I have powered from 5V usb then I have removed that connection and powered from particle debugger. and the output was success..
Hey, if you are interested to share, how you were able to debug the issue. Please share.. ?? I'm very interested to known the backend process.. of this..??
What is USB FS device? , why i needed to do the change the value from 512 to 64.. and How did you conclude that there is some electrical issue.. (did you read from HEX code or ???) .
Please answer to the above question it will be helpful for me for my documentation...
from edbg.
Don't do bold text either. I can read fine.
I was able to tell because I ran into a similar issue some time ago with another person. Hex codes were useful in confirming the issue. You could see that debugger responded with 0xff for all but first command. 0xff is the error code. It means that it was interpreting extra byes (stuff over 64 bytes) as commands too. And that obviously would not work.
USB HID protocol that is used for CMSIS-DAP communication requires frames to be sent with fixed size. USB Full Speed devices support 64 bytes max, so this is the size that is commonly used. USB High Speed devices can go higher, so 512 or 1024 bytes are common.
Linux and Windows ports use OS-specific APIs to determine the size of the endpoint and automatically adjust. MAC port is not really maintained, since I don't use macs and don't have any apple hardware. So the size is just set to a fixed value.
from edbg.
Related Issues (20)
- error_exit() function and target reset HOT 1
- Error: hid_error is not implemented yet HOT 20
- Ubuntu 20 edbg flash broken? HOT 3
- unable to unlock HOT 4
- Binary downloads HOT 7
- Programming ATsaml21e17b HOT 2
- Segmentation fault on OSX when debugger in use by openocd HOT 7
- CMSIS-DAP v2 support requirement HOT 5
- edbg compiled on Raspberry Pi 4B hangs while using free-DAP to program SAMD21 HOT 3
- RP2040 support? HOT 28
- board unusable after write fuse operation on SAML11-XPRO HOT 5
- Why is the RP2040 max flash 2MB? HOT 1
- libhidapi.0.dylib not loaded on Mac HOT 5
- Request to add entry for SAM V70N19 Rev B HOT 1
- "nanoDAP" adapter not supported in Linux HOT 2
- WAIT response after erasing flash HOT 7
- Can't list devices on Ubuntu 20.04 HOT 4
- Kinetis KL26 HOT 2
- Add support for PUYA PY32F0xx HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edbg.