File tree Expand file tree Collapse file tree 2 files changed +23
-20
lines changed
Expand file tree Collapse file tree 2 files changed +23
-20
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ void load_serial_number(void) {
6262 uint8_t raw_id [COMMON_HAL_MCU_PROCESSOR_UID_LENGTH ];
6363 common_hal_mcu_processor_get_uid (raw_id );
6464
65+ usb_serial_number [0 ] = 0x300 | sizeof (usb_serial_number );
6566 for (int i = 0 ; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH ; i ++ ) {
6667 for (int j = 0 ; j < 2 ; j ++ ) {
6768 uint8_t nibble = (raw_id [i ] >> (j * 4 )) & 0xf ;
Original file line number Diff line number Diff line change @@ -778,30 +778,32 @@ def make_cdc_iad(cdc_comm_interface, name):
778778 variable_name = StringIndex .index_to_variable [idx ]
779779 if not variable_name :
780780 variable_name = "string_descriptor{}" .format (idx )
781+ pointers_to_strings .append ("{name}" .format (name = variable_name ))
781782
782783 const = "const "
783784 if variable_name == "usb_serial_number" :
784- const = ""
785- c_file .write (
786- """\
787- {const}uint16_t {NAME}[] = {{
788- """ .format (
789- const = const , NAME = variable_name
785+ length = len (b )
786+ c_file .write (" uint16_t {NAME}[{length}];\n " .format (NAME = variable_name , length = length // 2 ))
787+ else :
788+ c_file .write (
789+ """\
790+ const uint16_t {NAME}[] = {{
791+ """ .format (
792+ const = const , NAME = variable_name
793+ )
790794 )
791- )
792- pointers_to_strings .append ("{name}" .format (name = variable_name ))
793- n = 0
794- while i < len (b ):
795- length = b [i ]
796- for j in range (length // 2 ):
797- c_file .write ("0x{:04x}, " .format (b [i + 2 * j + 1 ] << 8 | b [i + 2 * j ]))
798- n += 1
799- c_file .write ("\n " )
800- i += length
801- c_file .write (
802- """\
803- };
804- """
795+ n = 0
796+ while i < len (b ):
797+ length = b [i ]
798+ for j in range (length // 2 ):
799+ c_file .write ("0x{:04x}, " .format (b [i + 2 * j + 1 ] << 8 | b [i + 2 * j ]))
800+ n += 1
801+ c_file .write ("\n " )
802+ i += length
803+ c_file .write (
804+ """\
805+ };
806+ """
805807 )
806808
807809c_file .write (
You can’t perform that action at this time.
0 commit comments