urjaman / fast-usbserial Goto Github PK
View Code? Open in Web Editor NEWATMega16U2 firmare - faster than arduino-usbserial
ATMega16U2 firmare - faster than arduino-usbserial
Hi.
I have updated fw on arduino's 16u2 chip and than I made
make ftdi
make flash-u2
Than with command:
e.g flashrom -o test.txt -p serprog:dev=com4:2000000 -r test.bin
I got errors flashrom invalid response 0xFF from device and something about a buffer.
can this speed be custom adjusted?
I'm using RTS and DTR for some control, but I found that, when I set DTR, PD7 goes LOW, but set RTS, PD6 not have any change.
then I change this function
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
wdt_disable();
/* Hardware Initialization */
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Timer0 is the LED timeout timer... */
TCCR0B = _BV(CS02);
/* Timer1 is the USB flush timeout timer. */
OCR1A = 8000; // 0.5ms at 16Mhz
TCCR1A = 0;
TCCR1B = _BV(WGM12) | _BV(CS10);
/* Pull target /RESET line high */
AVR_RESET_LINE_PORT |= AVR_DTR_LINE_MASK;
AVR_RESET_LINE_PORT |= AVR_RTS_LINE_MASK;
AVR_RESET_LINE_DDR |= AVR_DTR_LINE_MASK;
AVR_RESET_LINE_DDR |= AVR_RTS_LINE_MASK;
}
/** Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event.
*
* \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced
*/
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR);
bool CurrentRTSState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_RTS);
if (CurrentDTRState){
AVR_RESET_LINE_PORT &= ~AVR_DTR_LINE_MASK;
}else{
AVR_RESET_LINE_PORT |= AVR_DTR_LINE_MASK;
}
if (CurrentRTSState){
AVR_RESET_LINE_PORT &= ~AVR_RTS_LINE_MASK;
}else{
AVR_RESET_LINE_PORT |= AVR_RTS_LINE_MASK;
}
}
and I change makefile
CDEFS += -DAVR_DTR_LINE_MASK="(1 << 7)"
CDEFS += -DAVR_RTS_LINE_MASK="(1 << 6)"
and I found that, when I setup RTS, there's nothing happen, but when I set DTR, something interesting happen, RTS and DTR goes to LOW together.
I think that function EVENT_CDC_Device_ControLineStateChanged
not be called when I set RTS.
I debug, and found that, when I set RTS, function Endpoint_IsSETUPReceived
return false when I set RTS, but return true when I set DTR
static inline bool Endpoint_IsSETUPReceived(void)
{
return ((UEINTX & (1 << RXSTPI)) ? true : false);
}
I'm unfamiliar with avr MCU, and I do not know what to do that.
How is it faster and what was the problem with the original usbserial?
Hi,
I've seen this code and it really seems to be an awesome solution. I haven't had time to test it though.
It looks like you are using an old version of LUFA. Which isnt bad at all, but it would be interesting if you could update this to the latest LUFA and still get it working. Then we could also see it in the LUFA USB-Serial example and not only for Arduino.
And I guess you used Windows to compile the firmware (since I didnt get that working under linux again with those old sources). You could also update avr-gcc to 4.8.1 or 4.9.2 to maybe get more speed or more flash improvements:
https://nicohood.wordpress.com/2015/02/20/compiling-with-avr-gcc-4-9-2-under-windows/
https://nicohood.wordpress.com/2015/01/24/installing-avr-gcc-4-8-1-and-arduino-ide-1-6-on-raspberry-pi/
I am developing a 16u2 Bootloader that gives the opportunity to upload sketches to the 328 as usual and also to the 16u2 itself. If I have time I'd like to integrate this, if you'd like to. Is this okay for you? If you feel like playing with the bootloader and apply those patches before I've got time to, feel free to help.
https://github.com/NicoHood/HoodLoader2
NicoHood/HoodLoader2#13
It would be nice if you could do a little writeup about how this works and what youve' changed? Hope I have a chance to test this soon. (I need a 32u2 .hex file so I need to recompile it myself before using it).
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.