4.7.8.1.5.1. Enet TSN GPTP Example

4.7.8.1.5.1.1. Makefile

For an example of the app makefile, please refer to <enet>/examples/enet_tsn/enet_tsn_gptp_example/makefile. There are some important notes to consider:

  • To include TSN components, add the following macros:

    INCLUDE_INTERNAL_INTERFACES += tsn_gptp tsn_combase tsn_unibase tsn_uniconf
    COMP_LIST_COMMON += tsn_combase tsn_unibase tsn_gptp tsn_uniconf mmcsd fatfs_indp
    
  • Ensure that the tsninit.c, gptp_init.c``and ``debug_log.c files are included in the app’s source:

    SRCS_COMMON += main.c tsninit.c gptp_init.c debug_log.c
    
  • If the log task is used, define the TSN_USE_LOG_BUFFER macro:

    CFLAGS_LOCAL_COMMON += -DTSN_USE_LOG_BUFFER=1
    

4.7.8.1.5.1.2. Build Enet TSN GPTP example

  • Navigate to the <pdk>/packages/ti/build directory:

    $ cd <pdk>/packages/ti/build
    
  • Build the TSN modules (tsn_unibase, tsn_combase, tsn_gptp, tsn_uniconf):

    $ make tsn_unibase tsn_combase tsn_gptp tsn_uniconf
    
  • To clean the build and remove generated files:

    $ make tsn_unibase_clean tsn_combase_clean tsn_gptp_clean tsn_uniconf_clean
    
  • You can specify the build mode as either release or debug. By default, the release mode is built. To build in debug mode, use the BUILD_PROFILE=debug option:

    $ make tsn_unibase tsn_combase tsn_gptp tsn_uniconf  BUILD_PROFILE=debug
    
  • If you want to build with C++ compiling rules, use the CPLUSPLUS_BUILD=yes option:

    $ make tsn_unibase tsn_combase tsn_gptp tsn_uniconf CPLUSPLUS_BUILD=yes
    
  • To build the TSN GPTP example app in the PDK, use the following command:

    $ make enet_tsn_gptp_example_freertos CORE=mcu2_0
    

    The example app binary file can be found at the following location:

    <pdk>/packages/ti/binary/enet_tsn_example_freertos/bin/j7200_evm/enet_tsn_gptp_example_freertos_mcu2_0_release.xer5f
    

    This command will build the TSN example app (enet_tsn_gptp_example_freertos) using the FreeRTOS operating system and targeting the mcu2_0 core. Adjust the command according to your specific requirements, such as selecting a different operating system or core if needed.

