Skip to content

Commit cc4b008

Browse files
committed
[ion/usb] Fake alt interface to fix NumWorks website
1 parent 1b9b53a commit cc4b008

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

build/config.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DEBUG ?= 0
66
HOME_DISPLAY_EXTERNALS ?= 1
77
EPSILON_VERSION ?= 15.5.0
88
OMEGA_VERSION ?= 2.0.2
9-
UPSILON_VERSION ?= 1.1.0
9+
UPSILON_VERSION ?= 1.1.0-dev
1010
# OMEGA_USERNAME ?= N/A
1111
OMEGA_STATE ?= dev
1212
EPSILON_APPS ?= calculation graph rpn code statistics probability solver atomic sequence regression reader settings external

ion/src/device/shared/usb/calculator.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Calculator : public Device {
6363
* switching to DFU mode. It does not apply to the calculator.*/
6464
2048, // wTransferSize: Maximum number of bytes that the device can accept per control-write transaction
6565
0x0100),// bcdDFUVersion
66-
m_interfaceDescriptor(
66+
m_interfaceDescriptor1(
6767
0, // bInterfaceNumber
6868
k_dfuInterfaceAlternateSetting, // bAlternateSetting
6969
0, // bNumEndpoints: Other than endpoint 0
@@ -72,9 +72,20 @@ class Calculator : public Device {
7272
2, // bInterfaceProtocol: DFU Mode (not DFU Runtime, which would be 1)
7373
4, // iInterface: Index of the Interface string, see m_descriptor
7474
&m_dfuFunctionalDescriptor),
75+
m_interfaceDescriptor2(
76+
0, // bInterfaceNumber
77+
k_dfuInterfaceAlternateSetting + 1, // bAlternateSetting
78+
0, // bNumEndpoints: Other than endpoint 0
79+
0xFE, // bInterfaceClass: DFU (https://www.usb.org/defined-class-codes)
80+
1, // bInterfaceSubClass: DFU
81+
2, // bInterfaceProtocol: DFU Mode (not DFU Runtime, which would be 1)
82+
// TODO: Use real descriptor, not required for now as the descriptor isn't
83+
// used anywhere in DFU firmware, but is only present so NumWorks website work.
84+
4, // iInterface: Index of the Interface string, see m_descriptor
85+
&m_dfuFunctionalDescriptor),
7586
m_configurationDescriptor(
76-
9 + 9 + 9, // wTotalLength: configuration descriptor + interface descriptor + dfu functional descriptor lengths
77-
1, // bNumInterfaces
87+
9 + 18 + 18, // wTotalLength: configuration descriptor + interface descriptor + dfu functional descriptor lengths
88+
2, // bNumInterfaces
7889
k_bConfigurationValue, // bConfigurationValue
7990
0, // iConfiguration: No string descriptor for the configuration
8091
0x80, /* bmAttributes:
@@ -83,7 +94,7 @@ class Calculator : public Device {
8394
* Bit 5: Remote Wakeup (allows the device to wake up the host when the host is in suspend)
8495
* Bit 4..0: Reserved, set to 0 */
8596
0x32, // bMaxPower: half of the Maximum Power Consumption
86-
&m_interfaceDescriptor),
97+
&m_interfaceDescriptor1),
8798
m_webUSBPlatformDescriptor(
8899
k_webUSBVendorCode,
89100
k_webUSBLandingPageIndex),
@@ -99,6 +110,9 @@ class Calculator : public Device {
99110
//m_interfaceStringDescriptor("@SRAM/0x20000000/01*256Ke"),
100111
/* Switch to this descriptor to use dfu-util to write in the SRAM.
101112
* FIXME Should be an alternate Interface. */
113+
// Epsilon 25.6.0 descriptors for example
114+
// @SRAM/0x20000000/01*252Ke
115+
// @Flash/0x90030000/61*064Kg,64*064Kg
102116
m_microsoftOSStringDescriptor(k_microsoftOSVendorCode),
103117
m_workshopURLDescriptor(URLDescriptor::Scheme::HTTPS, "getupsilon.web.app"),
104118
m_extendedCompatIdDescriptor("WINUSB"),
@@ -141,7 +155,8 @@ class Calculator : public Device {
141155
// Descriptors
142156
DeviceDescriptor m_deviceDescriptor;
143157
DFUFunctionalDescriptor m_dfuFunctionalDescriptor;
144-
InterfaceDescriptor m_interfaceDescriptor;
158+
InterfaceDescriptor m_interfaceDescriptor1;
159+
InterfaceDescriptor m_interfaceDescriptor2;
145160
ConfigurationDescriptor m_configurationDescriptor;
146161
WebUSBPlatformDescriptor m_webUSBPlatformDescriptor;
147162
BOSDescriptor m_bosDescriptor;

0 commit comments

Comments
 (0)