nerdralph / usbasp

usbasp improved firmware
GNU General Public License v2.0
51 stars 14 forks source link

TPI is missing #7

Closed dioannidis closed 2 years ago

dioannidis commented 3 years ago

Hi,

I don't know if it is by choice but the TPI capabilities is missing :

" } else if (data[1] == USBASP_FUNC_GETCAPABILITIES) { replyBuffer[0] = USBASP_CAP_0_TPI; replyBuffer[1] = 0; replyBuffer[2] = 0; replyBuffer[3] = 0; len = 4; "

regards,

nerdralph commented 3 years ago

I've done nothing with the TPI code, and have no TPI devices to test with. There's code there to handle TPI, but I have no idea if it works or not.

dioannidis commented 3 years ago

Hi,

I've one or two attiny10's laying around. I'll give it a try and let you know. Do you have any particular test that you want me to perform except of course writing and reading ?

regards,

nerdralph commented 3 years ago

I've one or two attiny10's laying around. I'll give it a try and let you know. Do you have any particular test that you want me to perform except of course writing and reading ?

That sounds fine to me.

dioannidis commented 3 years ago

Hi,

if I enable TPI support, then the firmware doesn't fit in atmega48.

"avr-gcc -Wall -Wextra -Os -Iusbdrv -I. -mmcu=atmega48 -o main.bin usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o isp.o clock.o tpi.o main.o -Wl,-Map,main.map c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: main.bin section .text' will not fit in regiontext' c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: region `text' overflowed by 18 bytes"

Are you ok by this ? I remember you saying that you would like to keep it running on atmega48 .

regards,

nerdralph commented 3 years ago

If it is only 18 bytes over 4096, it should be easy to optimize that away. On my test builds -flto cuts the size by more than 100 bytes. Can you give that a try? Just add '-flto' to COMPILE in Makefile.

dioannidis commented 3 years ago

Hi,

the test is unsuccessful . USBasp TPI seems that is not compatible, with the -flto optimization. I couldn't read or write a basic blink code to the t10. A lot of broken pipes errors.

regards,

nerdralph commented 3 years ago

OK. I have a couple other ideas that should save a few bytes that I'll try. If that doesn't work, then I'd want to use a build flag to enable TPI, so it could still work on the m48.

nerdralph commented 3 years ago

I just pushed a couple tweaks that dropped 20 bytes off the size. That should be enough for your TPI changes to still fit in 4096 bytes.

dioannidis commented 3 years ago

Hi,

now the firmware is 4096 FLASH with 112 SRAM for the atmega48 with TPI enabled.

I tested writing and reading a attiny10 with the main.hex firmware uploaded in atmega48P, atmega8 and atmega88PA. Also I tested the WCID enumeration and the ICP programming at the same time. It worked with Arduino IDE's (1.8.13) avrdude and with the latest avrdude builded from source with cygwin64 in Windows 10 . I reverted the vendor name change because it wasn't recognizable as usbasp and one had to selected it as usbasp-clone . Also the changes in usbdrv.c made the TPI unreliable ( don't know why ....... ).

regards,

nerdralph commented 3 years ago

I'll look over your changes. I'm concerned about your comment regarding the changes to usbdrv.c. Changing initialized variables (data section) to zero'd variables (bss) that get initialized from main is something that I've done in other projects. If TPI became unreliable after that change, it suggests a memory corruption bug elsewhere in the code that is stomping on memory.

dioannidis commented 2 years ago

Closing assuming there is no interest.