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

32 u4 support #26

Open
wants to merge 15 commits into
base: 32U4_support
Choose a base branch
from
Open

Conversation

haweiler
Copy link

Added support for AVR 32U4 using Arduino IDE. Library from Arduino IDE is used for initializing USB mainly. As there's a bug in Win not allowing the Arduino to send replies back it only works using Linux. For finding out where the sketch can't continue I added some LED flashing stuff also using Arduino library.

Modified JICE_io and jtag2updi to compile for 32U4.
Failed to transfer files though. USB port shows up, HEX reply to command as expected, but couldn't program, yet.
Support for Arduino devices using HW_SERIAL for communication with PC, UART used for UPDI.
Separated UPDI for type1 (bitbang) and type3 (UART). Changed to more 'relaxed' timings for using UPDI.
Separated files for UPDI using bitbang/UART. Forgot to add changed Jtag2.cpp.
32U4 support only working using Linux right now due to a bug in windows not allowing the 32U4 to send a reply to avrdude.
@ElTangas
Copy link
Owner

I think you messed up the latest commit to your repository, there are lots of duplicate files in the root directory that should be in the source directory.

messed up commit: wrong directory
messed up commit: wrong directory
messed up commit: wrong directory
messed up commit: wrong directory
messed up commit: wrong directory
messed up commit: wrong directory
messed up commit: wrong directory
messed up commit: wrong directory
Added support for AVR 32U4. Due to an issue how COM (with 32U4) is handled in windows, not allowing the Arduino to send feedback while trying to program, it's only working using Linux. Arduino libraries are being used for init of USB and also for some LED flashing added for finding where the sketch stops working using windows.
@haweiler
Copy link
Author

Sorry, hope I got that fixed now. I had to manual merge some files. Please check if something went wrong there with the changes done due to the tiny0/1 adds.

@ElTangas
Copy link
Owner

ElTangas commented Feb 18, 2020

The code cannot have unconditional dependencies on Arduino libraries, It must compile on systems that don't have the Arduino libraries installed (that is, for targets other than the mega32U4).
In other words, you need to wrap every Arduino dependent code in conditional compile blocks.

edit: for example wrap the blocks with

#if UPDI_IO_TYPE == 3
...
#endif`

@ElTangas ElTangas changed the base branch from master to 32U4_support February 18, 2020 13:31
@ElTangas
Copy link
Owner

I created a branch to work on the code, since even after you address the issue from the previous comment, there will probably be more things to change before merging with main.

@haweiler
Copy link
Author

I can wrap the dependencies, no prob. But what happens with those files from
C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr (if I take the win version) as there are io.h, iom32u4.h, C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h?
I guess I won't go for an approach to even have the 32U4 being able to compile without Arduino libs, by picking the USB stuff from the libs. But you're not out after that if I get that right.

@haweiler
Copy link
Author

And is it a good idea to keep the 'LED_blink' in? I added it only for that windows usb issue, as the ardino-ide has no debugger. But I could change that to setting LED on/off by setting the registers directly as you did (SYS::setLED, SYS::clearLED) - or put that in with an optional compile switch.

@ElTangas
Copy link
Owner

ElTangas commented Feb 18, 2020

I guess I won't go for an approach to even have the 32U4 being able to compile without Arduino libs, by picking the USB stuff from the libs. But you're not out after that if I get that right.

No, what I want is not to break compatibility with things that work in the current version, like building by running the makefiles on a system without Arduino.
But this is for other targets, not 32U4. That one will require Arduino libraries to be installed on the system but I'm ok with that.

edit: yes, regarding the LED, please use Arduino libraries only when absolutely needed. I'll be reviewing their use later, anyway.

@rneurink
Copy link

rneurink commented May 12, 2020

Hi, might be a bad place to post this, there are no issues available on @haweiler fork.
Is this code currently in working condition? I haven't had any luck so far with an arduino micro.
Any writeup how to get this working with the atmega32u4 would be highly appreciated

`
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

              System wide configuration file is "C:\Users\xxxxx\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\1.1.5/avrdude.conf"

              Using Port                    : COM10
              Using Programmer              : jtag2updi
     avrdude: ser_recv(): read error: The I/O operation has been aborted because of either a thread exit or an application request.


     avrdude: jtagmkII_getsync(): sign-on command: status -1
     avrdude: ser_send(): write error: sorry no info avail
     avrdude: jtagmkII_send(): failed to send command to serial port
     avrdude: ser_recv(): read error: The device does not recognize the command.`

EDIT: Verbose
`
avrdude.exe: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\xxxxx\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\1.1.5/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : jtag2updi
avrdude.exe: jtagmkII_open_pdi()
avrdude.exe: jtagmkII_getsync()
avrdude.exe: jtagmkII_getsync(): Sending sign-on command:
avrdude.exe: jtagmkII_send(): sending 1 bytes
avrdude.exe: Send: . [1b] . [00] . [00] . [01] . [00] . [00] . [00] . [0e] . [01] . [f3] . [97]
avrdude.exe: jtagmkII_recv():
avrdude.exe: ser_recv(): programmer is not responding
avrdude.exe: jtagmkII_recv(): Timeout receiving packet
avrdude.exe: jtagmkII_getsync(): sign-on command: status -1
avrdude.exe: jtagmkII_getsync(): Sending sign-on command:
avrdude.exe: jtagmkII_send(): sending 1 bytes
avrdude.exe: Send: . [1b] . [00] . [00] . [01] . [00] . [00] . [00] . [0e] . [01] . [f3] . [97]
avrdude.exe: jtagmkII_recv():
avrdude.exe: ser_recv(): programmer is not responding
avrdude.exe: jtagmkII_recv(): Timeout receiving packet
avrdude.exe: jtagmkII_getsync(): sign-on command: status -1
avrdude.exe: jtagmkII_getsync(): Sending sign-on command:
avrdude.exe: jtagmkII_send(): sending 1 bytes
avrdude.exe: Send: . [1b] . [00] . [00] . [01] . [00] . [00] . [00] . [0e] . [01] . [f3] . [97]

`

@haweiler
Copy link
Author

haweiler commented May 13, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants