Skip to content

Commit ce8864f

Browse files
factory: burn mac based on factory serial
1 parent 67d7105 commit ce8864f

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

tp2bmc/board/tp2bmc/factory_overlay/upper/factory/config.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
PRODUCT_NAME="TuringPi2"
44
PRODUCT_SERIAL_PREFIX=""
55
# production month. format= 'YYmm'
6-
PRODUCTION_TIME="2406"
6+
PRODUCTION_TIME="2408"
77

88
RK1_USERNAME=ubuntu
99
RK1_PASSWORD=Turingpi123
@@ -19,3 +19,4 @@ NODE4_IP="192.168.0.104"
1919
ASSERT_VERSION=4211
2020
ASSERT_MODEL_NAME="Turing Pi 2 (v2.5.1)"
2121

22+
TPI_MAC_BASE="C4FF841"
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
#!/bin/bash
22

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
185

196
days_since_may() {
207
# Extract year and month from PRODUCTION_TIME
@@ -35,13 +22,47 @@ local diff_days=$((diff_seconds / 86400))
3522
echo "$diff_days"
3623
}
3724

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)
3845

3946
tpi_factory_serial="${PRODUCT_SERIAL_PREFIX}${serial}" \
4047
tpi_product_name="$PRODUCT_NAME" \
4148
tpi_production_time="$(days_since_may)" \
49+
tpi_mac="$generated_mac" \
4250
tpi eeprom set
4351

4452
if [[ $? -ne 0 ]]; then
4553
echo -e "${RED} Error burning eeprom!${NC}"
4654
exit 1
4755
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

Comments
 (0)