[acme-dev] SF.net SVN: acme-dev:[76] acme-boot

  • From: claudyus@xxxxxxxxxxxxxxxxxxxxx
  • To: acme-dev@xxxxxxxxxxxxx
  • Date: Mon, 11 Oct 2010 14:07:12 +0000

Revision: 76
          http://acme-dev.svn.sourceforge.net/acme-dev/?rev=76&view=rev
Author:   claudyus
Date:     2010-10-11 14:07:11 +0000 (Mon, 11 Oct 2010)

Log Message:
-----------
Add acme bootloader

Added Paths:
-----------
    acme-boot/
    acme-boot/AcmeBootProject/
    acme-boot/AcmeBootProject/BootAT26.c
    acme-boot/AcmeBootProject/BootAT45.c
    acme-boot/AcmeBootProject/BootEeprom.c
    acme-boot/AcmeBootProject/BootNand.c
    acme-boot/AcmeBootProject/BootNor.c
    acme-boot/AcmeBootProject/BootSdcard.c
    acme-boot/AcmeBootProject/Makefile
    acme-boot/AcmeBootProject/README.txt
    acme-boot/AcmeBootProject/boot.h
    acme-boot/AcmeBootProject/doit.sh
    acme-boot/AcmeBootProject/fatfs_config.h
    acme-boot/AcmeBootProject/macaddress.txt
    acme-boot/AcmeBootProject/main.c
    acme-boot/AcmeBootProject/main.h
    acme-boot/AcmeBootProject/make_all
    acme-boot/AcmeBootProject/pizzica.py
    acme-boot/AcmeBootProject/runit.sh
    acme-boot/AcmeBootProject/xmodem.py
    acme-boot/at91lib/
    acme-boot/at91lib/boards/
    acme-boot/at91lib/boards/NetusG20/
    acme-boot/at91lib/boards/NetusG20/at91sam9g20/
    acme-boot/at91lib/boards/NetusG20/at91sam9g20/AT91SAM9G20.h
    acme-boot/at91lib/boards/NetusG20/at91sam9g20/chip.h
    acme-boot/at91lib/boards/NetusG20/at91sam9g20/chip.mak
    acme-boot/at91lib/boards/NetusG20/at91sam9g20/norflash.lds
    acme-boot/at91lib/boards/NetusG20/at91sam9g20/sram.lds
    acme-boot/at91lib/boards/NetusG20/board.h
    acme-boot/at91lib/boards/NetusG20/board_cstartup.S
    acme-boot/at91lib/boards/NetusG20/board_lowlevel.c
    acme-boot/at91lib/boards/NetusG20/board_memories.c
    acme-boot/at91lib/boards/NetusG20/board_memories.h
    acme-boot/at91lib/drivers/
    acme-boot/at91lib/drivers/async/
    acme-boot/at91lib/drivers/async/async.c
    acme-boot/at91lib/drivers/async/async.h
    acme-boot/at91lib/drivers/dmad/
    acme-boot/at91lib/drivers/dmad/dmad.c
    acme-boot/at91lib/drivers/dmad/dmad.h
    acme-boot/at91lib/drivers/macb/
    acme-boot/at91lib/drivers/macb/macb.c
    acme-boot/at91lib/drivers/macb/macb.h
    acme-boot/at91lib/drivers/macb/mii.h
    acme-boot/at91lib/drivers/twi/
    acme-boot/at91lib/drivers/twi/twid.c
    acme-boot/at91lib/drivers/twi/twid.h
    acme-boot/at91lib/memories/
    acme-boot/at91lib/memories/MEDSdcard.c
    acme-boot/at91lib/memories/MEDSdcard.h
    acme-boot/at91lib/memories/Media.c
    acme-boot/at91lib/memories/Media.h
    acme-boot/at91lib/memories/nandflash/
    acme-boot/at91lib/memories/nandflash/EccNandFlash.c
    acme-boot/at91lib/memories/nandflash/EccNandFlash.h
    acme-boot/at91lib/memories/nandflash/NandCommon.h
    acme-boot/at91lib/memories/nandflash/NandFlashModel.c
    acme-boot/at91lib/memories/nandflash/NandFlashModel.h
    acme-boot/at91lib/memories/nandflash/NandFlashModelList.c
    acme-boot/at91lib/memories/nandflash/NandFlashModelList.h
    acme-boot/at91lib/memories/nandflash/NandSpareScheme.c
    acme-boot/at91lib/memories/nandflash/NandSpareScheme.h
    acme-boot/at91lib/memories/nandflash/RawNandFlash.c
    acme-boot/at91lib/memories/nandflash/RawNandFlash.h
    acme-boot/at91lib/memories/nandflash/SkipBlockNandFlash.c
    acme-boot/at91lib/memories/nandflash/SkipBlockNandFlash.h
    acme-boot/at91lib/memories/norflash/
    acme-boot/at91lib/memories/norflash/NorFlashAmd.c
    acme-boot/at91lib/memories/norflash/NorFlashAmd.h
    acme-boot/at91lib/memories/norflash/NorFlashApi.c
    acme-boot/at91lib/memories/norflash/NorFlashApi.h
    acme-boot/at91lib/memories/norflash/NorFlashCFI.c
    acme-boot/at91lib/memories/norflash/NorFlashCFI.h
    acme-boot/at91lib/memories/norflash/NorFlashCommon.c
    acme-boot/at91lib/memories/norflash/NorFlashCommon.h
    acme-boot/at91lib/memories/norflash/NorFlashIntel.c
    acme-boot/at91lib/memories/norflash/NorFlashIntel.h
    acme-boot/at91lib/memories/sdmmc/
    acme-boot/at91lib/memories/sdmmc/sdmmc_mci.c
    acme-boot/at91lib/memories/sdmmc/sdmmc_mci.h
    acme-boot/at91lib/memories/spi-flash/
    acme-boot/at91lib/memories/spi-flash/at26.c
    acme-boot/at91lib/memories/spi-flash/at26.h
    acme-boot/at91lib/memories/spi-flash/at26d.c
    acme-boot/at91lib/memories/spi-flash/at26d.h
    acme-boot/at91lib/memories/spi-flash/at45.c
    acme-boot/at91lib/memories/spi-flash/at45.h
    acme-boot/at91lib/memories/spi-flash/at45d.c
    acme-boot/at91lib/memories/spi-flash/at45d.h
    acme-boot/at91lib/memories/spi-flash/spid.c
    acme-boot/at91lib/memories/spi-flash/spid.h
    acme-boot/at91lib/peripherals/
    acme-boot/at91lib/peripherals/cp15/
    acme-boot/at91lib/peripherals/cp15/cp15.c
    acme-boot/at91lib/peripherals/cp15/cp15.h
    acme-boot/at91lib/peripherals/cp15/cp15_asm_gcc.S
    acme-boot/at91lib/peripherals/dbgu/
    acme-boot/at91lib/peripherals/dbgu/dbgu.c
    acme-boot/at91lib/peripherals/dbgu/dbgu.h
    acme-boot/at91lib/peripherals/dma/
    acme-boot/at91lib/peripherals/dma/dma.c
    acme-boot/at91lib/peripherals/dma/dma.h
    acme-boot/at91lib/peripherals/irq/
    acme-boot/at91lib/peripherals/irq/aic.c
    acme-boot/at91lib/peripherals/irq/irq.h
    acme-boot/at91lib/peripherals/mci/
    acme-boot/at91lib/peripherals/mci/mci.c
    acme-boot/at91lib/peripherals/mci/mci.h
    acme-boot/at91lib/peripherals/mci/mci_hs.c
    acme-boot/at91lib/peripherals/mci/mci_hs.h
    acme-boot/at91lib/peripherals/pio/
    acme-boot/at91lib/peripherals/pio/pio.c
    acme-boot/at91lib/peripherals/pio/pio.h
    acme-boot/at91lib/peripherals/pmc/
    acme-boot/at91lib/peripherals/pmc/pmc.c
    acme-boot/at91lib/peripherals/pmc/pmc.h
    acme-boot/at91lib/peripherals/rstc/
    acme-boot/at91lib/peripherals/rstc/rstc.c
    acme-boot/at91lib/peripherals/rstc/rstc.h
    acme-boot/at91lib/peripherals/twi/
    acme-boot/at91lib/peripherals/twi/twi.c
    acme-boot/at91lib/peripherals/twi/twi.h
    acme-boot/at91lib/utility/
    acme-boot/at91lib/utility/assert.h
    acme-boot/at91lib/utility/hamming.c
    acme-boot/at91lib/utility/hamming.h
    acme-boot/at91lib/utility/math.c
    acme-boot/at91lib/utility/math.h
    acme-boot/at91lib/utility/stdio.c
    acme-boot/at91lib/utility/string.c
    acme-boot/at91lib/utility/trace.c
    acme-boot/at91lib/utility/trace.h
    acme-boot/external_libs/
    acme-boot/external_libs/fat/
    acme-boot/external_libs/fat/fatfs/
    acme-boot/external_libs/fat/fatfs/src/
    acme-boot/external_libs/fat/fatfs/src/diskio.c
    acme-boot/external_libs/fat/fatfs/src/diskio.h
    acme-boot/external_libs/fat/fatfs/src/ff.c
    acme-boot/external_libs/fat/fatfs/src/ff.h
    acme-boot/external_libs/fat/fatfs/src/integer.h

