Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2159
-gerrit
commit 8d0f41a754da02824d861639ad91b74c90723d48
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Wed Jan 16 11:59:34 2013 -0600
Utility to run the snow bios in user mode
This program lets you test run a snow coreboot image in user mode
on a properly equipped arm system (usually an ARM chromebook).
This is a real time saver as you don't have to flash each time.
We've found and fixed some nasty bugs with this one.
Anyway, the instructions on how to use this are in the binary.
Change-Id: Ib555ef51fd7e930905a2ee5cbfda1cc6f068278e
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
util/runfw/Makefile | 23 ++++++++
util/runfw/googlesnow.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 160 insertions(+)
diff --git a/util/runfw/Makefile b/util/runfw/Makefile
new file mode 100644
index 0000000..cd5a1f7
--- /dev/null
+++ b/util/runfw/Makefile
@@ -0,0 +1,23 @@
+#
+# runfw -- run firmware in user mode.
+#
+# Copyright (C) 2013 The ChromiumOS Authors. All rights reserved.
+#
+# 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; version 2 of the License.
+#
+# 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
+#
+
+all: googlesnow
+
+googlesnow: googlesnow.c
+ cc -g -o googlesnow googlesnow.c
diff --git a/util/runfw/googlesnow.c b/util/runfw/googlesnow.c
new file mode 100644
index 0000000..25ef3a2
--- /dev/null
+++ b/util/runfw/googlesnow.c
@@ -0,0 +1,137 @@
+/*
+ * googlesnow - run google snow firmware in user mode
+ *
+ * Copyright (C) 2013 The ChromiumOS Authors. All rights reserved.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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 <stdio.h>
+#include <err.h>
+#include <sys/mman.h>
+
+#include <string.h>
+
+enum addresses {
+ regs = 0x10000000,
+ sram = 0x2020000,
+ sramsize = 0x77fff,
+};
+
+// 0x20234b0
+main(int argc, char *argv[])
+{
+ int fd;
+ int devmem;
+ void *regbase;
+ void *srambase;
+ void (*coreboot)(void) = (void *)0x2023400;
+
+ if (argc != 3)
+ errx(1, "usage: runbios rom-file start-address");
+
+ fd = open(argv[1], 2);
+ if (fd < 0)
+ err(1, argv[1]);
+ devmem = open("/dev/mem", 2);
+ if (devmem < 0)
+ err(1, argv[1]);
+ srambase = mmap((void *)sram, sramsize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (-1 == (int)sram)
+ err(1, "mmap");
+ memset((void *)sram, 0xff, sramsize);
+
+ /* now sort of do what bl1 does: read the 'rom' into the sram */
+ /* skip the bl1. We don't run it. */
+ if (pread(fd, coreboot, 30*1024, 0x2000) < 30*1024)
+ err(1, "read 'rom'");
+ /* you want to be in gdb at this point. */
+ coreboot = (void *) (strtoul(argv[2], 0, 0));
+ coreboot();
+}
+#if 0
+/* cc -g googlesnow.c */
+/* typical run
+gdb a.out
+(gdb) list 50
+
+45 i2c = mmap((void *)0x12c60000, 0x10000, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, devmem, (off_t) 0x12c60000);
+46 if (-1 == (int)i2c)
+47 err(1, "mmap i2c");
+48
+49 /* now sort of do what bl1 does: read the 'rom' into the sram */
+50 if (pread(fd, coreboot, 30*1024, 0x2000) < 30*1024)
+51 err(1, "read 'rom'");
+52 /* you want to be in gdb at this point. */
+53 coreboot = (void *) strtoull(argv[2], 0, 0);
+54 coreboot();
+(gdb) br 54
+Breakpoint 3 at 0x8798: file runbios.c, line 54.
+(gdb) run ~/coreboot/build/coreboot.rom 0x020234b0
+The program being debugged has been started already.
+Start it from the beginning? (y or n) y
+
+Starting program: /root/coreboot/util/runarmbios/a.out ~/coreboot/build/coreboot.rom 0x020234b0
+
+Breakpoint 3, main (argc=3, argv=0x7efff7c4) at runbios.c:54
+54 coreboot();
+(gdb) symbol-file ~/coreboot/build/cbfs/fallback/bootblock.debug
+Load new symbol table from "/root/coreboot/build/cbfs/fallback/bootblock.debug"? (y or n) y
+Reading symbols from /root/coreboot/build/cbfs/fallback/bootblock.debug...done.
+Error in re-setting breakpoint 3: No source file named runbios.c.
+(gdb) display/i $pc
+1: x/i $pc
+=> 0x8798: ldr r3, [r11, #-8]
+(gdb) stepi
+0x0000879c in ?? ()
+1: x/i $pc
+=> 0x879c: blx r3
+(gdb)
+0x020234b0 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b0 <call_bootblock>: ldr sp, [pc, #3800] ; 0x2024390
+(gdb)
+0x020234b4 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b4 <call_bootblock+4>: bic sp, sp, #7
+(gdb)
+0x020234b8 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b8 <call_bootblock+8>: mov r0, #0
+(gdb)
+0x020234bc in call_bootblock ()
+1: x/i $pc
+=> 0x20234bc <call_bootblock+12>: blx 0x20244b8 <main>
+(gdb)
+main (bist=0) at src/arch/armv7/bootblock_simple.c:37
+37 {
+1: x/i $pc
+=> 0x20244b8 <main>: push {r3, lr}
+(gdb)
+42 bootblock_mainboard_init();
+1: x/i $pc
+=> 0x20244ba <main+2>: bl 0x2023c08 <bootblock_mainboard_init>
+(gdb)
+bootblock_mainboard_init () at src/mainboard/google/snow/bootblock.c:2124
+2124 {
+1: x/i $pc
+=> 0x2023c08 <bootblock_mainboard_init>: stmdb sp!, {r4, r5, r6, r7, r9, r10, r11, lr}
+(gdb)
+2127 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+1: x/i $pc
+=> 0x2023c0c <bootblock_mainboard_init+4>: movs r1, #0
+
+Note you are now debugging source, and pretty much all commands work.
+*/
+#endif
Paul Menzel (paulepanter(a)users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2160
-gerrit
commit d0c39ce6c0868bf8e8dc9b11f78af5aefc3be81e
Author: Martin Roth <martin(a)se-eng.com>
Date: Thu Jan 10 12:41:40 2013 -0700
F15tn: Modify devicetree to fix S3 resume
The way that devicetree.cb was configured for the family 15tn boards
was doing... interesting things to the video device initialization.
This was causing S3 resume to fail.
There is a disconnect between how the devicetree should be configured
if there are multiple HT links on the CPU and how it's configured if
there's only one HT link. These platforms were set up as if they
had multiple HT links, which was causing duplicate instances of
devices in the device list.
The scan for the IO Hub was removed from the northbridge code which
isn't a problem for F15tn devices.
Change-Id: I3556b43027746e36b07de7cb1bece4d1b37a3c34
Signed-off-by: Martin Roth <martin(a)se-eng.com>
---
src/mainboard/amd/parmer/devicetree.cb | 4 +---
src/mainboard/amd/thatcher/devicetree.cb | 4 +---
src/northbridge/amd/agesa/family15tn/northbridge.c | 23 ----------------------
3 files changed, 2 insertions(+), 29 deletions(-)
diff --git a/src/mainboard/amd/parmer/devicetree.cb b/src/mainboard/amd/parmer/devicetree.cb
index 4a59b51..32f5484 100644
--- a/src/mainboard/amd/parmer/devicetree.cb
+++ b/src/mainboard/amd/parmer/devicetree.cb
@@ -25,7 +25,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci_domain 0 on
subsystemid 0x1022 0x1410 inherit
chip northbridge/amd/agesa/family15tn # CPU side of HT root complex
- device pci 18.0 on # northbridge
chip northbridge/amd/agesa/family15tn # PCI side of HT root complex
device pci 0.0 on end # Root Complex
device pci 1.0 on end # Internal Graphics P2P bridge 0x9804
@@ -38,7 +37,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci 7.0 on end # LAN
device pci 8.0 off end # NB/SB Link P2P bridge
end
- end
chip southbridge/amd/agesa/hudson # it is under NB/SB Link, but on the same pci bus
device pci 10.0 on end # XHCI HC0
device pci 10.1 on end # XHCI HC1
@@ -75,7 +73,7 @@ chip northbridge/amd/agesa/family15tn/root_complex
register "boot_switch_sata_ide" = "0" # 0: boot from SATA. 1: IDE
register "gpp_configuration" = "4"
end #southbridge/amd/hudson
-# device pci 18.0 on end
+ device pci 18.0 on end
#device pci 18.0 on end
device pci 18.1 on end
device pci 18.2 on end
diff --git a/src/mainboard/amd/thatcher/devicetree.cb b/src/mainboard/amd/thatcher/devicetree.cb
index 2a91e1a..561a5b2 100644
--- a/src/mainboard/amd/thatcher/devicetree.cb
+++ b/src/mainboard/amd/thatcher/devicetree.cb
@@ -25,7 +25,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci_domain 0 on
subsystemid 0x1022 0x1410 inherit
chip northbridge/amd/agesa/family15tn # CPU side of HT root complex
- device pci 18.0 on # northbridge
chip northbridge/amd/agesa/family15tn # PCI side of HT root complex
device pci 0.0 on end # Root Complex
device pci 1.0 on end # Internal Graphics P2P bridge 0x9804
@@ -38,7 +37,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci 7.0 on end # LAN
device pci 8.0 off end # NB/SB Link P2P bridge
end
- end
chip southbridge/amd/agesa/hudson # it is under NB/SB Link, but on the same pci bus
device pci 10.0 on end # XHCI HC0
device pci 10.1 on end # XHCI HC1
@@ -92,7 +90,7 @@ chip northbridge/amd/agesa/family15tn/root_complex
register "boot_switch_sata_ide" = "0" # 0: boot from SATA. 1: IDE
register "gpp_configuration" = "4"
end #southbridge/amd/hudson
-# device pci 18.0 on end
+ device pci 18.0 on end
#device pci 18.0 on end
device pci 18.1 on end
device pci 18.2 on end
diff --git a/src/northbridge/amd/agesa/family15tn/northbridge.c b/src/northbridge/amd/agesa/family15tn/northbridge.c
index 9318164..df632e3 100644
--- a/src/northbridge/amd/agesa/family15tn/northbridge.c
+++ b/src/northbridge/amd/agesa/family15tn/northbridge.c
@@ -446,35 +446,12 @@ static void northbridge_init(struct device *dev)
{
}
-static unsigned scan_chains(device_t dev, unsigned max)
-{
- unsigned nodeid;
- struct bus *link;
- device_t io_hub = NULL;
- u32 next_unitid = 0x18;
- nodeid = amdfam15_nodeid(dev);
- if (nodeid == 0) {
- for (link = dev->link_list; link; link = link->next) {
- //if (link->link_num == sblink) { /* devicetree put IO Hub on link_lsit[sblink] */
- if (link->link_num == 0) { /* devicetree put IO Hub on link_lsit[0] */
- io_hub = link->children;
- if (!io_hub || !io_hub->enabled) {
- die("I can't find the IO Hub, or IO Hub not enabled, please check the device tree.\n");
- }
- /* Now that nothing is overlapping it is safe to scan the children. */
- max = pci_scan_bus(link, 0x00, ((next_unitid - 1) << 3) | 7, 0);
- }
- }
- }
- return max;
-}
static struct device_operations northbridge_operations = {
.read_resources = read_resources,
.set_resources = set_resources,
.enable_resources = pci_dev_enable_resources,
.init = northbridge_init,
- .scan_bus = scan_chains,
.enable = 0,
.ops_pci = 0,
};
Paul Menzel (paulepanter(a)users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2160
-gerrit
commit 768c6d18e8457ffa069c7f4538ccd6f4ac163f4c
Author: Martin Roth <martin(a)se-eng.com>
Date: Thu Jan 10 12:41:40 2013 -0700
F15tn: Modify devicetree to fix S3 resume
The way that devicetree.cb was configured for the family 15tn boards
was doing... interesting things to the video device initialization.
This was causing S3 resume to fail.
There is a disconnect between how the devicetree should be configured
if there are multiple HT links on the CPU and how it's configured if
there's only one HT link. These platforms were set up as if they
had multiple HT links, which was causing duplicate instances of
devices in the device list.
The scan for the IO Hub was removed from the northbridge code which
isn't a problem for f15tn devices.
Change-Id: I3556b43027746e36b07de7cb1bece4d1b37a3c34
Signed-off-by: Martin Roth <martin(a)se-eng.com>
---
src/mainboard/amd/parmer/devicetree.cb | 4 +---
src/mainboard/amd/thatcher/devicetree.cb | 4 +---
src/northbridge/amd/agesa/family15tn/northbridge.c | 23 ----------------------
3 files changed, 2 insertions(+), 29 deletions(-)
diff --git a/src/mainboard/amd/parmer/devicetree.cb b/src/mainboard/amd/parmer/devicetree.cb
index 4a59b51..32f5484 100644
--- a/src/mainboard/amd/parmer/devicetree.cb
+++ b/src/mainboard/amd/parmer/devicetree.cb
@@ -25,7 +25,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci_domain 0 on
subsystemid 0x1022 0x1410 inherit
chip northbridge/amd/agesa/family15tn # CPU side of HT root complex
- device pci 18.0 on # northbridge
chip northbridge/amd/agesa/family15tn # PCI side of HT root complex
device pci 0.0 on end # Root Complex
device pci 1.0 on end # Internal Graphics P2P bridge 0x9804
@@ -38,7 +37,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci 7.0 on end # LAN
device pci 8.0 off end # NB/SB Link P2P bridge
end
- end
chip southbridge/amd/agesa/hudson # it is under NB/SB Link, but on the same pci bus
device pci 10.0 on end # XHCI HC0
device pci 10.1 on end # XHCI HC1
@@ -75,7 +73,7 @@ chip northbridge/amd/agesa/family15tn/root_complex
register "boot_switch_sata_ide" = "0" # 0: boot from SATA. 1: IDE
register "gpp_configuration" = "4"
end #southbridge/amd/hudson
-# device pci 18.0 on end
+ device pci 18.0 on end
#device pci 18.0 on end
device pci 18.1 on end
device pci 18.2 on end
diff --git a/src/mainboard/amd/thatcher/devicetree.cb b/src/mainboard/amd/thatcher/devicetree.cb
index 2a91e1a..561a5b2 100644
--- a/src/mainboard/amd/thatcher/devicetree.cb
+++ b/src/mainboard/amd/thatcher/devicetree.cb
@@ -25,7 +25,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci_domain 0 on
subsystemid 0x1022 0x1410 inherit
chip northbridge/amd/agesa/family15tn # CPU side of HT root complex
- device pci 18.0 on # northbridge
chip northbridge/amd/agesa/family15tn # PCI side of HT root complex
device pci 0.0 on end # Root Complex
device pci 1.0 on end # Internal Graphics P2P bridge 0x9804
@@ -38,7 +37,6 @@ chip northbridge/amd/agesa/family15tn/root_complex
device pci 7.0 on end # LAN
device pci 8.0 off end # NB/SB Link P2P bridge
end
- end
chip southbridge/amd/agesa/hudson # it is under NB/SB Link, but on the same pci bus
device pci 10.0 on end # XHCI HC0
device pci 10.1 on end # XHCI HC1
@@ -92,7 +90,7 @@ chip northbridge/amd/agesa/family15tn/root_complex
register "boot_switch_sata_ide" = "0" # 0: boot from SATA. 1: IDE
register "gpp_configuration" = "4"
end #southbridge/amd/hudson
-# device pci 18.0 on end
+ device pci 18.0 on end
#device pci 18.0 on end
device pci 18.1 on end
device pci 18.2 on end
diff --git a/src/northbridge/amd/agesa/family15tn/northbridge.c b/src/northbridge/amd/agesa/family15tn/northbridge.c
index 9318164..df632e3 100644
--- a/src/northbridge/amd/agesa/family15tn/northbridge.c
+++ b/src/northbridge/amd/agesa/family15tn/northbridge.c
@@ -446,35 +446,12 @@ static void northbridge_init(struct device *dev)
{
}
-static unsigned scan_chains(device_t dev, unsigned max)
-{
- unsigned nodeid;
- struct bus *link;
- device_t io_hub = NULL;
- u32 next_unitid = 0x18;
- nodeid = amdfam15_nodeid(dev);
- if (nodeid == 0) {
- for (link = dev->link_list; link; link = link->next) {
- //if (link->link_num == sblink) { /* devicetree put IO Hub on link_lsit[sblink] */
- if (link->link_num == 0) { /* devicetree put IO Hub on link_lsit[0] */
- io_hub = link->children;
- if (!io_hub || !io_hub->enabled) {
- die("I can't find the IO Hub, or IO Hub not enabled, please check the device tree.\n");
- }
- /* Now that nothing is overlapping it is safe to scan the children. */
- max = pci_scan_bus(link, 0x00, ((next_unitid - 1) << 3) | 7, 0);
- }
- }
- }
- return max;
-}
static struct device_operations northbridge_operations = {
.read_resources = read_resources,
.set_resources = set_resources,
.enable_resources = pci_dev_enable_resources,
.init = northbridge_init,
- .scan_bus = scan_chains,
.enable = 0,
.ops_pci = 0,
};
Paul Menzel (paulepanter(a)users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2165
-gerrit
commit f59736a755351379209f17a653dd14ebd4187efb
Author: Martin Roth <martin.roth(a)se-eng.com>
Date: Wed Jan 16 17:50:32 2013 -0700
F15tn / Hudson: Change SATA NumOfPorts register setting
The Number of Ports register says that it should be set to the maximum
number of ports supported by the silicon. AGESA was setting this to be
the number of enabled ports. If port 1 was the only port with a drive,
this value got set to 0, indicating 1 port. This causes SeaBIOS to only
look at port 0 and quit, never finding the drive on port 1.
Dave Frodin: I also verified that this patch allows a SATA drive plugged
into port 2 to be detected without a device in port 1.
Change-Id: I5d49e351864449520e3957bbb07edf0f3ec2fd47
Signed-off-by: Martin Roth <martin.roth(a)se-eng.com>
---
.../Fch/Sata/Family/Hudson2/Hudson2SataService.c | 25 ++++++----------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/Fch/Sata/Family/Hudson2/Hudson2SataService.c b/src/vendorcode/amd/agesa/f15tn/Proc/Fch/Sata/Family/Hudson2/Hudson2SataService.c
index d3eb263..bf97f8b 100644
--- a/src/vendorcode/amd/agesa/f15tn/Proc/Fch/Sata/Family/Hudson2/Hudson2SataService.c
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/Fch/Sata/Family/Hudson2/Hudson2SataService.c
@@ -83,7 +83,6 @@
* D E F I N I T I O N S A N D M A C R O S
*----------------------------------------------------------------------------------------
*/
-UINT8 NumOfSataPorts = 8;
/**
* FchSataGpioInitial - Sata GPIO function Procedure
@@ -581,7 +580,6 @@ FchShutdownUnconnectedSataPortClock (
{
UINT8 PortNumByte;
UINT8 PortSataStatusByte;
- UINT8 NumOfPorts;
UINT8 FchSataClkAutoOff;
FCH_DATA_BLOCK *LocalCfgPtr;
AMD_CONFIG_PARAMS *StdHeader;
@@ -590,7 +588,6 @@ FchShutdownUnconnectedSataPortClock (
StdHeader = LocalCfgPtr->StdHeader;
FchSataClkAutoOff = (UINT8) LocalCfgPtr->Sata.SataClkAutoOff;
- NumOfPorts = 0;
//
// Enable SATA auto clock control by default
//
@@ -606,28 +603,20 @@ FchShutdownUnconnectedSataPortClock (
}
} ///end of for (PortNumByte=0;PortNumByte<6;PortNumByte++)
- ReadMem (Bar5 + 0x0C, AccessWidth8, &PortSataStatusByte);
-
//
+ //Set the Ports Implemented register
//if all ports are in disabled state, report at least one port
//
+ ReadMem (Bar5 + 0x0C, AccessWidth8, &PortSataStatusByte);
if ( (PortSataStatusByte & 0xFF) == 0) {
RwMem (Bar5 + 0x0C, AccessWidth8, (UINT32) ~(0xFF), 01);
}
- ReadMem (Bar5 + 0x0C, AccessWidth8, &PortSataStatusByte);
-
- for (PortNumByte = 0; PortNumByte < MAX_SATA_PORTS; PortNumByte ++) {
- if (PortSataStatusByte & (1 << PortNumByte)) {
- NumOfPorts++;
- }
- }
-
- if ( NumOfPorts == 0) {
- NumOfPorts = 0x01;
- }
-
- RwMem (Bar5 + 0x00, AccessWidth8, 0xE0, NumOfPorts - 1);
+ //
+ // Number of Ports (NP): 0’s based value indicating the maximum number
+ // of ports supported by the HBA silicon.
+ //
+ RwMem (Bar5 + 0x00, AccessWidth8, 0xE0, MAX_SATA_PORTS - 1);
}
/**
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2159
-gerrit
commit ea852533f42707c5c5122986f350a57a61e7a2a9
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Wed Jan 16 11:59:34 2013 -0600
Utility to run the snow bios in user mode
This program lets you test run a snow coreboot image in user mode
on a properly equipped arm system (usually an ARM chromebook).
This is a real time saver as you don't have to flash each time.
We've found and fixed some nasty bugs with this one.
Anyway, the instructions on how to use this are in the binary.
Change-Id: Ib555ef51fd7e930905a2ee5cbfda1cc6f068278e
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
util/runfw/Makefile | 23 ++++++++
util/runfw/googlesnow.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 161 insertions(+)
diff --git a/util/runfw/Makefile b/util/runfw/Makefile
new file mode 100644
index 0000000..1c96adc
--- /dev/null
+++ b/util/runfw/Makefile
@@ -0,0 +1,23 @@
+#
+# runfw -- fun firmware in user mode.
+#
+# Copyright (C) 2013 The ChromiumOS Authors. All rights reserved.
+#
+# 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; version 2 of the License.
+#
+# 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
+#
+
+all: googlesnow
+
+googlesnow: googlesnow.c
+ cc -g -o googlesnow googlesnow.c
diff --git a/util/runfw/googlesnow.c b/util/runfw/googlesnow.c
new file mode 100644
index 0000000..80b9913
--- /dev/null
+++ b/util/runfw/googlesnow.c
@@ -0,0 +1,138 @@
+/*
+ * googlesnow - run google snow firmware in user mode
+ *
+ * Copyright (C) 2013 The ChromiumOS Authors. All rights reserved.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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 <stdio.h>
+#include <err.h>
+#include <sys/mman.h>
+
+#include <string.h>
+
+enum addresses {
+ regs = 0x10000000,
+ sram = 0x2020000,
+ sramsize = 0x77fff,
+};
+
+// 0x20234b0
+main(int argc, char *argv[])
+{
+ int fd;
+ int devmem;
+ void *regbase;
+ void *srambase;
+ void (*coreboot)(void) = (void *)0x2023400;
+
+ if (argc != 3)
+ errx(1, "usage: runbios rom-file start-address");
+
+ fd = open(argv[1], 2);
+ if (fd < 0)
+ err(1, argv[1]);
+ devmem = open("/dev/mem", 2);
+ if (devmem < 0)
+ err(1, argv[1]);
+ srambase = mmap((void *)sram, sramsize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (-1 == (int)sram)
+ err(1, "mmap");
+ memset((void *)sram, 0xff, sramsize);
+
+
+ /* now sort of do what bl1 does: read the 'rom' into the sram */
+ /* skip the bl1. We don't run it. */
+ if (pread(fd, coreboot, 30*1024, 0x2000) < 30*1024)
+ err(1, "read 'rom'");
+ /* you want to be in gdb at this point. */
+ coreboot = (void *) (strtoul(argv[2], 0, 0));
+ coreboot();
+}
+#if 0
+/* cc -g googlesnow.c */
+/* typical run
+gdb a.out
+(gdb) list 50
+
+45 i2c = mmap((void *)0x12c60000, 0x10000, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, devmem, (off_t) 0x12c60000);
+46 if (-1 == (int)i2c)
+47 err(1, "mmap i2c");
+48
+49 /* now sort of do what bl1 does: read the 'rom' into the sram */
+50 if (pread(fd, coreboot, 30*1024, 0x2000) < 30*1024)
+51 err(1, "read 'rom'");
+52 /* you want to be in gdb at this point. */
+53 coreboot = (void *) strtoull(argv[2], 0, 0);
+54 coreboot();
+(gdb) br 54
+Breakpoint 3 at 0x8798: file runbios.c, line 54.
+(gdb) run ~/coreboot/build/coreboot.rom 0x020234b0
+The program being debugged has been started already.
+Start it from the beginning? (y or n) y
+
+Starting program: /root/coreboot/util/runarmbios/a.out ~/coreboot/build/coreboot.rom 0x020234b0
+
+Breakpoint 3, main (argc=3, argv=0x7efff7c4) at runbios.c:54
+54 coreboot();
+(gdb) symbol-file ~/coreboot/build/cbfs/fallback/bootblock.debug
+Load new symbol table from "/root/coreboot/build/cbfs/fallback/bootblock.debug"? (y or n) y
+Reading symbols from /root/coreboot/build/cbfs/fallback/bootblock.debug...done.
+Error in re-setting breakpoint 3: No source file named runbios.c.
+(gdb) display/i $pc
+1: x/i $pc
+=> 0x8798: ldr r3, [r11, #-8]
+(gdb) stepi
+0x0000879c in ?? ()
+1: x/i $pc
+=> 0x879c: blx r3
+(gdb)
+0x020234b0 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b0 <call_bootblock>: ldr sp, [pc, #3800] ; 0x2024390
+(gdb)
+0x020234b4 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b4 <call_bootblock+4>: bic sp, sp, #7
+(gdb)
+0x020234b8 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b8 <call_bootblock+8>: mov r0, #0
+(gdb)
+0x020234bc in call_bootblock ()
+1: x/i $pc
+=> 0x20234bc <call_bootblock+12>: blx 0x20244b8 <main>
+(gdb)
+main (bist=0) at src/arch/armv7/bootblock_simple.c:37
+37 {
+1: x/i $pc
+=> 0x20244b8 <main>: push {r3, lr}
+(gdb)
+42 bootblock_mainboard_init();
+1: x/i $pc
+=> 0x20244ba <main+2>: bl 0x2023c08 <bootblock_mainboard_init>
+(gdb)
+bootblock_mainboard_init () at src/mainboard/google/snow/bootblock.c:2124
+2124 {
+1: x/i $pc
+=> 0x2023c08 <bootblock_mainboard_init>: stmdb sp!, {r4, r5, r6, r7, r9, r10, r11, lr}
+(gdb)
+2127 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+1: x/i $pc
+=> 0x2023c0c <bootblock_mainboard_init+4>: movs r1, #0
+
+Note you are now debugging source, and pretty much all commands work.
+*/
+#endif
the following patch was just integrated into master:
commit 1c706dc85830a1d91c7ff7c99ac48efd8d085613
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Thu Jan 17 11:14:17 2013 -0800
Fix the stack setup code so we can use an arbitrary 32-bit value
We've had obscure errors as the size of the bootblock changes.
This fix allows us to use a 32-bit constant. Please test on
real hardware before you ack.
Change-Id: Ic3d9f4763554bd6104ae9c4ce5bbacd17b40872c
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
Reviewed-on: http://review.coreboot.org/2168
Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
Tested-by: build bot (Jenkins)
Build-Tested: build bot (Jenkins) at Thu Jan 17 20:21:54 2013, giving +1
Reviewed-By: David Hendricks <dhendrix(a)chromium.org> at Thu Jan 17 20:17:43 2013, giving +2
See http://review.coreboot.org/2168 for details.
-gerrit
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2159
-gerrit
commit f4d65fb24718e4d9851cc137e222898a7c3a4350
Author: Ronald G. Minnich <rminnich(a)gmail.com>
Date: Wed Jan 16 11:59:34 2013 -0600
Utility to run the snow bios in user mode
This program lets you test run a snow coreboot image in user mode
on a properly equipped arm system (usually an ARM chromebook).
This is a real time saver as you don't have to flash each time.
We've found and fixed some nasty bugs with this one.
Anyway, the instructions on how to use this are in the binary.
Change-Id: Ib555ef51fd7e930905a2ee5cbfda1cc6f068278e
Signed-off-by: Ronald G. Minnich <rminnich(a)gmail.com>
---
util/runfw/Makefile | 4 ++
util/runfw/googlesnow.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 123 insertions(+)
diff --git a/util/runfw/Makefile b/util/runfw/Makefile
new file mode 100644
index 0000000..597046e
--- /dev/null
+++ b/util/runfw/Makefile
@@ -0,0 +1,4 @@
+all: googlesnow
+
+googlesnow: googlesnow.c
+ cc -g -o googlesnow googlesnow.c
diff --git a/util/runfw/googlesnow.c b/util/runfw/googlesnow.c
new file mode 100644
index 0000000..54ef43c
--- /dev/null
+++ b/util/runfw/googlesnow.c
@@ -0,0 +1,119 @@
+#include <stdio.h>
+#include <err.h>
+#include <sys/mman.h>
+
+#include <string.h>
+
+enum addresses {
+ regs = 0x10000000,
+ sram = 0x2020000,
+ sramsize = 0x77fff,
+};
+
+// 0x20234b0
+main(int argc, char *argv[])
+{
+ int fd;
+ int devmem;
+ void *regbase;
+ void *srambase;
+ void (*coreboot)(void) = (void *)0x2023400;
+
+ if (argc != 3)
+ errx(1, "usage: runbios rom-file start-address");
+
+ fd = open(argv[1], 2);
+ if (fd < 0)
+ err(1, argv[1]);
+ devmem = open("/dev/mem", 2);
+ if (devmem < 0)
+ err(1, argv[1]);
+ srambase = mmap((void *)sram, sramsize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (-1 == (int)sram)
+ err(1, "mmap");
+ memset((void *)sram, 0xff, sramsize);
+
+
+ /* now sort of do what bl1 does: read the 'rom' into the sram */
+ /* skip the bl1. We don't run it. */
+ if (pread(fd, coreboot, 30*1024, 0x2000) < 30*1024)
+ err(1, "read 'rom'");
+ /* you want to be in gdb at this point. */
+ coreboot = (void *) (strtoul(argv[2], 0, 0));
+ coreboot();
+}
+#if 0
+/* cc -g googlesnow.c */
+/* typical run
+gdb a.out
+(gdb) list 50
+
+45 i2c = mmap((void *)0x12c60000, 0x10000, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, devmem, (off_t) 0x12c60000);
+46 if (-1 == (int)i2c)
+47 err(1, "mmap i2c");
+48
+49 /* now sort of do what bl1 does: read the 'rom' into the sram */
+50 if (pread(fd, coreboot, 30*1024, 0x2000) < 30*1024)
+51 err(1, "read 'rom'");
+52 /* you want to be in gdb at this point. */
+53 coreboot = (void *) strtoull(argv[2], 0, 0);
+54 coreboot();
+(gdb) br 54
+Breakpoint 3 at 0x8798: file runbios.c, line 54.
+(gdb) run ~/coreboot/build/coreboot.rom 0x020234b0
+The program being debugged has been started already.
+Start it from the beginning? (y or n) y
+
+Starting program: /root/coreboot/util/runarmbios/a.out ~/coreboot/build/coreboot.rom 0x020234b0
+
+Breakpoint 3, main (argc=3, argv=0x7efff7c4) at runbios.c:54
+54 coreboot();
+(gdb) symbol-file ~/coreboot/build/cbfs/fallback/bootblock.debug
+Load new symbol table from "/root/coreboot/build/cbfs/fallback/bootblock.debug"? (y or n) y
+Reading symbols from /root/coreboot/build/cbfs/fallback/bootblock.debug...done.
+Error in re-setting breakpoint 3: No source file named runbios.c.
+(gdb) display/i $pc
+1: x/i $pc
+=> 0x8798: ldr r3, [r11, #-8]
+(gdb) stepi
+0x0000879c in ?? ()
+1: x/i $pc
+=> 0x879c: blx r3
+(gdb)
+0x020234b0 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b0 <call_bootblock>: ldr sp, [pc, #3800] ; 0x2024390
+(gdb)
+0x020234b4 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b4 <call_bootblock+4>: bic sp, sp, #7
+(gdb)
+0x020234b8 in call_bootblock ()
+1: x/i $pc
+=> 0x20234b8 <call_bootblock+8>: mov r0, #0
+(gdb)
+0x020234bc in call_bootblock ()
+1: x/i $pc
+=> 0x20234bc <call_bootblock+12>: blx 0x20244b8 <main>
+(gdb)
+main (bist=0) at src/arch/armv7/bootblock_simple.c:37
+37 {
+1: x/i $pc
+=> 0x20244b8 <main>: push {r3, lr}
+(gdb)
+42 bootblock_mainboard_init();
+1: x/i $pc
+=> 0x20244ba <main+2>: bl 0x2023c08 <bootblock_mainboard_init>
+(gdb)
+bootblock_mainboard_init () at src/mainboard/google/snow/bootblock.c:2124
+2124 {
+1: x/i $pc
+=> 0x2023c08 <bootblock_mainboard_init>: stmdb sp!, {r4, r5, r6, r7, r9, r10, r11, lr}
+(gdb)
+2127 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+1: x/i $pc
+=> 0x2023c0c <bootblock_mainboard_init+4>: movs r1, #0
+
+Note you are now debugging source, and pretty much all commands work.
+*/
+#endif