Arm-linux Learning Notes-(virtual machine Linux serial terminal and USB program download, based on TQ2440)

Source: Internet
Author: User
Tags goto

Yesterday, after installing the SSH service on Windows with Xshell landing found on the login is not on, because of the use of VirtualBox NAT mode, in NAT mode, the client can easily surf the internet, but want to link the host will need to open network address mapping

The first thing to know is that the SSH service is using 22 port, then open the adapter on the Windows host, VirtualBox installed a virtual network card, as follows

Virtual address is 192.168.56.1, next in the Virtual machine settings interface set network address mapping, first of all, also know the IP address of the virtual machine, as follows

The address is 10.0.2.15, you can do the port forwarding, the location is as follows

Follow the steps, set the name arbitrarily, the host IP is set to the IP of the virtual machine NIC, the port can write an unoccupied port, the subsystem IP is the Linux host IP, the port is the SSH service port, It is equivalent to say that when we connect SSH connection 192.168.56.1 2222 port, wirtualbox the data forward to the host's 22 port, after this one relay can login SSH, the next new SSH connection is as follows

Note the host and port number settings, as I said before, so that you can enter the user name password after the connection, as follows

Settings for shared folders

VirtualBox provides the ability to share folders, although it is written to mount automatically, but usually Ubuntu is not automatically mounted, as follows

This time we need to manually hang in the system in the shared folder, first you need to install the enhanced Feature Pack, usually installed, installed after the virtual machine used to be cool

Then create a folder to mount the shared folder

Mkdir/mnt/linuxshare

Can be built in a different location, but I'm used to being here, after the establishment can be mounted

Mount-t vboxsf Linuxshare/mnt/linuxshare

The first linuxshare is the name you made when you created the shared folder.

The second/mnt/linuxshare is the directory where you create the Mount folder

Command completed without error message Mount succeeded, then close terminal, reopen terminal

Vim/mnt/linuxshare/text.c after saving, the text.c file should appear in the shared folder under Windows.

Sometimes the command does not remember, the English document is more troublesome when we can choose to install the Chinese Help pack use the command

sudo apt-get update source

sudo apt-get install Manpages-zh installation Chinese manual

The man LS should be a Chinese hint after installation is complete.

Next is the serial port sharing problem, I use the USB to the serial port Chip ft232, This chip ubuntu14.02 comes with the driver, does not need additional installation, but we want this physical USB to the serial port to switch into the virtual machine inside, first installs a package, is the Wirtualbox usb2.0 enhancement Package, the name is called Oracle_vm_virtualbox_ Extension_pack-4.3.26-98988.vbox-extpack, Baidu Search on the official website of Oracle download, download after installation will be able to start usb2.0 support, followed by the following settings

Follow the settings to add this USB, and then restart the system, the reboot should be able to see the USB to the serial device, so view

If you don't have this device to see if it pops up, you can pop it up here

Serial equipment installed after the device opened, we know that the device on Linux is the corresponding files, serial device corresponding files here

/dev/ttyusb0

Next is the serial communication, we install two serial communication software, a command line a graphical, use the command

sudo apt-get install minicom//command line debugging assistant

sudo apt-get install cutecom//graphical debugging assistant

After installing the minicom, you need to set the command to

sudo minicom-s

Set the following

Save as default profile after Setup is complete, exit the interface, and enter it again

Minicom, automatically open the serial port (if it fails to open, the bottom right corner of the screen shows offline)

Then I hit the TQ2440 Development Board on my hand to norflash boot (nor has the bootloader), the display interface is as follows

Okay, here's the serial communication done, and then we need to get the USB to get rid of windows.

The first step is to download the installation Libusb-dev, as follows

sudo apt-get install Libusb-dev

After the installation is complete, remember to import the TQ2440 USB port into Linux, as follows

It's going to be a success here, download the program we need a tool, Windows has a dnw, someone did the DNW2, the source code is as follows

