Files
OpenCellular/util/uut/cmd.h
CHLin dcaf8edc47 util: uartupdatetool (UUT): Add tool to flash firmware by UART
When the FLPRG# strap pin is set to active low, and npcx7 chip is reset,
it will enter uut mode. This CL adds the host tool to communicate with
npcx chip in uut mode to flash ec firmware via UART port.

BRANCH=none
BUG=none
TEST=No build errors for make buildall.
TEST=
------------------------------------------------------------------------
1. Connect the servo connector (J24) on npcx7 EVB to servo board v2 via
flex cable.
2. Manually turn the switch SW1.6 to "ON" on npcx7 EVB.
3. Reset ec by issuing Power-Up or VCC1_RST reset.
4. Manually turn the switch SW1.6 to "OFF" on npcx7 EVB.
5. Move npcx7_evb from array BOARDS_NPCX_7M7X_JTAG to BOARDS_NPCX_UUT in
flash_ec.
6. "./util/flash_ec --board=npcx7_evb."

Change-Id: I2c588418e809e59f97ef4c3ad7ad13a3fef42f11
Signed-off-by: Dror Goldstein <dror.goldstein@nuvoton.com>
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/952037
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: Alexandru M Stan <amstan@chromium.org>
Tested-by: CH Lin <chlin56@nuvoton.com>
Tested-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-04-18 02:07:59 -07:00

70 lines
2.5 KiB
C

/*
* Copyright 2018 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __UTIL_UUT_CMD_H
#define __UTIL_UUT_CMD_H
#include <stdbool.h>
/*---------------------------------------------------------------------------
* Constant definitions
*---------------------------------------------------------------------------
*/
#define MAX_CMD_BUF_SIZE 10
#define MAX_RESP_BUF_SIZE 512
enum uart_protocol_cmd {
UFPP_H2D_SYNC_CMD = 0x55, /* Single-Byte Host to Device */
/* synchronization command */
UFPP_D2H_SYNC_CMD = 0x5A, /* Single-Byte Device to Host */
/* synchronization response */
UFPP_WRITE_CMD = 0x07, /* Write command and response */
UFPP_READ_CMD = 0x1C, /* Read command and response */
UFPP_READ_CRC_CMD = 0x89, /* Read CRC command and response */
UFPP_FCALL_CMD = 0x70, /* Call function command */
UFPP_FCALL_RSLT_CMD = 0x73, /* Call function response */
UFPP_SPI_CMD = 0x92, /* SPI specific command */
UFPP_ERROR_CMD = 0xFF /* Error response */
};
struct command_node {
uint8_t cmd[512];
uint32_t cmd_size;
uint32_t resp_size;
};
/*---------------------------------------------------------------------------
* Functions prototypes
*---------------------------------------------------------------------------
*/
void cmd_create_sync(uint8_t *cmd_info, uint32_t *cmd_len);
void cmd_create_write(uint32_t addr, uint32_t size, uint8_t *data_buf,
uint8_t *cmd_info, uint32_t *cmd_len);
void cmd_create_read(uint32_t addr, uint8_t size, uint8_t *cmd_info,
uint32_t *cmd_len);
void cmd_create_exec(uint32_t addr, uint8_t *cmd_info, uint32_t *cmd_len);
void cmd_build_sync(struct command_node *cmd_buf, uint32_t *cmd_num);
void cmd_build_exec_exit(uint32_t addr, struct command_node *cmd_buf,
uint32_t *cmd_num);
void cmd_build_exec_ret(uint32_t addr, struct command_node *cmd_buf,
uint32_t *cmd_num);
bool cmd_disp_sync(uint8_t *resp_buf);
bool cmd_disp_write(uint8_t *resp_buf, uint32_t resp_size, uint32_t resp_num,
uint32_t total_size);
bool cmd_disp_read(uint8_t *resp_buf, uint32_t resp_size, uint32_t resp_num,
uint32_t total_size);
void cmd_disp_data(uint8_t *resp_buf, uint32_t resp_size);
void cmd_disp_flash_erase_dev(uint8_t *resp_buf, uint32_t dev_num);
void cmd_disp_flash_erase_sect(uint8_t *resp_buf, uint32_t dev_num);
void cmd_disp_exec_exit(uint8_t *resp_buf);
void cmd_disp_exec_ret(uint8_t *resp_buf);
#endif /* __UTIL_UUT_CMD_H */