UltimateHackingKeyboard / firmware

Ultimate Hacking Keyboard firmware
Other
420 stars 66 forks source link

Implement checksum-based builds. #666

Closed kareltucek closed 1 year ago

kareltucek commented 1 year ago

Closes #440

mondalaci commented 1 year ago
/home/laci/projects/firmware/right/src/usb_commands/usb_command_get_device_property.c: In function 'UsbCommand_GetDeviceProperty':
/home/laci/projects/firmware/right/src/usb_commands/usb_command_get_device_property.c:88:64: error: 'DeviceMD5Checksums' undeclared (first use in this function)
   88 |             Utils_SafeStrCopy(((char*)GenericHidInBuffer) + 1, DeviceMD5Checksums[DEVICE_ID] , MD5_CHECKSUM_LENGTH);
      |                                                                ^~~~~~~~~~~~~~~~~~
kareltucek commented 1 year ago

Well, have you ran your ./generate-versions-h.js?

mondalaci commented 1 year ago

I think a device directory should be created in shared similarly to module.

shared should only contain files that are meant to be used by both devices and modules. Device-related and module-related files should be stored in their respective subdirectories of shared, and the includes should be revised accordingly.

kareltucek commented 1 year ago

Well, how does that help me in knowing device count in versions.h?

It seems like you also propose moving the js-generated md5sum info into two new files under module and device directories. Are you sure you want it that way? (Sounds like an unnecessary complication of the generate-versions-h.js code/process.)

mondalaci commented 1 year ago

I can see how my previous suggestion is impractical.

It seems to me that DEVICE_ID is defined for modules via Makedefs.mk. To resolve this issue properly, DEVICE_ID shouldn't be defined for modules to begin with.

Second, to be prudent, device.h should error out if both or neither of DEVICE_ID and MODULE_ID is specified; only one of them should be defined.

Finally, in the generated versions.h, we could use an #ifdef DEVICE_ID so that DeviceMD5Checksums would only be included for devices.

kareltucek commented 1 year ago

I see.

Refactored device.h into device/device.h and fixed Makefdefs as suggested.

mondalaci commented 1 year ago
    CC    caret_config.c
In file included from ../src/usb_interfaces/usb_interface_mouse.h:7,
                 from /home/laci/projects/firmware/right/src/usb_descriptors/usb_descriptor_configuration.h:9,
                 from /home/laci/projects/firmware/right/src/usb_composite_device.h:6,
                 from /home/laci/projects/firmware/right/src/key_action.h:9,
                 from /home/laci/projects/firmware/right/src/caret_config.h:6,
                 from /home/laci/projects/firmware/right/src/caret_config.c:1:
../src/usb_descriptors/usb_descriptor_device.h:6:14: fatal error: device/device.h: No such file or directory
    6 |     #include "device/device.h"
      |              ^~~~~~~~~~~~~~~~~
compilation terminated.
kareltucek commented 1 year ago

Oops! Fixed.