上部分主要是说了下调试方法。
另外修改了下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_

在使用mini2440开发板进行spiflash烧写过程中遇到困难,寻求高手指点,期待解决方案。
最低0.47元/天 解锁文章
2194

被折叠的 条评论
为什么被折叠?



