summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2016-09-11 18:48:02 +1000
committerDamien Zammit <damien@zamaudio.com>2016-09-11 18:48:02 +1000
commitd2d9fa720858b4738c229cf53712c05a99d0eab5 (patch)
tree9ed63ab6bb73622565f9c534f6620f6e14c0702e
parent6ac84e8376ed9f69fd569184cc3e2cf05beeadd0 (diff)
Added script to generate AGESA compatible user SMU firmware
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r--firmware/Makefile1
-rwxr-xr-xfirmware/makefirmware.sh91
-rw-r--r--firmware/smu.c5
-rw-r--r--signsmu.py10
4 files changed, 101 insertions, 6 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
index c26a638..3441ff8 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -30,6 +30,7 @@ all: $(TARGET)
$(TARGET): $(OBJS) $(OBJS2)
$(LD) $(LIBS) $(OBJS) $(OBJS2) -static -M -T smu.ld -o $(TARGET) >/dev/null
$(OC) -S -I elf32-lm32 -O binary $(TARGET) smu.rom
+ bash ./makefirmware.sh smu.rom > GnbSmuFirmwareTN.h
.c.o:
$(CC) $(LIBS) $(OPT) -Wall -ffreestanding -c $< -o $@
diff --git a/firmware/makefirmware.sh b/firmware/makefirmware.sh
new file mode 100755
index 0000000..b7e028c
--- /dev/null
+++ b/firmware/makefirmware.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# makefirmware.sh
+# Copyright (C) 2016 Damien Zammit <damien@zamaudio.com>
+#
+# 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 3 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.
+#
+
+FIRMWARE=$1
+
+LINES=$(od -t x4 -w4 -v -An --endian=big $FIRMWARE|wc -l)
+FWLEN=$(printf "0x%08x," $LINES)
+FWHEX=$(od -t x4 -w4 -v -An --endian=big $FIRMWARE|awk '{print "0x"$1","}')
+SHA1HASH=$(python ../signsmu.py $1 | awk '{print $1","}')
+
+echo "
+#ifndef _SMUFIRMWARE_H
+#define _SMUFIRMWARE_H
+
+UINT32 FirmwareTN[] = {
+ 0x000a00cb,
+ 0x00000040,"
+echo "$FWLEN"
+echo " 0x00010100,"
+echo "$SHA1HASH"
+echo " 0x0001d97c,
+ 0x0001da8c,
+ 0x00000000,
+ 0x0001daad,
+ 0x0001dabc,
+ 0x0001d9d0,
+ 0x0001dbf4,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0xaa55aa55,"
+echo "$FWHEX"
+echo "};"
+echo "#endif"
diff --git a/firmware/smu.c b/firmware/smu.c
index 8831317..28dfb28 100644
--- a/firmware/smu.c
+++ b/firmware/smu.c
@@ -10,13 +10,14 @@
* 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.
- * See <http://www.gnu.org/licenses/>.-
*/
#include "smu.h"
#include "delay.h"
#include "servicereq.h"
+#define SMU_POST(x) write32(0xe0003024, (x & 0xff))
+
void main(void)
{
int i;
@@ -40,6 +41,8 @@ void main(void)
write32(0xe0003004, INTACK | INTDONE);
write32(0x1f380, 1);
+ SMU_POST(0xcb);
+
while (1) {
e3 = read32(0xe0003000);
if ((e3 & ~1)) {
diff --git a/signsmu.py b/signsmu.py
index dcecd07..d90bab7 100644
--- a/signsmu.py
+++ b/signsmu.py
@@ -43,9 +43,9 @@ for wcnt in range(0,len(firmware)/4):
h = hmac.new(key1, firmware, hashlib.sha1)
mhash = h.digest()
-print hex(struct.unpack("<5I", mhash)[0])
-print hex(struct.unpack("<5I", mhash)[1])
-print hex(struct.unpack("<5I", mhash)[2])
-print hex(struct.unpack("<5I", mhash)[3])
-print hex(struct.unpack("<5I", mhash)[4])
+print hex(struct.unpack(">5I", mhash)[0])
+print hex(struct.unpack(">5I", mhash)[1])
+print hex(struct.unpack(">5I", mhash)[2])
+print hex(struct.unpack(">5I", mhash)[3])
+print hex(struct.unpack(">5I", mhash)[4])