@@ -91,6 +91,7 @@ metadata_gather() {
9191 sqlite3 " ${RPI_SB_PROVISIONER_MANUFACTURING_DB} " " PRAGMA journal_mode=WAL;" > /dev/null 2>&1
9292
9393 # Define the schema for devices table
94+ # Security tracking fields default to NULL to distinguish between not-applied vs unknown state
9495 EXPECTED_SCHEMA=" id integer primary key,
9596 boardname varchar(255) not null,
9697 serial char(8) not null,
@@ -105,6 +106,10 @@ metadata_gather() {
105106 memory varchar(255) not null,
106107 manufacturer varchar(255) not null,
107108 secure integer not null,
109+ jtag_locked integer DEFAULT NULL,
110+ eeprom_write_protected integer DEFAULT NULL,
111+ pubkey_programmed integer DEFAULT NULL,
112+ signed_boot_enabled integer DEFAULT NULL,
108113 provision_ts timestamp default current_timestamp"
109114
110115 # Check if the table exists
@@ -115,6 +120,41 @@ metadata_gather() {
115120 sqlite3 " ${RPI_SB_PROVISIONER_MANUFACTURING_DB} " " CREATE TABLE devices($EXPECTED_SCHEMA );" > /dev/null 2>&1
116121 fi
117122
123+ # Determine security flags based on provisioning configuration
124+ # JTAG lock status: 1 if enabled, 0 if explicitly disabled, NULL if not configured
125+ JTAG_LOCKED_VALUE=" NULL"
126+ if [ -n " ${RPI_DEVICE_LOCK_JTAG} " ]; then
127+ JTAG_LOCKED_VALUE=" 1"
128+ elif [ " ${SECURE} " = " 1" ]; then
129+ # For secure provisioning, explicitly track that JTAG locking was not enabled
130+ JTAG_LOCKED_VALUE=" 0"
131+ fi
132+
133+ # EEPROM write protection status: 1 if enabled, 0 if explicitly disabled, NULL if not configured
134+ EEPROM_WP_VALUE=" NULL"
135+ if [ -n " ${RPI_DEVICE_EEPROM_WP_SET} " ]; then
136+ EEPROM_WP_VALUE=" 1"
137+ elif [ " ${SECURE} " = " 1" ]; then
138+ # For secure provisioning, explicitly track that EEPROM WP was not enabled
139+ EEPROM_WP_VALUE=" 0"
140+ fi
141+
142+ # Public key programming: 1 for secure provisioning, 0 for non-secure, NULL for unknown
143+ PUBKEY_PROGRAMMED_VALUE=" NULL"
144+ if [ " ${SECURE} " = " 1" ]; then
145+ PUBKEY_PROGRAMMED_VALUE=" 1"
146+ elif [ " ${SECURE} " = " 0" ]; then
147+ PUBKEY_PROGRAMMED_VALUE=" 0"
148+ fi
149+
150+ # Signed boot: 1 for secure provisioning, 0 for non-secure, NULL for unknown
151+ SIGNED_BOOT_VALUE=" NULL"
152+ if [ " ${SECURE} " = " 1" ]; then
153+ SIGNED_BOOT_VALUE=" 1"
154+ elif [ " ${SECURE} " = " 0" ]; then
155+ SIGNED_BOOT_VALUE=" 0"
156+ fi
157+
118158 # Insert new device data
119159 sqlite3 " ${RPI_SB_PROVISIONER_MANUFACTURING_DB} " \
120160 " INSERT INTO devices( \
@@ -130,7 +170,11 @@ metadata_gather() {
130170 processor, \
131171 memory, \
132172 manufacturer, \
133- secure \
173+ secure, \
174+ jtag_locked, \
175+ eeprom_write_protected, \
176+ pubkey_programmed, \
177+ signed_boot_enabled \
134178 ) VALUES ( \
135179 '${BOARD_STR} ', \
136180 '${TARGET_DEVICE_SERIAL} ', \
@@ -144,7 +188,11 @@ metadata_gather() {
144188 '${PROCESSOR_STR} ', \
145189 '${MEMORY_STR} ', \
146190 '${MANUFACTURER_STR} ', \
147- '${SECURE} ' \
191+ '${SECURE} ', \
192+ ${JTAG_LOCKED_VALUE} , \
193+ ${EEPROM_WP_VALUE} , \
194+ ${PUBKEY_PROGRAMMED_VALUE} , \
195+ ${SIGNED_BOOT_VALUE} \
148196 );" > /dev/null 2>&1
149197 announce_stop " Manufacturing Database Insertion"
150198 fi
0 commit comments