Example #1
0
static void
ramtron_start(void)
{
	int ret;

	if (started)
		errx(1, "ramtron already mounted");

	if (!attached)
		ramtron_attach();

	/* start NXFFS */
	ret = nxffs_initialize(ramtron_mtd);

	if (ret < 0)
		errx(1, "failed to initialize NXFFS - erase ramtron to reformat");

	/* mount the ramtron */
	ret = mount(NULL, "/ramtron", "nxffs", 0, NULL);

	if (ret < 0)
		errx(1, "failed to mount /ramtron - erase ramtron to reformat");

	started = true;
	warnx("mounted ramtron at /ramtron");
	exit(0);
}
Example #2
0
static void
ramtron_erase(void)
{
	if (!attached)
		ramtron_attach();

//	if (at24c_nuke())
		errx(1, "erase failed");

	errx(0, "erase done, reboot now");
}
Example #3
0
static void
mtd_start(char *partition_names[], unsigned n_partitions)
{
	int ret;
	if (started)
		errx(1, "mtd already mounted");

	if (!attached) {
		#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1
		at24xxx_attach();
		#else
			#if defined(CONFIG_ARCH_BOARD_AERODROID) 
				#ifdef CONFIG_RAMTRON_FUJITSU
					ramtron_attach();
				#else
					spansion_attach();
				#endif
			#else
			ramtron_attach();
			#endif
		#endif
	}

	if (!mtd_dev) {
		warnx("ERROR: Failed to create RAMTRON FRAM MTD instance");
		exit(1);
	}

	unsigned long blocksize, erasesize, neraseblocks;
	unsigned blkpererase, nblocks, partsize;

	ret = mtd_get_geometry(&blocksize, &erasesize, &neraseblocks, &blkpererase, &nblocks, &partsize, n_partitions);
	if (ret)
		exit(3);

	/* Now create MTD FLASH partitions */

	FAR struct mtd_dev_s *part[n_partitions];
	char blockname[32];

	unsigned offset;
	unsigned i;

	for (offset = 0, i = 0; i < n_partitions; offset += nblocks, i++) {

		/* Create the partition */

		part[i] = mtd_partition(mtd_dev, offset, nblocks);

		if (!part[i]) {
			warnx("ERROR: mtd_partition failed. offset=%lu nblocks=%lu",
			      (unsigned long)offset, (unsigned long)nblocks);
			exit(4);
		}

		/* Initialize to provide an FTL block driver on the MTD FLASH interface */

		snprintf(blockname, sizeof(blockname), "/dev/mtdblock%d", i);

		ret = ftl_initialize(i, part[i]);

		if (ret < 0) {
			warnx("ERROR: ftl_initialize %s failed: %d", blockname, ret);
			exit(5);
		}

		/* Now create a character device on the block device */

		ret = bchdev_register(blockname, partition_names[i], false);

		if (ret < 0) {
			warnx("ERROR: bchdev_register %s failed: %d", partition_names[i], ret);
			exit(6);
		}
	}

	n_partitions_current = n_partitions;

	started = true;
	exit(0);
}