4.7.8.1.5.1.3. Running Enet TSN GPTP example

  • Launch a CCS debug session, load and run enet_tsn_gptp_example_freertos_mcu2_0_release.xer5f binary file to the MAIN_Cortex_R5_0_0. Alternatively, the example application can be loaded using any other boot method such as MMC/SD.

  • Logs will be printed in Main UART port 0. Below is an example of the log when gPTP works in slave mode:

    ==========================
    TSN Example App
    ==========================
    EnetBoard_setupPorts: 2 of 2 ports configurations found
    Configuring SerDes lane 2 for QSGMII
    EnetApp_appInitTask: EnetBoard_setupPorts() done
    EnetApp_appInitTask: EnetApp_init() done
    Start: uniconf_task
    EnetApp_uniconfTask: dbname: NULL
    EnetMcm: CPSW_5G on MAIN NAVSS
    Mdio_open: MDIO manual mode enabled
    PHY 16 is alive
    PHY 17 is alive
    PHY 18 is alive
    PHY 19 is alive
    EnetPhy_bindDriver: PHY 16: OUI:0001c1 Model:27 Ver:00 <-> 'vsc8514' : OK
    EnetPhy_bindDriver: PHY 17: OUI:0001c1 Model:27 Ver:00 <-> 'vsc8514' : OK
    Logger_task: started
    unibase-1.1.5-jacinto
    INF:cbase:tilld0: has mac: 00:00:00:00:00:00
    INF:cbase:tilld1: has mac: 00:00:00:00:00:00
    INF:cbase:cb_lld_task_create: uniconf_task stack_size=16384
    INF:uconf:simpledb_open:no data is imported
    INF:uconf:get_next_nameid:a new mod=xl4-data, enum=0
    INF:uconf:get_next_nameid:a new mod=xl4-extmod, enum=1
    INF:uconf:uc_hwal_open:
    INF:cbase:cb_rawsock_open:combase-1.1.4-jacinto
    INF:cbase:cb_rawsock_open:dmaTxChId=-1 numRxChannels=0 dmaRxChId=-1 nTxPkts=0 nRxPkts=0 pktSize=0
    INF:cbase:tilld0: alloc mac: 70:FF:76:1D:A5:C8
    INF:uconf:get_next_nameid:a new mod=ietf-interfaces, enum=2
    INF:uconf:get_next_nameid:a new mod=ieee1588-ptp-tt, enum=3
    INF:uconf:get_next_nameid:a new mod=ieee802-dot1q-bridge, enum=4
    INF:uconf:get_next_nameid:a new mod=ieee802-dot1ab-lldp, enum=5
    INF:uconf:get_next_nameid:a new mod=ieee802-dot1q-tsn-config-uni, enum=6
    INF:uconf:get_next_nameid:a new mod=excelfore-tsn-remote, enum=7
    INF:uconf:get_next_nameid:a new mod=excelfore-netconf-server, enum=8
    INF:uconf:get_next_nameid:a new mod=ietf-netconf-monitoring, enum=9
    INF:uconf:get_next_nameid:a new mod=ietf-yang-library, enum=10
    INF:uconf:create_semname_with_dbname:null dbname is specified.
    INF:cbase:cb_lld_task_create: uniconf_hwal_thread stack_size=16384
    INF:uconf:000000-569508:uniconf_main:uniconf started
    EnetApp_gptpYangConfig:domain=0
    EnetApp_gptpYangConfig:domain=1
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_SINGLE_CLOCK_MODE=1
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_USE_HW_PHASE_ADJUSTMENT=1
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_CLOCK_COMPUTE_INTERVAL_MSEC=100
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_FREQ_OFFSET_IIR_ALPHA_START_VALUE=1
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_FREQ_OFFSET_IIR_ALPHA_STABLE_VALUE=4
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_PHASE_OFFSET_IIR_ALPHA_START_VALUE=1
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_PHASE_OFFSET_IIR_ALPHA_STABLE_VALUE=4
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_MAX_DOMAIN_NUMBER=2
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_CMLDS_MODE=1
    EnetApp_gptpNonYangConfig:XL4_EXTMOD_XL4GPTP_SECOND_DOMAIN_THIS_CLOCK=1
    Start: gptp2d_task
    Start: estapp_task
    EnetApp_initTsn:gptp start done!
    CPU Load: 65%
    INF:cbase:cbl_query_response:tilld0 link DOWN !!!!
    INF:cbase:cbl_query_response:tilld1 link DOWN !!!!
    INF:cbase:tilld1: alloc mac: 70:FF:76:1D:A5:C9
    INF:uconf:get_next_nameid:a new extmod=xl4gptp, enum=0
    INF:uconf:create_semname_with_dbname:null dbname is specified.
    INF:cbase:cb_lld_task_create: gptp2d_task stack_size=16384
    INF:cbase:cb_lld_task_create: estapp_task stack_size=16384
    INF:cbase:cb_rawsock_open:combase-1.1.4-jacinto
    INF:cbase:cb_rawsock_open:dmaTxChId=1 numRxChannels=0 dmaRxChId=-1 nTxPkts=0 nRxPkts=0 pktSize=0
    INF:gptp:gptpman_run:max_domains=2, max_ports=2
    INF:cbase:cb_rawsock_open:combase-1.1.4-jacinto
    INF:cbase:cb_rawsock_open:dmaTxChId=8 numRxChannels=0 dmaRxChId=-1 nTxPkts=0 nRxPkts=0 pktSize=0
    INF:cbase:DmaOpen: TxChNum 1
    INF:cbase:DmaOpen: Rx startIdx 84 flowId 1
    INF:gptp:gptpmasterclock_init: gptp2-1.2.4-jacinto, ref_counter=1
    INF:gptp:gptpmasterclock_init:failed
    INF:gptp:gptpmasterclock_close: ref_counter=0
    INF:cbase:DmaOpen: TxChNum 8
    INF:gptp:gptpmasterclock_init: gptp2-1.2.4-jacinto, ref_counter=0
    INF:gptp:gptpmasterclock_close: ref_counter=-1
    INF:cbase:DmaOpen: Rx startIdx 84 flowId 2
    INF:cbase:LLDEnetFilter:destmac:01:80:C2:00:00:0E, vlanId:0, ethType:0x88f7
    INF:gptp:dev:tilld0 open success
    INF:gptp:dev:tilld1 open success
    INF:gptp:gptpnet_init:Open lldtsync OK!
    INF:gptp:IEEE1588-2019 performance monitoring disabled.
    INF:gptp:IEEE1588-2019 performance monitoring disabled.
    INF:gptp:gptpclock_mode_slave_main:domainIndex=0 already in SLAVE_MAIN
    INF:uconf:ydbi_get_item_ifk3vk0:no data
    INF:uconf:ydbi_get_item_ifk3vk0:no data
    INF:gptp:onenet_activate:tilld0 status=0, duplex=1, speed=0Mbps
    INF:uconf:ydbi_get_item_ifk3vk0:no data
    INF:uconf:ydbi_get_item_ifk3vk0:no data
    INF:gptp:onenet_activate:tilld1 status=0, duplex=1, speed=0Mbps
    INF:ubase:GPTP_MEDIUM_ALLOC: fragsize=16 fragused/fragnum=1301/2271 (57%)
    INF:ubase:GPTP_SMALL_ALLOC: fragsize=4 fragused/fragnum=34/126 (26%)
    INF:ubase:SM_DATA_INST: fragsize=8 fragused/fragnum=3770/7222 (52%)
    INF:gptp:gptpman_run:GPTPNET_INTERVAL_TIMEOUT_NSEC=125000000
    INF:gptp:gptpmasterclock_init: gptp2-1.2.4-jacinto, ref_counter=0
    INF:gptp:000001-377231:domainIndex=0, GM changed old=00:00:00:00:00:00:00:00, new=70:FF:76:FF:FE:1D:A5:C8
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=0, gmstate=2
    INF:gptp:set_phase_offsetGM:domainIndex=0, New adjustment(New GM?)
    INF:gptp:000001-379710:domainIndex=1, GM changed old=00:00:00:00:00:00:00:00, new=70:FF:76:00:01:1D:A5:C8
    INF:gptp:000001-379787:adjust_GM_btw_domains:domainIndex=1
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=1, gmstate=2
    INF:gptp:set_phase_offsetGM:domainIndex=1, New adjustment(New GM?)
    CpswMacPort_checkSgmiiStatus: MAC 1: SGMII link parter config port: link up: 1-Gbps Full-Duplex
    Cpsw_handleLinkUp: Port 1: Link up: 1-Gbps Full-Duplex
    MAC Port 1: link up
    INF:cbase:cbl_query_response:tilld0: link UP, speed=1000, duplex=1 !!!!
    INF:gptp:index=1 speed=1000, duplex=full
    INF:gptp:md_pdelay_resp_sm_recv_req:port=1, set receivedNonCMLDSPdelayReq=-1
    WRN:gptp:000004-877107:waiting_for_pdelay_interval_timer_proc:portIndex=1, sourcePortIdentity=70:FF:76:FF:FE:1D:9B:42, thisClock=70:FF:76:FF:FE:1D:A5:C8, neighborPropDelay=659
    INF:gptp:waiting_for_pdelay_interval_timer_proc:portIndex=1, not asCapable
    INF:gptp:set neighborGptpCapable, domainIndex=0, portIndex=1
    INF:gptp:set neighborGptpCapable, domainIndex=1, portIndex=1
    INF:gptp:set asCapable for domainIndex=0, portIndex=1
    INF:gptp:000005-000614:gptpgcfg_set_asCapable:domainInde=0, portIndex=1, ascapable=1
    INF:gptp:000005-000978:gm_stable:gm_unstable_proc:domainIndex=0
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=0, gmstate=1
    INF:gptp:000005-001099:active domain switched from 0 to 1
    INF:gptp:000005-001154:gm_stable:gm_unstable_proc:domainIndex=0
    INF:gptp:set asCapable for domainIndex=1, portIndex=1
    INF:gptp:000005-001610:gptpgcfg_set_asCapable:domainInde=1, portIndex=1, ascapable=1
    INF:gptp:000005-001922:gm_stable:gm_unstable_proc:domainIndex=1
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=1, gmstate=1
    INF:gptp:000005-002079:gm_stable:gm_unstable_proc:domainIndex=1
    INF:gptp:000005-125310:setSyncTwoStep_txSync:domainIndex=0, portIndex=1, sync gap=5125msec
    INF:gptp:000005-125665:setSyncTwoStep_txSync:domainIndex=1, portIndex=1, sync gap=5125msec
    INF:gptp:000005-125954:setFollowUp_txFollowUp:domainIndex=0, portIndex=1, fup gap=5125msec
    INF:gptp:000005-126689:setFollowUp_txFollowUp:domainIndex=1, portIndex=1, fup gap=5125msec
    INF:gptp:000005-812183:domainIndex=0, GM changed old=70:FF:76:FF:FE:1D:A5:C8, new=70:FF:76:FF:FE:1D:9B:42
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=0, gmstate=0
    INF:gptp:000005-812374:gm_stable:gm_unstable_proc:domainIndex=0
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=0, gmstate=1
    INF:gptp:000005-813160:domainIndex=1, GM changed old=70:FF:76:00:01:1D:A5:C8, new=70:FF:76:00:01:1D:9B:42
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=1, gmstate=0
    INF:gptp:000005-813377:gm_stable:gm_unstable_proc:domainIndex=1
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=1, gmstate=1
    INF:gptp:set_phase_offsetGM:domainIndex=0, New adjustment(New GM?)
    INF:gptp:set_phase_offsetGM:domainIndex=0, offset adjustment, diff=885934511
    INF:gptp:set_phase_offsetGM:domainIndex=1, New adjustment(New GM?)
    INF:gptp:set_phase_offsetGM:domainIndex=1, offset adjustment, diff=885926319
    WRN:gptp:000005-876210:waiting_for_pdelay_interval_timer_proc:portIndex=1, sourcePortIdentity=70:FF:76:FF:FE:1D:9B:42, thisClock=70:FF:76:FF:FE:1D:A5:C8, neighborPropDelay=663
    INF:gptp:waiting_for_pdelay_interval_timer_proc:portIndex=1, not asCapable
    INF:gptp:set_phase_offsetGM:domainIndex=0, offset adjustment by Freq., diff=10726
    INF:gptp:set_phase_offsetGM:domainIndex=1, New adjustment(New GM?)
    INF:gptp:set_phase_offsetGM:domainIndex=1, offset adjustment, diff=-885923142
    INF:gptp:set_phase_offsetGM:domainIndex=0, stable
    INF:gptp:clock_master_sync_receive:computeGmRateRatio:domainIndex=0 unstable rate=-6989ppb (timeleap_past)
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to 2863ppb, GMdiff=9852nsec
    INF:gptp:set_phase_offsetGM:domainIndex=1, stable
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -3252ppb, GMdiff=8812nsec
    INF:gptp:clock_master_sync_receive:computeGmRateRatio:domainIndex=1 unstable rate=-27314ppb (timeleap_past)
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to -28164ppb, GMdiff=-3397nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -6603ppb, GMdiff=8139nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 127041ppb, GMdiff=15511nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -8396ppb, GMdiff=7675nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 131519ppb, GMdiff=15584nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -9324ppb, GMdiff=7330nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 123236ppb, GMdiff=14108nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -9876ppb, GMdiff=7041nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 145557ppb, GMdiff=16386nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -10168ppb, GMdiff=6791nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 126690ppb, GMdiff=13579nsec
    INF:gptp:000006-875368:gm_stable:gm_stable_proc:domainIndex=0
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=0, gmstate=2
    INF:gptp:000006-875495:active domain switched from 1 to 0
    INF:gptp:000006-875657:gm_stable:gm_stable_proc:domainIndex=1
    INF:gptp:gptpclock_set_gmsync:gptpInstanceIndex=0, domainIndex=1, gmstate=2
    INF:gptp:waiting_for_pdelay_interval_timer_proc:set asCapableAcrossDomains, portIndex=1
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -10494ppb, GMdiff=6547nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 160372ppb, GMdiff=17219nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -10622ppb, GMdiff=6333nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 141435ppb, GMdiff=14401nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -10747ppb, GMdiff=6126nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 107379ppb, GMdiff=9837nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -10915ppb, GMdiff=5920nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 122709ppb, GMdiff=11397nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -10936ppb, GMdiff=5738nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 150238ppb, GMdiff=14389nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -16343ppb, GMdiff=-402nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 132452ppb, GMdiff=-1743nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -16415ppb, GMdiff=-389nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 137973ppb, GMdiff=-1021nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -16462ppb, GMdiff=-367nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 126943ppb, GMdiff=-2327nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -16514ppb, GMdiff=-349nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 143256ppb, GMdiff=-279nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -16560ppb, GMdiff=-331nsec
    IFV:gptp:domainIndex=1, clock_master_sync_receive:the master clock rate to 129506ppb, GMdiff=-1937nsec
    IFV:gptp:domainIndex=0, clock_master_sync_receive:the master clock rate to -16583ppb, GMdiff=-304nsec
    
      ...
    

