conorpp / u2f-zero

U2F USB token optimized for physical security, affordability, and style
Other
2.41k stars 200 forks source link

EFM8 is not locked at the end of the programming/flashing process #74

Closed vojnovski closed 6 years ago

vojnovski commented 6 years ago

Is there a reason why the EFM8 is not locked at the end of the programming process?

It could be done as specified here: https://www.silabs.com/community/mcu/8-bit/knowledge-base.entry.html/2016/01/13/locking_flash_using-RdLy, setting 0xFBFF (the EFM8 Lock Byte: https://www.silabs.com/documents/public/data-sheets/efm8ub1-datasheet.pdf) to 0x00 with the linker.

szszszsz commented 6 years ago

For completeness: currently 0xFBFF byte is conditionally set to -32 on each firmware start, at src/eeprom.c#L39

https://github.com/conorpp/u2f-zero/blob/6a177cad311c8710dae148fb6e2b7ffc3a8fd3b9/firmware/src/eeprom.c#L31-L40

conorpp commented 6 years ago

Yes, this locks the eeprom from debugger read out. Thanks!

szszszsz commented 6 years ago

Just to explain -32 - according to [1] this locks first 32 pages (32x512=16kB) of user flash.

[1] Reference Manual, Chapter 4.3.1, page 27, https://www.silabs.com/documents/public/reference-manuals/EFM8UB1-RM.pdf

szszszsz commented 6 years ago

@vojnovski Do you know, whether 0 would work the same and lock all the pages?

vojnovski commented 5 years ago

Hi @szszszsz, yes, from the same manual, setting it to 0 locks all user flash pages.