LUFA / FAT16 / PROM

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greets!

Has anyone seen a GCC example of using LUFA along with FAT16 to make an AVR or XMega project that simulates a mass storage device (MSD) using a serial PROM?

I have seen the LUFA MSD example, but gather it would also need to to the FAT16 heavy lifting on order to show the contents of a serial PROM as the storage medium on the PC.

The final goal would be to plug the AVR into the PC and then write files and directories to the PROM, which can later be accessed by another AVR.

Thanks,
Brad

I Like to Build Stuff : http://www.AtomicZombie.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The host expects a media block device, rather than a filesystem - so all you need is to make your USB mass storage device expose raw 512 byte blocks of storage and it will work fine (this is what the LUFA demos do). If you then want to access that data on the AVR side you need FATFS or some other FAT library to interpret the raw media, but the OS will use its own filesystem libraries.

If you just want to be able to store files from the OS side, use the Mass Storage demo. If you want to read or write files from the AVR side, check out this demo: https://github.com/abcminiuser/l... .

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, thanks. So the PC does the FS heavy lifting and the AVR just shovels data back and forth. I will just add the PROM routines to your great demo and that should do it.

As for later accessing those same files on another AVR, I will have to add FFS to the AVR/XMega that hosts the PROM.

Ok, got it.

I also plan to use your PDI example to allow this AVR (with PROM) to read a .hex file and then program another XMega via PDI. I guess I will have to use FFS to get access to that file once it is sent from the PC to the PROM.

Thanks,
Brad

I Like to Build Stuff : http://www.AtomicZombie.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another option is to make the USB AVR appear as a CDC-ACM (com port) then implement something like Ymodem in the AVR. From the PC you then use something like Hyperterminal to send the data. It's then up to you how it's stored internally and how you access it locally.

If you go the FatFs (MSD) route you may well find you only need the Petit version.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I have figured out what I want to do (or at least attempt to do)...

I want to use Dean's AVRISP/PDI emulator in AVR#1 to allow a PC connected via USB to directly program another AVR (XMega) on my board using PDI.

I also want avr#1 to give access to an SD card through the PC so I can store files on it (mass storage system).

So AVR#1 using LUFA will act as an AVRISP/PDI clone as well as a mass storage device connected to an SD card.

I know I am biting off a huge amount to chew here, but I can't see why this can't be done.

Do you think that the PC will enumerate 2 devices (AVRISP clone and mass storage device) at the same time, or will I need to have the AVR do some switching between the two functions?

It would be cool if when I plug in the USB, the PC responds with "mass host detected" and "found AVRISP-II hardware".

Brad

I Like to Build Stuff : http://www.AtomicZombie.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes a USB device can enumerate as several classes. LUFA has examples of this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately however it's not possible to create a composite device with AVRISP MKII and and other interface - the Jungo driver that the AVRISP-MKII will only bind at the device level, and not the interface level. If you want AVRISP MKII and Mass Storage functionality, you'll have to switch between them in firmware.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!