NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
SPI flash boot and flashing tool for DM36x
SPI Flash Support in the kernel[edit]
- The Default DM365 EVMs have an EEPROM connected to SPI0. To test the SPI Flash, the EEPROM connected to SPI0 was replaced with a SPI Flash device from Numonyx.
- The way we have structured the board setup code for our DaVinci devices,
devices such as an EEPORM or a SPI Flash are considered specific to the EVM.
- So, we setup the parameters for SPI EEPROM or SPI FLASH in the board specific code,
i.e /arch/arm/mach-davinci/board-dm365-evm.c.
- We have to replace this EEPROM specific setup with SPI Flash specific setup.
SPI Flash is treated as a MTD devices.
- Thus we have to do the following.
- First setup the partitions. This is an example only. The device tested was a 2GB device from Numonyx.
static struct mtd_partition dm365_spi_flash_partitions[] = {
{ .name = "Bootloader", .size = 0x00080000, .offset = 0, .mask_flags = MTD_WRITEABLE, /* we want this to be read only */ },{ .name = "Kernel-Filesystem", .offset = MTDPART_OFS_APPEND, .size = MTDPART_SIZ_FULL, .mask_flags = 0, },
};
- Then setup the SPI flash platform data
static const struct flash_platform_data dm365_spi_flash = {
.type = "m25p16", /* part tested was a Numonyx m25p16 device */ .name = "spi_flash", .parts = dm365_spi_flash_partitions, .nr_parts = ARRAY_SIZE(dm365_spi_flash_partitions),
}
- Finally appropriately modify the DM365 SPI board info.
static struct spi_board_info dm365_evm_spi_info[] __initconst = {
{ .modalias = "m25p80", .platform_data = &dm365_spi_flash, .max_speed_hz = 20 * 1000 * 1000, .bus_num = 0, .chip_select = 0, .mode =SPI_MODE_0, }
}
- Besides this we also need a change in the config for DM365.
- Enable the config option for CONFIG_MTD_M25P80 to enable the SPI flash device. Also enable CONFIG_M25PXX_USE_FAST_READ as well.
Please note that not all SPI FLASH devices will support the "fast read" option so please refer the device specific data sheet before enabling this option in DM365 .config
- We will have to disable the option to enable the SPI EEPROM, that it enabled by default as part of the davinci_dm365_defconfig that is part of the ARAGO tree.
- When the kernel comes up we should see the following
davinci_nand davinci_nand.0: controller rev. 2.3 spi_davinci spi_davinci.0: DaVinci SPI driver in EDMA mode Using RX channel = 17 , TX channel = 16 and event queue = 3 m25p80 spi0.0: m25p16 (2048 Kbytes) Creating 2 MTD partitions on "spi_flash": 0x000000000000-0x000000080000 : "Bootloader" 0x000000080000-0x000000200000 : "Kernel-Filesystem"
- There should be 2 mtd devices created for the SPI Flash. Because we have 5 MTD partitions for NAND by default, SPI MTD
partitions will be mtd5 and mtd6.
- MTD5 has been designated as read only and thus we will not be able to write to it.
- we can perform read, write and erase operations on MTD6
root@dm365-evm:/# flash_eraseall /dev/mtd6 Erasing 64 Kibyte @ 180000 -- 100 % complete. root@dm365-evm:/# echo "Texas Instruments" > /dev/mtd6 root@dm365-evm:/# strings /dev/mtd6 Texas Instruments