Mass (Storage) Progress

General, MyUSB Library, Projects No Comments »

Well, good news on the development front. The new micro-framework for Mass Storage commands works quite well, and now my flash disks which previously didn’t work now work perfectly. That’s not to say that it’s all well and good - I’ve got reports from a user about problems when the devices are swapped over on his STK525 board. I’ve been unable to replicate the problems, so if there are any STK525 users out there willing to run a few tests, please contact me ASAP.

Actually, I’d like to publicly thank the user mentioned above, Morne, for his generosity in donating to me for my work on the project. He’s not the first however — several AVRFreaks users have donated over the past year, allowing me to both have fun and pursue my hobby at the same time. I am sincerely grateful for the support (both monetary and otherwise) offered to me towards the development of my current and past projects by all the members of AVRFreaks and other AVR hobbyists.

One small task…

MyUSB Library, Projects No Comments »

I’m a bit frustrated at the Mass Storage demo - it doesn’t seem to work with a lot of devices and I can’t figure out why. As a result, I’m going to re-engineer the demo and create a small framework for creating disk commands so I can keep testing things out until it works.

Thanks to a suggestion by a MyUSB library user, the latest internal source changes the way the connection event fires in host mode, making it interrupt rather than polling driven. That allows for an improvement to the library; in both device and host modes, the USB task can be stopped when not needed. The new release will contain details on which events the task can be enabled and disabled upon, allowing for zero-CPU overhead USB when not active.

Minor Correction

MyUSB Library, Projects No Comments »

I’ve had to update the new MyUSB 1.1.0 download, due to a small bug. Because of its very close proximity to the release of V1.1.0 and the low bug severity, I’m not going to update the version number.

The reduced pipe freezing I implemented seemed to break host compatibility with some devices (so far one, a chinese USB stick which was also non-compliant in its connection timings), and as a result I’ve reverted the code for the control request transfers back to it’s original state. If you are using Host mode I suggest you re-download, otherwise the library is fine to use as-is.

MyUSB 1.1.0 Released

MyUSB Library, Projects No Comments »

Due to a number of pretty serious bug-fixes (eg. dual mode being broken in 1.0.X) I’ve decided to release 1.1.0 immediately. The new library is almost drop-in compatible with the old, and contains several new enhancements and fixes. I’ve created a migration page on my site Wiki for converting older projects to the new library, something which I’ll be doing for each new version. I don’t anticipate many show-stopper changes between minor versions, but it’s good to document those that exist.

You can browse the migration page for the latest version here.

The changelog for the new version is thus:

  • Fixed DCONNI interrupt being enabled accidentally after a USB reset
  • Fixed DDISCI interrupt not being disabled when a device is not connected
  • Added workaround for powerless pullup devices causing false disconnect interrupts
  • Added USB_DeviceEnumerationFailed event for Host mode
  • AVR_HOST_GetDeviceConfigDescriptor routine no longer modifies ConfigSizePtr if a valid buffer pointer is passed
  • Added ALLOCABLE_BYTES to DynAlloc, and added code to make the size of key storage variables dependant on size of memory parameters passed in via the user project’s makefile
  • Fixed incorrect device reset routine being called in USBTask
  • Devices which do not connect within the standard 300mS are now supported
  • Reduced control pipe freezing/unfreezing when sending control requests
  • Removed incorrect ATTR_PURE attribute from Scheduler_SetTaskMode(), which was preventing tasks from being started/stopped, as well as USB_InitTaskPointer(), which was breaking dual device/host USB projects
  • Changed scheduler to use the task name rather than IDs for setting the task mode, eliminating the need to have a task ID list
  • ID transistion interrupt now raises the appropriate device/host disconnect event if device attached
  • Fixed double VBUS change (and VBUS -) event when detatching in device mode
  • Added ability to disable ANSI terminal codes by the defining of DISABLE_TERMINAL_CODES in makefile
  • Removed return from ConfigurePipe and ConfigureEndpoint functions - use Pipe_IsConfigured() and Endpoint_IsConfigured() after calling the config functions to determine success

The new version is available from the normal MyUSB project page. If you find any bugs, please report them to me as soon as possible.

Workaround

MyUSB Library, Projects No Comments »

I’ve finished the workaround I mentioned in my last post, for USB devices which take longer than the standard 300mS to signal a connection to the host. I’ve yet again gone with the same approach as Atmel for the workaround, as I don’t want to re-invent the (square, in this case) wheel. By using a manually controlled VBUS and listening for the OTG session start request flag, I can ensure that a connected device receives as much time as it needs to get ready for connection before switching to automatic VBUS control. This simplifies the change somewhat, as it can be focused in the Unattached host state rather than spread out through the whole codebase.

I’m open to suggestions and comments for V1.1.0, which will be released very shortly. If you have any input for the project, please don’t hesitate to contact me, or leave a comment on this post.

Compliance should be mandatory

MyUSB Library, Projects No Comments »

More adjustments to MyUSB, for the upcomming V1.1.0 release. I’ve added in a powerless-pullup device workaround (the same method used by Atmel, since I don’t have access to such a faulty device) for non-compliant USB devices. That woraround prevents incorrect disconnection events after a USB bus reset when certain badly-engineered USB devices are attached. I still need to write a workaround for another class of badly designed devices; ones which do not signal a connection within the given 300mS and thus cause the VBUS to be disconnected prematurely before the enumeration commences.

