Skip to content

Commit 4238ae5

Browse files
PegaSwitchmshych
authored andcommitted
Pegatron EM21T54: add to support ONIE
This machine has 48x1GbE RJ45 and 6x10/25GbE SFP28 ports on Marvell AleyCat5X switch ASIC. CPU module is Marvell AleyCat5X 98DX3510. Signed-off-by: Wolf Lin <[email protected]> Signed-off-by: Michael Shych <[email protected]>
1 parent 887092b commit 4238ae5

File tree

20 files changed

+2541
-0
lines changed

20 files changed

+2541
-0
lines changed

build-config/scripts/onie-build-targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
{ "Vendor": "pegatron", "Platform": "pegatron_fn_6254_dn_f", "BuildEnv": "Debian9", "Release": "2021.05br", "Architecture": "amd64", "Notes": "No notes." },
229229
{ "Vendor": "pegatron", "Platform": "pegatron_dm6218_b", "BuildEnv": "Debian10", "Release": "2022.08br", "Architecture": "armv8a", "Notes": "No notes." },
230230
{ "Vendor": "pegatron", "Platform": "pegatron_dm2118_b", "BuildEnv": "Debian10", "Release": "2022.08br", "Architecture": "armv8a", "Notes": "No notes." },
231+
{ "Vendor": "pegatron", "Platform": "pegatron_em21t54", "BuildEnv": "Debian10", "Release": "2022.08br", "Architecture": "armv8a", "Notes": "No notes." },
231232