/*DNW2 Linux main file. This depends on Libusb. * * Author:fox <[email protected]> * LICENSE:GPL **/#include<stdio.h>#include<usb.h>#include<errno.h>#include<sys/stat.h>#include<fcntl.h>#include<unistd.h>#defineQq2440_secbulk_idvendor 0x5345#defineQq2440_secbulk_idproduct 0x1234structUsb_dev_handle *Open_port () {structUsb_bus *busses, *bus;    Usb_init ();    Usb_find_busses ();    Usb_find_devices (); Busses=usb_get_busses ();  for(bus=busses;bus;bus=bus->next) {         structUsb_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"); structUsb_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; }                }                returnHdev; }}} printf ("Target USB Device not found!\n"); returnNULL;}voidusage () {printf ("USAGE:DNW2 <file>\n\n");} unsignedChar* PREPARE_WRITE_BUF (Char*filename, unsignedint*Len) {unsignedChar*write_buf =NULL; structStat FS; intFD =open (filename, o_rdonly); if(-1==FD) {Perror ("cannot open file"); returnNULL; }    if(-1==fstat (FD, &FS)) {Perror ("cannot get file size"); Gotoerror; } write_buf= (unsignedChar*)malloc(fs.st_size+Ten); if(null==write_buf) {Perror ("malloc failed"); Gotoerror; }    if(Fs.st_size! = Read (FD, write_buf+8, Fs.st_size)) {Perror ("Reading file failed"); Gotoerror; } 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 +Ten;//download size;*len = Fs.st_size +Ten; returnWrite_buf;error:if(fd!=-1) Close (FD); if(NULL!=WRITE_BUF) Free(WRITE_BUF); Fs.st_size=0; returnNULL; }intMainintargcChar*argv[]) {    if(2!=argc)        {usage (); return 1; }    structUsb_dev_handle *hdev =Open_port (); if(!Hdev) {        return 1; } unsignedintLen =0; unsignedChar* Write_buf = Prepare_write_buf (argv[1], &Len); if(NULL==WRITE_BUF)return 1; unsignedintremain =Len; unsignedintTowrite; printf ("Writing data ... \ n");  while(remain) {Towrite= remain> +? +: Remain; if(Towrite! = Usb_bulk_write (Hdev,0x03, write_buf+ (Len-remain), Towrite, the) {perror ("Usb_bulk_write failed");  Break; } remain-=Towrite; printf ("\r%d%\t%d bytes", (Len-remain) * -/len, len-remain);    Fflush (stdout); }    if(0==remain) printf ("done!\n"); return 0;}

Copy to Linux and create the file dnw2.c, then go to its directory and compile the file

GCC Dnw2.c-o dnw2-lusb

Compile the time there are two small warnings, it does not matter, look at the directory, generated the DNW file as follows

Add the path of the file to the environment variable, the path depends on where you put it, such as I put in the/HOME/WORK/DNW2, then I modify the/etc/environment file to look like this

Path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/ HOME/WORK/GCC-ARM-NONE-EABI-4_9-2015Q1/BIN:/HOME/WORK/DNW2"

The last one is my path

When you are done, remember

Source/etc/environment

At this time the environment variable is loaded successfully, then you can download directly, find a previous good bin file, burn write command as follows

DNW2 file name

If DNW2 can't find out whether the environment variable is not added, this command must be run in root mode

Sudo-i

Source/etc/environment

DNW2 file name

This should be okay, there's still a problem, look.

Echo $PATH look at the environment variables right

Here we can happily burn the kernel, mirror, bare-metal programs under Linux.

In addition, each time you write the need to manually insert the TQ2440USB device in the USB, you can also set the filter directly, the main reason is that after the completion of the Write 2440 USB device unplugged

It says Cutecom, it's used like this.

Well, today's note basically finished, the development environment basically OK

Arm-linux Learning Notes-(virtual machine Linux serial terminal and USB program download, based on TQ2440)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.