How would I go about making a custom serial usb device?

So say I have two or more storage areas on a chip and I want the user to be able to simply plug up a USB cable, fire up custom software on their computer, and have the software upload data to the 2 or more storage areas on the chip.

Right now this is what I'm envisioning with the end product and this is extremely early in planning. I'm about to buy an Arduino to play around with this idea and see if I can take it further and make a rough prototype happen but I'm not quite sure if this is possible with Arduino (although I imagine it will be given how low-level bare-metal Arduino is). I don't need anything complicated or to support a filesystem or whatnot, just a custom serial connection that will likely require a simple custom USB driver and custom software to use for transmission and upload of data.

I'm thinking about buying the Arduino Micro because I want the end device to be very simple, small, and to have a USB on it obviously so if I were to take this to production sometime in the future it would be relatively easy to move over especially since the ATmega32U4 on the micro already has a USB built-in and wouldn't require additional hardware support that would needlessly complicate things.

I've seen numerous examples of an the Micro being used for a Keyboard and Mouse but not really anything on the level or type that I'm looking for so was wondering if anyone could help guide me on if this is feasible with the Arduino and if so, how so?

Thanks in advance for your help.

a simple custom USB driver

Have you written any sort of USB driver? If not, spend some time studying the requirements. On Atmel chips, most people start with the V-USB driver (for any MCU) or chips with a built in USB controller (e.g. ATmega32u4).

It would be easy to establish a serial connection to a standard USB-equipped Arduino, and have the Arduino "store things" on a chip.

junebug12851:
So say I have two or more storage areas on a chip and I want the user to be able to simply plug up a USB cable, fire up custom software on their computer, and have the software upload data to the 2 or more storage areas on the chip.

IMHO that is much too vague to provide a basis for any advice.

I can't even think of any useful questions that might focus things.

...R

Is enough to write to the EEPROM, then Reset the uC, have it read a byte or two of EEPROM and decide which the sketch does from there?

@jremington

I haven't made a usb driver before but I'm well versed in C, C++, Assembly, and a number of other languages and frameworks including Windows programming and the Windows API to an extent so I'm fairly confident it won't be that difficult for me especially since I'm not trying to do anything real complex and whatnot.

However, driver aside, how would I begin to implement this in Arduino on the receiving side. Arduino would have to receive the incoming transmission and process it accordingly. I want the transmission to say this data goes to this location and this data goes to this location and Arduino would need to read that and dump the data accordingly to the correct areas. I've found no information anywhere that tells me how to do this in Arduino.

@Robin2

I had originally written a long reply to this comment, but I'm instead choosing not to reply

@CrossRoads

Can you clarify what you mean?

You mention writing to separate areas of the USB from your computer...
Why not create folders (directories) on your USB device, and a simple batch on your PC to copy/move/write to the required folder?.

I've found no information anywhere that tells me how to do this in Arduino.

Since you have not specified to which device the data are to go, I'm not surprised.

However, the actions you so vaguely describe sound similar to the open source Arduino bootloader.

@lastchancename

I figured emulating a file system with folders and having the OS drop files in for my arduino would be a bit much to implement, I'd much rather just a simple binary blob transmission where said binary blob is received as-is and stored where directed. Would this not be easier?

@jremington

Respectively, how can I be any more specific?

  1. The microprocessor on the Arduino Micro connects to the computer via a USB cable.
  2. custom driver allows custom software to tell the microprocessor it's about to send a binary blob and that it should go into storage "0" or "1" which would be magic numbers the microprocessor would understand.
  3. The microprocessor replies back to said software that it understands and accepts the data transmission and that it's waiting for the incoming data.
  4. The software sends the raw bytes over which would be a huge binary blob
  5. The custom software would then announce it's finished sending the data over
  6. The microprocessor would then reply that it was received and stored successfully

That's about as specific as I can get. I'm asking how do I make this communication happen on the Arduino side? I'm unable to find help or resources anywhere for this level of communication to the OS over a USB connection.

Yep, that is exactly what the Arduino bootloader does. Source is freely available.

Thank you very much that's really helpful :slight_smile: , I'll look into it

The most common PC counterpart to the bootloader is avrdude, also open source.

Im not sure what the delema is. if your software is written for windows with visual studio I know for sure that C# has a simple library for a serial connection. just state the port and the baud rate and you are good to go. the arduino sends and recieved to your custom software same as the serial moniter in arduino's compiler.

when you plug in an arduino through usb the PC detects the serial connection and it get assigned a port called something like "com3" or "com4".

I assume there are similar librarys for mac and whatever other popular software languages too.

i think the answer to your question is more simple than you think.

you shouldn't need any driver. you just need to know the string name of the port and modern computer software languages take care of the rest to get the arduino taking to the PC and sending bytes. I just did this a few months ago with a windows app.

from there do whatever you want with the bytes back and forth.

one thing to consider is that the read/write speed of a serial connection on a little arduino board is not going to come close to the speeds that a PC would normally function or write to a hard drive.

@taterking

I haven't done this particular thing with the Arduino so a custom usb driver was initial brainstorming since I'm thinking too generically. It was actually right after my last message that i got to thinking the same thing like, wait, it's already a COM device to the computer and has serial functionality built-in and that I could probably just use that which would tremendously simplify things but thank you for clarifying.

I understand the transfer will probably be slow but the memory transfer is very small and regardless for this project speed isn't important since transferring won't happen that often.

Thank you again for clarifying this method.

junebug12851:
that i got to thinking the same thing like, wait, it's already a COM device to the computer and has serial functionality built-in and that I could probably just use that which would tremendously simplify things but thank you for clarifying.

Now perhaps you will better understand why I wrote Reply #2 :slight_smile:

...R