mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 10:31:02 +00:00
stm32/usb: Add support for board-specific serial number
By default, read USB serial number from flash, but provide a way
for boards to override the function (e.g., to read serial number
from unique chip id).
BRANCH=none
BUG=b:62280271
TEST=Flash hammer
lsusb -d 18d1:5022 -v -v | grep iSerial
shows different chip IDs on different boards.
Change-Id: I0917752bb8e04c1eff4dffc0b3714f63dcd942b0
Reviewed-on: https://chromium-review.googlesource.com/523045
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
8ba7c1762c
commit
d132e5ecbd
@@ -657,13 +657,20 @@ static int usb_set_serial(const char *serialno)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
/* By default, read serial number from flash, can be overridden. */
|
||||
__attribute__((weak))
|
||||
const char *board_read_serial(void)
|
||||
{
|
||||
return flash_read_serial();
|
||||
}
|
||||
|
||||
/* Retrieve serial number from pstate flash. */
|
||||
static int usb_load_serial(void)
|
||||
{
|
||||
const char *serialno;
|
||||
int rv;
|
||||
|
||||
serialno = flash_read_serial();
|
||||
serialno = board_read_serial();
|
||||
if (!serialno)
|
||||
return EC_ERROR_ACCESS_DENIED;
|
||||
|
||||
|
||||
@@ -1371,13 +1371,20 @@ static int usb_set_serial(const char *serialno)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
/* By default, read serial number from flash, can be overridden. */
|
||||
__attribute__((weak))
|
||||
const char *board_read_serial(void)
|
||||
{
|
||||
return flash_read_serial();
|
||||
}
|
||||
|
||||
/* Retrieve serial number from pstate flash. */
|
||||
static int usb_load_serial(void)
|
||||
{
|
||||
const char *serialno;
|
||||
int rv;
|
||||
|
||||
serialno = flash_read_serial();
|
||||
serialno = board_read_serial();
|
||||
if (!serialno)
|
||||
return EC_ERROR_ACCESS_DENIED;
|
||||
|
||||
|
||||
@@ -285,6 +285,12 @@ const char *system_get_chip_revision(void);
|
||||
*/
|
||||
int system_get_chip_unique_id(uint8_t **id);
|
||||
|
||||
/**
|
||||
* Optional board-level callback functions to read a unique serial number per
|
||||
* chip. Default implementation reads from flash (flash_read_serial).
|
||||
*/
|
||||
const char *board_read_serial(void) __attribute__((weak));
|
||||
|
||||
/*
|
||||
* Common bbram entries. Chips don't necessarily need to implement
|
||||
* all of these, error will be returned from system_get/set_bbram if
|
||||
|
||||
Reference in New Issue
Block a user