Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
affcbe41
Commit
affcbe41
authored
9 years ago
by
Dave Hylands
Committed by
Damien George
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Make USB serial number actually be unique.
parent
6a515b95
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
stmhal/usbd_desc.c
+20
-7
20 additions, 7 deletions
stmhal/usbd_desc.c
with
20 additions
and
7 deletions
stmhal/usbd_desc.c
+
20
−
7
View file @
affcbe41
...
@@ -40,9 +40,7 @@
...
@@ -40,9 +40,7 @@
#define USBD_LANGID_STRING 0x409
#define USBD_LANGID_STRING 0x409
#define USBD_MANUFACTURER_STRING "MicroPython"
#define USBD_MANUFACTURER_STRING "MicroPython"
#define USBD_PRODUCT_HS_STRING "Pyboard Virtual Comm Port in HS Mode"
#define USBD_PRODUCT_HS_STRING "Pyboard Virtual Comm Port in HS Mode"
#define USBD_SERIALNUMBER_HS_STRING "000000000010"
#define USBD_PRODUCT_FS_STRING "Pyboard Virtual Comm Port in FS Mode"
#define USBD_PRODUCT_FS_STRING "Pyboard Virtual Comm Port in FS Mode"
#define USBD_SERIALNUMBER_FS_STRING "000000000011"
#define USBD_CONFIGURATION_HS_STRING "Pyboard Config"
#define USBD_CONFIGURATION_HS_STRING "Pyboard Config"
#define USBD_INTERFACE_HS_STRING "Pyboard Interface"
#define USBD_INTERFACE_HS_STRING "Pyboard Interface"
#define USBD_CONFIGURATION_FS_STRING "Pyboard Config"
#define USBD_CONFIGURATION_FS_STRING "Pyboard Config"
...
@@ -158,11 +156,26 @@ STATIC uint8_t *USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t
...
@@ -158,11 +156,26 @@ STATIC uint8_t *USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t
* @retval Pointer to descriptor buffer
* @retval Pointer to descriptor buffer
*/
*/
STATIC
uint8_t
*
USBD_SerialStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
STATIC
uint8_t
*
USBD_SerialStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
USBD_SPEED_HIGH
)
{
// This document: http://www.usb.org/developers/docs/devclass_docs/usbmassbulk_10.pdf
USBD_GetString
((
uint8_t
*
)
USBD_SERIALNUMBER_HS_STRING
,
USBD_StrDesc
,
length
);
// says that the serial number has to be at least 12 digits long and that
}
else
{
// the last 12 digits need to be unique. It also stipulates that the valid
USBD_GetString
((
uint8_t
*
)
USBD_SERIALNUMBER_FS_STRING
,
USBD_StrDesc
,
length
);
// character set is that of upper-case hexadecimal digits.
}
//
// The onboard DFU bootloader produces a 12-digit serial number based on
// the 96-bit unique ID, so for consistency we go with this algorithm.
// You can see the serial number if you do:
//
// dfu-util -l
//
// See: https://my.st.com/52d187b7 for the algorithim used.
uint8_t
*
id
=
(
uint8_t
*
)
0x1fff7a10
;
char
serial_buf
[
16
];
snprintf
(
serial_buf
,
sizeof
(
serial_buf
),
"%02X%02X%02X%02X%02X%02X"
,
id
[
11
],
id
[
10
]
+
id
[
2
],
id
[
9
],
id
[
8
]
+
id
[
0
],
id
[
7
],
id
[
6
]);
USBD_GetString
((
uint8_t
*
)
serial_buf
,
USBD_StrDesc
,
length
);
return
USBD_StrDesc
;
return
USBD_StrDesc
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment