Hi, this is for testing. Works for me with seabios.
First optimize coreboot for your board, to get some space (remove
microcode updates or sth, we need about 60 KB).
Sorry haven't checked latest libpayload changes, so something might not
work.
I will write a blog post about this tomorrow.

Thanks,
Tadas Slotkus
>From 4a32d7dca4f8ccdca655ba5b164554212df6d83a Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <[email protected]>
Date: Fri, 1 Jul 2011 00:38:34 +0300
Subject: [PATCH] coreboot mods for flashrom payload

This enables to choose flashrom payload, when using SEABIOS with cbfs support
also libpayload temporary hack for malloc(>16KB) :)

Signed-off-by: Tadas Slotkus <[email protected]>
---
 payloads/libpayload/lib/libpayload.ldscript |    4 ++--
 src/arch/x86/Makefile.inc                   |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/payloads/libpayload/lib/libpayload.ldscript b/payloads/libpayload/lib/libpayload.ldscript
index 830a390..084bf20 100644
--- a/payloads/libpayload/lib/libpayload.ldscript
+++ b/payloads/libpayload/lib/libpayload.ldscript
@@ -34,8 +34,8 @@ OUTPUT_ARCH(i386)
 
 ENTRY(_entry)
 
-HEAP_SIZE = 16384;
-STACK_SIZE = 16384;
+HEAP_SIZE = 15003840;
+STACK_SIZE = 8003840;
 
 SECTIONS
 {
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index e9c00de..dc73493 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -106,6 +106,7 @@ ifeq ($(CONFIG_INCLUDE_CONFIG_FILE),y)
 	sed -e '/^#/d' -e '/^ *$$/d' $(DOTCONFIG) >> $(obj)/config.tmp ; \
 	$(CBFSTOOL) [email protected] add $(obj)/config.tmp config raw; rm -f $(obj)/config.tmp ; fi
 endif
+	$(CBFSTOOL) [email protected] add-payload ./payloads/flashrom/flashrom img/flashrom $(CBFS_PAYLOAD_COMPRESS_FLAG)
 	mv [email protected] $@
 	@printf "    CBFSPRINT  $(subst $(obj)/,,$(@))\n\n"
 	$(CBFSTOOL) $@ print
-- 
1.7.0.4

Download fresh FILO sources to payloads/filo dir. (not external or sth.)
Here is FILO config files for flashrom payload
after creating these files, run make config,
this will generate config.h file needed later.

Currently we use usb drivers, fat and ext2 fs, but intel.o object file is included
to object list without any config so you are free to modify makefiles.

Signed-off-by: Tadas Slotkus <[email protected]>

Index: .config
===================================================================
--- .config	(revision 0)
+++ .config	(revision 0)
@@ -0,0 +1,60 @@
+#
+# Automatically generated make config: don't edit
+# FILO version: 0.6.0
+# Fri Jul  1 00:09:48 2011
+#
+CONFIG_TARGET_I386=y
+
+#
+# Interface Options
+#
+# CONFIG_USE_GRUB is not set
+CONFIG_USE_AUTOBOOT=y
+CONFIG_AUTOBOOT_FILE="hda1:/vmlinuz root=/dev/hda1 console=tty0 console=ttyS0,115200"
+CONFIG_AUTOBOOT_DELAY=2
+
+#
+# Drivers
+#
+# CONFIG_IDE_DISK is not set
+# CONFIG_IDE_NEW_DISK is not set
+CONFIG_USB_DISK=y
+# CONFIG_FLASH_DISK is not set
+CONFIG_SUPPORT_PCI=y
+# CONFIG_PCI_BRUTE_SCAN is not set
+# CONFIG_SUPPORT_SOUND is not set
+
+#
+# Filesystems
+#
+CONFIG_FSYS_EXT2FS=y
+CONFIG_FSYS_FAT=y
+# CONFIG_FSYS_JFS is not set
+# CONFIG_FSYS_MINIX is not set
+# CONFIG_FSYS_REISERFS is not set
+# CONFIG_FSYS_XFS is not set
+# CONFIG_FSYS_ISO9660 is not set
+# CONFIG_FSYS_CRAMFS is not set
+# CONFIG_FSYS_SQUASHFS is not set
+# CONFIG_FSYS_CBFS is not set
+
+#
+# Loaders
+#
+# CONFIG_LINUX_LOADER is not set
+# CONFIG_WINCE_LOADER is not set
+# CONFIG_ARTEC_BOOT is not set
+
+#
+# Debugging & Experimental
+#
+# CONFIG_EXPERIMENTAL is not set
+# CONFIG_DEBUG_ALL is not set
+# CONFIG_DEBUG_ELFBOOT is not set
+# CONFIG_DEBUG_SEGMENT is not set
+# CONFIG_DEBUG_SYS_INFO is not set
+# CONFIG_DEBUG_BLOCKDEV is not set
+# CONFIG_DEBUG_VFS is not set
+# CONFIG_DEBUG_FSYS_EXT2FS is not set
+# CONFIG_DEBUG_PCI is not set
+# CONFIG_DEBUG_USB is not set
Index: lib.config
===================================================================
--- lib.config	(revision 0)
+++ lib.config	(revision 0)
@@ -0,0 +1,57 @@
+#
+# Automatically generated make config: don't edit
+# FILO version: 0.6.0
+# Fri Jul  1 00:09:40 2011
+#
+
+#
+# Generic Options
+#
+# CONFIG_EXPERIMENTAL is not set
+# CONFIG_OBSOLETE is not set
+# CONFIG_DEVELOPER is not set
+
+#
+# Architecture Options
+#
+CONFIG_TARGET_I386=y
+# CONFIG_TARGET_POWERPC is not set
+CONFIG_MULTIBOOT=y
+
+#
+# Standard Libraries
+#
+CONFIG_LIBC=y
+CONFIG_TINYCURSES=y
+# CONFIG_CBFS is not set
+
+#
+# Console Options
+#
+CONFIG_SERIAL_CONSOLE=y
+CONFIG_SERIAL_IOBASE=0x3f8
+# CONFIG_SERIAL_SET_SPEED is not set
+# CONFIG_SERIAL_ACS_FALLBACK is not set
+CONFIG_VIDEO_CONSOLE=y
+CONFIG_VGA_VIDEO_CONSOLE=y
+# CONFIG_GEODELX_VIDEO_CONSOLE is not set
+# CONFIG_COREBOOT_VIDEO_CONSOLE is not set
+CONFIG_PC_KEYBOARD=y
+CONFIG_PC_KEYBOARD_LAYOUT_US=y
+# CONFIG_PC_KEYBOARD_LAYOUT_DE is not set
+
+#
+# Drivers
+#
+CONFIG_PCI=y
+CONFIG_NVRAM=y
+# CONFIG_RTC_PORT_EXTENDED_VIA is not set
+CONFIG_SPEAKER=y
+CONFIG_USB=y
+CONFIG_USB_UHCI=y
+# CONFIG_USB_OHCI is not set
+CONFIG_USB_EHCI=y
+# CONFIG_USB_XHCI is not set
+CONFIG_USB_HID=y
+CONFIG_USB_HUB=y
+CONFIG_USB_MSC=y
This is experimental patch
Download fresh flashrom sources to payloads/flashrom dir.
try running "make payload"

currently only writting to flash is supported
writes rom image from usb flash drive to mainboard flash

if you don't have a backup chip this may brick your board
any error will halt the system

Signed-off-by: Tadas Slotkus <[email protected]>

Index: flash.h
===================================================================
--- flash.h	(revision 1357)
+++ flash.h	(working copy)
@@ -32,7 +32,11 @@
 #undef min
 #undef max
 #endif
-
+#ifdef __LIBPAYLOAD__
+#undef __linux__
+#define fprintf(stream, ...) printf(__VA_ARGS__)
+#define vfprintf(output_type, fmt, ap) vprintf(fmt, ap)
+#endif
 #define ERROR_PTR ((void*)-1)
 
 /* Error codes */
@@ -249,6 +253,7 @@
 
 /* cli_classic.c */
 int cli_classic(int argc, char *argv[]);
+int cli_payload(int argc, char *argv[]);
 
 /* layout.c */
 int read_romlayout(char *name);
Index: cli_output.c
===================================================================
--- cli_output.c	(revision 1357)
+++ cli_output.c	(working copy)
@@ -47,6 +47,8 @@
 	va_start(ap, fmt);
 	ret = vfprintf(output_type, fmt, ap);
 	va_end(ap);
+#ifndef __LIBPAYLOAD__
 	fflush(output_type);
+#endif
 	return ret;
 }
