DZone
IoT Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > IoT Zone > 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 · IoT Zone · Tutorial
Like (0)
Save
Tweet
3.09K 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

  • 8 Must-Have Project Reports You Can Use Today
  • Monolith vs Microservices Architecture: To Split or Not to Split?
  • The Power of Enum: Make Your Code More Readable and Efficient [Video]
  • Biometric Authentication: Best Practices

Comments

IoT Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • 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:

DZone.com is powered by 

AnswerHub logo