DIY min2440 Linux系统
来源:互联网 发布:mac运行windows虚拟机 编辑:程序博客网 时间:2024/04/30 13:05
X86下的Linux-os已经装过好多次了,然二mini2440开发板上的系统还没有装过,于是自己将原板子的系统格式化后,在Nor Flash下启动mini2440,. 需要做的准备工作,有一个和pc机连接的USB线,Linux下一个usb传输工具(dnw)在文章的最后会提供代码.一切就绪后,完成以下几步:
(1)将Nand Flash format and partition.具体做法是:选择q,然后bon part 0 320k 2368k(将Nand分为0~320k,320k~2368k(2M),2368~128M.(可能会提示有bad分区,不必理会)
(2)安装bootloader.可以是u-boot,vivi,e-boot等.我们以厂家给提供的vivi往为例.选择v后,打开另一个终端,在光碟提供的images/linux下用dnw2 suppervivi-128M(这个是我板子的型号)发送.
(3)烧写kernel.同样的方法用dnw2 zImage_N35(也是根据板子不同).
(4)烧写yaffs文件系统.方法一样:dnw2 root_qtopia_128M.
OK,记得要拔下USB线,重启系统来测试.
以下是dnw2的源代码:
/* dnw2 linux main file. This depends on libusb.
*
* Author: Fox <hulifox008@163.com>
* License: GPL
*
*/
#include <stdio.h>
#include <usb.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define QQ2440_SECBULK_IDVENDOR 0x5345
#define QQ2440_SECBULK_IDPRODUCT 0x1234
struct usb_dev_handle * open_port()
{
struct usb_bus *busses, *bus;
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
for(bus=busses;bus;bus=bus->next)
{
struct usb_device *dev;
for(dev=bus->devices;dev;dev=dev->next)
{
if( QQ2440_SECBULK_IDVENDOR==dev->descriptor.idVendor
&& QQ2440_SECBULK_IDPRODUCT==dev->descriptor.idProduct)
{
printf("Target usb device found!/n");
struct usb_dev_handle *hdev = usb_open(dev);
if(!hdev)
{
perror("Cannot open device");
}
else
{
if(0!=usb_claim_interface(hdev, 0))
{
perror("Cannot claim interface");
usb_close(hdev);
hdev = NULL;
}
}
return hdev;
}
}
}
printf("Target usb device not found!/n");
return NULL;
}
void usage()
{
printf("Usage: dnw2 <file>/n/n");
}
unsigned char* prepare_write_buf(char *filename, unsigned int *len)
{
unsigned char *write_buf = NULL;
struct stat fs;
int fd = open(filename, O_RDONLY);
if(-1==fd)
{
perror("Cannot open file");
return NULL;
}
if(-1==fstat(fd, &fs))
{
perror("Cannot get file size");
goto error;
}
write_buf = (unsigned char*)malloc(fs.st_size+10);
if(NULL==write_buf)
{
perror("malloc failed");
goto error;
}
if(fs.st_size != read(fd, write_buf+8, fs.st_size))
{
perror("Reading file failed");
goto error;
}
printf("Filename : %s/n", filename);
printf("Filesize : %d bytes/n", fs.st_size);
*((u_int32_t*)write_buf) = 0x30000000; //download address
*((u_int32_t*)write_buf+1) = fs.st_size + 10; //download size;
*len = fs.st_size + 10;
return write_buf;
error:
if(fd!=-1) close(fd);
if(NULL!=write_buf) free(write_buf);
fs.st_size = 0;
return NULL;
}
int main(int argc, char *argv[])
{
if(2!=argc)
{
usage();
return 1;
}
struct usb_dev_handle *hdev = open_port();
if(!hdev)
{
return 1;
}
unsigned int len = 0;
unsigned char* write_buf = prepare_write_buf(argv[1], &len);
if(NULL==write_buf) return 1;
unsigned int remain = len;
unsigned int towrite;
printf("Writing data .../n");
while(remain)
{
towrite = remain>512 ? 512 : remain;
if(towrite != usb_bulk_write(hdev, 0x03, write_buf+(len-remain), towrite, 3000))
{
perror("usb_bulk_write failed");
break;
}
remain-=towrite;
printf("/r%d%/t %d bytes ", (len-remain)*100/len, len-remain);
fflush(stdout);
}
if(0==remain) printf("Done!/n");
return 0;
}
编译: gcc dnw2.c -o dnw2 -lusb
为了方便将连接后的dnw2放在/usr/bin/下.
- DIY min2440 Linux系统
- DIY:自己动手做一个迷你 Linux 系统
- DIY:自己动手做一个迷你 Linux 系统
- DIY:自己动手做一个迷你 Linux 系统
- DIY安全的Linux系统服务平台
- DIY安全的Linux系统服务平台
- [转贴]DIY:自己动手做一个迷你 Linux 系统
- Linux手机DIY.内核初探.系统后台启动简单介绍
- Linux手机DIY.内核初探.系统后台启动简单介绍
- 系统恢复软盘DIY
- 系统热键DIY
- 随身Win8系统DIY
- 无线通信系统DIY
- DIY智能家居系统
- DIY轻量linux
- DIY Linux with Buildroot
- DIY Linux/Mac OSX
- 远程实时监控系统DIY
- 自动测试好帮手,自动点击屏幕AutoClickScreen(含源码)
- PB下面程序移植到VS2005环境(CE6 CEPLAYER)
- asp获取上一页地址的方法
- 几个有用的QQ群
- 只拷贝文件的驱动程序构建方法
- DIY min2440 Linux系统
- C语言中的移位操作
- 让span有固定宽度 兼容IE和firefox
- winCE改变字库方法
- Concatenating Fields
- 数据仓库客户信息整合
- 负载均衡
- C#Application.DoEvents();的作用。
- Windows Mobile boot 过程详解