Binaries in this directory and sub-directories are build with QT 5.15.15 on ARM-64 Debian-13 version of Arduino Uno Q OS.

Following are the sequence of steps to configure Arduino Uno Q for remote headless mode and to install CASP Remote Build Tools.
Use Linux terminal for writing commands mentioned in each of these steps.

- Connect monitor, keyboard and mouse to board and power it up. Use power supply with atleast 3Amp current rating.

- Login to 'arduino' user name with proper password. Ensure the board is connected to the internet.

- Update and upgrade system
   - sudo apt update -y
   - sudo apt upgrade -y

- Disable Arduino App-Lab from starting during boot
   - click start button on top left, goto Settings->Session and Startup->Application Autostart and uncheck Arduino App Lab

- Disable sleep and display off timeout
   - xset s off -dpms
   - also, click start button on top left, goto Settings->Session and Startup->Application Autostart and uncheck Screen Locker

- Auto Login to Arduino (optional)
   - open the related configuration file in nano editor
     - sudo nano /etc/lightdm/lightdm.conf
   - change the commented lines
     - #autologin-user=
       #autologin-user-timeout=0
     to
     - autologin-user=arduino
       autologin-user-timeout=10
     - press Ctrl-O then Enter to save, and Ctrl-X to exit

- Install any light weight GUI text editor (optional): eg. geany
   - sudo apt install geany -y

- Install remote desktop protocol (RDP) server
   - sudo apt install xrdp dbus-x11 -y
   - sudo systemctl enable xrdp
   - sudo systemctl start xrdp
   and after this access from windows default remote destop connection: <IP>:3389

- Enable SSH service (required for remote flashing MCU)
   - sudo /usr/bin/ssh-keygen -A
   - sudo systemctl enable ssh
   - sudo systemctl start ssh

- Install Samba to share folder on network
   - create a folder within your home folder
   - set its permissions (optional): sudo chmod -R 0777 <share_folder_path>
   - install samba: sudo apt install samba -y
   - open samba configuration file: sudo nano /etc/samba/smb.conf
     - scroll to the bottom and add your new share block (mentioned below) at the end
       [SharedFolder]
       comment = Network Share
       path = <your_shared_folder_path eg. /home/arduino/ShareFolder1>
       browsable = yes
       writable = yes
       guest ok = yes
       read only = no
     - press Ctrl-O then Enter to save, and Ctrl-X to exit
   - create a samba user password: sudo smbpasswd -a <your_username>
   - restart samba service to apply changes: sudo systemctl restart smbd nmbd
   - start samba service during system boot: sudo systemctl enable smbd nmbd
   - allow in firewall (optional): sudo ufw allow samba

- Install GCC tool chain (required for CASP)
    - sudo apt-get install build-essential gcc g++ -y

- Reboot the board and ensure that the above installed features RDP, SSH, shared folder software (samba) are working properly (refer below step for details on how to check rdp and shared folder). Disconnect the board from the monitor, keyboard and mouse and reboot the board while still connected to the WiFi.

- Access the board's desktop wirelessly from your host PC
    - on your host PC open remote desktop application and type the board IP address followed by port number 3389. eg. 192.168.0.115:3389.
    - enter user name and password when prompted. The board's desktop should now be accessible from your PC.

- Access the board's shared folder from your host PC
    - on Windows PC: open windows explorer and type the board IP. eg. \\192.168.0.115 in the address bar on the top.
    - on Linux or macOS: open any file explorer, locate other locations or connect to server options. type: smb://<IP eg.192.168.0.115>/<shared-folder-name> to access the folder
    - the board's shared folder should now be visible and accessible for read/write from the host PC.

- Install CASP and Arduino Uno Q BSP on host PC. If you are seeing this file, it mostly means this step is already done.
    - download and install CASP on host PC
    - run CASP and click start button on top left corner. goto 'Update->CASP Update' and try downloading and installing ArduinoUnoQ_MCU and ArduinoUnoQ_MPU BSPs.
      - these BSPs are shown under 'Update BSPs->32bit/64bit uC (FPU)' and 'Update BSPs->Embedded OS' respectively.

- Install CASP remote build tool chain on Arduino Uno Q for MPU
    - run CASP and create a new project (or open an existing project)
    - set target to ArduinoUnoQ_MPU
    - from the main tool bar click 'Build -> Generate RBuild BSP' to generate BSP folder on the desktop.
    - zip the folder and copy the zip file to Arduino Uno Q shared folder.
    - on Arduino Uno Q, unzip the copied zip file to the home directory. let's call this folder as 'casp_rbuild' folder.
    - open terminal in the casp_rbuild folder and type the following to install CASP remote build tool for MPU
      - chmod a+x casp_install.sh
      - ./casp_install.sh
    - the above installation should end with displaying a CASP simulation panel window
      - if the simulation panel is visible after installation, it indicates all the required dependencies are available and CASP is ready for remote build on MPU.
      - if no simulation panel is visible after installation it means some dependencies are missing. better to install dependencies with following commands. this step could take a while.
        - chmod a+x casp_install_dep.sh
        - ./casp_install_dep.sh
      - after installing the dependencies reboot the board and try installing casp rbuild tool chain again with following command
        - ./casp_install.sh

- Disable Arduino service related to MPU-MCU serial bridge (required by CASP to communicate with MCU). This method may not work across reboots.
    - display list of running services: systemctl --type=service --state=running
    - open terminal in the casp_rbuild folder and type the following command to claim 'ttyHS1' serial port 
      - sudo ./casp_ttyhs1_claim.sh
    - to unclaim the serial port and start the arduino-router service type the following command
      - sudo ./casp_ttyhs1_unclaim.sh

- To disable Arduino service related to MPU-MCU serial bridge across reboots without effecting other features such as remote flash upload etc. (this method may not work in future Arduino software releases)
    - sudo nano /var/lib/arduino-router/config/10-imola.conf
    - replace serial port 'ttyHS1' with 'ttyHS2'
    - press Ctrl-O then Enter to save, and Ctrl-X to exit
    - restart the board

===================================================================================================================================================

- Workaround if SimPanel cannot load libsimcode.so from build/bin
    - open terminal in current directory
    - sudo chmod a+x casp_cp_simcode.sh
    - sudo ./casp_cp_simcode.sh

- To enable auto-start for casp_rbuild.sh, casp_simpanel.sh and casp_gpio_bridge.sh during system startup run the following as desired
    - open terminal in current directory. type following commands without sudo.
    - ./casp_rbuild_autostart_enable.sh
    - ./casp_simpanel_autostart_enable.sh
    - ./casp_gpio_bridge_autostart_enable.sh

- To disable auto-start for the above three programs
    - open terminal in current directory. type following commands without sudo.
    - ./casp_rbuild_autostart_disable.sh
    - ./casp_simpanel_autostart_disable.sh
    - ./casp_gpio_bridge_autostart_disable.sh

- Configure linux to use a serial device such as an Arduino board connected to the USB port
    - list all serial devices along with their groups: ls -l /dev/tty*
    - add user to the group of the required serial device. this requires user logout and login again:
      - sudo usermod -a -G <group such as 'dialout'> <username>
    - change permissions of the device (example for ttyUSB0 device):
      - sudo chmod a+rw /dev/ttyUSB0

- Troubleshooting:
    - if an executable file failed to start. check the dependency library from the terminal.
      - use command: ldd <exe_file> to check its missing dependencies
    - if an error such as qt.qpa.plugin could not load qt"xcb".....
      - locate libqxcb.so from platforms folder and run 'ldd' to check its missing dependencies.
