fconfig is an application that allows to read and write RedBoot's configuration

parameters.

Examples,
 fconfig -l
 fconfig -w -n console_baud_rate -x 115200

WWW: http://andrzejekiert.ovh.org/software.html.en

PR:		ports/139977
Submitted by:	thompsa at FreeBSD.org
This commit is contained in:
Martin Wilke 2009-10-29 22:19:09 +00:00
parent ee23a798c7
commit c00ced85cc
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=243490
5 changed files with 130 additions and 0 deletions

View file

@ -208,6 +208,7 @@
SUBDIR += farbot SUBDIR += farbot
SUBDIR += fastest_cvsup SUBDIR += fastest_cvsup
SUBDIR += fatback SUBDIR += fatback
SUBDIR += fconfig
SUBDIR += fcron SUBDIR += fcron
SUBDIR += fdupes SUBDIR += fdupes
SUBDIR += fetchlog SUBDIR += fetchlog

24
sysutils/fconfig/Makefile Normal file
View file

@ -0,0 +1,24 @@
# New ports collection makefile for: fconfig
# Date created: Oct 26, 2009
# Whom: thompsa@FreeBSD.org
#
# $FreeBSD$
#
PORTNAME= fconfig
PORTVERSION= 20080329
CATEGORIES= sysutils
MASTER_SITES= http://downloads.openwrt.org/sources/ \
http://andrzejekiert.ovh.org/software/fconfig/
MAINTAINER= thompsa@FreeBSD.org
COMMENT= Read and modify RedBoot embedded boot configuration
WRKSRC= ${WRKDIR}/${PORTNAME}
USE_GMAKE= yes
PLIST_FILES= sbin/fconfig
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/fconfig ${PREFIX}/sbin
.include <bsd.port.mk>

View file

@ -0,0 +1,3 @@
MD5 (fconfig-20080329.tar.gz) = dac355e9f2a0f48c414c52e2034b6346
SHA256 (fconfig-20080329.tar.gz) = 4ff0e8f07e35e46b705c0dbe9d9544ede01ea092a69e3f7db03e55a3f2bb8eb7
SIZE (fconfig-20080329.tar.gz) = 10179

View file

@ -0,0 +1,94 @@
diff -urN crunchfc.c crunchfc.c
--- crunchfc.c 2008-03-30 01:21:47.000000000 +1300
+++ crunchfc.c 2009-10-26 09:13:04.000000000 +1300
@@ -407,6 +407,7 @@
MESSAGE(VERB_HIGH, "Writing %d bytes at offset %d\n",
TYPE_SIZE(key.type), offset);
+#if !defined(__FreeBSD__)
/* do an actual write to the device or file */
if (lseek(data->fd, data->offset+offset, SEEK_SET) == -1) {
MESSAGE(VERB_LOW, "lseek() failed\n");
@@ -416,6 +417,7 @@
MESSAGE(VERB_LOW, "write() failed\n");
return -1;
}
+#endif
/* keep our buffer in sync with the device or file */
memcpy(key.dataval, buf, TYPE_SIZE(key.type));
@@ -451,6 +453,7 @@
MESSAGE(VERB_HIGH, "Writing CRC at offset %d\n", len-4);
+#if !defined(__FreeBSD__)
/* do an actual write to the device or file */
if (lseek(data->fd, data->offset+len-4, SEEK_SET) == -1) {
MESSAGE(VERB_LOW, "CRC: lseek() failed\n");
@@ -460,6 +463,7 @@
MESSAGE(VERB_LOW, "CRC: write() failed\n");
return;
}
+#endif
/* keep our buffer in sync with the device or file */
memcpy(buf+len-4, &crc, sizeof(crc));
diff -urN fconfig.c fconfig.c
--- fconfig.c 2008-03-30 01:21:48.000000000 +1300
+++ fconfig.c 2009-10-26 10:11:01.000000000 +1300
@@ -45,6 +45,8 @@
#include "ftypes.h"
#include "crunchfc.h"
+#define REDBOOT_DEV "/dev/redboot/RedBoot config"
+
/*
* Parse type name, return type ID.
* Type ID is the type number in the type table.
@@ -163,6 +165,16 @@
recalculate_crc(&data);
+#if defined(__FreeBSD__)
+ /* FreeBSD needs to do a full sector write */
+ if (lseek(data.fd, 0, SEEK_SET) == -1) {
+ MESSAGE(VERB_LOW, "lseek() failed\n");
+ return -1;
+ }
+ if (write(data.fd, data.buf, MAX_CONFIG_DATA) == -1) {
+ MESSAGE(VERB_LOW, "write() failed\n");
+ }
+#endif
close_fconfig_handle(&data);
return 0;
@@ -292,8 +304,12 @@
}
if (device == NULL) {
+#if defined(__FreeBSD__)
+ device = REDBOOT_DEV;
+#else
MESSAGE(VERB_LOW, "You must provide a device name.\n");
exit(1);
+#endif
}
switch (mode) {
diff -urN ftypes.c ftypes.c
--- ftypes.c 2006-03-15 03:18:18.000000000 +1300
+++ ftypes.c 2009-10-26 10:07:04.000000000 +1300
@@ -21,8 +21,13 @@
#include <arpa/inet.h>
/* For ether_aton */
+#if defined(__FreeBSD__)
+#include <sys/types.h>
+#include <net/ethernet.h>
+#else
#include <net/ethernet.h>
#include <netinet/ether.h>
+#endif
#include <stdlib.h>
#include <stdio.h>

View file

@ -0,0 +1,8 @@
fconfig is an application that allows to read and write RedBoot's configuration
parameters.
Examples,
fconfig -l
fconfig -w -n console_baud_rate -x 115200
WWW: http://andrzejekiert.ovh.org/software.html.en