stm32: Enable chipid as usb serial number
Signed-off-by: Matt Baker <baker.matt.j@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
f76cb92b15
commit
8f6efe5a7b
|
@ -6,9 +6,9 @@ All dates in this document are approximate.
|
||||||
|
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
20191121: The USB name has changed on lpc176x. It now uses the unique
|
20191124: The USB names have changed on lpc176x and stm32. They now
|
||||||
chip id by default. Update the "serial" setting in the "mcu" config
|
use the unique chip id by default. Update the "serial" setting in the
|
||||||
section accordingly.
|
"mcu" config section accordingly.
|
||||||
|
|
||||||
20191121: The pressure_advance_lookahead_time parameter has been
|
20191121: The pressure_advance_lookahead_time parameter has been
|
||||||
removed. See example.cfg for alternate configuration settings.
|
removed. See example.cfg for alternate configuration settings.
|
||||||
|
|
|
@ -10,6 +10,7 @@ config STM32_SELECT
|
||||||
select HAVE_GPIO_I2C
|
select HAVE_GPIO_I2C
|
||||||
select HAVE_GPIO_SPI
|
select HAVE_GPIO_SPI
|
||||||
select HAVE_GPIO_BITBANGING
|
select HAVE_GPIO_BITBANGING
|
||||||
|
select HAVE_CHIPID
|
||||||
|
|
||||||
config BOARD_DIRECTORY
|
config BOARD_DIRECTORY
|
||||||
string
|
string
|
||||||
|
|
|
@ -37,7 +37,7 @@ src-$(CONFIG_MACH_STM32F4) += stm32/adc.c stm32/i2c.c
|
||||||
src-$(CONFIG_HAVE_GPIO_SPI) += stm32/spi.c
|
src-$(CONFIG_HAVE_GPIO_SPI) += stm32/spi.c
|
||||||
usb-src-$(CONFIG_HAVE_STM32_USBFS) := stm32/usbfs.c
|
usb-src-$(CONFIG_HAVE_STM32_USBFS) := stm32/usbfs.c
|
||||||
usb-src-$(CONFIG_HAVE_STM32_USBOTG) := stm32/usbotg.c
|
usb-src-$(CONFIG_HAVE_STM32_USBOTG) := stm32/usbotg.c
|
||||||
src-$(CONFIG_USBSERIAL) += $(usb-src-y) generic/usb_cdc.c
|
src-$(CONFIG_USBSERIAL) += $(usb-src-y) stm32/chipid.c generic/usb_cdc.c
|
||||||
serial-src-y := stm32/serial.c
|
serial-src-y := stm32/serial.c
|
||||||
serial-src-$(CONFIG_MACH_STM32F0) := stm32/stm32f0_serial.c
|
serial-src-$(CONFIG_MACH_STM32F0) := stm32/stm32f0_serial.c
|
||||||
src-$(CONFIG_SERIAL) += $(serial-src-y) generic/serial_irq.c
|
src-$(CONFIG_SERIAL) += $(serial-src-y) generic/serial_irq.c
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Support for extracting the hardware chip id on stm32
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
|
||||||
|
//
|
||||||
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
#include "generic/usb_cdc.h" // usb_fill_serial
|
||||||
|
#include "generic/usbstd.h" // usb_string_descriptor
|
||||||
|
#include "internal.h" // UID_BASE
|
||||||
|
#include "sched.h" // DECL_INIT
|
||||||
|
|
||||||
|
#define CHIP_UID_LEN 12
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
struct usb_string_descriptor desc;
|
||||||
|
uint16_t data[CHIP_UID_LEN * 2];
|
||||||
|
} cdc_chipid;
|
||||||
|
|
||||||
|
struct usb_string_descriptor *
|
||||||
|
usbserial_get_serialid(void)
|
||||||
|
{
|
||||||
|
return &cdc_chipid.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
chipid_init(void)
|
||||||
|
{
|
||||||
|
if (!CONFIG_USB_SERIAL_NUMBER_CHIPID)
|
||||||
|
return;
|
||||||
|
usb_fill_serial(&cdc_chipid.desc, ARRAY_SIZE(cdc_chipid.data)
|
||||||
|
, (void*)UID_BASE);
|
||||||
|
}
|
||||||
|
DECL_INIT(chipid_init);
|
Loading…
Reference in New Issue