Index: Makefile
===================================================================
--- Makefile	(revision 1357)
+++ Makefile	(working copy)
@@ -30,8 +30,9 @@
 EXPORTDIR ?= .
 AR      ?= ar
 RANLIB  ?= ranlib
+FILO_DIR = ../filo/
 
-WARNERROR ?= yes
+WARNERROR ?= no
 
 ifeq ($(WARNERROR), yes)
 CFLAGS += -Werror
@@ -85,10 +86,11 @@
 endif
 
 ifeq ($(OS_ARCH), libpayload)
-CC:=CC=i386-elf-gcc lpgcc
-AR:=i386-elf-ar
-RANLIB:=i386-elf-ranlib
+CC:=../libpayload/install/libpayload/bin/lpgcc
+AR_ARCH = --target=elf32-i386
+RANLIB_ARCH = --target=elf32-i386
 CPPFLAGS += -DSTANDALONE
+CPPFLAGS += -I$(FILO_DIR)include -I$(FILO_DIR)i386/include -I$(FILO_DIR)build
 ifeq ($(CONFIG_DUMMY), yes)
 UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
 else
@@ -126,6 +128,11 @@
 
 CLI_OBJS = flashrom.o cli_classic.o cli_output.o print.o
 
+include $(FILO_DIR).config
+TARGETS-y :=
+include $(FILO_DIR)drivers/Makefile.inc $(FILO_DIR)fs/Makefile.inc 
+FILO_OBJS = $(addprefix $(FILO_DIR), $(TARGETS-y)) $(FILO_DIR)main/strtox.o
+
 PROGRAMMER_OBJS = udelay.o programmer.o
 
 all: pciutils features $(PROGRAM)$(EXEC_SUFFIX)
