DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Languages
  4. Internet Programming on an ARM Guest

Internet Programming on an ARM Guest

Getting network programming working in embedded Linux used to be a pain. Not anymore. See cross-compiling in action when using an ARM QEMU guest.

Christopher Lamb user avatar by
Christopher Lamb
CORE ·
Jan. 25, 17 · Tutorial
Like (0)
Save
Tweet
Share
3.24K Views

Join the DZone community and get the full member experience.

Join For Free

Okay, so there are a couple of ways you can run networking on an ARM QEMU guest. The easiest is via SLIRP, the default user mode networking. It's slow and chatty, but for most IoT work, that's okay. There are alternative, higher performance approaches, but they hijack your local interface to the virtual bridge, removing networking from your host. This is fine, sometimes, but not that frequently. It's a real pain to work with if you're using it day-to-day, but handy for late-stage testing. Anyway, we're not going to use that. We'll use SLIRP instead.

Okay, first, use buildroot to configure an ARM image that includes libcurl. Using our previous buildroot configuration, just go to Target packages -> Libraries -> Networking, and select libcurl:

Image title

Go ahead and select the binary, too. This is handy for connectivity testing.

Now make your new image, and spin it up with QEMU, like we did in my previous article. You'll need to configure it with a new user too. Then test your internet connectivity:

Image title

Curl is especially useful for this when you're running in SLIRP mode because ICMP traffic (i.e. ping) isn't really supported (you can turn it on, but there's really no need, and it's kind of a hassle).

Now, build your ARM program from the previous article, using the IP address of your host. Remember, the QEMU command we use redirects host port 2222 to guest port 22, so you need to take this into account when you SCP the executable over:

$ scp -P 2222 test <username>@localhost:~/
<username>@localhost's password: 
test        100% 7204     7.0KB/s   00:00


Now, when you compiled the test program, you inserted the host IP address, right? Of course you did. Now, spin up Python's SimpleHTTPServer on your host, and run the test program on your guest:

Image title

Here, you can see my session on the guest on the left, where I ran the test program. The output is the directory listing, HTML-ized. On the right, you can see the GET request recorded in the SimpleHTTPServer session. You can also see all my tmux goodness, but you can ignore that.

Anyway, that's all there is to it! You've successfully run your first ARM cross-compiled networking program!

Arm (geography) Internet (web browser) Host (Unix) Testing IT Session (web analytics) Buildroot SPIN (software process) Python (language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How We Solved an OOM Issue in TiDB with GOMEMLIMIT
  • How Elasticsearch Works
  • AWS CodeCommit and GitKraken Basics: Essential Skills for Every Developer
  • Use Golang for Data Processing With Amazon Kinesis and AWS Lambda

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: