Ralim / IronOS

Open Source Soldering Iron firmware
https://ralim.github.io/IronOS/
GNU General Public License v3.0
7.1k stars 707 forks source link

BLE - need serial number for authenticity checker #1609

Closed River-Mochi closed 1 year ago

River-Mochi commented 1 year ago

Is your feature request related to a problem? Please describe.

There is an Authenticity checker for people who own pinecil V2 and want to check if it's legit. Currently, we have to read and transfer the long and tiny numbers from ID and Serial number from a tiny pinecil screen to the checker webpage. BLE already sends ID number, just need Serial number too.

Describe the solution you'd like

As soon as PineSAM starts getting the serial number on BLE, work can be started on how to integrate it to add the Checker feature for fun and convenience.

ew1abz commented 1 year ago

What is a Serial number, and what is ID? According to https://pinecil.pine64.org/, the Serial number is the second, long string from the Debug menu. If so, the FW already sends it via BLE https://github.com/Ralim/IronOS/blob/ccbee2187269fb9c286c7d1f6ae03f58a5cb1a05/source/Core/BSP/Pinecilv2/ble_handlers.cpp#L183

Although, in the FW we use the getDeviceID() function to get it. Very confusing. I assume we need to send the getDeviceValidation() output.

Before any renaming or implementation, it maybe makes sense to have more information about them. Which is set by the uCU manufacturer, and which is set by the Pine64 factory?

River-Mochi commented 1 year ago

If so, the FW already sends it via BLE

we are not currently seeing serial number in PineSAM @builder555 could you please check this if you have time?

@gamelaster will know how the serial number is set but my understanding is it is a combination of what is done on eflash of the bl706 chip at the factory and also something that is done in IRONOS firmware. gamelaster made the authentication webpage you linked and the BLISP flasher software.

River-Mochi commented 1 year ago

Pinesam app is here if you want to check it out https://github.com/builder555/PineSAM

gamelaster commented 1 year ago

@ew1abz Serial Number is set by chip manufacturer. Device validation is set by Pine Store factory.

Ralim commented 1 year ago

What is a Serial number, and what is ID?

Serial number is the ID burned by manufacturer that is the device MAC. ID is a unique key Pine burns at the factory and records in their db.

Serial number is printed using getDeviceID(); https://github.com/Ralim/IronOS/blob/11bad84ce7a44c9d2ef0141459a2dc175e5b671a/source/Core/Threads/OperatingModes/DebugMenu.cpp#L22

Meanwhile on the PinecilV2 we show the extra validation code from getDeviceValidation() Which returns the validation code in OTP.

According to https://pinecil.pine64.org/, the Serial number is the second, long string from the Debug menu. If so, the FW already sends it via BLE

https://github.com/Ralim/IronOS/blob/ccbee2187269fb9c286c7d1f6ae03f58a5cb1a05/source/Core/BSP/Pinecilv2/ble_handlers.cpp#L183

Although, in the FW we use the getDeviceID() function to get it. Very confusing. I assume we need to send the getDeviceValidation() output.

Before any renaming or implementation, it maybe makes sense to have more information about them. Which is set by the uCU manufacturer, and which is set by the Pine64 factory?

Happy for us to add getDeviceValidation to the BLE data to allow for this.

River-Mochi commented 1 year ago

I see it now, if I compare the serial number I see on the pinecil screen and my real BLE MAC address which pinsam terminal script shows me: my serial number is padded with 4 zeros, and then it's the reverse of my ble MAC address, in sets of 2 characters.

ew1abz commented 1 year ago

Thanks, everybody. That reaffirms my suspicions about misnaming things. Usually, serial number refers to a product SN. Here, on the device validation page and BLE GUI, it is used for naming chip unique ID. In the FW, though, all naming is OK. Anyway, the output of the getDeviceValidation() function should be exposed via BLE.

River-Mochi commented 1 year ago

Anyway, the output of the getDeviceValidation() function should be exposed via BLE.

@ew1abz

ew1abz commented 1 year ago

Let's stick with @Ralim terminology:

Serial number is the ID burned by manufacturer that is the device MAC. It is printed using getDeviceID() ID is a unique key Pine burns at the factory and records in their db. It is printed using getDeviceValidation()

do you mean getDeviceValidation() = serial number exactly as seen on Pinecil screen

No

is already available over BLE?

Yes, the Serial number is available over BLE. The ID is not.

or will you submit PR for this?

Yes, that's my intention.

will it stay this misname or get a new name?

Unfortunately, we have to keep the old naming. Otherwise, we need to change FW and Pinecil V2 Authenticity Checker. It'll not be backward compatible and will cause even more confusion at the user level.