Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with SAM D21 xplained pro board from Atmel #2

Open
pozzugno opened this issue Mar 9, 2016 · 5 comments
Open

Compatibility with SAM D21 xplained pro board from Atmel #2

pozzugno opened this issue Mar 9, 2016 · 5 comments

Comments

@pozzugno
Copy link

pozzugno commented Mar 9, 2016

I would like to use your project as a starting point for a bootloader compatible with Xplained Pro board from Atmel. I'm going to use Atmel Studio (Windows OS) as IDE.

Any suggestions. I understood your project was compiled in Linux OS. However the gcc toolchain should be the same.

In Windows, I couldn't find the source code files of ASF. They are automatically imported in your project during ASF wizard. I understood, in Linux ASF installs source code directly.

@pozzugno
Copy link
Author

Finally I compiled the project successfully under Atmel Studio 6.2 running in Windows 7 OS for SAM D21 Xplained Pro board. It works, great! The only problem, I have to delete the original FLASH.bin, before dragging the new firmware (but this is well written in README).

What I didn't understand is the virtual_flash_mem folder. It seems ASF already provides FAT (FatFS) service and Virtual Memory in RAM component. Why do you use your source code? Is it different from the original supplied by ASF?

@mattairtech
Copy link
Owner

Sorry about the late reply. Yes, Windows 7 (and later?) requires deleting the original file first. I don't think XP required this. It would really be nice to not have to do this, but I have not thought of a way.

First, this is an MSC device (MSD), which merely transfers 512 byte blocks of data between the host and the flash memory. MSC devices to not need any filesystem implementation. It is the host that needs to understand the filesystem. Some devices (cellphones) do implement FAT, but must unmount the filesystem from the phone OS before mounting to the computer OS using USB MSC (because it is simply a block device to the computer). Second, the flash memory must not actually contain any FAT structures (like the file allocation tables themselves). It can only contain the binary file that is transferred.

With these two things in mind, a minimal FAT implementation was needed, with FAT structures stored in the bootloader itself rather than anywhere in the rest of the flash. That's where the Virtual Memory folder comes in. This code basically can tell the difference between the FAT structures and the user binary, and it inserts/removes the FAT portions from the 512 byte blocks. This piece of code is the core of this bootloader, and it was written by Dean Camera of LUFA (www.lufa-lib.org) for an MSC bootloader for AVR 8-bit devices. Brilliant!

Note that ASF includes examples for an MSC based bootloader (sam0/applications/usb_msc_bootloader). However, this bootloader uses USB host mode to transfer data from a connected USB flash memory stick. I basically combined this ASF bootloader with the LUFA virtual memory code and some parts of another ASF example (USB MSC related).

@rutvikna
Copy link

Hey,
Thank you for the detailed information about the samd21 bootloader. I tried to compile the project in Atmel Studio (Windows 10) but ran into a lot of build errors. Can you please elaborate on how you got it working in Windows.

Also, I am trying to implement USB MSC Device stack on my samd21 + uSD board. My code works fine but it takes around 3 mins to load a 2gb SD Card and reads a file 12KiB/s. Do you have any input on that?

Thanks in advance!

@mattairtech
Copy link
Owner

This is not setup to compile on Windows. However, it looks like https://github.com/watterott/SAM-BAR (both CDC and MSD) has Atmel Studio project files, so you might want to try that. My knowledge on Atmel ASF source code is limited, so I afraid that I can't help out on the second question.

@rutvikna
Copy link

Will look into that project. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants