To create the SD image for SAMA5D27-SOM1-EK, it is required a PC running linux (i.e: Ubuntu desktop 19.10)
1. Installing mandatory packages in the PC:

    sudo apt-get install sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget

2. Installing other packages in the PC:

    sudo apt-get install libncurses5-dev libncursesw5-dev bzr cvs git mercurial rsync subversion graphviz python-matplotlib

3. Getting sources:

    git clone https://github.com/linux4sam/buildroot-at91.git
    git clone https://github.com/linux4sam/buildroot-external-microchip
    git checkout tags/linux4sam_6.2 -b buildroot-at91-linux4sam_6.2
    git checkout tags/linux4sam_6.2 -b buildroot-ext-mchp_linux4sam_6.2

4. Build rootfs image

In buildroot-at91 folder:
    BR2_EXTERNAL=../buildroot-external-microchip/ make sama5d27_som1_ek_headless_defconfig
    make

5. Customizing Buildroot

    make menuconfig

Enable the packages:
    - \Target packages\Networking applications\iputils
    - \Target packages\Networking applications\openssh
    - \Target packages\Shell and utilities\inotify-tools (only for the example bash file of the application note)

Note: New version uses glibc, not uClibc

6. Run Buildroot compilation

    make

7. Kernel configuration

    make linux-menuconfig

Enable as module:
    - \Device Drivers\Network Device Support\"Universal TUN/TAP device driver support"

    make linux-build

8. Creation of SD image

    make

9. Copy SD image to SD card (not uSD)

    Copy /linux_coord/buildroot-at91/output/images/sdcard.img to SD card (i.e: using balenaEtcher)

10. Connect SD card to SAMA5D27-SOM1-EK1 an power-up

11. Config IP address in SAMA5D27-SOM1-EK1 linux to access easily to it

For example:
    ip address add 192.168.1.102/24 dev eth0
    ifconfig eth0 up

So <target-ip-address> is 192.168.1.102

-------------- Coordinator example ---------------------
Using USI_host v2.0.0

12. Compile example:

- Copy example package to PC linux. For example, in linux_coord folder:

    cp <source>/010-usi-host-g3coord_linux ~/linux_coord/010-usi-host-g3coord_linux
    cd ~/linux_coord/010-usi-host-g3coord_linux
  
- Select cross-compiler

    export CROSS_COMPILE=~/linux_coord/buildroot-at91/output/host/bin/arm-buildroot-linux-gnueabihf-

- Clean and compile code

    make clean && make all

13. Copy application to EK

    scp g3coordd root@<target-ip-address>:/usr/bin

14. Initialize TUN in EK

    - First time after creating image
  
    mkdir /dev/net
    mknod /dev/net/tun c 10 200
    chmod 0666 /dev/net/tun

    - Every time the board is rebooted, before launching coordinator application

    modprobe tun

15. Test coordinator example

15.a. Launch coordinator application in EK

    g3coordd -b CEN_A -d /dev/ttyS1 -s 230400

15.b. Or, copy & launch bash file ping_app.sh in EK















