How to compile and execute custom applications on a Layerscape board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to compile and execute custom applications on a Layerscape board

How to compile and execute custom applications on a Layerscape board

This topic explains steps to compile and execute Hello World program (in C) on a Layerscape board. Similarly, you can execute other custom applications on your board.

  1. Create a Hello World program in C. 
  2. Copy this file (.c) on a Ubuntu machine (using WinSCP).
  3. Run the following command to convert the .c file into a binary file.
    $ aarch64-linux-gnu-gcc <.c file> -o <binary file>
    For example:
    $ aarch64-linux-gnu-gcc Hello_World.c -o Hello_World 
    Note: You can use this command in the same directory in which .c file is present or provide path of this file.
  4. Connect to the board console on which you want to execute the custom application via terminal and boot the board with LITB.

    Note: It is suggested to boot the board with Tiny Linux for executing custom application. 

    => tftp 0xa0000000 lsdk2004_yocto_tiny_LS_arm64.itb
    Using e1000#0 device
    TFTP from server 192.168.3.1; our IP address is 192.168.3.142
    Filename 'lsdk2004_yocto_tiny_LS_arm64.itb'.
    Load address: 0xa0000000
    Loading: #################################################################
             #################################################################
             #####################################################
             4.3 MiB/s
    done
    Bytes transferred = 37030212 (2350944 hex)
    
    => bootm 0xa0000000#lx2160ardb
    ## Loading kernel from FIT Image at a0000000 ...
       Using 'lx2160ardb' configuration
       Trying 'kernel' kernel subimage
         Description:  ARM64 Kernel
         Created:      2021-02-03   6:01:29 UTC
         Type:         Kernel Image
         Compression:  gzip compressed
         Data Start:   0xa00000d0
         Data Size:    14086432 Bytes = 13.4 MiB
  5. When Tiny Linux boots, enable Ethernet to download the HelloWorld program on the board.
    1. To see the available networks.
      root@TinyLinux:~# ifconfig -a
      eth0      Link encap:Ethernet  HWaddr 68:05:ca:2b:2c:ca
                BROADCAST MULTICAST  MTU:1500  Metric:1
                RX packets:0 errors:0 dropped:0 overruns:0 frame:0
                TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
                Interrupt:114 Memory:90460c0000-90460e0000
      
      lo        Link encap:Local Loopback
                inet addr:127.0.0.1  Mask:255.0.0.0
                inet6 addr: ::1/128 Scope:Host
                UP LOOPBACK RUNNING  MTU:65536  Metric:1
                RX packets:0 errors:0 dropped:0 overruns:0 frame:0
                TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
      
      sit0      Link encap:UNSPEC  HWaddr 00-00-00-00-31-00-6C-6F-00-00-00-00-00-00-00-00
                NOARP  MTU:1480  Metric:1
                RX packets:0 errors:0 dropped:0 overruns:0 frame:0
                TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
      
    2. Enable the Ethernet connection.
      # ifconfig <eth interface> <IP address> netmask <netmask> up
      For example:
      root@TinyLinux:~# ifconfig eth0 192.168.3.121 netmask 255.255.255.0 up
    3. Set the gateway IP and ping the server to test the connection.
      # route add default gw <gateway IP>
      # ping <server IP>
      For example:
      root@TinyLinux:~# route add default gw 192.168.3.1
      root@TinyLinux:~# ping 192.168.3.1
      PING 192.168.3.1 (192.168.3.1): 56 data bytes
      64 bytes from 192.168.3.1: seq=0 ttl=64 time=0.479 ms
      64 bytes from 192.168.3.1: seq=1 ttl=64 time=0.204 ms
      
  6. Download the HelloWorld binary file on your board.
    For example:
    root@TinyLinux:~# scp user@192.168.3.1:/tftpboot/LX2160ARDB/HelloWorld .
    
  7. Execute the HelloWorld application.
    root@TinyLinux:~# ./HelloWorld
    Hello, World!

 

 

No ratings
Version history
Last update:
‎03-17-2021 02:24 AM
Updated by: