.. _vx6-topics:

VxWorks 6 Topics
****************

Building a Kernel
=================

**GNATemulator** supports a specific BSP for VxWorks 6, the first step is to
build a kernel with this BSP.

To create a VxWorks 6 kernel:

#. In WorkBench: File -> New -> VxWorks Image Project
#. Enter project name (e.g. GNATemu_kernel), click :guilabel:`Next`
#. On **GNATemulator** for **PowerPC e500v2 VxWorks 6.x**, select the
   **wrSbc8548** BSP, and on **GNATemulator** for **PowerPC VxWorks 6.x**
   select the **wrSbc834x** BSP.
#. Select the `gnu` tool chain.
#. Click `Next` twice
#. Select Profile: :guilabel:`PROFILE_DEVELOPMENT` and click :guilabel:`Finish`
#. In the kernel configuration window for BSP wrSbc8548 profile:

    #. Exclude DRV_TIMER_OPENPIC
    #. Include INCLUDE_STANDALONE_SYM_TBL
    #. Include FOLDER_DOSFS2
    #. Set LOCAL_MEM_SIZE to 0x8000000 # Note 0x800_0000
    #. Set WIND_JOBS_MAX to 256

#. In the kernel configuration window for BSP wrSbc834x profile:

    #. Exclude INCLUDE_NET_DRV
    #. Include INCLUDE_NETSTAT
    #. Include INCLUDE_STANDALONE_SYM_TBL
    #. Include FOLDER_DOSFS2
    #. Set LOCAL_MEM_SIZE to 0x8000000 # Note 0x800_0000
    #. Set WIND_JOBS_MAX to 256
    #. Change IP addresses of DEFAULT_BOOT_LINE to h=192.168.0.1 e=192.168.0.2

#. On **GNATemulator** for **PowerPC VxWorks 6.x**

    #. Click on :guilabel:`File -> Import...`
    #. Select :guilabel:`General -> File System` and press :guilabel:`Next`
    #. In the :guilabel:`File System` dialog, browse to following directory

        ``<GNATEMULATOR_INSTALL_DIR>/share/gnatemu/<TARGET>/autoexec``

    #. Press :guilabel:`OK`
    #. Press :guilabel:`Select All` then :guilabel:`Finish`
    #. Answer :guilabel:`Yes To All` in the :guilabel:`Overwrite...` dialog box

#. To build the kernel run: Project -> Build Project

You can find the kernel image at ``<PROJECT_ROOT_DIR>/Default/VxWorks``.

Running GNATemulator
====================

Downloadable Kernel Module
--------------------------

**GNATemulator** takes the DKM (.out) as last command line argument,
 automatically loads and runs it and then stop execution.

.. code-block:: console

    $ powerpc-wrs-vxworks-gnatemu --kernel=<PROJECT_ROOT_DIR>/Default/VxWorks print.out
    Target Name: vxTarget

    Adding 6942 symbols for standalone.


                    VxWorks

    Copyright 1984-2012  Wind River Systems, Inc.

                 CPU: Wind River SBC8349E
        Runtime Name: VxWorks
     Runtime Version: 6.9
         BSP version: 6.9/0
             Created: Dec  1 2012, 19:28:15
    ED&R Policy Mode: Deployed
       WDB Comm Type: WDB_COMM_END
                 WDB: Agent Disabled.


    cmdline: kernel print.out
    Instantiating /tmp as rawFs,  device = 0x1
    Formatting /tmp for DOSFS
    Instantiating /tmp as rawFs, device = 0x1
    Formatting...-> OK.
    Mount ramdisk in /tmp...OK
    copy host:print.out -> local:print.out
    708798 byte(s) transferred
    <runkernel print.out at addr=0x17567e0 id=24468064>
    Hello world!
    </runkernel>

Interactive Mode
----------------

When there is no DKM on the command line, **GNATemulator** starts vxWorks in
interactive mode.

.. code-block:: console

    $ powerpc-wrs-vxworks-gnatemu --kernel=<PROJECT_ROOT_DIR>/Default/VxWorks
    Target Name: vxTarget

    Adding 6942 symbols for standalone.


                    VxWorks

    Copyright 1984-2012

                 CPU: Wind River SBC8349E
        Runtime Name: VxWorks
     Runtime Version: 6.9
         BSP version: 6.9/0
             Created: Dec  1 2012, 19:28:15
    ED&R Policy Mode: Deployed
       WDB Comm Type: WDB_COMM_END
                 WDB: Agent Disabled.

    cmdline:
    Instantiating /tmp as rawFs,  device = 0x1
    Formatting /tmp for DOSFS

    Instantiating /tmp as rawFs, device = 0x1
    Formatting...-> OK.
    Mount ramdisk in /tmp...OK
    Run_shell
    ->

Connecting Workbench to **GNATemulator**
========================================

The Wind River Debug Server (DFW) can connect to **GNATemulator** using the
``wdbrpc`` back-end that will use the Ethernet connection available in
**GNATemulator**.

To create a new target server for **GNATemulator** and VxWorks 6:

#. Click on :guilabel:`New Connection...` in the :guilabel:`Target` menu of
   Workbench.

#. Select :guilabel:`Wind River VxWorks 6.x Target Server Connection` as the
   system type.

#. In the :guilabel:`Target Server Options` page, select :guilabel:`wdbrpc` as
   the Backend, set the IP address to ``127.0.0.1`` and the port to
   ``17185``.

#. Set the Kernel image

#. To complete the setup of the target server you can keep the other fields to
   their default values

#. Start **GNATemulator** with the ``--wdb`` option
#. Note: INCLUDE_WDB_ALWAYS_ENABLED must be in kernel configuration.

   ``$ powerpc-wrs-vxworks-gnatemu --wdb --kernel=<PROJECT_ROOT_DIR>/Default/VxWorks``

#. Click on :guilabel:`Connect '...'` in the :guilabel:`Target` menu.


Using the internal TFTP server
==============================

**GNATemulator**'s internal TFTP server can be used to load file and
executable on the target.

#. Open the kernel project created in `Building a Kernel`
#. In the kernel configuration window:

    #. Include INCLUDE_TFTP_CLIENT
    #. Include INCLUDE_IPTFTPC
    #. Include INCLUDE_IPTFTP_CLIENT_CMD
    #. Include INCLUDE_RAM_DISK
    #. Set RAM_DISK_SIZE to 16000000
    #. Set RAM_DISK_DEV_NAME to "/tmp"

#. In addition for the **wrSbc834x** BSP:
    #. Set DEFAULT_BOOT_LINE to "mottsec(0,0)host:target/config/wrSbc834x/vxWorks h=192.168.0.1 e=192.168.0.2 g=192.168.0.1 u=vxworks tn=wrSbc834x"

#. Re-build the kernel: Project -> Build Project

To use the TFTP in VxWorks:

#. Start **GNATemulator**

    ``$ powerpc-wrs-vxworks-gnatemu --wdb --kernel=<PROJECT_ROOT_DIR>/default/vxWorks``

#. In the VxWorks prompt, format the ram disk

    ``-> dosFsVolFormat ("/tmp", 0, 0)``

#. Change current directory

    ``-> cd "/tmp"``

#. Enter command mode

    ``-> cmd``

#. Use the `tftp` command to download a file

    ``[vxWorks *]# tftp 192.168.0.1 get test.txt``

Here is a complete example of TFTP session:

