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.
$ 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.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
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)
# ifconfig <eth interface> <IP address> netmask <netmask> up
For example:
root@TinyLinux:~# ifconfig eth0 192.168.3.121 netmask 255.255.255.0 up
# 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
For example:
root@TinyLinux:~# scp user@192.168.3.1:/tftpboot/LX2160ARDB/HelloWorld .
root@TinyLinux:~# ./HelloWorld
Hello, World!