UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Adam Taylor’s MicroZed Chronicles Part 137: Getting the Snickerdoodle to say “hello world” and wireless transfer

by Xilinx Employee on ‎07-05-2016 12:46 PM (64,351 Views)

 

By Adam Taylor

 

With the Snickerdoodle up and running and talking to the network, my next step is to develop a simple “hello world” program to run on the current Linux build. It’s very straightforward to do this. All we need is to use is the Xilinx SDK. Because we are developing the program for an existing Linux kernel, we do not need to use a hardware definition or a BSP. Instead we can open SDK and select

 

 

file -> open -> new application project

 

 

Within the dialog box, select the operating system as Linux and leave all of the other boxes empty, apart from the project name.

 

 

Image1.jpg 

 

Click on next and select the “hello world” example. Once this folder has opened, you will see the helloworld.c file under the src directory within the project explorer. Obviously we can increase the complexity of the program. However, for now I just want to pipe-clean the process of running the application.

 

The next step is build the source code and generate the ELF file, which will end up under your Debug or Release directories depending upon your current build setting.

 

To run this file, we need to transfer it into the file system of the SD Card. There are a number of ways we can do this. The simple way is to transfer the ELF file to the SD card using the development PC. The more complex way is to use file sharing over WiFi. To finish off this blog, we will look at both ways.

 

To do both, we need to download some software for our development PC.

 

The simplest manner to transfer the “hello world” program into the Linux file system is to insert the SD Card into the development PC and transfer the file. If you are developing on a Linux system this should be no issue. However, if you are running a Windows development PC like I am, then you will run into file system issues. This means your Windows PC will not be able to see the file system without software that can see the Ext2 file system Linux uses. I downloaded the ext2ifs application from http://www.fs-driver.org/, which allowed me to transfer files to the SD Card’s root fs. I had no issues when I later ran the executable from the SD Card.

 

Of course the more interesting approach enables us to take full advantage of WiFi connectivity to transfer files. To do this, I used WinSCP and enabled remote log on over SSH. Transferring files was then as simple as drag and drop to and from the SD Card in the Snickerdoodle.

 

But to use WiFi for transferring files, first we have to configure the Snickerdoodle to allow us to access it remotely over SSH. The first thing to do is to set a password for the root account. We do this using the command sudo passwd. You will be asked to enter your chosen password twice, do not forget it. We’ll need it.

 

The next step is to edit the SSH configuration file. Similar to last week, we can use VI to edit this:

 

 

Image2.jpg 

 

Within the file, scroll down to the line “PermitRootLogin without-password” and comment it out. Then on the line below, enter “PermitRootLogin yes” and then save and exit the file.

 

 

 Image3.jpg

 

 

With the file saved, exit VI. We can then restart the SSH service before we try to log in. We do this with the command service ssh restart. Once this is completed we can try logging in from Putty using SSH and the Snickerdoodle’s IP address (see last week’s blog for how to connect to a WiFi network). If successful, we should see an interface very similar to an RS-232 serial terminal interface.

 

If you can log in, close the Putty session and open the WinSCP program. Leave the protocol as default and enter the user name (root) and password and then click connect. This will open a GUI like the one shown below which shows the files on your PC and the Snickerdoodle.

 

 Image7.jpg

 

 

Navigate to where you wish to move the file to on the Snickerdoodle and then find the ELF you wish to run within your workspace. Moving the file is as simple as clicking on upload and then selecting the correct setting from the transfer settings dialog.

 

 

Image4.jpg 

 

Image5.jpg

 

 

To ensure that the program executed correctly, I set the execute permission. Once the program file is uploaded, you should see it in appear under the Snickerdoodle window within WinSCP.

 

To confirm that it is present, you can use the RS-232 command line to navigate to the target directory for the transfer and then perform an ls command. You should see it present in the target directory.

 

Within the command line, type sudo ./<programme_name.elf> to execute the program and you should see the resulting “hello world” as shown below:

 

 

Image6.jpg 

 

We can of course use this facility to transfer all sorts of files to and from the Snickerdoodle wirelessly.

 

 

The code is available on Github as always.

 

If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.

 

 

 

  • First Year E Book here
  • First Year Hardback here.

 

 

 

 MicroZed Chronicles hardcopy.jpg

 

 

  • Second Year E Book here
  • Second Year Hardback here

 

 

MicroZed Chronicles Second Year.jpg

 

Comments
by Visitor jweatherbee
on ‎07-06-2016 12:00 AM

 

Also, I wanted to mention a "third" way.  And that is to simply put helloworld.c on the snickerdoodle over SSH and compile it there.

nano is also available for easier remote text file editing.

1.png

 

As a side note Nick Burkitt has managed to also get Linux TCF working here on snickerdoodle: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/krtkl-snickerdoodle/Nc0dUQQ98zA

We will probably build that into the stock root file system.

by Observer taylo_ap
on ‎07-10-2016 03:42 AM

Hi Jamil,

 

That is a very good point, I should have mentioned also that we can compile on the snickerdoodle as well. 

 

Cheers

 

Adam 

Labels
About the Author
  • Be sure to join the Xilinx LinkedIn group to get an update for every new Xcell Daily post! ******************** Steve Leibson is the Director of Strategic Marketing and Business Planning at Xilinx. He started as a system design engineer at HP in the early days of desktop computing, then switched to EDA at Cadnetix, and subsequently became a technical editor for EDN Magazine. He's served as Editor in Chief of EDN Magazine, Embedded Developers Journal, and Microprocessor Report. He has extensive experience in computing, microprocessors, microcontrollers, embedded systems design, design IP, EDA, and programmable logic.