Using the DDP service to set the MAC address

Q

How can I set the MAC address via the DDP service in the host application instead of using the address in the FDL file?

A

The Device Data Provider(DDP) supports two states:

  • HIL_DDP_SERVICE_STATE_PASSIVE

  • HIL_DDP_SERVICE_STATE_ACTIVE

Only in passive state, the information marked as “writeable” are allowed to be changed. In passive state, writeable data is volatile and not used for configuration.

Once the state has been switched to active, these parameters are considered as valid and they cannot be changed anymore. These parameters can now be used for firmware configuration. A switch of the state from active to passive is not supported.

So if you want to use the DDP service to set the MAC address, the first step is to enable DDP tag of LFW and set "DDP mode after firmware startp" to "Passive" via Tag List Editor.

Make sure the firmware is in passive mode after startup. Then you can use "HIL_DDP_SERVICE_SET_REQ" with HIL_DDP_SERVICE_DATATYPE_MAC_ADDRESSES_COM datatype to set the MAC addresses of the COM side.

After that, don't forget to set DDP service back to active mode, before sending the configuration packet.

Please refer to DPM packet-based services manual ((netX Dual-Port Memory packet-based services - netX 90/4000/4100 - Packet API (Revision 5))) for more information about Device Data Provider.


You can also refer to the following code as a reference:


void App_SysPkt_DDP_SetComMac(CIFX_PACKET* ptPkt)
{
  uint8_t abMyComMacAddresses[8][6] =
    {
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x0 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x1 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x2 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x3 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x4 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x5 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x6 },
      { 0xaa, 0xb, 0xc, 0xd, 0xe, 0x7 },
    };
  HIL_DDP_SERVICE_SET_REQ_T* ptReq = (HIL_DDP_SERVICE_SET_REQ_T*)ptPkt;

  memset(ptReq, 0, sizeof(HIL_HW_HARDWARE_INFO_REQ_T));

  ptReq->tHead.ulDest = HIL_PACKET_DEST_SYSTEM;
  ptReq->tHead.ulCmd  = HIL_DDP_SERVICE_SET_REQ;
  ptReq->tHead.ulLen  = sizeof(ptReq->tData.ulDataType) + sizeof(abMyComMacAddresses);

  ptReq->tData.ulDataType = HIL_DDP_SERVICE_DATATYPE_MAC_ADDRESSES_COM;
  memcpy(ptReq->tData.uDataType.atMacAddress, abMyComMacAddresses, sizeof(abMyComMacAddresses));
...
}
---------------------------------------------------------------------------------------------------
void App_SysPkt_DDP_SetStatePassive(CIFX_PACKET* ptPkt)
{
  HIL_DDP_SERVICE_SET_REQ_T* ptReq = (HIL_DDP_SERVICE_SET_REQ_T*)ptPkt;

  memset(ptReq, 0, sizeof(HIL_HW_HARDWARE_INFO_REQ_T));

  ptReq->tHead.ulDest = HIL_PACKET_DEST_SYSTEM;
  ptReq->tHead.ulCmd  = HIL_DDP_SERVICE_SET_REQ;
  ptReq->tHead.ulLen  = sizeof(ptReq->tData.ulDataType) + sizeof(ptReq->tData.uDataType.ulValue);;
  ptReq->tData.ulDataType = HIL_DDP_SERVICE_DATATYPE_STATE;
  ptReq->tData.uDataType.ulValue = HIL_DDP_SERVICE_STATE_PASSIVE;
...
}