Writing to FAT32 USB flash drive
Hello everyone,
First off, let me introduce myself, as this is my first post here. My name is Jesse, I’m 32 years old, and I recently graduated with a bachelor’s degree in Electronics IT. I’ve just started my first job as an embedded software developer. As one of my first projects, I’ve been given the task of maintaining a product called the Gafferscontrol, which is running on a Propeller 2 (P2):
https://www.gafferscontrol.com/
This small device is essentially a DMX controller. Via USB, the user can load different libraries or perform firmware updates. The previous developer made extensive use of the library by garryj and, to my knowledge, wrote a custom Spin2 wrapper for reading from USB (I’ll attach both files for reference). After examining the code, everything looks prepared for implementing a write function as well, but the low-level PASM code currently lacks this functionality.
A little background
As the first paragraph may suggest, I’m very much a junior in this field. My only prior experience with microcontrollers comes from Arduino and ESP32 projects. Over the past few months, I’ve been extensively researching the Propeller architecture and got my hands on both the Propeller 1 and 2 demo boards. I followed the Propeller Labs, DeSilva’s Assembly Tutorial, read the documentation, etc.
Last week, I managed to write a DMX driver for the P1 in PASM. Getting that to work felt like my first real achievement.
USB
While doing my homework on the Propellers, I tried to get a solid grasp of the USB standard—and, honestly, my head hurt after the first week of trying to read the full specification. Luckily, I found some excellent material by J. Axelson, who distilled all that information into a “mere” 300 pages. Reading her work gave me a much better understanding of the protocol and just enough motivation to tackle this problem.
The task at hand
I’ve been tasked with implementing a write function that exports all fixture settings to a flash drive. I added the BBB_set_sector function to the USB_cog_test.spin library, as well as a BBB_set_sector_struct command wrapper. Higher up in the Spin2 library, I added a writeblock() function to attempt writing my first FAT entry for a regular file.
Of course, this didn’t work right away, so my next step is to solder the debug pins and hook up a logic analyzer to track down any issues.
The question
At this point, I’m honestly a bit in over my head, so any help would be greatly appreciated. Hopefully someone here has already gone down this route and can provide some demo code or at least point me in the right direction.
Thanks in advance!
J.

Comments
Getting that @garryj code working is a noble cause, but probably very difficult...
If it were me, I'd cheat and just use a VDrive3:
https://ftdichip.com/products/vdrive3/