用mini2440烧写spiflash『中』

在使用mini2440开发板进行spiflash烧写过程中遇到困难,寻求高手指点,期待解决方案。
上部分主要是说了下调试方法。
另外修改了下spidev.c中的
//static unsigned bufsiz = 4096;
static unsigned bufsiz = 4*1024*1024;

下面贴上烧写/读取程序。
程序的致命弱点是速度太慢,主要是因为每次ret = ioctl(Fd_dev, SPI_IOC_MESSAGE(2), Spi_tr);调用都要花费20ms,

希望高手可以提出解决方法。

/*
 * SPI program chip(using spidev driver)
 *
 * Copyright (c) 2007  MontaVista Software, Inc.
 * Copyright (c) 2007  Anton Vorontsov <avorontsov@ru.mvista.com>
 * Copyright (c) 2012 fengchen <fengchen_rs@qq.com>
 * 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.
 *
 * Cross-compile with cross-gcc -I/path/to/cross-kernel/include
 */

#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>

/*********spi conf******************/
#define SPI_BITS_PER_WORD 8
#define SPI_SPEED 25000000
#define SPI_MODE 0
#define SPI_DEVICE "/dev/spidev0.0"
#define ONCE_READ_MAX_BYTES 3*1024*1024

/*********device******************/
#define MX25L32
//#define MX25L64
//#define W25Q80

/*******************pagesize*******************/
#define SIZE_1M_PAGE_NUM 256*16	//(256sectors)*(16pages/sector)

#ifdef W25Q80
//#define CHIP_ID 0x13
#define SPI_FLASH_25_X_XX
#define PAGE_NUM SIZE_1M_PAGE_NUM
#define TIME_ERASECHIP 2*1000*1000
#define TIME_PAGEPROGRAM 700
#endif

#ifdef MX25L32
//#define CHIP_ID 0x15
#define SPI_FLASH_25_X_XX
#define PAGE_NUM SIZE_1M_PAGE_NUM*4
#define TIME_ERASECHIP 25*1000*1000
#define TIME_PAGEPROGRAM 1400
#endif

#ifdef MX25L64
//#define CHIP_ID 0x16
#define SPI_FLASH_25_X_XX
#define PAGE_NUM SIZE_1M_PAGE_NUM*8
#define TIME_ERASECHIP 50*1000*1000
#define TIME_PAGEPROGRAM 1400
#endif

/*************** cmd type ************/
struct cmd_type {
	char* cmd_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值