Added: acme-boot/AcmeBootProject/BootAT26.c
===================================================================
--- acme-boot/AcmeBootProject/BootAT26.c                                (rev 0)
+++ acme-boot/AcmeBootProject/BootAT26.c        2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,163 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+#ifdef ORIGIN_serialflash
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <board_memories.h>
+#include <pio/pio.h>
+#include <utility/assert.h>
+#include <utility/trace.h>
+#include <spi-flash/at26d.h>
+#include "main.h"
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+
+// Transfer return codes
+#define BOOT_AT26_SUCCESS   0 /// All requested transfer are successfull
+#define BOOT_AT26_NO_DEVICE 1 /// No AT26 devices has been detected
+
+#define SPCK        1000000 /// SPI clock frequency, in Hz.
+
+//------------------------------------------------------------------------------
+//         Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//         Internal variables
+//------------------------------------------------------------------------------
+Spid spid; /// SPI driver instance.
+At26 at26; /// AT26 driver instance.
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initialize AT46 driver. Depending on the AT91SAM device, SLOTA or SLOTB are
+/// defined according to the board.h definitions.
+//------------------------------------------------------------------------------
+void AT26Init()
+{
+    // Initialize the SPI transfer, spid and at26 parameters
+    // As there is no serial flash on AT91-EK boards, they are usually 
connected through
+    // an extension board which has the SD card format. That's why AT26 pin 
definition
+    // is used.
+#if defined(AT26_SLOT_A)
+    const Pin pins[]  = {BOARD_AT26_A_SPI_PINS, BOARD_AT26_A_NPCS_PIN};
+    PIO_Configure(pins, PIO_LISTSIZE(pins));
+    SPID_Configure(&spid, BOARD_AT26_A_SPI_BASE, BOARD_AT26_A_SPI_ID);
+    AT26_Configure(&at26, &spid, BOARD_AT26_A_NPCS);
+#elif defined(AT26_SLOT_B)
+    const Pin pins[]  = {BOARD_AT26_B_SPI_PINS, BOARD_AT26_B_NPCS_PIN};
+    PIO_Configure(pins, PIO_LISTSIZE(pins));
+    SPID_Configure(&spid, BOARD_AT26_B_SPI_BASE, BOARD_AT26_B_SPI_ID);
+    AT26_Configure(&at26, &spid, BOARD_AT26_B_NPCS);
+#else
+#error "-F- AT26_SLOT_A or  AT26_SLOT_B must be defined"
+#endif //BOARD_AT26_A
+}
+
+//------------------------------------------------------------------------------
+//         Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initialize serial flash devices and transfer one or sevral modules from
+/// serial flash to the target memory (SRAM/SDRAM).
+/// \param pTd    Pointer to transfer descriptor array.
+/// \param nbTd  Number of transfer descriptors.
+/// \return 0 if successfull.
+//------------------------------------------------------------------------------
+int BOOT_AT26_CopyBin(const Tdesc *pTd, unsigned char nbTd)
+{
+    unsigned int jedecId;
+    unsigned int sizeToCopy; // remaining bytes number to copy
+    unsigned int pageSize;  // Dataflash page size
+    unsigned int packetSize; // Dataflash read size
+    unsigned int memoryOffset; // Dataflash read offset
+    unsigned char *pDest; // Dest pointer for copy
+
+    // Initialize the SPI transfer, spid and at26 parameters
+    AT26Init();
+    TRACE_INFO("Init AT26 Serialflash\n\r");
+
+    // Read the JEDEC ID of the device to identify it
+    jedecId = AT26D_ReadJedecId(&at26);
+
+    if (AT26_FindDevice(&at26, jedecId) == 0) {
+        TRACE_ERROR("Device not detected or unknown\n\r");
+        return BOOT_AT26_NO_DEVICE;
+    }
+
+    pageSize = AT26_PageSize(&at26);
+
+    if (at26.pDesc->name)
+        TRACE_INFO("SerialFlash detected : %s\n\r", at26.pDesc->name);
+
+    // Foreach module transfer data from AT26 to memory
+    while (nbTd--) {
+
+        TRACE_INFO("Copy \"%s\" (%d bytes) from SerialFlash 0x%08x to 
0x%08x\n\r", 
+                      pTd->strDescr, 
+                      pTd->size,
+                      pTd->offset,
+                      (unsigned int) pTd->dest
+                      );
+
+        pDest = (unsigned char*)pTd->dest;
+        sizeToCopy = pTd->size;
+        memoryOffset = pTd->offset;
+
+        while (sizeToCopy > 0) {
+
+            // Write packet after packets
+            packetSize = (sizeToCopy < pageSize) ? sizeToCopy : pageSize;
+
+            // Read the page and copy
+            AT26D_Read(&at26, pDest, packetSize, memoryOffset);
+
+            // Update pointer
+            memoryOffset += packetSize;
+            pDest += packetSize;
+            sizeToCopy -= packetSize;
+        }
+
+        ++pTd;
+    }
+    return BOOT_AT26_SUCCESS;
+}
+
+#endif // FROM_serialflash
+

Added: acme-boot/AcmeBootProject/BootAT45.c
===================================================================
--- acme-boot/AcmeBootProject/BootAT45.c                                (rev 0)
+++ acme-boot/AcmeBootProject/BootAT45.c        2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,179 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifdef ORIGIN_dataflash
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <board_memories.h>
+#include <pio/pio.h>
+#include <utility/assert.h>
+#include <utility/trace.h>
+#include <utility/math.h>
+#include <spi-flash/at45d.h>
+
+#include "main.h"
+
+//------------------------------------------------------------------------------
+//         Definitions
+//------------------------------------------------------------------------------
+
+// Transfer return codes
+#define BOOT_AT45_SUCCESS   0 /// All requested transfer are successfull
+#define BOOT_AT45_NO_DEVICE 1 /// No AT45 devices has been detected
+
+#define SPCK        20000000 /// SPI clock frequency, in Hz.
+
+//------------------------------------------------------------------------------
+//         Internal variables
+//------------------------------------------------------------------------------
+
+Spid spid; /// SPI driver instance.
+At45 at45; /// AT45 driver instance.
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/// Initialize AT45 driver. Depending on the AT91SAM device, SLOTA or SLOTB are
+/// defined according to the board.h definitions.
+//------------------------------------------------------------------------------
+static void AT45Init(void)
+{
+#if defined(AT45_SLOT_A)
+    const Pin pins[]  = {BOARD_AT45_A_SPI_PINS, BOARD_AT45_A_NPCS_PIN};
+    PIO_Configure(pins, PIO_LISTSIZE(pins));
+    SPID_Configure(&spid, BOARD_AT45_A_SPI_BASE, BOARD_AT45_A_SPI_ID);
+    SPID_ConfigureCS(&spid, BOARD_AT45_A_NPCS, AT45_CSR(BOARD_MCK, SPCK));
+    AT45_Configure(&at45, &spid, BOARD_AT45_A_NPCS);
+#elif defined(AT45_SLOT_B)
+    const Pin pins[]  = {BOARD_AT45_B_SPI_PINS, BOARD_AT45_B_NPCS_PIN};
+    PIO_Configure(pins, PIO_LISTSIZE(pins));
+    SPID_Configure(&spid, BOARD_AT45_B_SPI_BASE, BOARD_AT45_B_SPI_ID);
+    SPID_ConfigureCS(&spid, BOARD_AT45_B_NPCS, AT45_CSR(BOARD_MCK, SPCK));
+    AT45_Configure(&at45, &spid, BOARD_AT45_B_NPCS);
+#else
+    #error "-F- AT45_SLOT_A or  AT45_SLOT_B must be defined"
+#endif //AT45_slot_A    
+}
+
+//------------------------------------------------------------------------------
+//         Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Erase the first page of the dataflash memory. This function allows to
+/// auto erase the at91bootstrap in order to restart from SAM-BA boot atfter
+/// the next power-up sequence.
+//------------------------------------------------------------------------------
+void BOOT_AT45_EraseBoot(void)
+{
+    // Initialize the SPI transfer, spid and at45 parameters
+    AT45Init();
+    TRACE_INFO("Init AT45 Dataflash\n\r");
+    
+    // Erase the first page of the dataflash
+    AT45D_Erase(&at45, 0);
+}
+
+//------------------------------------------------------------------------------
+/// Initialize AT45 devices and transfer one or sevral modules from At45 to the
+/// target memory (SRAM/SDRAM).
+/// \param pTd    Pointer to transfer descriptor array.
+/// \param nbTd  Number of transfer descriptors.
+/// \return 0 if successfull.
+//------------------------------------------------------------------------------
+int BOOT_AT45_CopyBin(const Tdesc *pTd, unsigned char nbTd)
+{
+    const At45Desc *pDesc; // Pointer to the connected AT45 parameter
+    unsigned int pageSize;  // Dataflash page size
+    unsigned int packetSize; // Dataflash read size
+    unsigned int memoryOffset; // Dataflash read offset
+    unsigned char *pDest; // Dest pointer for copy
+    unsigned int sizeToCopy; // remaining bytes number to copy
+    unsigned char status = 0;
+
+    // Initialize the SPI transfer, spid and at45 parameters
+    AT45Init();
+    TRACE_INFO("Init AT45 Dataflash\n\r");
+
+    // Configure pins
+    status = AT45D_GetStatus(&at45);
+
+    // Detect AT45 device connected
+    pDesc = AT45_FindDevice(&at45, status);
+
+    if (pDesc == (const At45Desc *) 0) {
+        TRACE_ERROR("Device not detected or unknown\n\r");
+        return BOOT_AT45_NO_DEVICE;
+    }
+
+    pageSize = AT45_PageSize(&at45);
+
+    if (at45.pDesc->name)
+        TRACE_INFO("Dataflash detected : %s\n\r", at45.pDesc->name);
+
+    // Foreach module transfer data from AT45 to memory
+    while (nbTd--) {
+
+        TRACE_INFO("Copy \"%s\" (%d bytes) from DataFlash 0x%08x to 
0x%08x\n\r", 
+                      pTd->strDescr, 
+                      pTd->size, 
+                      pTd->offset, 
+                      (unsigned int) pTd->dest
+                      );    
+
+        pDest = (unsigned char*)pTd->dest;
+        sizeToCopy = pTd->size;
+        memoryOffset = pTd->offset;
+
+        while (sizeToCopy > 0) {
+
+            // Write packet after packets
+            packetSize = (sizeToCopy < pageSize) ? sizeToCopy : pageSize;
+
+            // Read the page and copy
+            AT45D_Read(&at45, pDest, packetSize, memoryOffset);
+
+            // Update pointer
+            memoryOffset += packetSize;
+            pDest += packetSize;
+            sizeToCopy -= packetSize;
+        }
+
+        ++pTd;
+    }
+
+    return BOOT_AT45_SUCCESS;
+}
+
+#endif // dataflash

