at91bootstrap. introduction device initialization such as clock speed configuration, pio settings,...

29
AT91Bootstrap

Upload: isabella-horton

Post on 06-Jan-2018

220 views

Category:

Documents


1 download

DESCRIPTION

Peripheral Drivers PIO PIOA controller handles pin_number from 0 to 31 PIOB controller handles pin_number from 32 to 61 PIOC controller handles pin from 62 to 95 /* Convert Pin Number into PIO controller index */ static inline unsigned pin_to_controller(unsigned pin) { return (pin) / 32; }

TRANSCRIPT

Page 1: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

AT91Bootstrap

Page 2: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

Introduction • Device initialization such as clock speed configuration,

PIO settings, etc.

• Peripheral drivers such as PIO, PMC, SDRAMC, etc.

• Physical media algorithms such as DataFlash®, NANDFlash, Parallel Flash, etc.

• File System drivers such as JFFS2, FAT, etc.

• Compression and Cipher algorithms

• Application Launcher for ELF, Linux®, etc.

Page 3: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

Peripheral DriversPIO

• PIOA controller handles pin_number from 0 to 31

• PIOB controller handles pin_number from 32 to 61

• PIOC controller handles pin from 62 to 95

/* Convert Pin Number into PIO controller index */static inline unsigned pin_to_controller(unsigned pin){

return (pin) / 32;}

Page 4: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

pio_desc Structure

Table. pio_desc Structure

Table. pio_type Enumeration

Table. PIO Attributes

Page 5: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

pio_desc Structure

Example.

const struct pio_desc hw_pio[] = {{"RXD", AT91C_PIN_PA(9), 0, PIO_DEFAULT, PIO_PERIPH_A},{"TXD", AT91C_PIN_PA(10), 0, PIO_DEFAULT, PIO_PERIPH_A},{"", 0, 0, PIO_DEFAULT, PIO_PERIPH_A},

};

Page 6: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

pio_setup() Function

Table. pio_setup() Function

Example.const struct pio_desc hw_pio[] = {

{"PCK0", AT91C_PIN_PA(7), 0, PIO_DEFAULT, PIO_PERIPH_B},{"PCK1", AT91C_PIN_PA(8), 0, PIO_DEFAULT, PIO_PERIPH_B},{"", 0, 0, PIO_DEFAULT, PIO_PERIPH_A},

}; /* Configure the PIO controller to output PCK0 */pio_setup(hw_pio);

Page 7: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

pio_get_value() Function

pio_set_value() FunctionTable. pio_get_value() Function

Table. pio_set_gpio_value() Function

Page 8: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

/* Device specific... */#define PIO_TEST_OUT AT91C_PIN_PA(7)#define PIO_TEST_IN AT91C_PIN_PA(8)/* Device non specific... */const struct pio_desc hw_pio[] = {

{"TEST_OUT", PIO_TEST_OUT, 0, PIO_DEFAULT, PIO_OUTPUT},{"TEST_IN", PIO_TEST_IN, 0, PIO_DEGLITCH, PIO_INPUT},{"", 0, 0, PIO_DEFAULT, PIO_PERIPH_A},

};/* Configure the PIO controller to output PCK0 */pio_setup(hw_pio);/* Test the default value */if (pio_get_value(PIO_TEST_IN) == 1)

return 0; /* Return failed *//* Force a high level on PIO_TEST_OUT pin */pio_set_value(PIO_TEST_OUT, 1);/* Test the default value */if (pio_get_value(PIO_TEST_IN) == 0)

return 0; /* Return failed */return 1; /* Success */

Example.

Page 9: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

PMC/* Automatically generated using ... */#define PMC_PLLAR 0x12345678 /* MOSC = 18.423Mhz,MUL = ,DIV = */#define PMC_PLLBR 0x12345678 /* MOSC = 18.423Mhz, MUL =,DIV = */#define PMC_MCKR 0x12345678 /* MCK = PLLA */#define PLL_TIMEOUT 1000000/* Configure PLLA */if (!pmc_cfg_plla(PMC_PLLAR, PLL_TIMEOUT))

goto pmc_error;/* Switch MCK on PLLA output PCK = PLLA = 2 * MCK */if (!pmc_cfg_mck(PMC_MCKR, PLL_TIMEOUT))

goto pmc_error;/* Configure PLLB */if (!pmc_cfg_pllb(PMC_PLLBR, PLL_TIMEOUT))

goto pmc_error;pmc_error:

/* Reset the device*/

Page 10: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

pmc_cfg_plla() Function

pmc_cfg_pllb() FunctionTable. pmc_cfg_plla()function

Table. pmc_cfg_pllb()function

Page 11: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

pmc_cfg_mck() Function

pmc_cfg_pck() FunctionTable. pmc_cfg_mck()function

Table. pmc_cfg_mck()function

Page 12: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

SDRAMC Prerequisite

• CFG_SDRAM and CFG_HW_INIT flags must be defined in your board project header file.Example: Define these flags in board/at91sam9260ek/dataflash/at91sam9260ek.h

• Create a function sdramc_hw_init() in your board source file.Example: Define this function in board/at91sam9260ek/at91sam9260ek.c

Page 13: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

sdramc_hw_init() Function

#ifdef CFG_SDRAMvoid sdramc_hw_init(void){ const struct pio_desc sdramc_pio[] = {

