-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserial_out_math.ino
More file actions
53 lines (47 loc) · 971 Bytes
/
serial_out_math.ino
File metadata and controls
53 lines (47 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
avr-glitch AVR code
A very basic loop which does some simple arithmetic, used to demonstrate
when a successful glitch attack has corrupted data or instructions.
*/
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void doreset() {
Serial.println("reset occured.");
}
//no exit
void mainloop(){
while (1) {
digitalWrite(LED_BUILTIN, HIGH);
delay(200);
digitalWrite(LED_BUILTIN, LOW);
delay(200);
int i,j;
i = 0;
i = j;
int ctr=0;
for(i=0;i<500;i++){
for(j=0;j<500;j++){
if (j%100==0) {
ctr++;
}
}
if (j < 300) {
Serial.print("glitch! j = ");
Serial.println(j);
}
}
Serial.print(i);
Serial.print(" + ");
Serial.print(j);
Serial.print(" = ");
Serial.print(i+j);
Serial.print(" ctr: ");
Serial.println(ctr);
}
}
void loop() {
doreset();
mainloop();
}