John Kiernan <jkiernan@birinc.com> wrote:
Chris Herborth wrote:
I’m not 100% sure about the behaviour of environment variables in build
files; the only examples I can find have the environment variable being
set on the same line as the command, so I assume they’re not carried over.
You could move those commands that need the environment variable into a
shell script, and then include esh (for example) in your startup script…
Thanks Chris,
That gave me an idea, this works: (no other script files necessary > 
RTMIO_MAC=000102030405 # default address
get_mac_program # get the stored MAC address and set RTMIO_MAC
esh -c “io-net -d speedo mac=$RTMIO_MAC,speed=100,duplex=1 -p tcpip”
Thanks for your help,
John
John,
Newer versions of the network drivers support a mechanism for reading
the MAC address from the system page, if it is not specified on the command
line. In order to populate the system page with the MAC address, you would
need to modify the startup code for your board (normally, the init_hwinfo()
routine), similar to the following:
uint8_t mac_buf[6];
uintptr_t flash_ptr;
flash_ptr = startup_io_map(flash_size,flash_addr);
/*
- read MAC address from flash and program it into the syspage
*/
for(i=0; i < 6; i++)
mac_buf = in8(flash_ptr + offset_to_mac_addr + i);
hwi_add_device(HWI_ITEM_BUS_UNKNOWN, HWI_ITEM_DEVCLASS_NETWORK, “network”, 0);
hwi_add_nicaddr(mac_buf,6);
startup_io_unmap(flash_ptr);
To verify if the address is getting put in the syspage correctly, you can run
the following stand-alone program, after the board has booted:
#include <sys/mman.h>
#include <errno.h>
#include <sys/syspage.h>
#include <hw/sysinfo.h>
#include <sys/neutrino.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned start,i;
struct hwi_nicaddr *tag;
unsigned off=0;
if ((start = hwi_find_item (HWI_NULL_OFF, “network”, NULL)) == HWI_NULL_OFF)
return (-1);
if ((start = hwi_find_tag(start,0,“nicaddr”)) == HWI_NULL_OFF)
return (-1);
tag = hwi_off2tag(start);
printf(“mac address = 0x”);
for(i=0;i<6;i++)
printf("%2.2X",tag->addr);
printf("\n");
return(0);
}
–
David Green (dgreen@qnx.com)
QNX Software Systems Ltd.
http://www.qnx.com