232233
{ "Vendor": "plexxi", "Platform": "px_switch2", "BuildEnv": "Debian9", "Release": "None", "Architecture": "amd64", "Notes": "Build automation failure." },
233234

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
=========================================
2+
Installing ONIE on Pegatron EM21T54
3+
=========================================
4+
5+
Cross-Compiling ONIE
6+
====================
7+
8+
Change directories to "build-config" to compile ONIE.
9+
10+
To compile ONIE first change directories to "build-config" and then
11+
type "make MACHINEROOT=../machine/pegatron MACHINE=pegatron_em21t54 all". For example::
12+
13+
$ cd build-config
14+
$ make -j4 MACHINEROOT=../machine/pegatron MACHINE=pegatron_em21t54 all
15+
16+
When complete, the ONIE binaries are located in
17+
build/images:
18+
pegatron_em21t54-r0.dtb
19+
pegatron_em21t54-r0.initrd
20+
pegatron_em21t54-r0.vmlinuz
21+
pegatron_em21t54-r0.itb
22+
23+
Installing ONIE on a Blank Machine
24+
============================
25+
Step 1: Format usb stick to FAT32 file system
26+
27+
=> mkfs.vfat -F /dev/sdX1
28+
29+
Step 2: Copy ONIE kernel (pegatron_dm6218_b-r0.itb)
30+
31+
=> mount /dev/sdX1 /mnt/usb
32+
=> cp pegatron_em21t54-r0.itb /mnt/usb/
33+
=> umount /mnt/usb
34+
35+
Step 3: Copy ONIE updater image (onie-updater-arm64-pegatron_dm6218_b-r0)
36+
37+
=> mount /dev/sdX1 /mnt/usb
38+
=> cp onie-updater-arm64-pegatron_em21t54-r0 /mnt/usb/
39+
=> umount /mnt/usb
40+
41+
Step 4: Shutdown you platform and place you usb stick onto the platform
42+
43+
Step 5: boot the ONIE kernel in USB stick
44+
and then ONIE will install the ONIE binaries to eMMC
45+
46+
=> run onie_embed_bootcmd
47+
48+
Boot the ONIE binaries from USB stick
49+
=====================================
50+
Step 1: Format usb stick to FAT32 file system
51+
52+
=> mkfs.vfat -F /dev/sdX1
53+
54+
Step 2: Copy ONIE kernel (pegatron_em21t54-r0.itb)
55+
56+
=> mount /dev/sdX1 /mnt/usb
57+
=> cp pegatron_em21t54-r0.itb /mnt/usb/
58+
=> umount /mnt/usb
59+
60+
Step 3: Shutdown you platform and place you usb stick onto the platform
61+
62+
Step 4: boot the ONIE kernel
63+
64+
=> run onie_usb_bootcmd
65+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CONFIG_SYS_EEPROM=y
2+
CONFIG_SYS_EEPROM_SYSFS_FILE=y
3+
CONFIG_SYS_EEPROM_SYSFS_FILE_PATH="/sys/bus/i2c/devices/0-0054/eeprom"
4+
CONFIG_SYS_EEPROM_OFFSET=0
5+
CONFIG_SYS_EEPROM_SIZE=256
6+
CONFIG_SYS_EEPROM_MAX_SIZE=2048
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
3+
diff --git a/miscutils/fw_env.c b/miscutils/fw_env.c
4+
index 777c369..56ae7bc 100644
5+
--- a/miscutils/fw_env.c
6+
+++ b/miscutils/fw_env.c
7+
@@ -35,6 +35,8 @@
8+
#define CMD_GETENV "fw_printenv"
9+
#define CMD_SETENV "fw_setenv"
10+
11+
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
12+
+
13+
#define min(x, y) ({ \
14+
typeof(x) _min1 = (x); \
15+
typeof(y) _min2 = (y); \
16+
@@ -838,9 +840,9 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
17+
18+
ioctl (fd, MEMLOCK, &erase);
19+
20+
- processed += blocklen;
21+
+ processed += erasesize;
22+
block_seek = 0;
23+
- blockstart += blocklen;
24+
+ blockstart += erasesize;
25+
}
26+
27+
if (write_total > count)
28+
@@ -1241,9 +1243,12 @@ static int get_config (const char *fname)
29+
if (rc < 4)
30+
continue;
31+
32+
- if (rc < 5)
33+
+ if (rc < 5){
34+
/* Default - 1 sector */
35+
- ENVSECTORS (i) = 1;
36+
+ /*ENVSECTORS (i) = 1;*/
37+
+ /* Assume enough sectors to cover the environment */
38+
+ ENVSECTORS(i) = DIV_ROUND_UP(ENVSIZE(i), DEVESIZE(i));
39+
+ }
40+
41+
i++;
42+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix_fw_env_bug.patch
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Pegatron EM21T54 specific info
2+
3+
# over ride default behaviour
4+
[ -r /etc/machine.conf ] && . /etc/machine.conf
5+
6+
mmc_device="${onie_mmc_device}"
7+
mmc_device_partition="${onie_mmc_device}3"
8+
demo_volume_label="ONIE-DEMO-OS"
9+
10+
create_demo_gpt_partition()
11+
{
12+
blk_dev="$1"
13+
14+
# See if demo partition already exists -- look for the filesystem
15+
# label.
16+
part_info="$(blkid | grep $demo_volume_label | awk -F: '{print $1}')"
17+
if [ -n "$part_info" ] ; then
18+
# delete existing partition
19+
demo_part="$(echo -n $part_info | sed -e s#${blk_dev}p##)"
20+
sgdisk -d ${demo_part} -s ${blk_dev} || {
21+
echo "Error: Unable to delete partition $demo_part on $blk_dev"
22+
exit 1
23+
}
24+
partprobe
25+
fi
26+
27+
# Find next available partition
28+
last_part_info=$(sgdisk -p ${blk_dev} | tail -n 1)
29+
last_part_num=$(echo "${last_part_info}" | awk '{print $1}')
30+
last_part_end=$(echo "${last_part_info}" | awk '{print $3}')
31+
demo_part=$(( $last_part_num + 1 ))
32+
demo_part_start=$(( $last_part_end + 1 ))
33+
# sectors_per_mb = (1024 * 1024) / 512 = 2048
34+
sectors_per_mb=2048
35+
demo_part_end=$(( $demo_part_start + 128 * $sectors_per_mb ))
36+
demo_attr_bitmask="0x0"
37+
demo_blk_dev="${onie_mmc_device}${demo_part}"
38+
39+
# Create new partition
40+
echo "Creating new demo partition ${blk_dev}p$demo_part ..."
41+
sgdisk --new=${demo_part}::${demo_part_end} \
42+
--attributes=${demo_part}:=:$demo_attr_bitmask \
43+
--change-name=${demo_part}:$demo_volume_label "$blk_dev" || {
44+
echo "Error: Unable to create partition $demo_part on $blk_dev"
45+
exit 1
46+
}
47+
partprobe
48+
49+
mkfs.ext4 -F -L $demo_volume_label $demo_blk_dev || {
50+
echo "Error: Unable to create file system on $blk_dev"
51+
exit 1
52+
}
53+
54+
blkid
55+
}
56+
57+
create_demo_msdos_partition()
58+
{
59+
blk_dev="$1"
60+
61+
# See if demo partition already exists -- look for the filesystem
62+
# label.
63+
part_info="$(blkid | grep $demo_volume_label | awk -F: '{print $1}')"
64+
if [ -n "$part_info" ] ; then
65+
# delete existing partition
66+
demo_part="$(echo -n $part_info | sed -e s#${blk_dev}p##)"
67+
parted -s $blk_dev rm $demo_part || {
68+
echo "Error: Unable to delete partition $demo_part on $blk_dev"
69+
exit 1
70+
}
71+
partprobe
72+
fi
73+
74+
# Find next available partition
75+
last_part_info="$(parted -s -m $blk_dev unit s print | tail -n 1)"
76+
last_part_num="$(echo -n $last_part_info | awk -F: '{print $1}')"
77+
last_part_end="$(echo -n $last_part_info | awk -F: '{print $3}')"
78+
# Remove trailing 's'
79+
last_part_end=${last_part_end%s}
80+
demo_part=$(( $last_part_num + 1 ))
81+
demo_part_start=$(( $last_part_end + 1 ))
82+
# sectors_per_mb = (1024 * 1024) / 512 = 2048
83+
sectors_per_mb=2048
84+
demo_part_end=$(( $demo_part_start + ( 128 * $sectors_per_mb ) - 1 ))
85+
demo_blk_dev="${onie_mmc_device}${demo_part}"
86+
87+
# Create new partition
88+
echo "Creating new demo partition ${blk_dev}p$demo_part ..."
89+
parted -s --align optimal $blk_dev unit s \
90+
mkpart primary $demo_part_start $demo_part_end set $demo_part boot on || {
91+
echo "ERROR: Problems creating demo msdos partition $demo_part on: $blk_dev"
92+
exit 1
93+
}
94+
partprobe
95+
96+
mkfs.ext4 -F -L $demo_volume_label $demo_blk_dev || {
97+
echo "Error: Unable to create file system on $blk_dev"
98+
exit 1
99+
}
100+
101+
blkid
102+
}
103+
104+
create_demo_part() {
105+
echo "INFO: Create Demo NOS Partition"
106+
107+
local part_table_type=$(/usr/sbin/parted $mmc_device print | grep "Partition Table" | awk -F: '{print $2}' | sed 's/ //g')
108+
109+
# Create ONIE Demo OS partition
110+
if [ "${part_table_type}" = "gpt" ] ; then
111+
create_demo_gpt_partition $mmc_device
112+
else
113+
create_demo_msdos_partition $mmc_device
114+
fi
115+
}
116+
117+
install_uimage() {
118+
create_demo_part
119+
120+
demo_part_info="$(blkid | grep ${demo_volume_label} | awk -F: '{print $1}')"
121+
122+
# Copy demo-pegatron-dm2118.itb to demo partition.
123+
tmp_dir=$(mktemp -d)
124+
mount ${mmc_device_partition} ${tmp_dir} > /dev/null 2>&1
125+
cp -f demo-${platform}.itb ${tmp_dir}/demo-onie-os.itb
126+
sync ; sync
127+
umount ${tmp_dir}
128+
}
129+
130+
hw_load() {
131+
echo "ext4load usb 0:3 \$loadaddr demo-onie-os.itb && run onie_args"
132+
}

0 commit comments

Comments
 (0)