@@ -361,7 +368,9 @@
 # FIXME There needs to be a better way to do this
 LIBS += ../libpci/lib/libpci.a
 else
+ifneq ($(OS_ARCH), libpayload)
 LIBS += -lpci
+endif
 ifeq ($(OS_ARCH), OpenBSD)
 # For (i386|amd64)_iopl(2).
 LIBS += -l$(shell uname -m)
@@ -381,15 +390,25 @@
 FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
 
 LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
-OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS) 
+OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
 
+ifeq ($(OS_ARCH), libpayload)
+OBJS += $(FILO_OBJS) payload.o
+endif
+
 $(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
 	$(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(FEATURE_LIBS) $(LIBS)
 
 libflashrom.a: $(LIBFLASHROM_OBJS)
-	$(AR) rcs $@ $^
-	$(RANLIB) $@
+	$(AR) rcs $@ $^ $(AR_ARCH)
+	$(RANLIB) $@ $(AR_ARCH)
 
+payload:
+	make OS_ARCH=libpayload
+
+payload.a:
+	make OS_ARCH=libpayload libflashrom.a
+
 # TAROPTIONS reduces information leakage from the packager's system.
 # If other tar programs support command line arguments for setting uid/gid of
 # stored files, they can be handled here as well.
@@ -402,7 +421,9 @@
 # This includes all frontends and libflashrom.
 # We don't use EXEC_SUFFIX here because we want to clean everything.
 clean:
-	rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d
+	rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d .*.tmp
+	find $(FILO_DIR) -path "../*.o" -delete
+	find $(FILO_DIR) -path "../*.d" -delete
 
 distclean: clean
 	rm -f .features .libdeps
@@ -519,6 +540,6 @@
 djgpp-dos: clean
 	make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip WARNERROR=no OS_ARCH=DOS
 
-.PHONY: all clean distclean compiler pciutils features export tarball dos featuresavailable
+.PHONY: all clean distclean compiler pciutils features export tarball dos featuresavailable payload payload.a
 
 -include $(OBJS:.o=.d)
Index: cli_classic.c
===================================================================
--- cli_classic.c	(revision 1357)
+++ cli_classic.c	(working copy)
@@ -22,8 +22,10 @@
  */
 
 #include <stdio.h>
+#ifndef __LIBPAYLOAD__
 #include <fcntl.h>
 #include <sys/stat.h>
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <getopt.h>
@@ -150,12 +152,14 @@
 	if (selfcheck())
 		exit(1);
 
+#ifndef __LIBPAYLOAD__
 	setbuf(stdout, NULL);
+#endif
 	/* FIXME: Delay all operation_specified checks until after command
 	 * line parsing to allow --help overriding everything else.
 	 */
 	while ((opt = getopt_long(argc, argv, optstring,
-				  long_options, &option_index)) != EOF) {
+				  long_options, &option_index)) != -1) {
 		switch (opt) {
 		case 'r':
 			if (++operation_specified > 1) {
Index: layout.c
===================================================================
--- layout.c	(revision 1357)
+++ layout.c	(working copy)
@@ -136,9 +136,9 @@
 }
 #endif
 
-#ifndef __LIBPAYLOAD__
 int read_romlayout(char *name)
 {
+#ifndef __LIBPAYLOAD__
 	FILE *romlayout;
 	char tempstr[256];
 	int i;
@@ -191,8 +191,10 @@
 	fclose(romlayout);
 
 	return 0;
+#else
+	return -1;
+#endif
 }
-#endif
 
 int find_romentry(char *name)
 {
Index: payload.c
===================================================================
--- payload.c	(revision 0)
+++ payload.c	(revision 0)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2011 Tadas Slotkus
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include "fs.h"
+#define LINE_SIZE	40
+
+int cli_classic(int argc, char *argv[]);
+
+int cli_payload(int argc, char *argv[])
+{
+	usb_initialize();
+	while (havechar())
+		getchar();
+
+	char *argt[8], line[LINE_SIZE], lineb[LINE_SIZE];
+	memset(line, 0, LINE_SIZE);
+	//set a predefined line
+	strcpy(line + 1, "-w uda1:/coreboot.rom\0");
+
+	while (1) {
+		argc = 0;
+		printf("\nEnter cmd line args like: -w uda1:/coreboot.rom\n");
+		strcpy(line + getline(line + 1, LINE_SIZE - 1) + 1, "\0\0");
+		memcpy(lineb, line, LINE_SIZE);
+		argt[argc++] = strtok(line, " ");
+		while (((argt[argc] = strtok(NULL, " ")) < (line + LINE_SIZE)) \
+				&& (strlen(argt[argc]) > 0))
+			argc++;
+
+#if 0	//debug fishing args from line
+		int i;
+		printf("\ngot args:\n");
+		for (i = 0; i < argc; i++)
+			printf("%d:%s|\n", i, argt[i]);
+		printf("\n");
+#endif
+		if (!file_open(argt[2]))// TODO: this needs checking which argt is actually filename
+			printf("\nfile not found\n");
+		else
+			cli_classic(argc, argt);
+		memcpy(line, lineb, LINE_SIZE);
+	}
+	return 0;
+}
+
+int read_buf_from_file(unsigned char *buf, unsigned long size, char *fname)
+{
+	if (!file_open(fname)){
+		perror(fname);
+		return 1;
+	}
+	file_seek(0);
+	printf("\nread %d bytes\n", file_read(buf, size));
+	file_close();
+	return 0;
+}
+
+void print_a_completion (char *name)
+{
+	// Nothing yet.
+}
+
Index: nicintel.c
===================================================================
--- nicintel.c	(revision 1357)
+++ nicintel.c	(working copy)
@@ -23,12 +23,14 @@
 #include "flash.h"
 #include "programmer.h"
 
+#define PCI_VENDOR_ID_INTEL 0x8086
+
 uint8_t *nicintel_bar;
 uint8_t *nicintel_control_bar;
 
 const struct pcidev_status nics_intel[] = {
-	{PCI_VENDOR_ID_INTEL, 0x1209, NT, "Intel", "8255xER/82551IT Fast Ethernet Controller"},
-	{PCI_VENDOR_ID_INTEL, 0x1229, NT, "Intel", "82557/8/9/0/1 Ethernet Pro 100"},
+	{0x8086, 0x1209, NT, "Intel", "8255xER/82551IT Fast Ethernet Controller"},
+	{0x8086, 0x1229, NT, "Intel", "82557/8/9/0/1 Ethernet Pro 100"},
 
 	{},
 };
Index: flashrom.c
===================================================================
--- flashrom.c	(revision 1357)
+++ flashrom.c	(working copy)
@@ -1218,6 +1218,7 @@
 	return ret;
 }
 
+#ifndef __LIBPAYLOAD__
 int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename)
 {
 	unsigned long numbytes;
@@ -1250,9 +1251,11 @@
 	}
 	return 0;
 }
+#endif
 
 int write_buf_to_file(unsigned char *buf, unsigned long size, const char *filename)
 {
+#ifndef __LIBPAYLOAD__
 	unsigned long numbytes;
 	FILE *image;
 
@@ -1272,6 +1275,7 @@
 			 filename);
 		return 1;
 	}
+#endif
 	return 0;
 }
 
@@ -1784,7 +1788,11 @@
 
 int main(int argc, char *argv[])
 {
+#ifdef __LIBPAYLOAD__
+	return cli_payload(argc, argv);
+#else
 	return cli_classic(argc, argv);
+#endif
 }
 
 /* FIXME: This function signature needs to be improved once doit() has a better
_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to