HI,
i am using a mega2560 clone (elegoo mega2560 R3).
When connecting it always shows up as a usb device with PID0042 and VID2341 and a long serial number.
I want to change those to other numbers because i am trying to emulate another device. I think that is possible with the mega, i followed this tutorial: shackstack changing VID
But even when i select my newly created board and upload my code, the VID/PID doesnt change.
I can program the arduino using the arduino ide and VSCode with Platform IO
I managed to update the 16U2 Firmware. I had to use a hexfile found on the forum, the one found on the Arduino github pages is broken.
Do you know where in the hex file pid/VID is? i can search for them but the pid is 0010 which is really common in that file. Also i think the serial number is not in there...
Hmm, you need the actual source code rather than the .hex file. That way you can recompile it with whatever VID & PID you like. After a short search I couldn't locate it, but then again maybe I didn't look hard enough.
This is a long shot and a complete hack but you could give it a go! Beyond here be dragons as they say!
I went to this github page:
And downloaded the file: Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex
If that's the right file, then here's the contents of the start of the file:
:1000000090C00000A9C00000A7C00000A5C000006B
:10001000A3C00000A1C000009FC000009DC0000060
:100020009BC0000099C0000097C0000048C40000B9
:100030000CC4000091C000008FC000008DC0000003
:100040008BC0000089C0000087C0000085C0000090
:1000500083C0000081C000007FC0000002C100001A
:100060007BC0000079C0000077C0000075C00000B0
:1000700073C0000071C000006FC000006DC00000C0
:100080006BC0000069C0000067C0000065C00000D0
:1000900063C0000061C000001201100102000008EE
:1000A0004123420001000102DC0109023E0002017D <--- Maybe this is the VID & PID
:1000B00000C0320904000001020201000524000111
:1000C0001004240206052406000107058203080027
If the VID & PID are 16-bit values, then they will likely be store lower byte the upper byte. You can see on the line I pointed to, that there is 4123 and 4200 which would fit.
Now, you can probably change these to whatever you like, BUT you need to alter the checksum byte (currently 0x7D) at the end of that line to the correct value or the programmer will likely throw an error/warning.
Just found a a website that will be really useful to you if you want to play with VID & PID and calculate the right checksum.
It lets you type in (or copy & paste) an ASCII hex string and tells you the checksum you need. For the possible VID & PID line, I pasted in 1000A0004123420001000102DC0109023E000201 (ignoring the colon) and hit calculate. It popped out the answer 7D, which is correct. That should save you some messing about.
it worked but didnt solve my problem....
is there anything that can emulate a real usb mass storage device? Like a software defined USB stick so to speak
Not sure what you mean. Did you manage to alter the VID & PID like you wanted?
Note that the 16u2 firmware code only knows how to be a USB-Serial interface. Changing the VID & PID won't alter that.
It seems that your project is to emulate a USB mass storage device that has a specific VID & PID? Is that because there is an application running on a PC that only works with a USB device with a specific VID & PID?
How much storage are you looking for?
You may get more mileage with one of the SAMD processors that has built-in USB hardware.
Yes i have some old application that stores output only on a certain usb stick. It also requires the stick to start. The stick has to be plugged in when starting it.
i dont need much space, 4gb would be insanely high.
i hoped the if something is plugged in with same VID/PID that that counts already. sadly it doesnt
You might be able to get an Arduino Micro (it has a 16u2) and an SPI flash memory chip and cobble them together to essentially create a custom USB stick with whatever VID & PID you liked.
Yes, you can use an SD card. Your 16u2 micro would translate the USB instructions and carry out the appropriate actions on the file(s) on your SD card.
I took a further look at the Reddit / Youtube video and the code is based on the LUFA (Lightweight USB Framework for AVRs) libraries. If you've not found it yet, head over to:
The web page says that one of the demo programs is for a Mass Storage Device.
My arduino micro clone arrived. i can programm it through the usb port without issues.
When i experiment with the LUFA framework i assume that programming it through usb is not possible anymore. So i tried programming it using my mega as an ISP.
I tried burning the bootloader first according to this article: https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoISP
That failed as the device could not be identified. It seems to fail bc my micro clone does not feature an external crystal. I solved that by using another Arduino as isp script as suggested here: Invalid device signature error
but now i have the next error: stk programmer not responding. any ideas how to continue?
no the initial bootloader is still on the board and working fine. I can programm "blink" for example using the arduino ide and just connect the micro with USB. But since i want to change the bootloader i have to program the micro using my mega.
Since i wanted to be rather safe than sorry i tried just nurning the initial bootloader again to the micro, but i get the above mentioned error