Skip to content

Commit 031f541

Browse files
committed
Improve config
Signed-off-by: cybnon <stefan.weber93@googlemail.com>
1 parent e0ba3c4 commit 031f541

File tree

2 files changed

+5
-90
lines changed

2 files changed

+5
-90
lines changed

include/atecc608_handler.h

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const uint8_t ECCX08_DEFAULT_CONFIGURATION_VALS[112] = {
2323
0x8F, 0x8F,
2424
0x9F, 0x8F,
2525
0xAF, 0x8F,
26-
0x00, 0x00,
26+
0x00, 0x00,
2727
0x00, 0x00,
2828
0x00, 0x00,
2929
0x00, 0x00,
@@ -65,8 +65,8 @@ const uint8_t ECCX08_DEFAULT_CONFIGURATION_VALS[112] = {
6565
0x1C, 0x00,
6666
0x1C, 0x00,
6767
0x1C, 0x00,
68-
0x3C, 0x00,
69-
0x3C, 0x00,
68+
0x00, 0x00,
69+
0x00, 0x00,
7070
0x3C, 0x00,
7171
0x3C, 0x00,
7272
0x3C, 0x00,
@@ -75,91 +75,6 @@ const uint8_t ECCX08_DEFAULT_CONFIGURATION_VALS[112] = {
7575
0x1C, 0x00
7676
};
7777

78-
const uint8_t ENERGY_AGENT_ATEC_CONFIG[128] = {
79-
// Bytes 0-3: Device-specific settings (I2C_Address, Reserved, OTPmode, ChipMode)
80-
0xC0, 0x00, 0x55, 0x00,
81-
82-
// Bytes 4-35: SlotConfig for slots 0-15 (2 bytes per slot)
83-
// Slots 0-7: Unchanged SlotConfig settings
84-
0x83, 0x60, // Slot 0 (Bytes 4-5)
85-
0x87, 0x60, // Slot 1 (Bytes 6-7)
86-
0x8F, 0x60, // Slot 2 (Bytes 8-9)
87-
0x83, 0x60, // Slot 3 (Bytes 10-11)
88-
0x83, 0x60, // Slot 4 (Bytes 12-13)
89-
0x8F, 0x8F, // Slot 5 (Bytes 14-15)
90-
0x9F, 0x8F, // Slot 6 (Bytes 16-17)
91-
0xAF, 0x8F, // Slot 7 (Bytes 18-19)
92-
93-
// Slot 8: Configured for plaintext read/write
94-
0x00, 0x00, // Slot 8 (Bytes 20-21)
95-
96-
// Slots 9-15: Unchanged SlotConfig settings
97-
0x00, 0x00, // Slot 9 (Bytes 22-23)
98-
0x00, 0x00, // Slot 10 (Bytes 24-25)
99-
0x00, 0x00, // Slot 11 (Bytes 26-27)
100-
0x00, 0x00, // Slot 12 (Bytes 28-29)
101-
0x00, 0x00, // Slot 13 (Bytes 30-31)
102-
0x00, 0x00, // Slot 14 (Bytes 32-33)
103-
0xAF, 0x8F, // Slot 15 (Bytes 34-35)
104-
105-
// Bytes 36-43: Counter[0]
106-
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
107-
108-
// Bytes 44-51: Counter[1]
109-
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
110-
111-
// Bytes 52-67: LastKeyUse (16 bytes)
112-
0xFF, 0xFF, 0xFF, 0xFF, // Slots 0-3
113-
0xFF, 0xFF, 0xFF, 0xFF, // Slots 4-7
114-
0xFF, 0xFF, 0xFF, 0xFF, // Slots 8-11
115-
0xFF, 0xFF, 0xFF, 0xFF, // Slots 12-15
116-
117-
// Bytes 68-71: Write via commands only - start
118-
0x00, // UserExtra (Byte 68)
119-
0x00, // Selector (Byte 69)
120-
0x55, // LockValue (Byte 70)
121-
0x55, // LockConfig (Byte 71)
122-
123-
// Bytes 72-73: SlotLocked
124-
0xFF, 0xFF,
125-
126-
// Bytes 74-75: RFU
127-
0x00, 0x00,
128-
129-
// Bytes 76-79: X509format
130-
0x00, 0x00, 0x00, 0x00,
131-
132-
// Bytes 80-111: KeyConfig for slots 0-15 (2 bytes per slot)
133-
// Slots 0-6: Unchanged KeyConfig settings
134-
0x33, 0x00, // Slot 0 (Bytes 80-81)
135-
0x33, 0x00, // Slot 1 (Bytes 82-83)
136-
0x33, 0x00, // Slot 2 (Bytes 84-85)
137-
0x1C, 0x00, // Slot 3 (Bytes 86-87)
138-
0x33, 0x00, // Slot 4 (Bytes 88-89)
139-
0x1C, 0x00, // Slot 5 (Bytes 90-91)
140-
0x1C, 0x00, // Slot 6 (Bytes 92-93)
141-
0x1C, 0x00, // Slot 7 (Bytes 94-95)
142-
143-
// Slot 8: KeyConfig adjusted for plaintext read/write
144-
0x00, 0x00, // Slot 8 (Bytes 96-97)
145-
146-
// Slots 9-15: Unchanged KeyConfig settings
147-
0x3C, 0x00, // Slot 9 (Bytes 98-99)
148-
0x3C, 0x00, // Slot 10 (Bytes 100-101)
149-
0x3C, 0x00, // Slot 11 (Bytes 102-103)
150-
0x3C, 0x00, // Slot 12 (Bytes 104-105)
151-
0x3C, 0x00, // Slot 13 (Bytes 106-107)
152-
0x3C, 0x00, // Slot 14 (Bytes 108-109)
153-
0x1C, 0x00, // Slot 15 (Bytes 110-111)
154-
155-
// Bytes 112-127: Remaining bytes (RFU or padding)
156-
0x00, 0x00, 0x00, 0x00, // Bytes 112-115
157-
0x00, 0x00, 0x00, 0x00, // Bytes 116-119
158-
0x00, 0x00, 0x00, 0x00, // Bytes 120-123
159-
0x00, 0x00, 0x00, 0x00 // Bytes 124-127
160-
};
161-
162-
16378
extern "C" int atecc_handler_write_configuration(const uint8_t *config, size_t len);
16479
extern "C" int atecc_handle_write_default_configuration();
16580
extern "C" int atecc_handler_lock_zone(uint8_t zone);

src/atecc608_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int atecc_handle_write_default_configuration(){
3838
status = atcab_init(&cfg);
3939
if (status == ATCA_SUCCESS)
4040
{
41-
status = atecc_handler_write_configuration(ENERGY_AGENT_ATEC_CONFIG, sizeof(ENERGY_AGENT_ATEC_CONFIG));
41+
status = atecc_handler_write_configuration(ECCX08_DEFAULT_CONFIGURATION_VALS, sizeof(ECCX08_DEFAULT_CONFIGURATION_VALS));
4242
return status;
4343
}
4444
return status;
@@ -226,7 +226,7 @@ int atecc_handler_write_data(int slot, uint8_t* data, size_t data_len) {
226226
}
227227

228228
if (data_len > slot_size) {
229-
return ATCA_BAD_PARAM; // Data length exceeds slot size
229+
return slot_size;
230230
}
231231

232232
status = atcab_wakeup();

0 commit comments

Comments
 (0)