[bootloader] Fix exam mode with Epsilon 19 and add support for Epsilon 20 (#302)

* [bootloader] Fix exam mode on Epsilon 19

* [bootloader] Fix comment indentation

* [bootloader] Restore comment indentation (even if GitHub tell that it isn't indented properly)

* [bootloader] Turn tabulations into spaces

* [bootloader] Mark Epsilon 19 as "safe to boot"

* [bootloader] Fix Epsilon 20 boot

* [bootloader] Chang version to 1.0.2
This commit is contained in:
Yaya-Cout
2022-12-03 18:14:43 +01:00
committed by GitHub
parent 08eb1aec99
commit 851ec2ab69
10 changed files with 196 additions and 141 deletions

View File

@@ -1,10 +1,26 @@
#include <bootloader/utility.h>
#include <string.h>
// This function takes a pointer to a string (version) and the size of the
// string (versionSize) and returns an integer representing the version.
// Example: "1.2.3" will return 10203.
// "1.0.1-dev" will return 10001.
int Utility::versionSum(const char * version, int length) {
int sum = 0;
for (int i = 0; i < length; i++) {
sum += version[i] * (strlen(version) * 100 - i * 10);
int currentNumber = 0;
// List of numbers that are allowed in a version
const char * allowedNumbers = "0123456789";
for (int i = 0; i < length; i++) {
if (version[i] == '.') {
sum = sum * 100 + currentNumber;
currentNumber = 0;
} else if (strchr(allowedNumbers, version[i]) != nullptr) {
currentNumber = currentNumber * 10 + (version[i] - '0');
} else {
// We found a character that is not a number or a dot, so we stop
break;
}
}
sum = sum * 100 + currentNumber;
return sum;
}