gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > How can i read the mac-address?

#68403 - viko - Tue Jan 24, 2006 10:01 am

I'm thinking to add a authorization to the ds according to the mac address, so my program can be run only on my ds.

How can i read the mac-address which is set in the firmware at 0x000036-0x00003B ?

#68411 - chishm - Tue Jan 24, 2006 12:08 pm

Taken from NDSTech Wiki, modified for use with libnds:
Code:
void readFirmware(uint32 address, uint32 size, uint8 * buffer) {
  uint32 index;

  // Read command
  while (REG_SPICNT & SPI_BUSY);
  REG_SPICNT = SPI_ENABLE | SPI_CONTINUOUS | SPI_DEVICE_NVRAM;
  REG_SPIDATA = FW_READ;
  while (REG_SPICNT & SPI_BUSY);

  // Set the address
  REG_SPIDATA =  (address>>16) & 0xFF;
  while (REG_SPICNT & SPI_BUSY);
  REG_SPIDATA =  (address>>8) & 0xFF;
  while (REG_SPICNT & SPI_BUSY);
  REG_SPIDATA =  (address) & 0xFF;
  while (REG_SPICNT & SPI_BUSY);

  for (index = 0; index < size; index++) {
    REG_SPIDATA = 0;
    while (REG_SPICNT & SPI_BUSY);
    buffer[index] = REG_SPIDATA & 0xFF;
  }
  REG_SPICNT = 0;
}

_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#68414 - zxr750j - Tue Jan 24, 2006 12:50 pm

Most AP's can show the MAC-addresses of connected nic's don't they?