On Wed, Sep 26, 2007 at 05:07:45PM -0400, Ward Vandewege wrote: > > I would like a way to change the MAC address for a rom image with some tool - > ideally as an option to flashrom, I guess. Keep in mind that there can be > multiple addresses on a board!
I just wrote a small utility to set the appropiate bytes in linuxbios.rom. Any comments? Would you like a patch to integrate it in the build system? -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.)
/* * Copyright (C) 2007 Robert Millan <[EMAIL PROTECTED]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> void error_exit (char *msg) { if (msg) perror (msg); exit (1); } int main (int argc, char **argv) { int fd, mac[2], mac_vendor, mac_serial; char *dummy = NULL; if (argc != 4) { printf ("Usage: %s linuxbios.rom vendor serial\n", argv[0]); exit (1); } fd = open (argv[1], O_RDONLY | O_WRONLY); if (fd == -1) error_exit ("open"); mac_vendor = (int) strtol (argv[2], &dummy, 16); mac_serial = (int) strtol (argv[3], &dummy, 16); if (lseek (fd, (int) 0xffffffd0, SEEK_END) == -1) error_exit ("lseek"); /* FIXME: assuming same endianess */ mac[0] = ((mac_vendor & 0xff) << 24) | mac_serial; mac[1] = mac_vendor >> 8; if (write (fd, mac, sizeof(mac)) == -1) error_exit ("write"); close (fd); return 0; }
-- linuxbios mailing list [email protected] http://www.linuxbios.org/mailman/listinfo/linuxbios
