ruggedBOARD
Tutorial Using Python
Tutorial Using Python
  • Overview
  • Quick Start with RB
    • Pre-Requisite
      • Required Hardware and Software Components
      • Host Setup
      • Linux Commands
    • Power Up your RB
    • Fiddle with RB Command-line
  • Lib-Mraa & UPM Sensor Libraries (Python)
    • First Python Program
    • Know Your Libraries
      • LibMRAA
        • Python Programming using MRAA (SPI)
        • Python Programming using MRAA (PWM)
        • Python Programming using MRAA (gpio_blink)
        • Python Programming using MRAA (Aio)
      • LibUPM
    • Example Programs for Sensors
      • Procedure to interface phyNODE with RB
      • Accelerometer
      • Temperature Sensor
      • Pressure Sensor
      • Humidity Sensor
      • Magnetometer
      • PIR Sensor
      • Ultrasonic Sensor
      • Gas Sensor (MQ5)
    • mikroBUS UPM Sensor
    • Example programs for Communication Protocols
      • GPIO
      • I2C
      • UART
  • Hello World in C language
    • Setting up Environment
    • Transferring Files from Host to Board
    • Write your first C program
  • IoT Implementation
    • What is IoT?
    • IoT Protocols
    • MQTT Setup
  • Peripherals Functionality Testing using C Language
    • Interfaces
      • GPIO(General purpose Input/Output):
      • UART(Universal Asynchronous Receiver-Transmitter)
      • RS232
      • RS485
      • CAN
      • MikroBUS
      • mPCIe
  • Advance RB
    • Preparing SD card in case of OS failure
Powered by GitBook
On this page

Was this helpful?

  1. Hello World in C language

Write your first C program

PreviousTransferring Files from Host to BoardNextWhat is IoT?

Last updated 6 years ago

Was this helpful?

Step 1: Find a suitable text editor that suits you eg: Atom, Sublime text, vim, notepad ++, etc..

Step2: Write a small C code on your HOST PC and save it with a .c extension(eg: hello.c). You can try our example code given below:

#include <stdio.h>
int main()
{
	printf("Hello board!!\n");
	return 0;
}

Step 3: Open your terminal (ctrl + alt + T), navigate to the Toolchain folder and untar the gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xzfile using the command tar -xvf gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xz.

Step 4: Navigate to the mentioned folder /Toolchain/gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf/binand then type in pwdand copy the path that appears.

Step 5: Open the env.shfile and paste the copied path to the corresponding line.

Step 6: Run the env.shfile by using the command . env.sh. Make sure the the toolchain is running on your PC by typing "arm" and hitting the <TAB> key twice.

If the toolchain isn't running you'll only see a very few of them. NOTE: Do not close or switch your terminal as it will disable the toolchain that is running. We need to compile the C file with the enabled toolchain to get an executable that can be executed on the Board, as our PC is an X86 architecture and the board is an ARM architecture.

Step 7: Navigate back to your C folder and compile the C code using the toolchain enabled terminal. arm-linux-gnueabihf-gcc hello.c -o hello_board

Step 8: Copy the file to /var/lib/tftpboot. Type in cp hello_board /var/lib/tftpbootto copy the binary.

Step 10: Give the necessary permissions chmod +x hello_board

Step 11: Run the binary using ./hello_board

------------------Congratulations on running your first C program on the Board!!--------------------

Step 9: Open a Terminal on the board, Transfer the compiled binary "hello_board" to the board either by TFTP or by SD Card. () Now you can see your binary on the rootfs of the board.

Click here to follow the process to transfer files from Host to Board
Untarring Toolchain
After untarring Toolchain
Enabled Toolchain
You just said hello to your board! :)