Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

RE: setup ethernet MAC address from running program

$
0
0

Hello tomo,

You are correct in that there's no API call to control MAC address. It is assigned inside protected source you can't modify, but the #define it's assigned from is in clear source (sf_el_nx_cfg.h). I have a solution that does exactly what you ask, except that it bypasses a configurator and hence, it isn't a use-case we support.

In my project, I create an array to store MAC address, i.e.
static uint32_t mac_address[2] BSP_PLACE_IN_SECTION(".data_flash") = {0x00008888, 0x12345678};

You'll have to make sure that the value is assigned in the same place you declare the array, as if you'd like to write to e.g. data flash on runtime, you'll require a driver (if it's initialized, then it will be written to data flash by the debugger/programmer). In my case, there isn't anything else stored in the .data_flash section, so I'm confident the items are given addresses 0x40100000 and 0x40100004, respectively. If you plan to have other data stored in that section too, it's best if you create a separate section to hold your MAC address to make sure it's always in the same place (if you're using IAR compiler, you can use @ to specify the address for the data).

In the sf_el_nx_cfg.h, I replaced the defines for higher and lower part of the MAC address with pointers to the array I allocated earlier, i.e.:
#define SF_EL_NX_CFG_ENET1_MAC_H *((uint32_t *) 0x40100000UL)
#define SF_EL_NX_CFG_ENET1_MAC_L *((uint32_t *) 0x40100004UL)

It's also best to save your changes at this point and set sf_el_nx.cfg to read-only to prevent these changes from being overwritten.

I'm also attaching a NetX + USBX HTTP server project that implements the solution I described above: (Please visit the site to view this file)
Please bear in mind that this project bypasses the Synergy configurator and therefore we cannot provide support to any issues that arise due to this implementation.

Regards


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>