Add uid fetch, revert USB hacks
This commit is contained in:
parent
a9d3ad86e5
commit
bc7ba33892
@ -1,7 +1,7 @@
|
|||||||
USB_VID = 0x239A
|
USB_VID = 0x239A
|
||||||
USB_PID = 0x802A
|
USB_PID = 0x802A
|
||||||
USB_PRODUCT = "STM32F411VE Discovery Board - CPy"
|
USB_PRODUCT = "STM32F411VE Discovery Board - CPy"
|
||||||
USB_MANUFACTURER = "Adafruit Industries LLC"
|
USB_MANUFACTURER = "STMicroelectronics"
|
||||||
USB_REDUCED_ENDPOINT = 1
|
USB_REDUCED_ENDPOINT = 1
|
||||||
|
|
||||||
INTERNAL_FLASH_FILESYSTEM = 1
|
INTERNAL_FLASH_FILESYSTEM = 1
|
||||||
|
@ -28,17 +28,20 @@
|
|||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "supervisor/shared/translate.h"
|
#include "supervisor/shared/translate.h"
|
||||||
|
|
||||||
|
#include "stm32f4xx_hal.h"
|
||||||
|
|
||||||
|
#define STM32_UUID ((uint32_t *)0x1FFF7A10)
|
||||||
|
|
||||||
float common_hal_mcu_processor_get_temperature(void) {
|
float common_hal_mcu_processor_get_temperature(void) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t common_hal_mcu_processor_get_frequency(void) {
|
uint32_t common_hal_mcu_processor_get_frequency(void) {
|
||||||
return 64000000ul;
|
return SystemCoreClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<3; i++) {
|
||||||
((uint32_t*) raw_id)[i] = 0;
|
((uint32_t*) raw_id)[i] = STM32_UUID[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
|
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
|
||||||
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
|
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
|
||||||
|
|
||||||
#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8
|
#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 12
|
||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
|
|||||||
INTERNAL_LIBM = 1
|
INTERNAL_LIBM = 1
|
||||||
|
|
||||||
# Chip supplied serial number, in bytes
|
# Chip supplied serial number, in bytes
|
||||||
USB_SERIAL_NUMBER_LENGTH = 16
|
USB_SERIAL_NUMBER_LENGTH = 24
|
||||||
|
|
||||||
# Longints can be implemented as mpz, as longlong, or not
|
# Longints can be implemented as mpz, as longlong, or not
|
||||||
LONGINT_IMPL = MPZ
|
LONGINT_IMPL = MPZ
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8
|
|
||||||
|
|
||||||
// Serial number as hex characters. This writes directly to the USB
|
// Serial number as hex characters. This writes directly to the USB
|
||||||
// descriptor.
|
// descriptor.
|
||||||
@ -43,7 +42,7 @@ extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2];
|
|||||||
void load_serial_number(void) {
|
void load_serial_number(void) {
|
||||||
// create serial number based on device unique id
|
// create serial number based on device unique id
|
||||||
uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
|
uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
|
||||||
//common_hal_mcu_processor_get_uid(raw_id);
|
common_hal_mcu_processor_get_uid(raw_id);
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
((uint32_t*) raw_id)[i] = 0;
|
((uint32_t*) raw_id)[i] = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user