Added: acme-boot/AcmeBootProject/BootEeprom.c
===================================================================
--- acme-boot/AcmeBootProject/BootEeprom.c                              (rev 0)
+++ acme-boot/AcmeBootProject/BootEeprom.c      2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,249 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifdef ORIGIN_eeprom
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <board_memories.h>
+#include <pio/pio.h>
+#include <irq/irq.h>
+#include <dbgu/dbgu.h>
+#include <twi/twi.h>
+#include <utility/math.h>
+#include <utility/assert.h>
+#include <utility/trace.h>
+#include <drivers/twi/twid.h>
+#include <drivers/async/async.h>
+
+#include <stdio.h>
+#include <string.h>
+#include "main.h"
+
+//------------------------------------------------------------------------------
+//         Definitions
+//------------------------------------------------------------------------------
+
+// Transfer return codes
+#define BOOT_EEPROM_SUCCESS            0 /// All requested transfer are 
successfull
+#define BOOT_EEPROM_ERROR_GP           1 /// 
+
+
+//------------------------------------------------------------------------------
+//         Internal variables
+//------------------------------------------------------------------------------
+
+/// TWI clock frequency in Hz.
+#define TWCK            400000
+
+/// Slave address of AT24C chips.
+#define AT24C_ADDRESS   0x50
+
+#if   defined(AT24C01)
+#define NAME_REF       "AT24C01"
+#define TOTAL_SIZE     128
+#define PAGE_SIZE      8
+#elif defined(AT24C02)
+#define NAME_REF       "AT24C02"
+#define TOTAL_SIZE     256
+#define PAGE_SIZE      8
+#elif defined(AT24C04)
+#define NAME_REF       "AT24C04"
+#define TOTAL_SIZE     512
+#define PAGE_SIZE      16
+#elif defined(AT24C08)
+#define NAME_REF       "AT24C08"
+#define TOTAL_SIZE     1024
+#define PAGE_SIZE      16
+#elif defined(AT24C16)
+#define NAME_REF       "AT24C16"
+#define TOTAL_SIZE     2048
+#define PAGE_SIZE      16
+#elif defined(AT24C32)
+#define NAME_REF       "AT24C32"
+#define TOTAL_SIZE     4096
+#define PAGE_SIZE      32
+#elif defined(AT24C64)
+#define NAME_REF       "AT24C64"
+#define TOTAL_SIZE     8192
+#define PAGE_SIZE      32
+#elif defined(AT24C128)
+#define NAME_REF       "AT24C128"
+#define TOTAL_SIZE     16384
+#define PAGE_SIZE      64
+#elif defined(AT24C256)
+#define NAME_REF       "AT24C256"
+#define TOTAL_SIZE     32768
+#define PAGE_SIZE      64
+#elif defined(AT24C512)
+#define NAME_REF       "AT24C512"
+#define TOTAL_SIZE     65536
+#define PAGE_SIZE      128
+#elif defined(AT24C1024)
+#define NAME_REF       "AT24C1024"
+#define TOTAL_SIZE     131072
+#define PAGE_SIZE      256
+#else
+#error serial eeprom not defined
+#endif
+
+/// TWI driver instance.
+static Twid twid;
+
+/// Pio pins to configure.
+#if !defined(PINS_TWI0)
+static const Pin pins[] = {PINS_TWI};
+#define BOARD_BASE_TWI      AT91C_BASE_TWI
+#define BOARD_ID_TWI        AT91C_ID_TWI
+#else
+static const Pin pins[] = {PINS_TWI0};
+#define BOARD_BASE_TWI      AT91C_BASE_TWI0
+#define BOARD_ID_TWI        AT91C_ID_TWI0
+#endif
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// TWI interrupt handler. Forwards the interrupt to the TWI driver handler.
+//------------------------------------------------------------------------------
+void ISR_Twi(void)
+{
+    TWID_Handler(&twid);
+}
+
+//------------------------------------------------------------------------------
+/// Initialize EEPROM device. 
+//------------------------------------------------------------------------------
+static void EepromInit()
+{
+    TRACE_INFO("Init TWI EEPROM %s\n\r", NAME_REF);
+
+    // Configure Pins
+    PIO_Configure(pins, PIO_LISTSIZE(pins));
+
+    // Configure TWI
+    AT91C_BASE_PMC->PMC_PCER = 1 << BOARD_ID_TWI;
+    TWI_ConfigureMaster(BOARD_BASE_TWI, TWCK, BOARD_MCK);
+    TWID_Initialize(&twid, BOARD_BASE_TWI);
+    IRQ_ConfigureIT(BOARD_ID_TWI, 0, ISR_Twi);
+    IRQ_EnableIT(BOARD_ID_TWI);
+
+}
+
+//------------------------------------------------------------------------------
+/// Dummy callback, to test asynchronous transfer modes.
+//------------------------------------------------------------------------------
+void TestCallback()
+{
+    //printf("-I- Callback fired !\n\r");
+}
+
+//------------------------------------------------------------------------------
+//         Exported functions
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/// Erase the first page of the EEPROM memory. This function allows to
+/// auto erase the at91bootstrap in order to restart from SAM-BA boot atfter
+/// the next power-up sequence.
+//------------------------------------------------------------------------------
+void BOOT_EEPROM_EraseBoot()
+{
+    // blank
+}
+
+//------------------------------------------------------------------------------
+/// Initialize EEPROM devices and transfer one or sevral modules from EEPROM 
to the
+/// target memory (SRAM/SDRAM).
+/// \param pTd    Pointer to transfer descriptor array.
+/// \param nbTd   Number of transfer descriptors.
+//------------------------------------------------------------------------------
+int BOOT_EEPROM_CopyBin(const Tdesc *pTd, unsigned char nbTd)
+{ 
+    unsigned char *pDest; // Dest pointer for copy
+    unsigned int sizeToCopy; // remaining bytes number to copy
+    unsigned int memoryOffset; // Dataflash read offset
+    unsigned int packetSize; // Dataflash read size
+    Async async;
+    
+    // Initialize EEPROM
+    EepromInit();
+
+    // Check word alignment
+    if (pTd->offset % PAGE_SIZE) {
+    
+        TRACE_ERROR("Offset not word aligned\n\r");
+        return BOOT_EEPROM_ERROR_GP;
+    }
+    
+    // Transfert data from EEPROM to External RAM
+    
//-------------------------------------------------------------------------   
+    memset(&async, 0, sizeof(async));
+    async.callback = (void *) TestCallback;
+
+    // Foreach module transfer data from EEPROM to memory
+    while (nbTd--) {
+       
+        TRACE_INFO("Copy \"%s\" (%d bytes) from EEPROM 0x%08x to 0x%08x\n\r", 
+                      pTd->strDescr, 
+                      pTd->size, 
+                      pTd->offset, 
+                      pTd->dest
+                      );    
+
+        pDest = (unsigned char*)pTd->dest;
+        sizeToCopy = pTd->size;
+        memoryOffset = pTd->offset;
+
+        while (sizeToCopy > 0) {
+
+            // Write packet after packets
+            packetSize = (sizeToCopy < PAGE_SIZE) ? sizeToCopy : PAGE_SIZE;
+
+            // Read the page and copy
+            TWID_Read(&twid, AT24C_ADDRESS, memoryOffset, 2, pDest, PAGE_SIZE, 
&async);
+            while (!ASYNC_IsFinished(&async));
+
+            // Update pointer
+            memoryOffset += packetSize;
+            pDest += packetSize;
+            sizeToCopy -= packetSize;
+        }
+
+        ++pTd;
+    }
+
+    return BOOT_EEPROM_SUCCESS;
+}
+
+#endif //eeprom

