1
1
#! /bin/bash
2
2
3
- read -p " Enter the the last digits of product serial from the sticker: ${PRODUCT_SERIAL_PREFIX}${PRODUCTION_TIME} " serial
4
-
5
- ./install_firmware
6
- if [[ $? -ne 0 ]]; then
7
- echo -e " ${RED} installation of firmware failed!${NC} "
8
- exit 1
9
- fi
10
-
11
- # insert cookie to be picked up by bootloader.
12
- # This signals the bootloader not load the factory image, but too boot from
13
- # flash
14
- install_magic=0x12341234
15
- install_addr=0x0709010C
16
- devmem $install_addr 32 $install_magic
17
-
3
+ source config.sh
4
+ read -p " Enter product serial from the sticker: ${PRODUCT_SERIAL_PREFIX} " serial
18
5
19
6
days_since_may () {
20
7
# Extract year and month from PRODUCTION_TIME
@@ -35,13 +22,47 @@ local diff_days=$((diff_seconds / 86400))
35
22
echo " $diff_days "
36
23
}
37
24
25
+ generate_mac () {
26
+ # its been told that the factory serial is composed out of the following
27
+ # elements:
28
+ # XZC:Our company name initial
29
+ # T: project name of Turing PI initial
30
+ # 2211:Production time November 2022
31
+ # 00605:Product serial number
32
+
33
+ # get the last five digits
34
+ local product_digits=$(( 10 #${serial: -5} ))
35
+ if ! [[ " $product_digits " =~ ^[0-9]+$ ]]; then
36
+ echo -e " ${RED} ERROR: provided serial is not correct. Expected a serial ending with at least containing 5 digits${NC} "
37
+ exit 1
38
+ fi
39
+
40
+ eui_48=$( printf " %05X" " $product_digits " )
41
+ echo " ${TPI_MAC_BASE}${eui_48} "
42
+ }
43
+
44
+ generated_mac=$( generate_mac)
38
45
39
46
tpi_factory_serial=" ${PRODUCT_SERIAL_PREFIX}${serial} " \
40
47
tpi_product_name=" $PRODUCT_NAME " \
41
48
tpi_production_time=" $( days_since_may) " \
49
+ tpi_mac=" $generated_mac " \
42
50
tpi eeprom set
43
51
44
52
if [[ $? -ne 0 ]]; then
45
53
echo -e " ${RED} Error burning eeprom!${NC} "
46
54
exit 1
47
55
fi
56
+
57
+ ./install_firmware
58
+ if [[ $? -ne 0 ]]; then
59
+ echo -e " ${RED} installation of firmware failed!${NC} "
60
+ exit 1
61
+ fi
62
+
63
+ # insert cookie to be picked up by bootloader.
64
+ # This signals the bootloader not load the factory image, but too boot from
65
+ # flash
66
+ install_magic=0x12341234
67
+ install_addr=0x0709010C
68
+ devmem $install_addr 32 $install_magic
0 commit comments