ARM Notes:
1--Using the Jlink in Linux Operating System:=1= Install the libusb library:
sudo apt-get install libusb-dev
=2= Download The Jlink Driver for Linux
Unzip the Driver,Enter the Directory:
Run the Command below in the terminate with root Right to Copy the shared libraries to /usr/lib directory:
mv libjlinkarm.so.4/usr/lib/
mv libjlinkarm.so.4.22.0/usr/lib/
=3=Now We Can Run the JlinkExe or Start file to Run the software:
sudo ./start
or
sudo ./JlinkExe 2--Use the PUTTY instead of SecureCRT in Ubuntu Linux
=1=Install ssh protocol :
sudo apt-get install ssh
=2=Install the FTP Server vsftp
sudo apt-get install vsftp
After installed , it must be configured and restart
=3=Use the FileZilla replace the CuteFTP.
Before use the putty to visit the other linux OS , you must make sure the firewall has been closed or properly configured . 3-- Install the Serial Soft And Export the linux-arm-gcc to the PATH
========== Vedio:(please change the suffix to .tar.7z)================
点击此处下载 ourdev_633406I5XS1E.rar(文件大小:20.61M) (原文件名:Ubuntu_ARM_1Step__.mpeg.tar.7z.rar) 4--Use the DNW or usb2ram download the user progrom to the ARM
==========from:http://apps.hi.baidu.com/share/detail/22264303==========
ubuntu下ARM开发环境的配置
以下配置是个人总结,在自己的电脑上测试通过,按此方法配置请根据自身情况修改
一般C语言开发环境的安装:
sudo apt-get install build-essential
Minicom的安装:
#lsmod | grep usbserial
#sudo apt-get install minicom
#minicom -s /配置minicom
A-Serial Device:/dev/ttyUSB0 因为我是USB转串口
E-Bps/Par/Bits:115200 8N1
F和G均用NO
然后保存为dfl
tftp的安装:
sudo apt-get install tftp-hpa tftpd-hpa
sudo apt-get install xinetd
建立tftp服务的目录
cd /
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot
sudo gedit /etc/xinetd.d/tftp
文件内容如下:
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot -c
per_source = 11
cps = 100 2
}
然后sudo /etc/init.d/xinetd restart
sudo in.tftpd -l /tftpboot
用网线连接计算机和开发板后,设置好计算机的IP地址,然后打开tftp服务,进入开发板终端,输入tftp -gr filename 计算机IP 便可下载程序,程序必须位于/tftpboot下
将有线网卡的IP地址设为静态:
sudo gedit /etc/network/interfaces
加入以下几行
auto eth0
iface eth0 inet static
address 192.168.1.88
gateway 192.168.1.1
netmask 255.255.255.0
arm-linux-gcc的安装:
下载包后,在/usr/local/下建立名为arm的文件夹,然后解压缩,将里面的bin文件夹添加到环境变量,方法如下
sudo gedit /etc/profile
在后面加入export PATH="$PATH:/usr/local/arm/2.95.3/bin",根据版本不同文件夹名字也不一样,bin目录下有arm-linux-***一些文件就是我们要找的,然后注销使环境变量生效
echo $PATH可以看看设置是否成功
像一般的C一样写个hello.c
然后arm-linux-gcc hello.c -o hello
编译好的hello在ubuntu下运行不了,可以./hello试下
用上面的tftp把hello弄到开发板的/tmp目录下,然后chmod 777 hello后就可以运行了 /*usb2ram.cGNU License*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <usb.h>
const char *
hexdump(const void *data, unsigned int len)
{
static char string;
unsigned char *d = (unsigned char *) data;
unsigned int i, left;
string = '\0';
left = sizeof(string);
for (i = 0; len--; i += 3) {
if (i >= sizeof(string) -4)
break;
snprintf(string+i, 4, " %02x", *d++);
}
return string;
}
#define QT2410_VENDOR_ID 0x5345
#define QT2410_PRODUCT_ID 0x1234
#define QT2410_OUT_EP 0x03
#define QT2410_IN_EP 0x81
static struct usb_dev_handle *hdl;
static struct usb_device *find_qt2410_device(void)
{
struct usb_bus *bus;
for (bus = usb_busses; bus; bus = bus->next) {
struct usb_device *dev;
for (dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.idVendor == QT2410_VENDOR_ID
&& dev->descriptor.idProduct == QT2410_PRODUCT_ID
&& dev->descriptor.iManufacturer == 1
&& dev->descriptor.iProduct == 2
&& dev->descriptor.bNumConfigurations == 1
&& dev->config->bNumInterfaces == 1
&& dev->config->iConfiguration == 0)
return dev;
}
}
return NULL;
}
static u_int16_t qt2410_csum(const unsigned char *data, u_int32_t len)
{
u_int16_t csum = 0;
int j;
for (j = 0; j < len; j ++) {
csum += data;
}
return csum;
}
#define CHUNK_SIZE 100
static int qt2410_send_file(u_int32_t addr, void *data, u_int32_t len)
{
int ret = 0;
unsigned char *buf, *cur;
u_int16_t csum = qt2410_csum(data, len);
u_int32_t len_total = len + 10;
printf("csum = 0x%4x\n", csum);
/* 4 bytes address, 4 bytes length, data, 2 bytes csum */
buf = malloc(len_total);
if (!buf)
return -ENOMEM;
/* FIXME: endian safeness !!! */
buf = addr & 0xff;
buf = (addr >> 8) & 0xff;
buf = (addr >> 16) & 0xff;
buf = (addr >> 24) & 0xff;
buf = len_total & 0xff;
buf = (len_total >> 8) & 0xff;
buf = (len_total >> 16) & 0xff;
buf = (len_total >> 24) & 0xff;
memcpy(buf+8, data, len);
buf = csum & 0xff;
buf = (csum >> 8) & 0xff;
printf("send_file: addr = 0x%08x, len = 0x%08x\n", addr, len);
for (cur = buf; cur < buf+len_total; cur += CHUNK_SIZE) {
int remain = (buf + len_total) - cur;
if (remain > CHUNK_SIZE)
remain = CHUNK_SIZE;
#if 0
printf("sending urb(0x%08x): %s\n",
addr + (cur - buf), hexdump(cur, remain));
#endif
if((cur-buf)%(500*CHUNK_SIZE)==0){
printf("+\n");
}
ret = usb_bulk_write(hdl, QT2410_OUT_EP, cur, remain, 0);
if (ret < 0)
break;
}
free(buf);
return ret;
}
#if 0
static int qt2410_send_file(u_int32_t addr, void *data, u_int32_t len)
{
int i, ret;
u_int32_t cur_addr;
void *cur_data;
for (cur_addr = addr, cur_data = data;
cur_addr < addr + len;
cur_addr += CHUNK_SIZE, cur_data += CHUNK_SIZE) {
int remain = (data + len) - cur_data;
if (remain > CHUNK_SIZE)
remain = CHUNK_SIZE;
ret = qt2410_send_chunk(cur_addr, cur_data, remain);
if (ret < 0)
return ret;
}
return 0;
}
#endif
#define KERNEL_RAM_BASE 0x30008000
//#define KERNEL_RAM_BASE 0x33F80000
u_int32_t str2hex(char *str)
{
u_int32_t tmp;
u_int32_t hex=0;
int i;
for(i=0;i<strlen(str);i++)
{
tmp=str-'0';
hex+=pow(16,7-i)*tmp;
}
return hex;
}
int main(int argc, char **argv)
{
struct usb_device *dev;
char *filename, *prog;
struct stat st;
int fd;
u_int32_t word = 0x7c7c7c7c;
u_int32_t ram_base;
if(argc==2){
ram_base=KERNEL_RAM_BASE;
filename = argv; }
else if(argc==3){
ram_base=str2hex(argv);
//printf("\nram_base=%x\n",ram_base);
filename = argv; }
else{
printf("Usage:usb2ramaddrfilename\n");
printf("i.e: usb2ram30008000led.bin\n");
exit(1);
}
usb_init();
if (!usb_find_busses())
exit(1);
if (!usb_find_devices())
exit(1);
dev = find_qt2410_device();
if (!dev) {
printf("Cannot find MY-2410 device in waiting download mode\n");
exit(1);
}
hdl = usb_open(dev);
if (!hdl) {
printf("Unable to open usb device: %s\n", usb_strerror());
exit(1);
}
if (usb_claim_interface(hdl, 0) < 0) {
printf("Unable to claim usb interface 1 of device: %s\n", usb_strerror());
exit(1);
}
if (!filename) {
printf("You have to specify the file you want to flash\n");
exit(2);
}
fd = open(filename, O_RDONLY);
if (fd < 0){
printf("Can not open %s",filename);
exit(2);
}
if (fstat(fd, &st) < 0) {
printf("Error to access file `%s': %s\n", filename, strerror(errno));
exit(2);
}
/* mmap kernel image passed as parameter */
prog = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (!prog)
exit(1);
if (qt2410_send_file(ram_base, prog, st.st_size)) {
printf("\nEnd of downloading program\n");
exit(1);
}
exit(0);
} /*Makeflie of usb2ram*/
#!/usr/bin/make
cc=gcc
LDFLAGS=-lusb -lm
all: usb2ram
clean:
-rm -f *.o usb2ram
usb2ram: usb2ram.o
$(CC) $(LDFLAGS) -o $@ $<
boot_usb.o: boot_usb.c
$(CC) $(CFLAGS) -o $@ -c $<
.PHONEY: all clean
============(orignal)from: http://blog.csdn.net/dengchendeng/archive/2010/11/24/6033533.aspx===============
usb2ram软件下载地址:
http://forum.ubuntu.org.cn/viewtopic.php?f=97&t=107504
下载下来的压缩包中解压后是有一个可执行文件的,但是这个可执行文件一般不能执行,需要在自己的系统上重新编译才能用
首先要修改Makefile文件,在第一行之后添加如下这行,用以设定编译器:
CC=gcc
修改之后的Makefile文件如下:
#!/usr/bin/make
CC=gcc
LDFLAGS=-lusb -lm
all: usb2ram
clean:
-rm -f *.o usb2ram
usb2ram: usb2ram.o
$(CC) $(LDFLAGS) -o $@ $<
boot_usb.o: boot_usb.c
$(CC) $(CFLAGS) -o $@ -c $<
.PHONEY: all clean
编译前先清除无用的文件,以确保后面能够正常编译,这时执行一下命令:
make clean
再次编译前要确保有libusb 和libusb-dev两个库,我是看的网上文章的提示。若是没有,编译时就会提示:
cc -lusb -lm -o usb2ram usb2ram.o
/usr/bin/ld: cannot find -lusb
collect2: ld returned 1 exit status
make: *** 错误 1
于是我就输入命令: sudo apt-get install libusb libusb-dev进行两个库的安装
这时又有提示:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
E: 无法找到软件包 libusb
说是找不到libusb,这时我就输入如下命令:
sudo apt-get install libusb-dev
只安装libusb-dev这个库,这个库可以找的到,安装好之后再make,就成功生成了usb2ram可执行文件
下面讲讲它的用法:
我用的是TQ2440的开发板,首先确保norflash里面有bootloader,这时选择从norflash启动,
出现如下菜单界面:
##### Boot for Nand Flash Main Menu#####
Download u-boot to Nand Flash
Download Eboot
Download Linux Kernel
Download WinCE NK.bin
Download CRAMFS image
Download YAFFS image
Download to SDRAM & Run
Boot the system
Format the Nand Flash
Set the boot parameters
Download User Program
Download LOGO Picture (.bmp) to NandFlash
Set LCD Parameters
Reboot u-boot
quit from menu
Enter your selection:1
在这里我选择的是1:下载uboot到nandflash
这时终端提示:
USB host is connected. Waiting a download.
表示你现在可以使用usb2ram软件下载镜像文件了
这时启动另外一个终端,进入usb2ram可执行文件所在的目录,输入一下命令:
sudo ./usb2ram 30000000 /home/deng/ARM/images/u-boot_W35.bin
这个命令的形式是:sudo ./usb2ram地址文件
一开始在命令之前没有加sudo,提示如下错误:
Unable to claim usb interface 1 of device: could not claim interface 0: Operation not permitted
加上之后就好了
现在切换到由nandflash启动,启动时按住空格建进入下载模式,这时跟norflash启动效果一样,说明uboot已经下载到了nandflash中
也可以用同样的方法将其他的镜像下载只开发板 CH340 CH341 , USBToRS232 Driver for Windows 7 X64:
(验证可用的CH340,CH241的USB转RS232 在windows 7 64位系统下的驱动):
点击此处下载 ourdev_639722FX7BGG.ZIP(文件大小:159K) (原文件名:CH341SER.ZIP) 7 --Install the VMWare in Ubuntu:
<1> Copy the Installer to the Ubuntu Filesystem : eg copy to the home directory
<2> sudo chomd 777 VWware****.bundle
<3> sudo ./VMware***.bundle
then follow the direction click the next button to the finish .
页:
[1]