\ Program Name: device-electronic-signature.fs \ Date: Wed 8 Nov 2019 \ Copyright 2019 t.porter , licensed under the GPL \ For Mecrisp-Stellaris by Matthias Koch \ Chip: STM32Fxxx \ -------------------------------------------------------------------------------------------------- \ \ $1FFFF7E8 offset Bits UID Function \ 0x00 Bits 31:0 UID[31:0] X and Y coordinates on the wafer expressed in BCD \ 0x04 Bits 7:0 UID[39:32] WAF_NUM[7:0] Wafer number (8-bit unsigned number) \ 0x04 Bits 31:8 UID[63:40] LOT_NUM[23:0] Lot number (ASCII encoded) \ 0x08 Bits 31:0 UID[95:64] LOT_NUM[55:24] Lot number (ASCII encoded) \ -------------------------------------------------------------------------------------------------- \ \ Olimex p103 #1 Test \ $1FFFF7E8 @ . 107741012 ok. \ $1FFFF7E8 4 + @ hex. 55528548 \ $1FFFF7E8 8 + @ hex. 87237267 ok. \ -------------------------------------------------------------------------------------------------- \ compiletoflash : is-ascii? ( u -- ) >r r@ 32 u>= r@ 127 u< and if r> emit else [char] . emit rdrop then ; : lot_num[23:0] ( u -- ) 4 + @ $FFFFFF00 and 8 rshift dup ." Lot_num ascii encoded [23:0]: 0x" hex. ." | " dup $ff0000 and 16 rshift is-ascii? space dup $ff00 and 8 rshift is-ascii? space $ff and is-ascii? cr ; : lot_num[55:24] ( u -- ) 8 + @ dup ." Lot_num ascii encoded [55:24]: 0x" hex. ." | " dup $ff000000 and 24 rshift is-ascii? space dup $ff0000 and 16 rshift is-ascii? space dup $ff00 and 8 rshift is-ascii? space $ff and is-ascii? cr ; : stm32id ( -- ) cr \ $1FFFF7E8 ( STM32F103 ) $1FFFF7AC ( STM32F0xx ) dup @ ." Die xy coords: " . cr dup 4 + @ $FF and ." Wafer Number: " . cr dup lot_num[23:0] lot_num[55:24] cr ; compiletoram \ stm32id