Added: acme-boot/AcmeBootProject/BootNand.c
===================================================================
--- acme-boot/AcmeBootProject/BootNand.c                                (rev 0)
+++ acme-boot/AcmeBootProject/BootNand.c        2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,299 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifdef ORIGIN_nandflash
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <board_memories.h>
+#include <pio/pio.h>
+#include <utility/assert.h>
+#include <utility/trace.h>
+#include "../at91lib/memories/nandflash/SkipBlockNandFlash.h"
+#include "../at91lib/memories/nandflash/RawNandFlash.h"
+
+#include <string.h>
+#include "main.h"
+
+//------------------------------------------------------------------------------
+//         Definitions
+//------------------------------------------------------------------------------
+
+// Transfer return codes
+#define BOOT_NAND_SUCCESS            0 /// All requested transfer are 
successfull
+#define BOOT_NAND_ERROR_NO_DEVICE    1 /// No nand devices has been detected
+#define BOOT_NAND_ERROR_GP           2
+
+//------------------------------------------------------------------------------
+//         Internal variables
+//------------------------------------------------------------------------------
+
+/// Nandflash memory size.
+static unsigned int memSize;
+/// Size of one block in the nandflash, in bytes.
+static unsigned int blockSize;
+/// Number of blocks in nandflash.
+static unsigned short numBlocks;
+/// Size of one page in the nandflash, in bytes.
+static unsigned short pageSize;
+/// Number of page per block
+static unsigned short numPagesPerBlock;
+// Nandflash bus width
+static unsigned char nfBusWidth = 16;
+
+#ifdef PINS_NANDFLASH
+
+/// Pins used to access to nandflash.
+static const Pin pPinsNf[] = {PINS_NANDFLASH};
+/// Nandflash device structure.
+static struct SkipBlockNandFlash skipBlockNf; 
+/// Address for transferring command bytes to the nandflash.
+static unsigned int cmdBytesAddr = BOARD_NF_COMMAND_ADDR;
+/// Address for transferring address bytes to the nandflash.
+static unsigned int addrBytesAddr = BOARD_NF_ADDRESS_ADDR;
+/// Address for transferring data bytes to the nandflash.
+static unsigned int dataBytesAddr = BOARD_NF_DATA_ADDR;
+/// Nandflash chip enable pin.
+static const Pin nfCePin = BOARD_NF_CE_PIN;
+/// Nandflash ready/busy pin.
+static const Pin nfRbPin = BOARD_NF_RB_PIN;
+
+#else
+
+/// Pins used to access to nandflash.
+static const Pin pPinsNf[] = {{0, 0, 0, 0, 0}}; 
+/// Nandflash device structure.
+static struct SkipBlockNandFlash skipBlockNf; 
+/// Address for transferring command bytes to the nandflash.
+static unsigned int cmdBytesAddr = 0;
+/// Address for transferring address bytes to the nandflash.
+static unsigned int addrBytesAddr = 0;
+/// Address for transferring data bytes to the nandflash.
+static unsigned int dataBytesAddr = 0;
+/// Nandflash chip enable pin.
+static const Pin nfCePin = {0, 0, 0, 0, 0};
+/// Nandflash ready/busy pin.
+static const Pin nfRbPin = {0, 0, 0, 0, 0};
+
+#endif
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/// Initialize NAND flash driver. 
+//------------------------------------------------------------------------------
+static void NandInit()
+{
+    //-------------------------------------------------------------------------
+    TRACE_INFO("Init NAND Flash\n\r");        
+    
+    // Configure SMC for Nandflash accesses (done each time because of old ROM 
codes)
+    BOARD_ConfigureNandFlash(nfBusWidth);
+    PIO_Configure(pPinsNf, PIO_LISTSIZE(pPinsNf));
+    
+    //memset(&skipBlockNf, 0, sizeof(skipBlockNf));          
+ 
+    if (SkipBlockNandFlash_Initialize(&skipBlockNf,
+                                              0,
+                                              cmdBytesAddr,
+                                              addrBytesAddr,
+                                              dataBytesAddr,
+                                              nfCePin,
+                                              nfRbPin)) {
+    
+        TRACE_ERROR("Device Unknown\n\r");
+    } 
+    
+    // Check the data bus width of the NandFlash
+    nfBusWidth = NandFlashModel_GetDataBusWidth((struct NandFlashModel 
*)&skipBlockNf);
+    
+    // Reconfigure bus width
+    BOARD_ConfigureNandFlash(nfBusWidth);
+
+    TRACE_INFO("Nandflash driver initialized\n\r"); 
+
+    // Get device parameters
+    memSize = NandFlashModel_GetDeviceSizeInBytes(&skipBlockNf.ecc.raw.model);
+    blockSize = NandFlashModel_GetBlockSizeInBytes(&skipBlockNf.ecc.raw.model);
+    numBlocks = 
NandFlashModel_GetDeviceSizeInBlocks(&skipBlockNf.ecc.raw.model);
+    pageSize = NandFlashModel_GetPageDataSize(&skipBlockNf.ecc.raw.model);
+    numPagesPerBlock = 
NandFlashModel_GetBlockSizeInPages(&skipBlockNf.ecc.raw.model);
+    
+    TRACE_INFO("Size of the whole device in bytes : 0x%x \n\r",memSize);
+    TRACE_INFO("Size in bytes of one single block of a device : 0x%x 
\n\r",blockSize);
+    TRACE_INFO("Number of blocks in the entire device : 0x%x \n\r",numBlocks);
+    TRACE_INFO("Size of the data area of a page in bytes : 0x%x 
\n\r",pageSize);
+    TRACE_INFO("Number of pages in the entire device : 0x%x 
\n\r",numPagesPerBlock);
+    TRACE_INFO("Bus width : %d \n\r",nfBusWidth);
+}
+
+//------------------------------------------------------------------------------
+//         Exported functions
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/// Erase the first page of the dataflash memory. This function allows to
+/// auto erase the at91bootstrap in order to restart from SAM-BA boot atfter
+/// the next power-up sequence.
+//------------------------------------------------------------------------------
+void BOOT_NAND_EraseBoot()
+{
+    // Initialize the Nand parameters
+    NandInit();
+    
+    // Erase the first page of the nandflash
+    #if !defined (OP_BOOTSTRAP_on)
+    SkipBlockNandFlash_EraseBlock(&(skipBlockNf), 0, SCRUB_ERASE);
+    #else
+    RawNandFlash_EraseBlock(&(skipBlockNf.ecc.raw), 0);
+    #endif
+}
+
+
+//------------------------------------------------------------------------------
+/// Initialize NAND devices and transfer one or sevral modules from Nand to the
+/// target memory (SRAM/SDRAM).
+/// \param pTd    Pointer to transfer descriptor array.
+/// \param nbTd   Number of transfer descriptors.
+//------------------------------------------------------------------------------
+int BOOT_NAND_CopyBin(const Tdesc *pTd, unsigned char nbTd)
+{ 
+    unsigned short block;
+    unsigned short page;
+    unsigned short offset;    
+   
+    unsigned char *ptr;
+    unsigned byteRead;    
+    
+    // Errors returned by SkipNandFlash functions
+    unsigned char error = 0;    
+/*...........................................................................*/
 
+    
+    // Initialize Nand
+    NandInit();
+    // Transfert data from Nand to External RAM
+    
//-------------------------------------------------------------------------   
+
+    // Foreach module transfer data from Nand to memory
+    while (nbTd--) {
+       
+        TRACE_INFO("Copy \"%s\" (%d bytes) from NAND 0x%08x to 0x%08x\n\r", 
+                      pTd->strDescr, 
+                      pTd->size, 
+                      pTd->offset, 
+                      pTd->dest
+                      );    
+    
+        #if !defined(OP_BOOTSTRAP_on)
+        // Check word alignment
+        if (pTd->offset % 4) {
+    
+              TRACE_ERROR("Offset not word aligned\n\r");
+              return BOOT_NAND_ERROR_GP;
+        }
+        #endif
+    
+        #if !defined(OP_BOOTSTRAP_on)
+        // Retrieve page and block addresses        
+        if (NandFlashModel_TranslateAccess(&(skipBlockNf.ecc.raw.model),
+                                           pTd->offset,
+                                           pTd->size,
+                                           &block,
+                                           &page,
+                                           &offset)) {
+              TRACE_ERROR("TranslateAccess Error\n\r");
+              return BOOT_NAND_ERROR_GP;
+        }
+        #else
+        NandFlashModel_TranslateAccess(&(skipBlockNf.ecc.raw.model),
+                                           pTd->offset,
+                                           pTd->size,
+                                           &block,
+                                           &page,
+                                           &offset);
+        #endif
+    
+        #if !defined(OP_BOOTSTRAP_on)
+        if (page || offset) {
+    
+              TRACE_ERROR("Address is not a block start\n\r");
+              return BOOT_NAND_ERROR_GP;
+        }    
+        #endif
+
+        ptr = (unsigned char*)pTd->dest;
+        byteRead = pTd->size;
+        
+        while(block < numBlocks)
+        {
+              for(page = 0; page < numPagesPerBlock; page++) {
+
+                  do{
+                      error = SkipBlockNandFlash_ReadPage(&skipBlockNf, block, 
page, ptr, 0);
+                      if (error == NandCommon_ERROR_BADBLOCK)
+                          block++;
+                      else
+                          break;
+                  }while(block < numBlocks && page == 0);
+
+                  #if !defined(OP_BOOTSTRAP_on)
+                  if (error) {
+                      TRACE_ERROR("SkipBlockNandFlash_ReadBlock: Cannot read 
page %d of block %d.\n\r", page, block);
+                      return BOOT_NAND_ERROR_GP;
+                  }
+                  #endif
+                  ptr += pageSize;
+                
+                  if(byteRead <= pageSize) {
+                      byteRead = 0;
+                      break;
+                  }
+                  else {
+                      byteRead -= pageSize;
+                  }
+              }
+          
+              if(byteRead == 0) {
+                break;
+            }          
+            else {
+                block++;        
+            }
+        }
+        
+        ++pTd;
+    }
+
+    return BOOT_NAND_SUCCESS;
+}
+
+#endif //nandflash

Added: acme-boot/AcmeBootProject/BootNor.c
===================================================================
--- acme-boot/AcmeBootProject/BootNor.c                         (rev 0)
+++ acme-boot/AcmeBootProject/BootNor.c 2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,158 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifdef ORIGIN_norflash
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <board_memories.h>
+#include <pio/pio.h>
+#include <utility/assert.h>
+#include <utility/trace.h>
+#include <memories/norflash/NorFlashCFI.h>
+#include <memories/norflash/NorFlashApi.h>
+
+
+#include <string.h>
+#include "main.h"
+
+//------------------------------------------------------------------------------
+//         Definitions
+//------------------------------------------------------------------------------
+
+// Transfer return codes
+#define BOOT_NOR_SUCCESS            0 /// All requested transfer are 
successfull
+#define BOOT_NOR_ERROR_NO_DEVICE    1 /// No nor devices has been detected
+
+#if defined(at91sam9263)
+#define AT91_NORFLASH_BASE    AT91C_EBI0_CS0
+#else
+#define AT91_NORFLASH_BASE    AT91C_EBI_CS0
+#endif
+
+
+//------------------------------------------------------------------------------
+//         Internal variables
+//------------------------------------------------------------------------------
+
+/// Pins to configure for the application
+#ifdef PINS_NORFLASH
+static const Pin pPins[] = {
+   PINS_NORFLASH
+};
+#endif
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/// Initialize Nor flash driver. 
+//------------------------------------------------------------------------------
+static unsigned int NorInit(struct NorFlash* pNorFlash)
+{
+    //-------------------------------------------------------------------------
+    TRACE_INFO("Init Nor Flash\n\r");        
+    
+    // Configure pins for Norflash
+#ifdef PINS_NORFLASH
+    PIO_Configure(pPins, PIO_LISTSIZE(pPins));
+#endif
+
+    pNorFlash->norFlashInfo.baseAddress = BOARD_NORFLASH_ADDR;
+    pNorFlash->norFlashInfo.deviceChipWidth = BOARD_NORFLASH_DFT_BUS_SIZE;
+
+    if(BOARD_NORFLASH_DFT_BUS_SIZE == 8) {
+        TRACE_INFO("8-bit Nor Flash\n\r");
+        pNorFlash->norFlashInfo.deviceChipWidth = FLASH_CHIP_WIDTH_8BITS;
+    }
+    else if(BOARD_NORFLASH_DFT_BUS_SIZE == 16) {
+        TRACE_INFO("16-bit Nor Flash\n\r");
+        pNorFlash->norFlashInfo.deviceChipWidth = FLASH_CHIP_WIDTH_16BITS;
+    }
+    else if(BOARD_NORFLASH_DFT_BUS_SIZE == 32) {
+        TRACE_INFO("32-bit Nor Flash\n\r");
+        pNorFlash->norFlashInfo.deviceChipWidth = FLASH_CHIP_WIDTH_32BITS;
+    }
+
+    return 0;
+
+}
+
+//------------------------------------------------------------------------------
+//         Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initialize NOR devices and transfer one or several modules from Nor to the
+/// target memory (SRAM/SDRAM).
+/// \param pTd    Pointer to transfer descriptor array.
+/// \param nbTd  Number of transfer descriptors.
+//------------------------------------------------------------------------------
+int BOOT_NOR_CopyBin(const Tdesc *pTd, unsigned char nbTd)
+{
+    unsigned int status;
+    struct NorFlash norFlash;
+    // Initialize Nor
+    
//-------------------------------------------------------------------------   
+    status = NorInit(&norFlash);
+    if(status) {
+        TRACE_ERROR("-E- Error during norflash initialization. \r\n");
+        return status;
+    }
+    
+    // Transfert data from Nor to External RAM
+    
//-------------------------------------------------------------------------   
+
+    //blockNumber = NorFlash_GetDeviceNumOfBlocks(&(norFlash.norFlashInfo));
+    while (nbTd--) {    
+
+        //blockOffset = 0;
+        TRACE_INFO("Copy \"%s\" (%d bytes) from NOR 0x%08x to 0x%08x\n\r", 
+                      pTd->strDescr, 
+                      pTd->size, 
+                      pTd->offset, 
+                      pTd->dest
+                      );        
+
+        NORFLASH_ReadData(&norFlash, pTd->offset, (unsigned char*)pTd->dest, 
pTd->size);
+        
+        ++pTd;
+    }
+
+    return BOOT_NOR_SUCCESS;
+}
+
+#endif // ORIGIN_norflash

Added: acme-boot/AcmeBootProject/BootSdcard.c
===================================================================
--- acme-boot/AcmeBootProject/BootSdcard.c                              (rev 0)
+++ acme-boot/AcmeBootProject/BootSdcard.c      2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,205 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+ 
+#ifdef ORIGIN_sdcard
+
+//------------------------------------------------------------------------------
+//         Headers
+//------------------------------------------------------------------------------
+#include <stdio.h>
+#include <string.h>
+#include <board.h>
+#include <utility/trace.h>
+#include <utility/assert.h>
+#include <utility/math.h>
+#include <memories/MEDSdcard.h>
+
+#include "fatfs_config.h"
+
+#include "main.h"
+
+//------------------------------------------------------------------------------
+//         Definitions
+//------------------------------------------------------------------------------
+
+// Transfer return codes
+#define BOOT_SDCARD_SUCCESS       0 /// All requested transfer are successfull
+#define BOOT_SDCARD_ERROR         1 
+
+//------------------------------------------------------------------------------
+//         Local variables
+//------------------------------------------------------------------------------
+/// File system instance.
+static FATFS fs; 
+/// File object instance.
+static FIL fileObject;
+
+//------------------------------------------------------------------------------
+//         Local constants
+//------------------------------------------------------------------------------
+
+/// Maximum number of LUNs which can be defined.
+#define MAX_LUNS        1
+
+/// Available medias.
+Media medias[MAX_LUNS];
+
+#define ID_DRV DRV_MMC
+
+//------------------------------------------------------------------------------
+//         Internal functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//         Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initialize SDcard and transfer one or sevral modules from SDCard to the
+/// target memory (SRAM/SDRAM).
+/// \param pTd    Pointer to transfer descriptor array.
+/// \param nbTd  Number of transfer descriptors.
+/// \return 0 if successfull.
+//------------------------------------------------------------------------------
+
+FRESULT res;
+    
+int BOOT_SDcard_CopyFile(const Tdesc *pTd, unsigned char nbTd)
+{
+    unsigned int ByteToRead;
+    unsigned int ByteRead;
+  
+    // Init Disk
+    #if defined(BOARD_SD_BOOT_MCISLOT)
+    MEDSdcard_Initialize(&medias[ID_DRV], BOARD_SD_BOOT_MCISLOT);
+    #else
+    printf("-E- SD boot slot is not defined.\n\r");
+    return 1;
+    #endif
+
+    memset(&fs, 0, sizeof(FATFS));  // Clear file system object    
+    res = f_mount(0, &fs);
+    if( res != FR_OK ) {
+        printf("f_mount pb: 0x%X\n\r", res);
+        return 0;
+    }
+
+    while (nbTd--) {
+
+        printf("Copy \"%s\" from SdCard to 0x%08x\n\r", 
+                      pTd->fileName,  
+                      pTd->dest       
+                      );
+        printf("Copy %s -> %d\n\r",__FILE__,__LINE__);
+    
+        res = f_open(&fileObject, pTd->fileName , FA_OPEN_EXISTING|FA_READ);
+        if( res != FR_OK ) {
+            printf("f_open read pb: 0x%X\n\r", res);
+            return 0;
+        }
+    
+        ByteToRead = pTd->size;
+        
+        // check the file size
+        if(ByteToRead < fileObject.fsize) {
+            TRACE_ERROR("File size %d <-> Max allowed size %d\n\r", 
(int)fileObject.fsize, (int)ByteToRead); 
+            return 0;           
+        }
+        
+        res = f_read(&fileObject, (void*)(pTd->dest), ByteToRead, &ByteRead);
+        if(res != FR_OK) {
+            TRACE_ERROR("f_read pb: 0x%X\n\r", res);
+            return 0;
+        }    
+    
+        res = f_close(&fileObject);
+        if( res != FR_OK ) {
+            TRACE_ERROR("f_close pb: 0x%X\n\r", res);
+            return 0;
+        }
+        
+        ++pTd;
+    }
+    
+    return 0;
+}
+
+
+int Acme_SDcard_CopyFile(char *filename,unsigned long destination,unsigned 
long size)
+{
+    unsigned int ByteToRead;
+    unsigned int ByteRead;
+  
+    // Init Disk
+    if (MEDSdcard_Initialize(&medias[ID_DRV], BOARD_SD_BOOT_MCISLOT)!=1) {
+        printf("microSD not found\n\r");
+        return 1;
+    }
+       SD_DisplaySdStatus(&medias[ID_DRV]);
+    
+       memset(&fs, 0, sizeof(FATFS));  // Clear file system object    
+    res = f_mount(0, &fs);
+    if( res != FR_OK ) {
+        printf("f_mount pb: 0x%X\n\r", res);
+        return 1;
+    }
+
+    printf("Load %s from microSD\n\r",filename);
+    res = f_open(&fileObject, filename, FA_OPEN_EXISTING|FA_READ);
+    if( res != FR_OK ) {
+        printf("File not found\n\r");
+        return 1;
+    }
+
+    if (size>0) {
+        ByteToRead = size;
+    } else {
+        ByteToRead = fileObject.fsize;
+    }
+    
+    printf("File lenght: %d\n\r", (int)fileObject.fsize); 
+    printf("Byte to read: %d\n\r", (int)ByteToRead); 
+    
+    res = f_read(&fileObject, (void*)(destination), ByteToRead, &ByteRead);
+    if(res != FR_OK) {
+        printf("f_read pb: 0x%X\n\r", res);
+        return 1;
+    }    
+
+    res = f_close(&fileObject);
+    if( res != FR_OK ) {
+        printf("f_close pb: 0x%X\n\r", res);
+        return 1;
+    }
+    
+    return 0;
+}
+
+
+#endif // ORIGIN_sdcard

Added: acme-boot/AcmeBootProject/Makefile
===================================================================
--- acme-boot/AcmeBootProject/Makefile                          (rev 0)
+++ acme-boot/AcmeBootProject/Makefile  2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,364 @@
+# ----------------------------------------------------------------------------
+#         ATMEL Microcontroller Software Support
+# ----------------------------------------------------------------------------
+# Copyright (c) 2008, Atmel Corporation
+#
+# 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 disclaimer below.
+# 
+# Atmel's name may not be used to endorse or promote products derived from
+# this software without specific prior written permission. 
+# 
+# DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+# DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+# ---------------------------------------------------------------------------- 
+
+#     Makefile for compiling at91bootstrap-project
+
+#-------------------------------------------------------------------------------
+#        User-modifiable options
+#-------------------------------------------------------------------------------
+
+# Optimization level, put in comment for debugging
+ifeq ($(OP_BOOTSTRAP), on)
+OPTIMIZATION = -march=armv5t -Os
+else
+    ifeq ($(OP_BOOTSTRAP_MCI), on)
+    OPTIMIZATION = -march=armv5t -Os
+    else
+    OPTIMIZATION = -O2
+    endif
+endif
+
+# AT91 library directory
+AT91LIB = ../at91lib
+EXTLIBS = ../external_libs
+
+# Output directories
+BIN = bin
+OBJ = obj
+
+#-------------------------------------------------------------------------------
+#        Command lines parameters managment
+#-------------------------------------------------------------------------------
+
+# CHIP        (M)  chip name
+# BOARD       (M)  board name
+# ORIGIN      (M)  memory where the module will be read
+# DESTINATION (M)  memory where the module will be copied
+# BIN_SIZE    (M)  module size to read and copy
+# FROM_ADDR   (M*) source memory address offset where the module will be read
+# FILE_NAME   (M*) name of the file to copy (for FAT formated memory)
+# DEST_ADDR   (M)  destination memory address where the module will be copied
+# VDDMEMSEL   (O)  EBI power supply selection (1.8V, 3.3V)
+# STR_DESCR   (O)  Module description (optional user data)
+# BOOTNAME    (O)  Bootstrap binary name
+# TRACE_LEVEL (O)  if not defined, none trace
+# ORIGIN_REF  (M*) Needed for EEPROM boot
+
+# Notes :
+# (M) mandatory parameter
+# (O) optional parameter
+# (M*) mandatory parameter depending on the boot (SDCard boot or other)
+
+# Default output file basename (if not defined by user)
+#-------------------------------------------------------------------------------
+BOOTNAME_BASE = boot-$(BOARD)-$(ORIGIN)2$(DESTINATION)
+
+ifndef    FPGAINIT
+FPGAINIT = 0
+endif
+
+ifeq ($(FPGAINIT),1)
+BOOTNAME = $(BOOTNAME_BASE)-fpga
+else
+BOOTNAME = $(BOOTNAME_BASE)
+endif
+
+# if there is only one binary to copy, its size, its source address and its 
+# destination address can be given as makefile argument
+#-------------------------------------------------------------------------------
+ifdef BIN_SIZE
+CFLAGS += -DBIN_SIZE=$(BIN_SIZE)
+endif
+
+ifdef FROM_ADDR
+CFLAGS += -DFROM_ADDR=$(FROM_ADDR)
+endif
+
+ifdef DEST_ADDR
+CFLAGS += -DDEST_ADDR=$(DEST_ADDR)
+endif
+
+ifdef FILE_NAME
+CFLAGS += -DFILE_NAME=$(FILE_NAME)
+endif
+
+ifdef STR_DESCR
+CFLAGS += -DSTR_DESCR=$(STR_DESCR)
+endif
+
+# EBI power supply : EBI1V8 = 1.8V or EBI3V3 = 3.3V
+#-------------------------------------------------------------------------------
+ifeq ($(VDDMEMSEL),EBI1V8)
+CFLAGS += -DVDDMEMSEL_EBI1V8
+endif
+
+ifeq ($(VDDMEMSEL),EBI3V3)
+CFLAGS += -DVDDMEMSEL_EBI3V3
+endif
+
+#ifdef VDDMEMSEL
+#CFLAGS += -DVDDMEMSEL=$(VDDMEMSEL)
+#endif
+
+# Compile with chip specific features
+#-------------------------------------------------------------------------------
+include $(AT91LIB)/boards/$(BOARD)/$(CHIP)/chip.mak
+
+# Special init for CAP9
+#-------------------------------------------------------------------------------
+ifeq ($(CHIP),at91cap9)
+ifeq ($(FPGAINIT),1)
+CFLAGS += -DFPGAINIT
+endif
+endif
+
+# PATH_BOOT_H allows to use a special boot.h for specific project with several 
+# modules to copy. If not defined, the normal boot.h of the at91bootstrap 
+# project is used
+#-------------------------------------------------------------------------------
+ifndef PATH_BOOT_H
+PATH_BOOT_H = .
+endif
+
+# PATH_OUTPUT_DIR allows to choose the directory where the BIN directory 
+# will be created
+#-------------------------------------------------------------------------------
+ifdef PATH_OUTPUT_DIR
+BIN = $(PATH_OUTPUT_DIR)/bin
+OBJ = $(PATH_OUTPUT_DIR)/obj
+endif
+
+#-------------------------------------------------------------------------------
+#        Tools
+#-------------------------------------------------------------------------------
+
+# Tool suffix when cross-compiling
+#CROSS_COMPILE= arm-none-eabi-
+CROSS_COMPILE?= 
/home/tanzilli/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-
+
+# Compilation tools
+CC = $(CROSS_COMPILE)gcc
+SIZE = $(CROSS_COMPILE)size
+STRIP = $(CROSS_COMPILE)strip
+OBJCOPY = $(CROSS_COMPILE)objcopy
+
+CFLAGS += -Wall -mlong-calls -ffunction-sections
+CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) 
+CFLAGS += -D$(CHIP) 
+CFLAGS += -DBOARD=$(BOARD)
+CFLAGS += -DORIGIN_$(ORIGIN)
+CFLAGS += -DDESTINATION_$(DESTINATION)
+CFLAGS += -DTRACE_LEVEL=$(TRACE_LEVEL)
+
+ASFLAGS = -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D__ASSEMBLY__
+LDFLAGS = -g $(OPTIMIZATION) -nostartfiles 
-Wl,--gc-sections,-Map=$(OUTPUT).map,--cref
+
+#-------------------------------------------------------------------------------
+#        Files
+#-------------------------------------------------------------------------------
+
+# Includes paths
+INCLUDES += -I$(PATH_BOOT_H)
+INCLUDES += -I$(AT91LIB)
+INCLUDES += -I$(AT91LIB)/boards/$(BOARD)
+INCLUDES += -I$(AT91LIB)/peripherals
+INCLUDES += -I$(AT91LIB)/components
+INCLUDES += -I$(AT91LIB)/memories
+INCLUDES += -I$(EXTLIBS)/fat/fatfs/src
+INCLUDES += -I$(AT91LIB)/drivers
+
+# Sources path
+VPATH += $(AT91LIB)/utility
+VPATH += $(AT91LIB)/peripherals
+VPATH += $(AT91LIB)/peripherals/pio
+VPATH += $(AT91LIB)/memories/spi-flash
+VPATH += $(AT91LIB)/peripherals/irq
+VPATH += $(AT91LIB)/peripherals/dbgu
+#VPATH += $(AT91LIB)/peripherals/emac
+VPATH += $(AT91LIB)/boards/$(BOARD)
+VPATH += $(AT91LIB)/boards/$(BOARD)/$(CHIP)
+VPATH += $(AT91LIB)/peripherals/cp15
+#VPATH += $(AT91LIB)/drivers/macb
+
+# Objects built from C source files
+C_OBJECTS += main.o
+C_OBJECTS += pio.o
+#C_OBJECTS += emac.o
+#C_OBJECTS += macb.o
+C_OBJECTS += aic.o
+C_OBJECTS += board_memories.o
+C_OBJECTS += board_lowlevel.o
+C_OBJECTS += stdio.o
+C_OBJECTS += string.o
+C_OBJECTS += dbgu.o
+C_OBJECTS += trace.o
+
+ifeq ($(CHIP),at91cap9)
+ifeq ($(FPGAINIT),1)
+C_OBJECTS += board_fpga_init.o
+endif
+endif
+
+# Objects built from Assembly source files
+ASM_OBJECTS += board_cstartup.o
+ASM_OBJECTS += cp15_asm_gcc.o
+
+#-------------------------------------------------------------------------------
+# MEMORY SOURCE : SDcard
+#-------------------------------------------------------------------------------
+ifeq ($(ORIGIN),sdcard)
+
+INCLUDES += -I.
+
+VPATH += $(AT91LIB)/memories
+VPATH += $(AT91LIB)/utility
+VPATH += $(AT91LIB)/memories/sdmmc
+VPATH += $(AT91LIB)/peripherals/mci
+VPATH += $(EXTLIBS)/fat/fatfs/src
+VPATH += $(AT91LIB)/peripherals/dma
+VPATH += $(AT91LIB)/drivers/dmad
+
+C_OBJECTS += BootSdcard.o
+C_OBJECTS += diskio.o
+C_OBJECTS += ff.o
+C_OBJECTS += Media.o
+C_OBJECTS += MEDSdcard.o
+C_OBJECTS += spid.o
+C_OBJECTS += at26.o
+C_OBJECTS += math.o
+C_OBJECTS += at45.o
+ifeq ($(CHIP_IP_MCI), MCI_DMA)
+C_OBJECTS += dmad.o
+C_OBJECTS += dma.o
+C_OBJECTS += mci_hs.o
+else
+C_OBJECTS += mci.o
+endif
+C_OBJECTS += sdmmc_mci.o
+
+MEMORIES = sram
+
+endif
+
+#-------------------------------------------------------------------------------
+# Optimization bootstrap : at91sam9260
+#-------------------------------------------------------------------------------
+ifeq ($(OP_BOOTSTRAP), on)
+C_INTERWORK_FLAGS += $(CFLAGS)
+C_INTERWORK_FLAGS += -mthumb-interwork
+CFLAGS += -mthumb
+CFLAGS += -DOP_BOOTSTRAP_$(OP_BOOTSTRAP)
+endif
+
+ifeq ($(OP_BOOTSTRAP), on)
+C_INTERWORK_OBJECTS = cp15.o
+else
+    ifeq ($(OP_BOOTSTRAP_MCI), on)
+    C_INTERWORK_OBJECTS = cp15.o
+    else
+    C_OBJECTS += cp15.o
+    endif
+endif
+
+#-------------------------------------------------------------------------------
+# Optimize bootstrap mci re-init : at91sam9263 at91sam9g20
+#-------------------------------------------------------------------------------
+ifeq ($(OP_BOOTSTRAP_MCI), on)
+CFLAGS += -DOP_BOOTSTRAP_MCI_$(OP_BOOTSTRAP_MCI)
+endif
+
+ifeq ($(OP_BOOTSTRAP_MCI), on)
+C_INTERWORK_FLAGS += $(CFLAGS)
+C_INTERWORK_FLAGS += -mthumb-interwork
+CFLAGS += -mthumb
+CFLAGS += -DOP_BOOTSTRAP_MCI_$(OP_BOOTSTRAP_MCI)
+endif
+
+#===============================================================================
+
+OUTPUT      := $(BIN)/$(BOOTNAME)
+
+#-------------------------------------------------------------------------------
+#              Rules
+#-------------------------------------------------------------------------------
+# Append OBJ and BIN directories to filenames
+C_OBJECTS   := $(addprefix $(OBJ)/, $(C_OBJECTS))
+ASM_OBJECTS := $(addprefix $(OBJ)/, $(ASM_OBJECTS))
+C_INTERWORK_OBJECTS   := $(addprefix $(OBJ)/, $(C_INTERWORK_OBJECTS))
+
+all: $(BIN) $(OBJ) $(MEMORIES)
+
+$(BIN) $(OBJ):
+       @mkdir $@
+
+$(MEMORIES): $(ASM_OBJECTS) $(C_OBJECTS) $(C_INTERWORK_OBJECTS)
+       echo 
"**************************************************************************"
+       echo "***** Boot from $(ORIGIN) to $(DESTINATION) (execute in 
$(MEMORIES)) *****"
+       echo 
"--------------------------------------------------------------------------"
+       $(CC) $(LDFLAGS) -T"$(AT91LIB)/boards/$(BOARD)/$(CHIP)/$(MEMORIES).lds" 
-o $(OUTPUT).elf $^
+       $(OBJCOPY) -O binary $(OUTPUT).elf $(OUTPUT).bin
+       $(SIZE) $(ASM_OBJECTS) $(C_OBJECTS) $(OUTPUT).elf
+
+$(C_OBJECTS): $(OBJ)/%.o: %.c Makefile
+       $(CC) $(CFLAGS) -c -o $@ $<
+
+$(C_INTERWORK_OBJECTS): $(OBJ)/%.o: %.c Makefile
+       $(CC) $(C_INTERWORK_FLAGS) -c -o $@ $<
+
+$(ASM_OBJECTS): $(OBJ)/%.o: %.S Makefile
+       $(CC) $(ASFLAGS) -c -o $@ $<
+       
+debug_sram: sram
+       perl ../resources/gdb/debug.pl $(OUTPUT).elf    
+
+clean:
+       -rm -f $(OBJ)/*.o $(BIN)/*.elf $(BIN)/*.map
+
+help:
+       @echo  "Below the description of the command line parameters :"
+       @echo  "   - CHIP        Chip name (Ex: at91cap9)"
+       @echo  "   - BOARD       board name (Ex: at91cap9-dk)"
+       @echo  "   - ORIGIN      Source memory where the module to copy will 
read"
+       @echo  "                 (dataflash / serialflash / sdcard / nandflash 
/ norflash)"
+       @echo  "   - DESTINATION Destination memory where the module will be 
copied"
+       @echo  "                 (sdram / ddram)"
+       @echo  "   - BIN_SIZE    Binary size to copy"
+       @echo  "   - FROM_ADDR   Address in source memory where the module will 
be read"
+       @echo  "                 (not used for SDCard boot)"
+       @echo  "   - FILE_NAME   file name to copy (only for SDcard boot)"
+       @echo  "   - DEST_ADDR   Address in destination memory where the module 
will be copied"
+       @echo  "                 and where the bootstrap program will do a jump"
+       @echo  "   - STR_DESCR   Description of the module to copy"
+       @echo  "   - BOOTNAME    File name of the output binary. By default the 
output name is"
+       @echo  "                 boot-$(BOARD)-$(ORIGIN)2$(DESTINATION).bin"
+       @echo  "   - TRACE_LEVEL Determine the trace level. If not present, 
none trace."
+       @echo ""
+       @echo " Note 1: The use of FROM_ADDR and FILE_NAME is exclusive."
+       @echo ""
+       @echo " Note 2: the last 3 parameters are optional. All the other are 
mandatory."
+

Added: acme-boot/AcmeBootProject/README.txt
===================================================================
--- acme-boot/AcmeBootProject/README.txt                                (rev 0)
+++ acme-boot/AcmeBootProject/README.txt        2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,21 @@
+To compile this file use:
+
+Set the PATH to your GNU cross compiler in the Makefile
+CROSS_COMPILE= /home/tanzilli/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-
+
+cd ./AcmeBoot
+make CHIP=at91sam9g20 BOARD=NetusG20 ORIGIN=sdcard DESTINATION=sdram 
OP_BOOTSTRAP_MCI=on TRACE_LEVEL=1 clean all
+
+Program the Netus G20 dataflash with ./bin/boot-NetusG20-sdcard2sdram.bin 
binary file
+
+Same in the first FAT16 partition the uimage uncompressed kernel file. 
+Please note that you have to se the boot option in the kerlen config because 
the foxg20-bin file in not used anymore.
+
+The default MAC address is hardware coded in the main.c:
+/// The MAC address used for demo
+static unsigned char MacAddress[6] = {0x00, 0x45, 0x56, 0x78, 0x9a, 0xac};
+
+More info on AcmeBoot is available on 
http://foxg20.acmesystems.it/doku.php?id=dev:acmeboot
+
+
+

Added: acme-boot/AcmeBootProject/boot.h
===================================================================
--- acme-boot/AcmeBootProject/boot.h                            (rev 0)
+++ acme-boot/AcmeBootProject/boot.h    2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,131 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+#define FILE_NAME ""
+#define STR_DESCR ""
+#define BIN_SIZE 0
+#define DEST_ADDR 0
+
+
+#ifndef BOOT_H_
+#define BOOT_H_
+
+//-----------------------------------------------------------------------------
+//         Headers
+//-----------------------------------------------------------------------------
+
+#include "main.h"
+
+//-----------------------------------------------------------------------------
+//         Macros
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+//         Defines
+//-----------------------------------------------------------------------------
+/// MACH_TYPE this define is used by u-boot to launch Linux
+#if defined(at91sam9260ek)
+#define MACH_TYPE       0x44B       /* AT91SAM9260-EK */
+#elif defined(at91sam9261ek)
+#define MACH_TYPE       0x350       /* AT91SAM9261-EK */
+#elif defined(at91sam9263ek)
+#define MACH_TYPE       0x4B2       /* AT91SAM9263-EK */
+#elif defined(at91sam9g20ek)
+#define MACH_TYPE       0x658       /* AT91SAM9G20-EK */
+#elif defined(at91sam9rlek)
+#define MACH_TYPE       1326        /* AT91SAM9RL-EK */
+#elif defined(at91sam9xeek)
+#define MACH_TYPE       0x44B       /* AT91SAM9XE-EK same id as 
AT91SAM9260-EK*/
+#elif defined(at91sam9m10ek)
+#define MACH_TYPE       1830        /* AT91SAM9M10 */
+#elif defined(at91cap9)
+#define MACH_TYPE 0x05A2            /* AT91CAP9 */
+#elif defined(at91sam9g45ek)
+#define MACH_TYPE       2212        /* AT91SAM9G45-EK */
+#elif defined(at91sam9g10ek)
+#define MACH_TYPE       2159        /* AT91SAM9G10-EK */
+
+#endif
+
+/// BOOT_RECOVERY is enabled by default for the at91sam9269
+/// If BOOT_RECOVERY option is enabled, then nvm first sector can be erased
+/// by pushing a button after power up sequence. After the following power-up
+/// sequence, the ROM code will execute until SAM-BA boot.
+#if defined(at91sam9260ek)
+#define BOOT_RECOVERY 1
+#endif
+
+//-----------------------------------------------------------------------------
+//         Variables
+//-----------------------------------------------------------------------------
+
+#if defined(ORIGIN_sdcard)
+// memory source address is not used for SDcard boot (only STR_FILE)
+#define FROM_ADDR 0
+#else
+// file name is not used for non formated memory boot (only FROM_ADDR)
+#define FILE_NAME ""
+#endif
+
+#if !defined(STR_DESCR)
+#define STR_DESCR ""
+#endif
+
+#if defined(FROM_ADDR) &&  \
+    defined(FILE_NAME)  &&  \
+    defined(DEST_ADDR) &&  \
+    defined(BIN_SIZE)  &&  \
+    defined(STR_DESCR)    
+    
+const Tdesc tabDesc[] = {
+    {FROM_ADDR, FILE_NAME, DEST_ADDR, BIN_SIZE, STR_DESCR}    
+};
+
+#else
+
+    #if !defined(FROM_ADDR)
+    #error FROM_ADDR not defined !
+    #endif
+    #if !defined(FILE_NAME)
+    #error FILE_NAME not defined !
+    #endif
+    #if !defined(DEST_ADDR)
+    #error DEST_ADDR not defined !
+    #endif
+    #if !defined(BIN_SIZE)
+    #error BIN_SIZE not defined !
+    #endif
+    #if !defined(STR_DESCR) 
+    #error STR_DESCR not defined !
+    #endif
+
+#endif /* Default arguments */
+
+#endif /*BOOT_H_*/
+

Added: acme-boot/AcmeBootProject/doit.sh
===================================================================
--- acme-boot/AcmeBootProject/doit.sh                           (rev 0)
+++ acme-boot/AcmeBootProject/doit.sh   2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+make CHIP=at91sam9g20 BOARD=NetusG20 ORIGIN=sdcard DESTINATION=sdram 
OP_BOOTSTRAP_MCI=on TRACE_LEVEL=1 clean all
+


Property changes on: acme-boot/AcmeBootProject/doit.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: acme-boot/AcmeBootProject/fatfs_config.h
===================================================================
--- acme-boot/AcmeBootProject/fatfs_config.h                            (rev 0)
+++ acme-boot/AcmeBootProject/fatfs_config.h    2010-10-11 14:07:11 UTC (rev 76)
@@ -0,0 +1,765 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * 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 disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifndef FATFS_CONFIG_H
+#define FATFS_CONFIG_H
+#include "integer.h"
+
+//------------------------------------------------------------------------------
+//      Other definitions
+//------------------------------------------------------------------------------
+
+/*-----------------------------------------------------------------------*/
+/* Correspondence between drive number and physical drive                */
+/* Note that Tiny-FatFs supports only single drive and always            */
+/* accesses drive number 0.                                              */
+
+#define DRV_MMC          0
+#define DRV_NAND         1
+#define DRV_SDRAM        2
+#define DRV_ATA          3
+#define DRV_USB          4
+
+
+#define SECTOR_SIZE_DEFAULT 512
+#define SECTOR_SIZE_SDRAM  512
+#define SECTOR_SIZE_SDCARD 512
+
+/*---------------------------------------------------------------------------/
+/ FatFs Configuration Options
+/
+/ CAUTION! Do not forget to make clean the project after any changes to
+/ the configuration options.
+/
+/----------------------------------------------------------------------------*/
+
+
+#define _WORD_ACCESS   0
+/* The _WORD_ACCESS option defines which access method is used to the word
+/  data in the FAT structure.
+/
+/   0: Byte-by-byte access. Always compatible with all platforms.
+/   1: Word access. Do not choose this unless following condition is met.
+/
+/  When the byte order on the memory is big-endian or address miss-aligned
+/  word access results incorrect behavior, the _WORD_ACCESS must be set to 0.
+/  If it is not the case, the value can also be set to 1 to improve the
+/  performance and code efficiency. */
+
+
+#define _FS_MINIMIZE   3
+/* The _FS_MINIMIZE option defines minimization level to remove some functions.
+/
+/  0: Full function.
+/   1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
+/      are removed.
+/  2: f_opendir and f_readdir are removed in addition to level 1.
+/  3: f_lseek is removed in addition to level 2. */
+
+#define        _FS_TINY        1
+/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
+/  object instead of the sector buffer in the individual file object for file
+/  data transfer. This reduces memory consumption 512 bytes each file object. 
*/
+
+#if _FS_TINY != 1
+#define _FS_READONLY   0
+/* Setting _FS_READONLY to 1 defines read only configuration. This removes
+/  writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
+/  f_truncate and useless f_getfree. */
+#else
+#define _FS_READONLY   1
+/* Setting _FS_READONLY to 1 defines read only configuration. This removes
+/  writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
+/  f_truncate and useless f_getfree. */
+#endif
+
+#define        _USE_STRFUNC    0
+/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
+
+
+#define        _USE_MKFS       1
+/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
+
+
+#define        _USE_FORWARD    0
+/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. 
*/
+
+
+#define _CODE_PAGE     932
+/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
+/
+/   932  - Japanese Shift-JIS (DBCS, OEM, Windows)
+/   936  - Simplified Chinese GBK (DBCS, OEM, Windows)
+/   949  - Korean (DBCS, OEM, Windows)
+/   950  - Traditional Chinese Big5 (DBCS, OEM, Windows)
+/   1250 - Central Europe (Windows)
+/   1251 - Cyrillic (Windows)
+/   1252 - Latin 1 (Windows)
+/   1253 - Greek (Windows)
+/   1254 - Turkish (Windows)
+/   1255 - Hebrew (Windows)
+/   1256 - Arabic (Windows)
+/   1257 - Baltic (Windows)
+/   1258 - Vietnam (OEM, Windows)
+/   437  - U.S. (OEM)
+/   720  - Arabic (OEM)
+/   737  - Greek (OEM)
+/   775  - Baltic (OEM)
+/   850  - Multilingual Latin 1 (OEM)
+/   858  - Multilingual Latin 1 + Euro (OEM)
+/   852  - Latin 2 (OEM)
+/   855  - Cyrillic (OEM)
+/   866  - Russian (OEM)
+/   857  - Turkish (OEM)
+/   862  - Hebrew (OEM)
+/   874  - Thai (OEM, Windows)
+/      1 - ASCII (Valid for only non LFN cfg.)
+*/
+
+
+#define        _USE_LFN        0
+#define        _MAX_LFN        255             /* Maximum LFN length to handle 
(max:255) */
+/* The _USE_LFN option switches the LFN support.
+/
+/   0: Disable LFN.
+/   1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
+/   2: Enable LFN with dynamic working buffer on the caller's STACK.
+/
+/  The working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable LFN,
+/  a Unicode handling functions ff_convert() and ff_wtoupper() must be added
+/  to the project. */
+
+
+#define _FS_RPATH      0
+/* When _FS_RPATH is set to 1, relative path feature is enabled and f_chdir,
+/  f_chdrive function are available.
+/  Note that output of the f_readdir fnction is affected by this option. */
+
+
+#define _FS_REENTRANT  0
+#define _TIMEOUT               1000    /* Timeout period in unit of time ticks 
of the OS */
+#define        _SYNC_t                 HANDLE  /* Type of sync object used on 
the OS. e.g. HANDLE, OS_EVENT*, ID and etc.. */
+/* To make the FatFs module re-entrant, set _FS_REENTRANT to 1 and add user
+/  provided synchronization handlers, ff_req_grant, ff_rel_grant, 
ff_del_syncobj
+/  and ff_cre_syncobj function to the project. */
+
+
+#define _DRIVES                1
+/* Number of volumes (logical drives) to be used. */
+
+
+#define        _MAX_SS         512
+/* Maximum sector size to be handled. (512/1024/2048/4096) */
+/* Usually set 512 for memory card and hard disk but 1024 for floppy disk, 
2048 for MO disk */
+/* When _MAX_SS > 512, GET_SECTOR_SIZE must be implememted to disk_ioctl() */
+
+
+#define        _MULTI_PARTITION        0
+/* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
+/ drive number and can mount only first primaly partition. When it is set to 1,
+/ each volume is tied to the partitions listed in Drives[]. */
+
+
+
+/* End of configuration options. Do not change followings without care.     */
+/*--------------------------------------------------------------------------*/
+
+
+
+/* DBCS code ranges and SBCS extend char conversion table */
+
+#if _CODE_PAGE == 932  /* Japanese Shift-JIS */
+#define _DF1S  0x81    /* DBC 1st byte range 1 start */
+#define _DF1E  0x9F    /* DBC 1st byte range 1 end */
+#define _DF2S  0xE0    /* DBC 1st byte range 2 start */
+#define _DF2E  0xFC    /* DBC 1st byte range 2 end */
+#define _DS1S  0x40    /* DBC 2nd byte range 1 start */
+#define _DS1E  0x7E    /* DBC 2nd byte range 1 end */
+#define _DS2S  0x80    /* DBC 2nd byte range 2 start */
+#define _DS2E  0xFC    /* DBC 2nd byte range 2 end */
+
+#elif _CODE_PAGE == 936        /* Simplified Chinese GBK */
+#define _DF1S  0x81
+#define _DF1E  0xFE
+#define _DS1S  0x40
+#define _DS1E  0x7E
+#define _DS2S  0x80
+#define _DS2E  0xFE
+
+#elif _CODE_PAGE == 949        /* Korean */
+#define _DF1S  0x81
+#define _DF1E  0xFE
+#define _DS1S  0x41
+#define _DS1E  0x5A
+#define _DS2S  0x61
+#define _DS2E  0x7A
+#define _DS3S  0x81
+#define _DS3E  0xFE
+
+#elif _CODE_PAGE == 950        /* Traditional Chinese Big5 */
+#define _DF1S  0x81
+#define _DF1E  0xFE
+#define _DS1S  0x40
+#define _DS1E  0x7E
+#define _DS2S  0xA1
+#define _DS2E  0xFE
+
+#elif _CODE_PAGE == 437        /* U.S. (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 720        /* Arabic (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 737        /* Greek (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
 \
+                               
0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 775        /* Baltic (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 850        /* Multilingual Latin 1 (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 852        /* Latin 2 (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F,
 \
+                               
0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF}
+
+#elif _CODE_PAGE == 855        /* Cyrillic (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F,
 \
+                               
0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF,
 \
+                               
0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 857        /* Turkish (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E,
 \
+                               
0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 858        /* Multilingual Latin 1 + Euro (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 862        /* Hebrew (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 866        /* Russian (OEM) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 874        /* Thai (OEM, Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F,
 \
+                               
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}
+
+#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F,
 \
+                               
0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF}
+
+#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F,
 \
+                               
0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
+
+#elif _CODE_PAGE == 1253 /* Greek (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA,
 \
+                               
0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF}
+
+#elif _CODE_PAGE == 1254 /* Turkish (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}
+
+#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 1256 /* Arabic (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF}
+
+#elif _CODE_PAGE == 1257 /* Baltic (Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}
+
+#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */
+#define _DF1S  0
+#define _EXCVT 
{0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F,
 \
+                               
0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
 \
+                               
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F}
+
+#elif _CODE_PAGE == 1  /* ASCII (for only non-LFN cfg) */
+#define _DF1S  0
+
+#else
+#error Unknown code page
+
+#endif
+
+
+
+/* Character code support macros */
+
+#define IsUpper(c)     (((c)>='A')&&((c)<='Z'))
+#define IsLower(c)     (((c)>='a')&&((c)<='z'))
+#define IsDigit(c)     (((c)>='0')&&((c)<='9'))
+
+#if _DF1S      /* DBCS configuration */
+
+#if _DF2S      /* Two 1st byte areas */
+#define IsDBCS1(c)     (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || 
((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
+#else          /* One 1st byte area */
+#define IsDBCS1(c)     ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
+#endif
+
+#if _DS3S      /* Three 2nd byte areas */
+#define IsDBCS2(c)     (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || 
((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) 
<= _DS3E))
+#else          /* Two 2nd byte areas */
+#define IsDBCS2(c)     (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || 
((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
+#endif
+
+#else          /* SBCS configuration */
+
+#define IsDBCS1(c)     0
+#define IsDBCS2(c)     0
+
+#endif /* _DF1S */
+
+
+
+/* Definitions corresponds to multi partition */
+
+#if _MULTI_PARTITION           /* Multiple partition configuration */
+
+typedef struct _PARTITION {
+       BYTE pd;        /* Physical drive# */
+       BYTE pt;        /* Partition # (0-3) */
+} PARTITION;
+
+extern
+const PARTITION Drives[];                      /* Logical drive# to physical 
location conversion table */
+#define LD2PD(drv) (Drives[drv].pd)    /* Get physical drive# */
+#define LD2PT(drv) (Drives[drv].pt)    /* Get partition# */
+
+#else                                          /* Single partition 
configuration */
+
+#define LD2PD(drv) (drv)       /* Physical drive# is equal to the logical 
drive# */
+#define LD2PT(drv) 0           /* Always mounts the 1st partition */
+
+#endif
+
+
+
+/* Definitions corresponds to multiple sector size */
+
+#if _MAX_SS == 512
+#define        SS(fs)  512U
+
+#elif _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096
+#define        SS(fs)  ((fs)->s_size)
+
+#else
+#error Sector size must be 512, 1024, 2048 or 4096.
+
+#endif
+
+
+
+/* Type of file name on FatFs API */
+
+#if _LFN_UNICODE && _USE_LFN
+typedef WCHAR XCHAR;   /* Unicode */
+#else
+typedef char XCHAR;            /* SBCS, DBCS */
+#endif
+
+
+
+/* File system object structure */
+
+typedef struct _FATFS_ {
+       BYTE    fs_type;        /* FAT sub type */
+       BYTE    drive;          /* Physical drive number */
+       BYTE    csize;          /* Number of sectors per cluster */
+       BYTE    n_fats;         /* Number of FAT copies */
+       BYTE    wflag;          /* win[] dirty flag (1:must be written back) */
+       WORD    id;                     /* File system mount ID */
+       WORD    n_rootdir;      /* Number of root directory entries (0 on 
FAT32) */
+#if _FS_REENTRANT
+       _SYNC_t sobj;           /* Identifier of sync object */
+#endif
+#if _MAX_SS != 512
+       WORD    s_size;         /* Sector size */
+#endif
+#if !_FS_READONLY
+       BYTE    fsi_flag;       /* fsinfo dirty flag (1:must be written back) */
+       DWORD   last_clust;     /* Last allocated cluster */
+       DWORD   free_clust;     /* Number of free clusters */
+       DWORD   fsi_sector;     /* fsinfo sector */
+#endif
+#if _FS_RPATH
+       DWORD   cdir;           /* Current directory (0:root)*/
+#endif
+       DWORD   sects_fat;      /* Sectors per fat */
+       DWORD   max_clust;      /* Maximum cluster# + 1. Number of clusters is 
max_clust - 2 */
+       DWORD   fatbase;        /* FAT start sector */
+       DWORD   dirbase;        /* Root directory start sector (Cluster# on 
FAT32) */
+       DWORD   database;       /* Data start sector */
+       DWORD   winsect;        /* Current sector appearing in the win[] */
+       BYTE    win[_MAX_SS];/* Disk access window for Directory/FAT */
+} FATFS;
+
+
+
+/* Directory object structure */
+
+typedef struct _DIR_ {
+       FATFS*  fs;                     /* Pointer to the owner file system 
object */
+       WORD    id;                     /* Owner file system mount ID */
+       WORD    index;          /* Current read/write index number */
+       DWORD   sclust;         /* Table start cluster (0:Static table) */
+       DWORD   clust;          /* Current cluster */
+       DWORD   sect;           /* Current sector */
+       BYTE*   dir;            /* Pointer to the current SFN entry in the 
win[] */
+       BYTE*   fn;                     /* Pointer to the SFN (in/out) 
{file[8],ext[3],status[1]} */
+#if _USE_LFN
+       WCHAR*  lfn;            /* Pointer to the LFN working buffer */
+       WORD    lfn_idx;        /* Last matched LFN index number (0xFFFF:No 
LFN) */
+#endif
+} DIR;
+
+
+
+/* File object structure */
+
+typedef struct _FIL_ {
+       FATFS*  fs;                     /* Pointer to the owner file system 
object */
+       WORD    id;                     /* Owner file system mount ID */
+       BYTE    flag;           /* File status flags */
+       BYTE    csect;          /* Sector address in the cluster */
+       DWORD   fptr;           /* File R/W pointer */
+       DWORD   fsize;          /* File size */
+       DWORD   org_clust;      /* File start cluster */
+       DWORD   curr_clust;     /* Current cluster */
+       DWORD   dsect;          /* Current data sector */
+#if !_FS_READONLY
+       DWORD   dir_sect;       /* Sector containing the directory entry */
+       BYTE*   dir_ptr;        /* Ponter to the directory entry in the window 
*/
+#endif
+#if !_FS_TINY
+       BYTE    buf[_MAX_SS];/* File R/W buffer */
+#endif
+} FIL;
+
+
+
+/* File status structure */
+
+typedef struct _FILINFO_ {
+       DWORD   fsize;          /* File size */
+       WORD    fdate;          /* Last modified date */
+       WORD    ftime;          /* Last modified time */
+       BYTE    fattrib;        /* Attribute */
+       char    fname[13];      /* Short file name (8.3 format) */
+#if _USE_LFN
+       XCHAR*  lfname;         /* Pointer to the LFN buffer */
+       int     lfsize;         /* Size of LFN buffer [chrs] */
+#endif
+} FILINFO;
+
+
+
+/* File function return code (FRESULT) */
+
+typedef enum {
+       FR_OK = 0,                      /* 0 */
+       FR_DISK_ERR,            /* 1 */
+       FR_INT_ERR,                     /* 2 */
+       FR_NOT_READY,           /* 3 */
+       FR_NO_FILE,                     /* 4 */
+       FR_NO_PATH,                     /* 5 */
+       FR_INVALID_NAME,        /* 6 */
+       FR_DENIED,                      /* 7 */
+       FR_EXIST,                       /* 8 */
+       FR_INVALID_OBJECT,      /* 9 */
+       FR_WRITE_PROTECTED,     /* 10 */
+       FR_INVALID_DRIVE,       /* 11 */
+       FR_NOT_ENABLED,         /* 12 */
+       FR_NO_FILESYSTEM,       /* 13 */
+       FR_MKFS_ABORTED,        /* 14 */
+       FR_TIMEOUT                      /* 15 */
+} FRESULT;
+
+
+
+/*--------------------------------------------------------------*/
+/* FatFs module application interface                           */
+
+FRESULT f_mount (BYTE, FATFS*);                                                
/* Mount/Unmount a logical drive */
+FRESULT f_open (FIL*, const XCHAR*, BYTE);                     /* Open or 
create a file */
+FRESULT f_read (FIL*, void*, UINT, UINT*);                     /* Read data 
from a file */
+FRESULT f_write (FIL*, const void*, UINT, UINT*);      /* Write data to a file 
*/
+FRESULT f_lseek (FIL*, DWORD);                                         /* Move 
file pointer of a file object */
+FRESULT f_close (FIL*);                                                        
        /* Close an open file object */
+FRESULT f_opendir (DIR*, const XCHAR*);                                /* Open 
an existing directory */
+FRESULT f_readdir (DIR*, FILINFO*);                                    /* Read 
a directory item */
+FRESULT f_stat (const XCHAR*, FILINFO*);                               /* Get 
file status */
+FRESULT f_getfree (const XCHAR*, DWORD*, FATFS**);     /* Get number of free 
clusters on the drive */
+FRESULT f_truncate (FIL*);                                                     
/* Truncate file */
+FRESULT f_sync (FIL*);                                                         
/* Flush cached data of a writing file */
+FRESULT f_unlink (const XCHAR*);                                               
/* Delete an existing file or directory */
+FRESULT        f_mkdir (const XCHAR*);                                         
/* Create a new directory */
+FRESULT f_chmod (const XCHAR*, BYTE, BYTE);                    /* Change 
attriburte of the file/dir */
+FRESULT f_utime (const XCHAR*, const FILINFO*);                /* Change 
timestamp of the file/dir */
+FRESULT f_rename (const XCHAR*, const XCHAR*);         /* Rename/Move a file 
or directory */
+FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*);      /* 
Forward data to the stream */
+FRESULT f_mkfs (BYTE, BYTE, WORD);                                     /* 
Create a file system on the drive */
+FRESULT f_chdir (const XCHAR*);                                                
/* Change current directory */
+FRESULT f_chdrive (BYTE);                                                      
/* Change current drive */
+
+#if _USE_STRFUNC
+int f_putc (int, FIL*);                                                        
        /* Put a character to the file */
+int f_puts (const char*, FIL*);                                                
/* Put a string to the file */
+int f_printf (FIL*, const char*, ...);                         /* Put a 
formatted string to the file */
+char* f_gets (char*, int, FIL*);                                       /* Get 
a string from the file */
+#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
+#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
+#ifndef EOF
+#define EOF -1
+#endif
+#endif
+
+
+
+/*--------------------------------------------------------------*/
+/* User defined functions                                       */
+
+/* Real time clock */
+#if !_FS_READONLY
+DWORD get_fattime (void);      /* 31-25: Year(0-127 org.1980), 24-21: 
Month(1-12), 20-16: Day(1-31) */
+                                                       /* 15-11: Hour(0-23), 
10-5: Minute(0-59), 4-0: Second(0-29 *2) */
+#endif
+
+/* Unicode - OEM code conversion */
+#if _USE_LFN
+WCHAR ff_convert (WCHAR, UINT);
+WCHAR ff_wtoupper (WCHAR);
+#endif
+
+/* Sync functions */
+#if _FS_REENTRANT
+BOOL ff_cre_syncobj(BYTE, _SYNC_t*);
+BOOL ff_del_syncobj(_SYNC_t);
+BOOL ff_req_grant(_SYNC_t);
+void ff_rel_grant(_SYNC_t);
+#endif
+
+
+
+/*--------------------------------------------------------------*/
+/* Flags and offset address                                     */
+
+
+/* File access control and file status flags (FIL.flag) */
+
+#define        FA_READ                         0x01
+#define        FA_OPEN_EXISTING        0x00
+#if _FS_READONLY == 0
+#define        FA_WRITE                        0x02
+#define        FA_CREATE_NEW           0x04
+#define        FA_CREATE_ALWAYS        0x08
+#define        FA_OPEN_ALWAYS          0x10
+#define FA__WRITTEN                    0x20
+#define FA__DIRTY                      0x40
+#endif
+#define FA__ERROR                      0x80
+
+
+/* FAT sub type (FATFS.fs_type) */
+
+#define FS_FAT12       1
+#define FS_FAT16       2
+#define FS_FAT32       3
+
+
+/* File attribute bits for directory entry */
+
+#define        AM_RDO  0x01    /* Read only */
+#define        AM_HID  0x02    /* Hidden */
+#define        AM_SYS  0x04    /* System */

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

Other related posts:

  • » [acme-dev] SF.net SVN: acme-dev:[76] acme-boot - claudyus