SBL2e - Basic Questions

Discussion to talk about software related topics only.
Post Reply
cmo
Posts: 20
Joined: Sat Jul 24, 2010 4:20 pm

SBL2e - Basic Questions

Post by cmo »

I've got a few simple questions regarding the SBL2e device. As we know the structure of this device is a bit different and I can't figure out the following:

1. What is the command to force a reboot, ForceReboot() is not available?

2. How do I retrieve the MAC address? I see the MyIpAddr and others but no MyMac? Is there a global define somewhere?

3. How to I set static network settings? In reading the "SBL2e programming guide" it says that if you define the MyIpAddr, MyIpMask, MyIpGateway, etc, before InitializeStack() it should work, however DHCP, which is called in InitializeStack() continues to get called. Can someone provide a simple script to help?

Thanks in advance.
k1mgy
Posts: 24
Joined: Thu Oct 14, 2010 8:25 am

Re: SBL2e - Basic Questions

Post by k1mgy »

I cannot speak to your board specifically. This is from my massive 2-week knowledge base for the SB70LC.

1. ForceReboot() is included in bsp.h:
#include <bsp.h>


2. The Ethernet MAC address is stored in the ConfigRecord structure. The NNHK programming manual, starting at page 21, describes this structure and how to retrieve/set values.

3. This is the way to do it for Static:

InitializeStack(); // Initialize TCP Stack
if (EthernetIP == 0) // Enable DHCP if no static IP
GetDHCPAddress();

GetDHCPAddress() is perhaps being called somewhere in your code?

A static address can only be used if the IP address is other that the default 0.0.0.0 so while looking at the ConfigRecord you might discover that it is not set within...

At first I used the IP Setup program (one of the NetBurner tools). If the values for the NDK settings are all 0, then DHCP will be used by the board. You can set the IP, etc, as you wish using the tool.

Hope this helps.

/m
cmo
Posts: 20
Joined: Sat Jul 24, 2010 4:20 pm

Re: SBL2e - Basic Questions

Post by cmo »

Thanks k1mgy. You helped me to get reboot to work, however still no luck with getting the MAC address or setting static network settings. The SBL2e is a quite a bit different. Can anyone help? Any examples specific to the SBL2e?

Thanks.
k1mgy
Posts: 24
Joined: Thu Oct 14, 2010 8:25 am

Re: SBL2e - Basic Questions

Post by k1mgy »

Here's what works for me:

Code: Select all

MACADR MAC_ADDR;

MAC_ADDR=InterfaceMAC(0);
iprintf("MAC_ADDR 0 = %04x%04x%04x\n",MAC_ADDR.phywadr[0],MAC_ADDR.phywadr[1],MAC_ADDR.phywadr[2]);
MAC_ADDR=InterfaceMAC(1);
iprintf("MAC_ADDR 1 = %04x%04x%04x\n",MAC_ADDR.phywadr[0],MAC_ADDR.phywadr[1],MAC_ADDR.phywadr[2]);

User avatar
Forrest
Posts: 288
Joined: Wed Apr 23, 2008 10:05 am

Re: SBL2e - Basic Questions

Post by Forrest »

You can get a MAC address out of the gConfigRec struct...

Code: Select all

		iprintf("My MAC address is: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
				gConfigRec.mac_address[0], gConfigRec.mac_address[1],
				gConfigRec.mac_address[2], gConfigRec.mac_address[3],
				gConfigRec.mac_address[4], gConfigRec.mac_address[5]);

Code: Select all

   typedef struct
   {
         unsigned long recordsize;   /* The stored size of the struct */
         unsigned long ip_Addr;      /* The device IP Address */
         unsigned long ip_Mask;      /* The IP Address Mask */
         unsigned long ip_GateWay;   /* The address of the P gateway */
         unsigned long ip_TftpServer;/* The address of the TFTP server to load data from for debugging */
         unsigned long baud_rate;    /* The initial system Baud rate */
         unsigned char wait_seconds; /* The number of seconds to wait before booting */
         unsigned char bBoot_To_Application; /*True if we boot to the application, not the monitor */
         unsigned char bException_Action;    /*What should we do when we have an exception? */
         unsigned char m_FileName[80];       /*The file name of the TFTP file to load */
         unsigned char mac_address[6];       /*The Ethernet MAC address */
         unsigned char ser_boot;
         unsigned long ip_DNS_server;
         unsigned char core_mac_address[6];  /*The Base unit MAC address */
         unsigned char typeof_if;
         unsigned char direct_Tx;
         unsigned long m_ExtraData[4];
         unsigned char m_bUnused[3];
         unsigned char m_q_boot;        /* True to boot without messages */
         unsigned short checksum;       /* A Checksum for this structure */
   }__attribute__(( packed) ) ConfigRecord;
Forrest Stanley
Project Engineer
NetBurner, Inc

NetBurner Learn Articles: http://www.netburner.com/learn
cmo
Posts: 20
Joined: Sat Jul 24, 2010 4:20 pm

Re: SBL2e - Basic Questions

Post by cmo »

Thanks forrest, that helped. One more thing, how do I force a static IP address (with netmask etc...) on the SBL2e? The user manual says to assign it before the InitializeStack() but that's not working for me. "MyIpAddr" or the IP address in the structure you referenced doesn't work.

What variable do I set to avoid DHCP?

Thanks in advance.
Post Reply