I’ve also added in a new internal USB header file to define tokens in response to the defined USB mode in the user project makefile. As positive checks (#ifdef USB_CAN_BE_HOST) are easier to read than the negative checks currently used (#ifndef USB_DEVICE_ONLY) the new header file makes the compile-time mode separation clearer in the source.

While implementing the above workaround for the power-less pullup devices, I discovered a few mistakes I’d made: the DCONNI interrupt was enabled after a USB bus reset (which is incorrect - it is polled rather than vectored) and the DDISCI interrupt was never disabled after being enabled in the host state machine. While minor, the former especially can have a negative impact on performance in some cases and so I’ve corrected the source.

Non-compliance with the protocol layer I can understand, but how these devices that are non-compliant at the electrical layer passed QA I’ve no idea. Minus one to progress, I suppose.

AVRFreaks MyUSB Project Entry

MyUSB Library, Projects No Comments »

Last night I added a new project entry for MyUSB, to increase the project’s exposure. I’ve been holding off adding in a project entry for two reasons, one of which was unfounded.

First, I didn’t want people to forget about the project during its long development period. Better to post the project when it’s finished and prevent people from ignoring it later on due to early issues. That, and it’s against AVRFreaks policy to add unfinished projects to the academy.

Second, I wasn’t aware that AVRFreaks project entries can link solely to a project webpage, rather than having to host the project code on the AVRFreaks server. Doing the former allows me to keep one, constantly updated, download source for the project.

Since the posting of the project the download rate has increased (although this is likely to be short-term). I’m still happy that more people are taking a look; increased exposure should mean it’s used in more actual “real” projects. The following graph clearly shows the increased site activity after the project was added:

Graph of site visitors, Jan 2008

So far I’ve made a few adjustments slated for V1.1.0. The minor version bump will be due to the addition of a new Host Mode event, for the handling of devices which fail to complete the enumeration process properly. The new even fires before the VBUS is removed, allowing the user code to hook into the event to log it (and the error/state codes it provides) and/or halt the code progression until the offending device is removed, preventing a continuous off-on-fail enumeration loop. Stay tuned for the code update.

MyUSB 1.0.2

MyUSB Library, Projects No Comments »

MyUSB 1.0.2 has now been uploaded. As the version number indicates, this is a minior revision to the code, rather than a major enhancement.

The new version carries the new DynAlloc version I wrote about a few days ago (with the seperate DynAlloc zip file on the AVR Experiments page already containing the revised code) as well as enhancements to the Mass Storage demonstration application. After grumbling about the lack of standards compliance on the cheap no-name Chinese flash disks, I’ve decided to update the code to be (I believe) SBC-2/SBC-3 compliant by adding the READ-6, WRITE-6 and MODE-SENSE-10 commands. While the code worked already on the OSes I tested (Win98, WinXP, Vista, Ubuntu) the added standards compliance gives me the right to sit on my oh-so-high horse and complain about the dodgy flash disks.

In addition, I have a little more work to do on the Mass Storage Host code. I’ve fixed a problem in the existing code in the 1.0.2 revision, allowing for multiple read/write commands to be executed correctly, rather than just the one. However, on some of the no-name disks I’ve tried the code with it fails, either during enumeration or due to a BLOCK DATA IN pipe stall. More investigation needs to be done, but again this is likely due to a lack of standards compliance, as name-brand disks appear to work fine.

MyUSB 1.0.2 is available from the MyUSB page.

DynAlloc Improvements

Misc., Projects No Comments »

Well, I’m floundering a little for things to do (other than watch Stargate, and work on a small commercial application, that is) so I had a go at improving DynAlloc, my auto-defragmenting memory allocation library - available from my site separately on the AVR Experiments page, or as a part of MyUSB. The new code is slightly smaller and more efficient than the old.

By making use of the avr-lib-c optimized memory functions memcpy and memset, the need for my own code to replicate the functions is abolished. The avr-lib-c versions are assembly optimized (and thus slightly smaller) but also provides the benefit of being a separately linked function which can be called from the user-code without having to use up more flash than the CALL instruction.

I also changed the way the library works; now the first hole large enough is used, rather than looking for increasingly larger holes. That drastically reduces the number of searches the code has to do, but increases the need for defragmenting. It’s a good tradeoff however - the time used for the defragments should be much smaller than the time wasted doing the repetetive searches for exact-sized holes.

New laptop is awesome. I love the way I can control everything with my voice, mouse/keyboard or mobile phone (via bluetooth). Found some oddities with Vista, but no show-stoppers so far — I’ve been surprised at how well all my AVR tools and software behaves with it.

DB101 Library Hell

ButtLoad, Misc., MyUSB Library, Projects No Comments »

I’m pleased by the downloads of MyUSB - there’s been 42 in the last 9 days alone. While not a mind-boggling amount, it is not bad for an obscure project and shows that at least *someone* is interested in it.

I’ve been working on developing a commercial application of the DB101 board, from Atmel. So far I’ve been happy with the speed at which I can develop applications for the DB101, however I’m not hitting the limits of the Atmel-provided monster library. Understanding and modifying such a large codebase to allow for the features I want (menu separators, non-static dialogs) is a real pain, but I’m making progress.

I’ve also just updated the ButtLoad project source, to compile on the latest version of WinAVR. Unfortunately the most recent versions of AVR-GCC caused the size of the compiled binary to blow out past the allowable size, so I’ve added in the –relax linker option to change the CALL opcodes into the shorter RCALL opcodes where possible to save space. It now once again compiles (only) with the latest WinAVR, with the latest avr-libc. You can grab the modified code over at AVRFreaks.net.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in