4.7.8.1.5.1.4. Verification

Single port

Connect a port to a Linux PC and run gptp2d from the PC. The expected log from the slave side will be stable and reprinted like this:

INF:gptp:domainNumber=0, clock_master_sync_receive:the master clock rate to 65499ppb
INF:gptp:domainNumber=0, clock_master_sync_receive:the master clock rate to 61563ppb
INF:gptp:domainNumber=0, clock_master_sync_receive:the master clock rate to 58249ppb
INF:gptp:domainNumber=0, clock_master_sync_receive:the master clock rate to 55383ppb
...

Instead of displaying the clock_master_sync_receive:... log, the following log will be printed in the case of the master log:

domain=0, offset=0nsec, hw-adjrate=0ppb
        gmsync=true, last_setts64=0nsec
domain=0, offset=0nsec, hw-adjrate=0ppb
        gmsync=true, last_setts64=0nsec
CPU Load: 2%
domain=0, offset=0nsec, hw-adjrate=0ppb
        gmsync=true, last_setts64=0nsec
CPU Load: 2%
domain=0, offset=0nsec, hw-adjrate=0ppb
        gmsync=true, last_setts64=0nsec
CPU Load: 2%
domain=0, offset=0nsec, hw-adjrate=0ppb
        gmsync=true, last_setts64=0nsec
...

Multiple ports

In this function, gPTP is operating as a switch. The availability of this feature is determined by the board configuration rather than the gPTP stack. If a board enables multiple MAC ports, the gPTP function should operate properly. To test this function, please connect two PCs to two ports of the EVM.

When the EVM board acts as the master, only the master log will be printed out, while the two PCs will print the slave log. On the other hand, if one of the PCs acts as the master, the slave log will be printed by the other PC and the EVM, while the master PC will print the master log.

To identify which machine is the master, please check the log:

INF:gptp:001809-750000:domainIndex=0, GM changed old=24:76:25:FF:FE:96:6C:41, new=70:FF:76:FF:FE:1D:9B:77

In this case, the machine with the source MAC address of 70:FF:76:FF:FE:1D:9B:77 is the master.