From 35627f9a07eec481873251730a7a04ff62b5cc5f Mon Sep 17 00:00:00 2001 From: save Date: Tue, 17 Feb 2009 11:00:26 +0000 Subject: [CLEO][KERNEL] Added MTD partitions and userfs management git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4001 017c9cb6-072f-447c-8318-d5b54f68fe89 --- .../target/device/Spidcom/arizona/linux26.config | 19 ++- .../linux-2.6.25.10/arch/arm/mach-spc300/core.c | 42 +++++- cleopatre/linux-2.6.25.10/drivers/mtd/maps/Kconfig | 8 ++ .../linux-2.6.25.10/drivers/mtd/maps/Makefile | 1 + .../linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c | 155 +++++++++++++++++++++ cleopatre/userfs/Makefile | 40 ++++++ cleopatre/userfs/image/bin/NOPRUNE | 0 cleopatre/userfs/image/etc/NOPRUNE | 0 cleopatre/userfs/image/etc/network/interfaces | 19 +++ cleopatre/userfs/image/etc/rcS.d/NOPRUNE | 0 cleopatre/userfs/image/etc/sysctl.conf | 2 + cleopatre/userfs/image/scripts/download | 17 +++ cleopatre/userfs/image/scripts/plcdrv | 23 +++ cleopatre/userfs/image/scripts/startplc | 29 ++++ 14 files changed, 350 insertions(+), 5 deletions(-) create mode 100644 cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c create mode 100755 cleopatre/userfs/Makefile create mode 100644 cleopatre/userfs/image/bin/NOPRUNE create mode 100644 cleopatre/userfs/image/etc/NOPRUNE create mode 100644 cleopatre/userfs/image/etc/network/interfaces create mode 100644 cleopatre/userfs/image/etc/rcS.d/NOPRUNE create mode 100644 cleopatre/userfs/image/etc/sysctl.conf create mode 100755 cleopatre/userfs/image/scripts/download create mode 100755 cleopatre/userfs/image/scripts/plcdrv create mode 100755 cleopatre/userfs/image/scripts/startplc diff --git a/cleopatre/buildroot/target/device/Spidcom/arizona/linux26.config b/cleopatre/buildroot/target/device/Spidcom/arizona/linux26.config index 1384785385..9f1fafeb05 100644 --- a/cleopatre/buildroot/target/device/Spidcom/arizona/linux26.config +++ b/cleopatre/buildroot/target/device/Spidcom/arizona/linux26.config @@ -443,8 +443,14 @@ CONFIG_MTD_BLOCK=y # # RAM/ROM/Flash chip drivers # -# CONFIG_MTD_CFI is not set +CONFIG_MTD_CFI=y # CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_GEN_PROBE=y +CONFIG_MTD_CFI_ADV_OPTIONS=y +CONFIG_MTD_CFI_NOSWAP=y +# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set +# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set +CONFIG_MTD_CFI_GEOMETRY=y CONFIG_MTD_MAP_BANK_WIDTH_1=y CONFIG_MTD_MAP_BANK_WIDTH_2=y CONFIG_MTD_MAP_BANK_WIDTH_4=y @@ -455,6 +461,11 @@ CONFIG_MTD_CFI_I1=y CONFIG_MTD_CFI_I2=y # CONFIG_MTD_CFI_I4 is not set # CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_OTP is not set +CONFIG_MTD_CFI_INTELEXT=y +CONFIG_MTD_CFI_AMDSTD=y +# CONFIG_MTD_CFI_STAA is not set +CONFIG_MTD_CFI_UTIL=y # CONFIG_MTD_RAM is not set # CONFIG_MTD_ROM is not set # CONFIG_MTD_ABSENT is not set @@ -463,6 +474,9 @@ CONFIG_MTD_CFI_I2=y # Mapping drivers for chip access # # CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PHYSMAP is not set +# CONFIG_MTD_ARM_INTEGRATOR is not set +CONFIG_MTD_SPC300_NOR=y # CONFIG_MTD_PLATRAM is not set # @@ -773,8 +787,7 @@ CONFIG_CONFIGFS_FS=y # CONFIG_EFS_FS is not set CONFIG_JFFS2_FS=y CONFIG_JFFS2_FS_DEBUG=0 -CONFIG_JFFS2_FS_WRITEBUFFER=y -# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +# CONFIG_JFFS2_FS_WRITEBUFFER is not set # CONFIG_JFFS2_SUMMARY is not set # CONFIG_JFFS2_FS_XATTR is not set # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set diff --git a/cleopatre/linux-2.6.25.10/arch/arm/mach-spc300/core.c b/cleopatre/linux-2.6.25.10/arch/arm/mach-spc300/core.c index 0dfec2dcbf..845900a455 100644 --- a/cleopatre/linux-2.6.25.10/arch/arm/mach-spc300/core.c +++ b/cleopatre/linux-2.6.25.10/arch/arm/mach-spc300/core.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -69,9 +71,45 @@ struct sys_timer spc300_timer = { .offset = spc300_gettimeoffset }; +static struct mtd_partition spc300_partitions[] = { + { + .name = "u-boot", + .size = 0x00020000, + .offset = 0, + .mask_flags = 0, + }, { + .name = "u-boot params", + .size = 0x00010000, + .offset = MTDPART_OFS_APPEND, + .mask_flags = 0, + }, { + .name = "nvram", + .size = 0x00010000, + .offset = MTDPART_OFS_APPEND, + .mask_flags = 0, + }, { + .name = "user-fs", + .size = 0x00100000, + .offset = MTDPART_OFS_APPEND, + .mask_flags = 0, + }, { + .name = "image 0", + .size = 0x00360000, + .offset = MTDPART_OFS_APPEND, + .mask_flags = 0, + }, { + .name = "image 1", + .size = MTDPART_SIZ_FULL, + .offset = MTDPART_OFS_APPEND, + .mask_flags = 0, + } +}; + static struct flash_platform_data spc300_flash_data = { .map_name = "cfi_probe", - .width = 4 + .width = 1, + .parts = spc300_partitions, + .nr_parts = ARRAY_SIZE(spc300_partitions) }; static struct resource spc300_flash_resource = { @@ -81,7 +119,7 @@ static struct resource spc300_flash_resource = { }; static struct platform_device spc300_flash_device = { - .name = "armflash", + .name = "spc300norflash", .id = 0, .dev = { .platform_data = &spc300_flash_data, diff --git a/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Kconfig b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Kconfig index 12c253664e..4e04951e2c 100644 --- a/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Kconfig +++ b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Kconfig @@ -493,6 +493,14 @@ config MTD_OMAP_NOR These boards include the Innovator, H2, H3, OSK, Perseus2, and more. If you have such a board, say 'Y'. +config MTD_SPC300_NOR + tristate "SPC300 board NOR flash mappings" + depends on MTD_CFI && ARCH_SPC300 + help + This enables access to the NOR flash chips on SPC300-based + boards defining flash platform devices and flash platform data. + If you have such a board, say 'Y'. + # This needs CFI or JEDEC, depending on the cards found. config MTD_PCI tristate "PCI MTD driver" diff --git a/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Makefile b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Makefile index a9cbe80f99..30261c20e9 100644 --- a/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Makefile +++ b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/Makefile @@ -66,5 +66,6 @@ obj-$(CONFIG_MTD_DMV182) += dmv182.o obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o +obj-$(CONFIG_MTD_SPC300_NOR) += spc300_nor.o obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o diff --git a/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c new file mode 100644 index 0000000000..66aa6ff242 --- /dev/null +++ b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c @@ -0,0 +1,155 @@ +/* + * drivers/mtd/maps/spc300_nor.c + * + * Copyright (C) 2009 SPiDCOM Technologies + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +struct spc300flash_info { + struct mtd_partition *parts; + struct mtd_info *mtd; + struct map_info map; +}; + +static int __devinit spc300flash_probe(struct platform_device *pdev) +{ + int err; + struct spc300flash_info *info; + struct flash_platform_data *pdata = pdev->dev.platform_data; + struct resource *res = pdev->resource; + unsigned long size = res->end - res->start + 1; + + info = kzalloc(sizeof(struct spc300flash_info), GFP_KERNEL); + if(!info) + return -ENOMEM; + + if(!request_mem_region(res->start, size, "flash")) + { + err = -EBUSY; + goto out_free_info; + } + + info->map.virt = ioremap(res->start, size); + if(!info->map.virt) { + err = -ENOMEM; + goto out_release_mem_region; + } + info->map.name = pdev->dev.bus_id; + info->map.phys = res->start; + info->map.size = size; + info->map.bankwidth = pdata->width; + simple_map_init(&info->map); + + info->mtd = do_map_probe(pdata->map_name, &info->map); + if(!info->mtd) + { + err = -EIO; + goto out_iounmap; + } + info->mtd->owner = THIS_MODULE; + + if(pdata->parts) + { + add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts); + info->parts = pdata->parts; + } + else + { + add_mtd_device(info->mtd); + } + + platform_set_drvdata(pdev, info); + + return 0; + +out_iounmap: + iounmap(info->map.virt); +out_release_mem_region: + release_mem_region(res->start, size); +out_free_info: + kfree(info); + + return err; +} + +static int __exit spc300flash_remove(struct platform_device *pdev) +{ + struct spc300flash_info *info = platform_get_drvdata(pdev); + + platform_set_drvdata(pdev, NULL); + + if(info) + { + if(info->parts) + { + del_mtd_partitions(info->mtd); + } + else + { + del_mtd_device(info->mtd); + } + map_destroy(info->mtd); + release_mem_region(info->map.phys, info->map.size); + iounmap((void __iomem *) info->map.virt); + kfree(info); + } + + return 0; +} + +static struct platform_driver spc300flash_driver = { + .probe = spc300flash_probe, + .remove = __exit_p(spc300flash_remove), + .driver = { + .name = "spc300norflash", + }, +}; + +static int __init spc300flash_init(void) +{ + return platform_driver_register(&spc300flash_driver); +} + +static void __exit spc300flash_exit(void) +{ + platform_driver_unregister(&spc300flash_driver); +} + +module_init(spc300flash_init); +module_exit(spc300flash_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR ("SPiDCOM Technologies"); +MODULE_DESCRIPTION("MTD NOR map driver for SPC300 boards"); + diff --git a/cleopatre/userfs/Makefile b/cleopatre/userfs/Makefile new file mode 100755 index 0000000000..06a3a61edc --- /dev/null +++ b/cleopatre/userfs/Makefile @@ -0,0 +1,40 @@ +# BLOCK_SIZE : Size of a block for your flash device +BLOCK_SIZE= 65536 #for spansion S29GL064A10 + +# FLASHDISK_SIZE : Size of your flash file system +# it must be more than 512KB (524288B) +# and at least 5 x (size of a block) +#FLASHDISK_SIZE = 524288 +FLASHDISK_SIZE = 1048510 + + + +DIR=$(PWD) +IMAGE = $(DIR)/image +TMP_IMAGE = /tmp/fimage +FLASHDISK = $(DIR)/flashfs.jffs2 + +all: buildjffs2 + +clean: + rm -rf $(FLASHDISK) $(TMP_IMAGE) + +$(FLASHDISK): buildjffs2 + +buildjffs2: + rm -rf $(TMP_IMAGE) + cp -dpR $(IMAGE) $(TMP_IMAGE) + chmod -R a+x $(TMP_IMAGE)/scripts + /usr/bin/find $(TMP_IMAGE) -name NOPRUNE -exec echo {} > /tmp/list \; + rm -f `cat /tmp/list` + rm -f /tmp/list + sudo mkfs.jffs2 -l --pad=$(FLASHDISK_SIZE) -e $(BLOCK_SIZE) -d $(TMP_IMAGE) -o $(FLASHDISK) + rm -rf $(TMP_IMAGE) + +.PHONY: buildjffs2 + + + + + + diff --git a/cleopatre/userfs/image/bin/NOPRUNE b/cleopatre/userfs/image/bin/NOPRUNE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cleopatre/userfs/image/etc/NOPRUNE b/cleopatre/userfs/image/etc/NOPRUNE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cleopatre/userfs/image/etc/network/interfaces b/cleopatre/userfs/image/etc/network/interfaces new file mode 100644 index 0000000000..9909ca913f --- /dev/null +++ b/cleopatre/userfs/image/etc/network/interfaces @@ -0,0 +1,19 @@ +auto lo eth0 plc0 br0 + + iface lo inet loopback + + iface eth0 inet static + address 0.0.0.0 + netmask 255.255.255.0 + + iface plc0 inet static + address 0.0.0.0 + netmask 255.255.255.0 + + iface br0 inet static + address 192.168.2.1 + netmask 255.255.255.0 + + + + diff --git a/cleopatre/userfs/image/etc/rcS.d/NOPRUNE b/cleopatre/userfs/image/etc/rcS.d/NOPRUNE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cleopatre/userfs/image/etc/sysctl.conf b/cleopatre/userfs/image/etc/sysctl.conf new file mode 100644 index 0000000000..12baa96480 --- /dev/null +++ b/cleopatre/userfs/image/etc/sysctl.conf @@ -0,0 +1,2 @@ +net.plc.tmo_token = 20 +net.plc.master = 0 diff --git a/cleopatre/userfs/image/scripts/download b/cleopatre/userfs/image/scripts/download new file mode 100755 index 0000000000..e82d4594bc --- /dev/null +++ b/cleopatre/userfs/image/scripts/download @@ -0,0 +1,17 @@ +#!/bin/sh + +hostip="192.168.2.144" + +#check if first arguments = -a address +if [ "$1" = "-a" ] +then + hostip="$2" + shift + shift +fi + +for file in $* +do + ftpget -u spidcom -p spidcom $hostip $file $file +done + diff --git a/cleopatre/userfs/image/scripts/plcdrv b/cleopatre/userfs/image/scripts/plcdrv new file mode 100755 index 0000000000..6bd4f765b2 --- /dev/null +++ b/cleopatre/userfs/image/scripts/plcdrv @@ -0,0 +1,23 @@ +#!/bin/sh + +# This file is used to load correctly the PLC driver + +#Variables +module="plcdrv" +device="plcdrv" +mode="666" + +#Invoke insmod will all arguments +/sbin/insmod ./$module.ko $* || exit 1 + +#Remove old node +rm -f /dev/$device + +#Create new node +#major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices) +#we don't have awk command so... +major="254" + +mknod /dev/$device c $major 0 +chmod $mode /dev/$device + diff --git a/cleopatre/userfs/image/scripts/startplc b/cleopatre/userfs/image/scripts/startplc new file mode 100755 index 0000000000..0aa9771a1f --- /dev/null +++ b/cleopatre/userfs/image/scripts/startplc @@ -0,0 +1,29 @@ +#!/bin/sh + +# This file is used to to start the prototype with cesar and plcdrv + +#Variables +plc_module="plcdrv.ko" +leon_file=$1 +shift + +if [ "$leon_file" = "" ] +then + echo "You need to precise the Cesar binary file" + exit 1 +fi + +#Download Cesar binary +/root/scripts/download $leon_file +/root/scripts/download $plc_module + +#Insert plcdrv module +/root/scripts/plcdrv $* + +#Copy Cesar binary into Memory +dd if=$leon_file of=/dev/plcdrv + +#Open plc0 interface and added to the bridge +/sbin/ifconfig plc0 0.0.0.0 +brctl addif br0 plc0 + -- cgit v1.2.3