******************************************************************************
Demo for ChaN's FAT-module on STMicroelectronics STM32 microcontroller
Version Timestamp 20090430
by Martin Thomas, Kaiserslautern, Germany <mthomas(at)rhrk.uni-kl.de>
******************************************************************************
Copyright (c) 2009
- ChaN (FAT-Code, driver-template, ff_test_term)
- Martin Thomas (STM32 SD/MMC/SDHC driver and demo-application)
- ST Microelectronics (Standard Peripherals Firmware Library)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
******************************************************************************
This is a small demo-application to show how Chan's Fat-Module
can be used to interface MMC/SD/SDHC-Cards with a STM32 microcontroller
(ARM Ltd. Cortex-M3 core).
This code uses the _SPI-Interface_ - NOT a SDIO-Interface since the
Eval-Board here has the card-slot connected to SPI1 and the controller
on it does not offer SDIO. When using a STM32 with SDIO and a board which
has a card-slot connected to the SDIO the example code from the STM fwlib
can be used as low-level driver ("diskio").
Beside of the diskio-drivers for STM32 SPI you may find some useful code
when developing firmware with the GNU toolchain in this package (for
example: vectors-location, startup, linker-script, OpenOCD flash-
programming).
I have done only minor modification in the firmware-library to avoid
warnings The modifications can be enabled by defining MOD_MTHOMAS_STMLIB
(enabled by default). Special versions of startup-code
(startup_stm32f10x_md_mthomas.c) and linker-script (stm32f103vb_flash.ld)
have been created for this project. They are based on the examples that
came with the STM Standard Peripherals Library V3.0.0.
Project-files for Keil/ARM uVision are included. The eval-version
will do to build the project using a GNU toolchain. For debugging
and simulation you may have to use the full version without
size-restricition (not tested here). For standalone building and
Eclipse a makefile is also included.
The package includes Eclipse settings and lauch configurations.
Sorry, no enough time to fully document this here. Just load the
workspace and give it a try. Very short guide:
- External Tools "OpenOCD": starts OpenOCD in the backgroud:
This uses the OpenOCD target-library. The current configuration
is for an Amontec JTAGkey interface and a STM32 with BSTAPID 0x16410041.
When using another interface/controller/board modify the
command-line options in Run->External Tools->Ext. Tools conf.->
leaf OpenOCD->field arguments. For all following debug configurations
OpenOCD has to run and it can be kept running. OpenOCD can be
terminated (right-click-Terminate) in the Debug view when something
hangs and it has to be restarted.
- Debug Configuration (launch) "OpenOCD load init only":
Transfers the load-image into the STM32's internal flash using
gdb's load-command and starts the application. Similar to
"make program" but no need to termintate a running OpenOCD and
restart it with different command-line-options or scripts.
- Debug Configuration "OpenOCD init debug":
Start debugging with an application already loaded into the
controller's flash
- Debug Configuration "OpenOCD init load debug":
Transfers the load-image into the flash-memory and starts
debugging (similar to "OpenOCD load init only" followed by
"OpenOCD init debug")
- Debug Configuration "OpenOCD resume":
Just resumes the target in case it is halted.
Code from others used in this project:
- Chan's FAT-Module R0.07a (4/2009)
- STM32F10x Standard Peripherals Library 3.0.0 with
CMSIS (4/2009)
- some utility code for time-calculations found
in public forums and not copyrighted (see rtc.c)
All used codes should be free for commercial and
non-commercial use. They are either non-copyrighted
or under a BSD-style license. So there is no need
to give away source-code which uses parts of this
project. My modifications are also basically free,
just read the BSD-license at the top of this text.
Of cause there is no warranty neither for the codes
from others nor for to code I have written.
Tested with:
- Controller: STM32F103VB Rev.Z ("medium density")
- Board: Manley EK-STM32F, SD-slot connected to STM32's SPI1
(this board does not connect card-detect and write-protect switches)
- SD-Cards: extrememory 1GB performace, SanDisk 256MB
- SDHC Card: SanDisk Ultra II SDHC 4GB
Tools:
- Compiler/Toolchain: GNU cross-toolchain for ARM (binutils, gcc)
- libc: newlib (only a few functions used)
used packages: Codesourcery G++ lite for ARM EABI Version 2008q1-126 and
2008q3-66
- IDEs/Editors:
- Programmers Notepad
- Eclipse Ganymede SR1 with CDT as in package Eclipse IDE for C/C++
Developers
This is not the current version in April 2009 but the CDT 5.0.2
does not offer a setting for the compiler invocation command in
Project->Properties->C/C++ Build->Discovery Options which is
needed to locate the inlude files of the toolchain (i.e. stdlib.h).
Additional plug-ins: CDT Hardware Debugging, Target Management Terminal,
RXTX Enduser Runtime.
- Keil uVision 3.72 Eval, uVision has only been used as IDE and for
a few tests with the simulator (the simulator is a very good tool!).
No effort has been made to make the code compatible with the RealView
Tools.
- other tool-software: OpenOCD for "batch programming" (make program)
and debugging with Eclipse/GDB Hardware Debugging
- JTAG-Interfaces: Amontec JTAGKey (Eclipse, make program), Keil ULINK(1)
(uVision). I have not used the "ST-LINKII" integrated on the Eval.-Board
since it did not work reliably with uVision and there is no support
in OpenOCD for it.
- This package comes with a OpenOCD directory including a Win32 binary
for FT2232 and par.-port interfaces based on OpenOCD sources SVN1468
("feature freeze"). If you are using a different version you may need
to adapt the settings (Makefile, target-library).
- Since I have had some problems with the gdb included in CS G++ 2008q1-66
I have replaced it with the gdb that comes with DevkitARM r26
(see below). This file is included (arm-eabi-gdb.exe).
******************************************************************************
Demo-Session with FAT-LFN and SPI-DMA ena
评论5