summaryrefslogtreecommitdiff
path: root/board/zinger/board.c
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-11-13 10:51:49 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-15 06:57:32 +0000
commitc44bd8b3a324148a898f865bcce1e6153bf3de8f (patch)
tree34c8beeb0f383ab46872f5160c14f974ac3b828b /board/zinger/board.c
parent56bbd902abb2219cb3ae42aa1546d0b6fc3a04a0 (diff)
downloadchrome-ec-c44bd8b3a324148a898f865bcce1e6153bf3de8f.tar.gz
pd: zinger: add firmware update alternate mode to zingerstabilize-6480.B
Add a Google Firmware Update alternate mode to zinger. This mode must be entered in order to allow the unstructured VDMs that we use for sending a new firmware. BUG=chrome-os-partner:33754 BRANCH=samus TEST=load on samus and zinger. see that "GFU" is printed on zinger console to represent that it entered GFU mode. use twinkie to see that samus sent discover identity, discover svids, discover modes, enter mode, and then read info. See on samus pd console that we received result of read info. from samus pd console with zinger attached: > pe 1 dump IDENT: [ID Header] 2c0018d1 :: AMA, VID:18d1 [Cert Stat] 00000000 [2] 50100001 [3] 00000003 [4] 52136b91 [5] 0401137d SVID[0]: 18d1 MODES: [1] 00000000 MODE[1]: svid:18d1 caps:00000000 Also, use a samus with cros_pd_update running in kernel, and see that zinger auto-updates when plugged in. Performed 10 updates with no failures. Change-Id: I8d4d38e4a9f649fe0889f688f262630ef55106ee Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229622 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/zinger/board.c')
-rw-r--r--board/zinger/board.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/board/zinger/board.c b/board/zinger/board.c
index 23776e084b..5dcbef04fb 100644
--- a/board/zinger/board.c
+++ b/board/zinger/board.c
@@ -12,6 +12,7 @@
#include "task.h"
#include "usb_pd.h"
#include "util.h"
+#include "version.h"
/* Insert the RSA public key definition */
const struct rsa_public_key pkey __attribute__((section(".rsa_pubkey"))) =
@@ -22,6 +23,10 @@ static const void *rw_sig = (void *)CONFIG_FLASH_BASE + CONFIG_FW_RW_OFF
/* Large 768-Byte buffer for RSA computation : could be re-use afterwards... */
static uint32_t rsa_workbuf[3 * RSANUMWORDS];
+static uint8_t *rw_hash;
+static uint8_t rw_flash_changed;
+static uint32_t info_data[6];
+
extern void pd_rx_handler(void);
/* RW firmware reset vector */
@@ -55,14 +60,12 @@ int is_ro_mode(void)
static int check_rw_valid(void)
{
int good;
- uint8_t *hash;
/* Check if we have a RW firmware flashed */
if (*rw_rst == 0xffffffff)
return 0;
- hash = flash_hash_rw();
- good = rsa_verify(&pkey, (void *)rw_sig, (void *)hash, rsa_workbuf);
+ good = rsa_verify(&pkey, (void *)rw_sig, (void *)rw_hash, rsa_workbuf);
if (!good) {
debug_printf("RSA verify FAILED\n");
return 0;
@@ -71,6 +74,30 @@ static int check_rw_valid(void)
return 1;
}
+uint32_t *board_get_info(void)
+{
+ if (rw_flash_changed) {
+ /* re-calculate RW hash */
+ rw_hash = flash_hash_rw();
+ rw_flash_changed = 0;
+ }
+
+ /* copy first 20 bytes of RW hash */
+ memcpy(info_data, rw_hash, 5 * sizeof(uint32_t));
+
+ /* copy other info into data msg */
+ info_data[5] = VDO_INFO(CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR,
+ CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR,
+ ver_get_numcommits(), !is_ro_mode());
+
+ return info_data;
+}
+
+void board_rw_contents_change(void)
+{
+ rw_flash_changed = 1;
+}
+
extern void pd_task(void);
int main(void)
@@ -79,6 +106,9 @@ int main(void)
debug_printf("Power supply started ... %s\n",
is_ro_mode() ? "RO" : "RW");
+ /* calculate hash of RW */
+ rw_hash = flash_hash_rw();
+
/* Verify RW firmware and use it if valid */
if (is_ro_mode() && check_rw_valid())
jump_to_rw();