ATMEL SAM9X5烧写引导文件

Table of Contents

介绍

ATMEL的SAM9X5系列CPU在设定从CPU内部的BOOTROM启动后,如果在启动过程中没有发现NANDFLASH、SPI FLASH、DATA FLASH或者I2C FLASH中具备可用的引导文件,则会启动SAMBA服务。此时用户可以通过串口或者USB对SAM9X5的启动FLASH进行编程。但是由于使用串口进行SAMBA控制的时候经常无反应,故建议使用USB接口(USB接口为SAM9X5的Device接口)。

使用SAMBA烧写启动文件

识别/安装USB驱动

如果CPU启动的SAMBA服务,则CPU在DBG口显示RomBOOT,同时电脑会发现一个新硬件(如果CPU找到了启动文件或者启动文件出错则不会有新硬件发现):

SAM9X5 New USB Device

安装驱动,完成后如下:

SAM9X5 AT91 Device

 

连接目标板

打开SAMBA软件,选择安装的USB转SERIAL的设备,选择连接:

SAM9X5 SAMBA Connect Configuration

由于我们采用NAND FLASH作为启动芯片,选择NandFlash选项卡:

SAM9X5 NandFlash Table

烧写启动文件

烧写Bootstrap步骤:“Enable NandFlash” -> “Pmecc configuration” -> “Send Boot File”,其中PMECC配置如下:

 

SAM9X5 PMECC Configuration

由于我们用的SAMSUNG的K9F2G08U0C-SIB0:

  • Block(Erase) size是0x20000
  • Page size是2048 byte + 64(OOB) byte
  • Sector size是512 byte
  • 一个Page包含4个Sectors

根据Linux内核中PMECC控制器对2048字节Page定义ECC在OOB中位置,故设定”Ecc offset“为48,”Number of ECC bits required“为2:

static struct nand_ecclayout pmecc_oobinfo_2048 = {
.eccbytes = 16,
.eccpos = { 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63
},
.oobfree = {
{2, 46},
},
};
switch (mtd->writesize) {
case 2048:
nand_chip->ecc.bytes = 16;
nand_chip->ecc.steps = 1;
nand_chip->ecc.layout = &pmecc_oobinfo_2048;
host->mm = GF_DIMENSION_13;
host->nn = (1 << host->mm) - 1;
/* 2-bits correction */
host->tt = 2;
host->sector_size = 512;
host->sector_number = mtd->writesize /
host->sector_size;
host->ecc_bytes_per_sector = 4;
host->alpha_to = pmecc_get_alpha_to(host);
host->index_of = pmecc_get_index_of(host);
break;

最后烧写Uboot即可。

采用MMC启动CPU烧写启动文件

另外一种更加便利的方式就是通过SD/TF卡启动CPU,然后在uboot下烧写启动文件。

SD/TF卡启动只需要使用at91bootstrap编译出SD卡启动的Bootstrap文件,以boot.bin为文件名存在SD/TF卡中。同时SD/TF卡格式化为FAT32分区即可。

由于我们采用的是SAMSUNG的NANDFLASH,不支持ONFI接口,所以要在前面的208字节填充PMECC的参数,在和编译出来的Bootstrap组合成可启动的Boostrap文件。

参考

  • http://www.atmel.com/tools/atmelsam-bain-systemprogrammer.aspx
  • http://www.at91.com/linux4sam/bin/view/Linux4SAM/AT91Bootstrap
  • http://www.at91.com/linux4sam/bin/view/Linux4SAM/PmeccConfigure
  • drivers/mtd/nand/atmel_nand_pmecc.c

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.