microchip-pic-avr-tools / pyedbglib

Low-level protocol library for communicating with Microchip CMSIS-DAP based debuggers
MIT License
12 stars 4 forks source link

SPI_CMD_GET_BAUD not working #9

Open mcsmark opened 1 month ago

mcsmark commented 1 month ago

I use the AVRISP protocol. But for some reason the SPI_CMD_GET_BAUD does not work. I do not get a valid response. I tried with SNAP and a curiosity 168 board. this is the test code command = bytearray([AvrIspProtocol.SPI_CMD_GET_BAUD]) self._spi_cmd_resp(command)

in the docs there is link to AVR069. but that use a different way of setting the clock.

this is the webpage ; https://onlinedocs.microchip.com/oxy/GUID-33422CDF-8B41-417C-9C31-E4521ADAE9B4-en-US-2/GUID-1FCCECA1-F85C-4179-BFEC-15CB8F6388AE.html

i did see in the code that spi clock is todo. maybe it was not done because it does not work? a tool like studio does not offer a way to set the clock either. it is kind of odd.

xedbg commented 3 weeks ago

BAUD set/get is implemented on Snap. I think the issue here is probably that _spi_cmd_resp() does not expect anything but "OK" or "Clock error" back from the tool. (https://github.com/microchip-pic-avr-tools/pyedbglib/blob/main/pyedbglib/protocols/avrispprotocol.py#L103) GET_BAUD returns the little-endian baud followed by OK (this could probably be confirmed by enabling debug logging)

mcsmark commented 3 weeks ago

thanks for your reply. i tried various programmers that support ISP protocol : SNAP, jtagice3, 168PB Xplained. i always get a protocol error. Setting the baud works but has no effect on some of the programmers. When i look in AVR Studio 7 only JTAGICE3 offers a way to set the clock. so i think the other devices have a fixed clock. i guess i need to contact microchip. and lastly, the microchip docs differ from the one from pyedbglib. using the source code works. when you just look at the documents (pdf and web) there are some small differences for some functions. it is great to have the working python source. i will ask microchip about these issues,

xedbg commented 3 weeks ago

I have worked with many of these tools over the years, so here is a quick summary:

So "newer" tools are technically less capable when using SPI - newer AVR devices use UPDI, so that's where the emphasis is.

mcsmark commented 3 weeks ago

thanks. yes that is understandable. I also endorse UPDI chips. But some customers need older ISP. Since ISP is built into SNAP i added it. And then i found mEDBG which also works well. except for the clock. a pity no source of the protocol is available otherwise i could have changed it. it is hard to get a good programmer that is affordable and easy to setup. the EDBG is simple to setup. I could do usbasp or some variant but the downside is the driver/libusb.