{"D0", AT91C_PIN_PC(16), 0, PIO_DEFAULT, PIO_PERIPH_A},{"D1", AT91C_PIN_PC(17), 0, PIO_DEFAULT, PIO_PERIPH_A},..{"D15", AT91C_PIN_PC(31), 0, PIO_DEFAULT, PIO_PERIPH_A},{"", 0, 0, PIO_DEFAULT, PIO_PERIPH_A},

};/* Configure the PIO controller to enable 32-bits SDRAM */ pio_setup(sdramc_pio);}#endif

Prototype: void sdramc_hw_init(void)

Page 14: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

sdramc_init() Function

Table. sdramc_init() Function

Page 15: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

DBGU Prerequisite

• CFG_DEBUG and CFG_HW_INIT flags must be defined in your board project header file.

Example: Define these flags in board/at91sam9260ek/dataflash/at91sam9261ek.h

Page 16: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

dbg_init() Function

Table. dbg_init() Function

dbg_print() Function

Table. dbg_print() Function

Page 17: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

DataFlash Prerequisite

• CFG_DATAFLASH flag must be defined in your board project header file.Example: Define this flag in board/at91sam9260ek/dataflash/at91sam9260ek.h

• Create a function df_hw_init() in your board source fileExample: Define this function in board/at91sam9260ek/at91sam9260ek.c

Page 18: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

df_hw_init() FunctionPrototype: void df_hw_init(void)

#ifdef CFG_DATAFLASHvoid df_hw_init(void){ const struct pio_desc df_pio[] = {

{"MISO", AT91C_PIN_PA(0), 0, PIO_DEFAULT, PIO_PERIPH_A},{"MOSI", AT91C_PIN_PA(1), 0, PIO_DEFAULT, PIO_PERIPH_A},{"SPCK", AT91C_PIN_PA(2), 0, PIO_DEFAULT, PIO_PERIPH_A},{"NPCS0", AT91C_PIN_PA(3), 0, PIO_DEFAULT, PIO_PERIPH_A},{"", 0, 0, PIO_DEFAULT, PIO_PERIPH_A},

};/* Configure the PIO controller to enable SPI DataFlash*/ pio_setup(df_pio);}#endif

Page 19: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

load_df() Function

Table. load_df()function

Page 20: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

NAND Flash Prerequisite

• CFG_NANDFLASH flag must be defined in your board project header file.Example: Define this flag in board/at91sam9260ek/nandflash/at91sam9260ek.h

• Create nandflash_hw_init() and nandflash_cfg_16bits_dbw_init() in your board source file.Example: Define this function in board/at91sam9260ek/at91sam9260ek.c

Page 21: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

nandflash_hw_init() Function

• PIOs used by the NAND Flash

• SMC timings

• HMatrix or Chip Configuration User Interface

Prototype: void nandflash_hw_init(void)

Page 22: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

nandflash_cfg_16bits_dbw_init() Function

#ifdef CFG_NANDFLASHvoid nandflash_cfg_16bits_dbw_init(void){

writel(readl(AT91C_BASE_SMC + SMC_CTRL3) |AT91C_SMC_DBW_WIDTH_SIXTEEN_BITS, AT91C_BASE_SMC + SMC_CTRL3);

}#endif

Example.

Page 23: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

load_nandflash() Function

Table. load_nandflash()function

Page 24: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

NAND Flash Features

Large Blocks vs. Small Blocks

• Large Block NAND Flash: parts bigger than 1 Gbit

• Small Block NAND Flash: parts smaller than 1 Gbit

Example.#define CFG_NANDFLASH /* Enable DataFlash Download */#define NANDFLASH_SMALL_BLOCKS /*Small Block NandFlash used */

Page 25: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc
Page 26: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

Compiling an AT91Bootstrap Project

Make Command1. Go into the board directory.

2. Select your board by going into the corresponding board directory.

3. Select your project by going into the corresponding project directory.

4. Configure your project (Makefile and header file).

5. Type make.

Page 27: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

Adding a New Board to an AT91Bootstrap Project

• Copy the board directory which is the most similar to your board, e.g. cd boardcp -r at91sam9261ek/ my_board/

• Rename board-specific files.cd my_boardmv at91sam9261ek.c my_board.cmv “project“/at91sam9261ek.h “project“/my_board.h

• Edit corresponding “project“ Makefile and modify BOARD variable accordingly.BOARD=my_boardPROJECT=“project“

• Make your modifications and compile the project.

Page 28: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

Adding a New Project to a Board

• Copy the board directory which is the most similar to your board.cd board/my_boardmkdir new_project

• Copy a Makefile and my_board.h header file.cp dataflash/* new_project/.

• Edit corresponding “new_project“ Makefile and modify PROJECT variable accordingly.

PROJECT=new_project

Page 29: AT91Bootstrap. Introduction Device initialization such as clock speed configuration, PIO settings, etc. Peripheral drivers such as PIO, PMC, SDRAMC, etc

Adding a New Driver to an AT91Bootstrap Project

• Add the new driver in the driver directory. Move the pieces of code which are product or board dependent into the board/your_board/ directory.

• If necessary, add an include file with the same driver name in the include directory.

• Use pre-processor instructions to insert your new feature into the AT91Bootstrap project.

• Add new driver file into project Makefile.