Polar route 1s (mt7620a) openwrt cross-compiling Go program

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Cause, because the coolpy5 core transition to go language development, so at present Superman is carrying out related technical research, in the process of writing everything is relatively smooth. Since Coolpy5 is a real business-grade performance system also filtered to coolpy prior to the release of Coolpy is supported by home routers for fog compute nodes directly to implement smart home or intelligent agriculture offline solution, so super talent carried out this technology prediction test, Also for the future coolpy this link closed loop for the preparation work. The following article about OPENWRT related to the basis will be skipped, do not understand the friends please find the relevant knowledge points on their own.

Skip the point of Knowledge:

1.linux Foundation (cross-compilation basis)

2.OPENWRT Management (OpenWrt Foundation)

Game start:

1. First connect to the router via putty to see the Router CPU architecture/There is an error in this, you see all the CPU-related descriptions are MIPS word, in fact, very 1s router of this cpu (MT7620A) is Mipsel architecture, That is, in cross-compilation we set the Goarch parameter should be mips32le correct, if you use the CPU is MIPS with other routers, please set this parameter to MIPS32.

2. Cross-compilation environment configuration, GO-MIPS32 this project maintenance number is 400+ person, I personally speculate this may be Golang team lead, Hope later can formally integrate into the new version of Golang.

Download Go-mips32 Source
git clone https://github.com/gomini/go-mips32.git
CD GO-MIPS32/SRC

Configuring go Compilation parameters
Export Goos=linux
Export Goarch=mips32le <== Change to MIPS32 if MIPS

Perform the compilation

./make.bash
Cd..

Create a post-compilation File Store folder
sudo mkdir/opt/mipsgo

Copy
sudo cp-r */opt/mipsgo

Go Engineering parameter configuration
Export Goroot=/opt/mipsgo
Export Path=/opt/mipsgo/bin: $PATH

3. Compile the Go program as a test

Mkdir/opt/slu

Cd/opt/slu

Vim Main.go

Source...................................................................

Package Main

Import "FMT"

Func Main () {
Fmt. Println ("Hello icoolpy.com")
}
Source.........................................................
Save exit

As the above has already been set path, you should compile and package the go source code directly in the. Go program folder to be packaged directly under go Build command to go build main.go

In the current directory will generate a compiled executable file, this file is our program, can be directly in the polar route 1s openwrt system running

Upload the main file to the router file system via WINSCP

The right to the main file, by default, the main file is not execute permissions, so through the command to let it can be run, after the successful modification can see the main file is shown as green.

Perform the main program test run

Hello icoolpy.com has been printed, stating that the program is working properly.

Add....................................................................................

If the developed source code needs to refer to other sources, you need to put the source of these packages into the target directory (in this case) before the Go Build command executes:/opt/mipsgo/src/

Note: If you are using a virtual machine running the compilation system, in the main system to drag and drop the package to the virtual system to pay attention to whether the copied files are normal, preferably packaged as a zip and then dragged into the virtual system.

Conclusion:

Coolpy5 will continue to support the hub node running offline on the internet as a fog computing terminal for the IoT system designed and developed for the purpose of designing and developing the above billion-level IoT operating equipment.

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.