.. code-block:: console

    $ echo Test TFTP server > test.txt
    $ powerpc-wrs-vxworks-gnatemu --wdb --kernel=<PROJECT_ROOT_DIR>/default/vxWorks
    Instantiating /tmp as rawFs,  device = 0x1
    Target Name: vxTarget
    Instantiating /ram as rawFs,  device = 0x10001
    Formatting /ram for DOSFS
    Instantiating /ram as rawFs, device = 0x10001
    Formatting...Retrieved old volume params with %38 confidence:
    Volume Parameters: FAT type: FAT32, sectors per cluster 0
      0 FAT copies, 0 clusters, 0 sectors per FAT
      Sectors reserved 0, hidden 0, FAT sectors 0
      Root dir entries 0, sysId (null)  , serial number 20000
      Label:"           " ...
    Disk with 64 sectors of 512 bytes will be formatted with:
    Volume Parameters: FAT type: FAT12, sectors per cluster 1
      2 FAT copies, 54 clusters, 1 sectors per FAT
      Sectors reserved 1, hidden 0, FAT sectors 2
      Root dir entries 112, sysId VXDOS12 , serial number 20000
      Label:"           " ...
    OK.

    Adding 6717 symbols for standalone.


                    VxWorks

    Copyright 1984-2012  Wind River Systems, Inc.

                 CPU: Wind River SBC8349E
        Runtime Name: VxWorks
     Runtime Version: 6.9
         BSP version: 6.9/0
             Created: Dec  1 2012, 19:28:15
    ED&R Policy Mode: Deployed
       WDB Comm Type: WDB_COMM_END
                 WDB: Agent Disabled.


    -> dosFsVolFormat ("/tmp", 0, 0)
    Formatting /tmp for DOSFS
    Instantiating /tmp as rawFs, device = 0x1
    Formatting...Retrieved old volume params with %38 confidence:
    Volume Parameters: FAT type: FAT32, sectors per cluster 0
      0 FAT copies, 0 clusters, 0 sectors per FAT
      Sectors reserved 0, hidden 0, FAT sectors 0
      Root dir entries 0, sysId (null)  , serial number 11690000
      Label:"           " ...
    Disk with 31250 sectors of 512 bytes will be formatted with:
    Volume Parameters: FAT type: FAT16, sectors per cluster 2
      2 FAT copies, 15546 clusters, 62 sectors per FAT
      Sectors reserved 1, hidden 0, FAT sectors 124
      Root dir entries 512, sysId VXDOS16 , serial number 11690000
      Label:"           " ...
    OK.
    value = 0 = 0x0
    -> cd "/tmp"
    value = 0 = 0x0
    -> cmd
    [vxWorks *]# tftp 192.168.0.1 get test.txt
    Transfer completed: 17 bytes in 0.0 seconds.
    [vxWorks *]# cat test.txt
    Test TFTP server
    [vxWorks *]#


VxWorks 6 Cert Topics
*********************

Building a Kernel
=================

**GNATemulator** supports a specific BSP for VxWorks 6 cert, the first step is
to build a kernel with this BSP.

To create a VxWorks 6 cert kernel:

#. In WorkBench: File -> New -> VxWorks Cert Image Project
#. Enter project name (e.g. GNATemu_kernel), click :guilabel:`Next`
#. On **GNATemulator** for **PowerPC e500v2 VxWorks 6.x**, select the
   **wrSbc8548** BSP, and on **GNATemulator** for **PowerPC VxWorks 6.x**
   select the **wrSbc834x** BSP.
#. Select the `gnu` tool chain.
#. Click `Next`
#. Select option with RTP support and click `Next`
#. Select a Profile and click :guilabel:`Finish`
#. In the kernel configuration window:

    #. Set LOCAL_MEM_SIZE to 0x8000000 # Note 0x800_0000

#. To build the kernel run: Project -> Build Project

You can find the kernel image at ``<PROJECT_ROOT_DIR>/Default/VxWorks``.

Running GNATemulator
====================

.. code-block:: console

    $ powerpc-wrs-vxworks-gnatemu --kernel=<PROJECT_ROOT_DIR>/Default/VxWorks


      Copyright 1984-2011 Wind River Systems, Inc.
      VxWorks Cert 6.6.4.1
      Created: Jun 14 2013, 17:48:22
      ...

Running tests on vxWorks Cert
=============================

To run a test on vxWorks Cert it has to be included in the kernel during build.
SKMs linked to the kernel binary, RTPs in a ROMFS. Then usrAppInit() must be
modified to load and/or run the test. You will find procedures to do so in
WorkBench documentation. Note that theses procedures can be scripted using the
`vxprj` command line tool.
