MAC and IP addresses

I’m trying to find out to set the MAC address and IP address.

In NetworkInterface.c function BaseType_t xNetworkInterfaceInitialise( void )
the MAC address is obtained by calling:

        xETH.Init.MACAddr = ( uint8_t * ) FreeRTOS_GetMACAddress();

There is a function in FreeRTOS_IP.c

const uint8_t * FreeRTOS_GetMACAddress( void )
{
    return ipLOCAL_MAC_ADDRESS;
}

That makes use of a define in FreeRTOS_IP_Private.h

#define ipLOCAL_MAC_ADDRESS           ( xDefaultPartUDPPacketHeader.ucBytes )

In turn the xDefaultPartUDPPacketHeader is defined in FreeRTOS_UDP_IP.c

UDPPacketHeader_t xDefaultPartUDPPacketHeader =
{
    /* .ucBytes : */
    {
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* Ethernet source MAC address. */
       0x08, 0x00,                          /* Ethernet frame type. */
        ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */
        0x00,                                /* ucDifferentiatedServicesCode. */
        0x00, 0x00,                          /* usLength. */
        0x00, 0x00,                          /* usIdentification. */
        0x00, 0x00,                          /* usFragmentOffset. */
        ipconfigUDP_TIME_TO_LIVE,            /* ucTimeToLive */
        ipPROTOCOL_UDP,                      /* ucProtocol. */
        0x00, 0x00,                          /* usHeaderChecksum. */
      0x00, 0x00, 0x00, 0x00               /* Source IP address. */
   }
};

Should I just replace
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Ethernet source MAC address. */

by the MAC address.
Somehow this does not seem right.
The STM32F767 seems to have a UID register that provides a Unique ID number.
Could I use this? How?

And in respect with the IP address. If I’m not using DHCP how can I define an IP address?

I see

    #define ipLOCAL_IP_ADDRESS_POINTER    ( ( uint32_t * ) &( xDefaultPartUDPPacketHeader.ulWords[ 20U / sizeof( uint32_t ) ] ) )

in FreeRTOS_IP_Private.h which suggests the same way…

thanks

You have to use FreeRTOS_IPInit() to initialize the stack.
I recommend to have a look at FreeRTOS+TCP Networking Tutorial and there you find e.g. TCP Networking Tutorial - Initialising the TCP/IP Stack including examples.

The STM32F767 seems to have a UID register that provides a Unique ID number.
Could I use this? How?

All FreeRTOS+TCP demos are using any MAC-address, and their purpose is just for testing.
Hartmut is right that FreeRTOS_IPInit()must be called to initialise the ( default ) IP- and MAC-address.
In real life, a device gets a MAC-address chip with a single purpose: to give your application a world-wide unique MAC-address. These chips normally have a 1-wire access.
As long as you are experimenting, or as long as you work on you private LAN, you are free to create your own MAC-addresses and the ST UID register can help you with that.

There are a few rules about the MAC-address though: some bits have a special meaning.