Go Down

Topic: use leo as HID and Mass storage. (Read 508 times) previous topic - next topic

damavox

Aug 13, 2017, 04:59 am Last Edit: Aug 13, 2017, 05:48 am by damavox
Just to break it down.
I have currently been experimenting with my Leo as an HID device.
controlling with an esp8266 as a virtual keyboard and mouse using a web interface hosted on the esp.

It got me thinking what else i could control and do using this setup.

So my question is if i attach a Micro sd card slot could i use it as mass storage as well. by mass storage i mean have the Sd card show up as a drive on my pc. Just like a Flash drive would if i plugged one in.

I viewed the LUFA project but it seems that with LUFA HID and Mass storage have separate boot loaders.

Is this possible and if so can someone point me towards some information to help me achieve this as i have spent a week searching through google results and have not yet found a solution or if it is possible.

Thanks in advanced!!


DrDiettrich

HID and mass storage are very different USB device types. I don't think that a single USB device can serve both purposes at the same time.

damavox

That's kinda what i was thinking.
Do you think it's possible to pull files from my pc via a serial connection or something and having them stored on the sd card? Or use the esp8266 to transfer them to a wireless N.A.S?
While still maintaining the HID function?

DrDiettrich

I'm not familiar with the Leonardo. Find out yourself, which communication channels can be used in addition to the USB port. E.g. on an Uno the USB port occupies the one and only Serial device of the controller. That's why many additional communication modules (BT, Ethernet...) connect to the SPI or I2C bus, which support many devices at the same time.

damavox

Thats above my head at this point in my learning. Which is why i haven't "found out for myself" and am asking the more experienced people here for assistance, advice or direction.
Thanks though I'll look more into serial communication. If my first plan is not possible.

PieterP

CNLohr created a software USB stack for the ESP8266. I think it supports HID, and you can probably upload/download files over WiFi if you want to. You might not even need an SD card, you could use SPIFFS in the ESP's flash memory (up to 3MB).

Pieter

damavox

#6
Aug 14, 2017, 03:22 am Last Edit: Aug 14, 2017, 03:27 am by damavox Reason: Added explanation of why the suggestion might not be a good fit for my project.
oh wow! thank you! I checked it out.
The concerns i have with this comes down to this limitation on the read me:

"This project only operates with low-speed USB (1.5 MBit/s) ideal for making peripherals, not for fake network devices and usb-serial bridges."

considering i will be controlling this from a virtual network. i don't believe it is a good fit.
Maybe i can learn or get the code modified in order to make it a better fit though.

GoForSmoke

Can the Leo switch between USB modes in run time? Data sends easy in CDC (what stock Uno uses) COM channel while HID handles various analog-axes and digital-button inputs but does HID have to and from drive commands?

If your PC app can make a serial connection to your Arduino then they can work together.
Arduino sends DOS file commands to the SD card that has a controller of its own, your PC engages it through a media reader.

But your Arduino can front-end for the card to allow the PC directory lists and file management as well as read and write files.
If the PC passes through commands for the card, the Arduino will only need to be a USB to SPI channel and buffer.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

damavox

Can the Leo switch between USB modes in run time? Data sends easy in CDC (what stock Uno uses) COM channel while HID handles various analog-axes and digital-button inputs but does HID have to and from drive commands?

If your PC app can make a serial connection to your Arduino then they can work together.
Arduino sends DOS file commands to the SD card that has a controller of its own, your PC engages it through a media reader.

But your Arduino can front-end for the card to allow the PC directory lists and file management as well as read and write files.
If the PC passes through commands for the card, the Arduino will only need to be a USB to SPI channel and buffer.
....And with that post i realized that I have a lot more to learn to successfully pull this project off.
I gotta be honest I only understand a little bit about what you mean but will try my best to learn and have a more intelligent update later this week.

Do you know of a project that uses the technique you speak of so that i can have a look at it and the code to see exactly whats going on and how its done?

If what you are saying is true then this is becoming more and more of a real possibility.
I'm starting to get excited. : )


GoForSmoke

I can tell you data transfer between PC and Arduino with SD been done without the HID part in loads of ways.
All the parts are there except code on PC and Arduino. Processing.org has the PC side of what Arduino is a Wiring side. There is a forum section specializing in interfacing with PC's.

See if the Leo and your PC OS will let you switch USB modes.  I haven't messed with it in maybe 4 years.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

damavox

Okay great! Thanks again for your help.

The HID part is important because what sparked this whole project is that I've been contracted to research "USB / HID attacks". And while conducting my test. I thought "I wonder if it's possible to transfer files with mininal or no foot print. Using something like ROBO COPY in the command line.

Then i thought about how useful or unique this type of setup would be for my home set-up.
Considering I've only been investigating this kind of thing for a couple months and am new to the world of microcontrollers. I started reaserching and searching through google. It didn't take me long to figure out that this hasn't been done before and if it has it's not well known of or burried deep within the internet.

So then I was presented with a challenge that i thought would be super cool and useful if i / we could conquer and use to learn.

Another path i thought of is instead of using the sdcard directly is if i pluged in a flash drive with a specified name. Then use the leo code and hid functions to search for a specific drive name and if the drive is found then copy files from a specific directory to it.

But i still haven't found a similar project that does this. Not an open source one anyway.


Anyway just brainstorming. I'm going to check out processing.org and your site on multitasking arduinos. As i might learn or be inspired from there too.

MorganS

This is still an open problem in the Arduino world. It would be fantastic to log some data on an Arduino and then plug it in to USB to download the files like a camera or whatever. It's a valid question to ask.

Unfortunately the solution seems to be more complex than the unpaid/open-source Arduino community can support. I know there's some active work going on with the Teensy 3.6 to attempt this, but I haven't kept up with the progress.

One possible solution is to put a USB hub in the box and plug a USB drive into it, along with the Arduino. But this won't let the Arduino access the storage. It's just a good place to store the manual for the Arduino device. I've seen this done with some commercial devices where they need to provide information about the device without shipping a printed manual with it. The HID or serial function of the device can proceed separately from the storage.

If you want the memory to be read-only to the PC then use an SD card adaptor and set the lock switch on the SD card.
"The problem is in the code you didn't post."

damavox

So if I understand you correctly. Tou are saying use a Flash Drive and then use the hid function to open a command prompt or powershell and send a keyboard command to copy to the flash drive by specifing a drive name?

If possible, which i believe it is. This would be a great use of the built in usb hub of my clients pcb. But it does tie up the only avalible port of there device. Outside of there own pcb for my uses it would work great.

GoForSmoke

With a little bit of reading it's clear that this is about making cheap hacks to stick in unprotected systems.

The fix is not leaving the PC open.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

damavox

#14
Aug 15, 2017, 12:30 pm Last Edit: Aug 15, 2017, 12:36 pm by damavox
Actually no.
Although that is my day job (sercurity researcher) that is not what this project is about.
It is alot easier to run some quick powershell, do some clean up and get out. Then invest serveral days, weeks and maybe even months in learning and pushing MC's past a point where most people think is impossible.
This is about engineering and computer science.

Go Up