For emulation, support --vidpid at runtime.
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2017-10-06 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* src/configure: Allow not specifying VIDPID.
|
||||||
|
|
||||||
|
* src/main.c [GNU_LINUX_EMULATION] (main): Handle "--vidpid"
|
||||||
|
option to assign vendor ID and product ID of USB.
|
||||||
|
|
||||||
|
* src/usb_desc.c [GNU_LINUX_EMULATION] (device_desc): Export.
|
||||||
|
|
||||||
|
* GNUK_USB_DEVICE_ID (0000:0000): New.
|
||||||
|
|
||||||
2017-10-05 NIIBE Yutaka <gniibe@fsij.org>
|
2017-10-05 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* src/stack-def.h (SIZE_1, SIZE_3): Tweak the size.
|
* src/stack-def.h (SIZE_1, SIZE_3): Tweak the size.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# VID:PID bcdDev Product_STRING Vendor_STRING
|
# VID:PID bcdDev Product_STRING Vendor_STRING
|
||||||
|
0000:0000 0200 Gnuk Emulation Free Software Initiative of Japan
|
||||||
234b:0000 0200 Gnuk Token Free Software Initiative of Japan
|
234b:0000 0200 Gnuk Token Free Software Initiative of Japan
|
||||||
20a0:4211 0200 Nitrokey Start Nitrokey
|
20a0:4211 0200 Nitrokey Start Nitrokey
|
||||||
##########<TAB> ##<TAB> ##########<TAB> #################
|
##########<TAB> ##<TAB> ##########<TAB> #################
|
||||||
|
|||||||
16
src/configure
vendored
16
src/configure
vendored
@@ -162,11 +162,6 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$vidpid" = "none"; then
|
|
||||||
echo "Please specify Vendor ID and Product ID by --vidpid option." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
BOARD_HEADER_FILE=board-$(echo $target | tr '_[:upper:]' '-[:lower:]').h
|
BOARD_HEADER_FILE=board-$(echo $target | tr '_[:upper:]' '-[:lower:]').h
|
||||||
echo "Header file is: $BOARD_HEADER_FILE"
|
echo "Header file is: $BOARD_HEADER_FILE"
|
||||||
ln -sf "../chopstx/board/$BOARD_HEADER_FILE" board.h
|
ln -sf "../chopstx/board/$BOARD_HEADER_FILE" board.h
|
||||||
@@ -227,6 +222,17 @@ else
|
|||||||
libs=""
|
libs=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$emulation" = "yes"; then
|
||||||
|
if test "$vidpid" = "none"; then
|
||||||
|
vidpid=0000:0000
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if test "$vidpid" = "none"; then
|
||||||
|
echo "Please specify Vendor ID and Product ID by --vidpid option." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# --enable-debug option
|
# --enable-debug option
|
||||||
if test "$debug" = "yes"; then
|
if test "$debug" = "yes"; then
|
||||||
DEBUG_MAKE_OPTION="ENABLE_DEBUG=1"
|
DEBUG_MAKE_OPTION="ENABLE_DEBUG=1"
|
||||||
|
|||||||
26
src/main.c
26
src/main.c
@@ -233,12 +233,34 @@ main (int argc, const char *argv[])
|
|||||||
#ifdef GNU_LINUX_EMULATION
|
#ifdef GNU_LINUX_EMULATION
|
||||||
#define FLASH_IMAGE_NAME ".gnuk-flash-image"
|
#define FLASH_IMAGE_NAME ".gnuk-flash-image"
|
||||||
|
|
||||||
if (argc >= 3 || (argc == 2 && !strcmp (argv[1], "--help")))
|
if (argc >= 4 || (argc == 2 && !strcmp (argv[1], "--help")))
|
||||||
{
|
{
|
||||||
fprintf (stdout, "Usage: %s [flash-image-file]", argv[0]);
|
fprintf (stdout, "Usage: %s [--vidpid=Vxxx:Pxxx] [flash-image-file]",
|
||||||
|
argv[0]);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc >= 2 && !strncmp (argv[1], "--vidpid=", 9))
|
||||||
|
{
|
||||||
|
extern uint8_t device_desc[];
|
||||||
|
uint32_t id;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
id = (uint32_t)strtol (&argv[1][9], &p, 16);
|
||||||
|
device_desc[8] = (id & 0xff);
|
||||||
|
device_desc[9] = (id >> 8);
|
||||||
|
|
||||||
|
if (p && p[0] == ':')
|
||||||
|
{
|
||||||
|
id = (uint32_t)strtol (&p[1], NULL, 16);
|
||||||
|
device_desc[10] = (id & 0xff);
|
||||||
|
device_desc[11] = (id >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
char *p = getenv ("HOME");
|
char *p = getenv ("HOME");
|
||||||
|
|||||||
@@ -59,7 +59,10 @@ static const uint8_t hid_report_desc[] = {
|
|||||||
#define USB_CCID_DATA_SIZE 64
|
#define USB_CCID_DATA_SIZE 64
|
||||||
|
|
||||||
/* USB Standard Device Descriptor */
|
/* USB Standard Device Descriptor */
|
||||||
static const uint8_t device_desc[] = {
|
#if !defined(GNU_LINUX_EMULATION)
|
||||||
|
static const
|
||||||
|
#endif
|
||||||
|
uint8_t device_desc[] = {
|
||||||
18, /* bLength */
|
18, /* bLength */
|
||||||
DEVICE_DESCRIPTOR, /* bDescriptorType */
|
DEVICE_DESCRIPTOR, /* bDescriptorType */
|
||||||
0x10, 0x01, /* bcdUSB = 1.1 */
|
0x10, 0x01, /* bcdUSB = 1.1 */
|
||||||
|
|||||||
Reference in New Issue
Block a user