Skip to content

Commit

Permalink
Omnia: Fix default MAC address
Browse files Browse the repository at this point in the history
Fix default MAC address generation in boot script.
In OpenWRT/TurrisOS the NICs take the MAC addresses from U-Boot that
sets the adresses in C code from data in I2C EEPROM to the NIC
registers. When Debian kernel starts it shuts down clocks for NICs
which means that the MAC addresses set by U-Boot are lost.

Add FDT modififaction to booscript that generate the MAC address
records to the FDT before the kernel is booted, so the MAC
get passed to the kernel in DT.
  • Loading branch information
tmshlvck committed Oct 18, 2021
1 parent 440713f commit 08c1453
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions omnia/files/genbootscr
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@ setenv omnia_boot_prep '${SCRIPT_PREPEND}'
setenv omnia_boot_lk 'load $BOOTDEV \${kernel_addr_r} /@${KERNEL_IMAGE}'
setenv omnia_boot_ldt_phy 'load $BOOTDEV \${fdt_addr_r} /@$DTPHY'
setenv omnia_boot_ldt_sfp 'load $BOOTDEV \${fdt_addr_r} /@$DTSFP'
setenv omnia_fixup_mac0 'setexpr fmac0 gsub : " " \$ethaddr; fdt resize; fdt set /soc/internal-regs/ethernet@70000 local-mac-address "[\${fmac0}]"'
setenv omnia_fixup_mac1 'setexpr fmac1 gsub : " " \$eth1addr; fdt resize; fdt set /soc/internal-regs/ethernet@30000 local-mac-address "[\${fmac1}]"'
setenv omnia_fixup_mac2 'setexpr fmac2 gsub : " " \$eth2addr; fdt resize; fdt set /soc/internal-regs/ethernet@34000 local-mac-address "[\${fmac2}]"'
EOF

if [ -f "${INITRD}" ]; then
cat >>/boot/boot.txt <<EOF
setenv omnia_boot_lrd 'load $BOOTDEV \${ramdisk_addr_r} /@${INITRD}'
setenv omnia_boot_brd 'bootz \${kernel_addr_r} \${ramdisk_addr_r}:0x\${filesize} \${fdt_addr_r};'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; if gpio input gpio@71_4; then echo SFP; run omnia_boot_ldt_sfp; else echo PHY; run omnia_boot_ldt_phy; fi; run omnia_boot_lrd; run omnia_boot_brd'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; if gpio input gpio@71_4; then echo SFP; run omnia_boot_ldt_sfp; else echo PHY; run omnia_boot_ldt_phy; fi; fdt addr \${fdt_addr_r}; run omnia_fixup_mac0; run omnia_fixup_mac1; run omnia_fixup_mac2; run omnia_boot_lrd; run omnia_boot_brd'
run omnia_boot
EOF
else
cat >>/boot/boot.txt <<EOF
setenv omnia_boot_b 'bootz \${kernel_addr_r} - \${fdt_addr_r};'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; if gpio input gpio@71_4; then echo SFP; run omnia_boot_ldt_sfp; else echo PHY; run omnia_boot_ldt_phy; fi; run omnia_boot_b;'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; if gpio input gpio@71_4; then echo SFP; run omnia_boot_ldt_sfp; else echo PHY; run omnia_boot_ldt_phy; fi; fdt addr \${fdt_addr_r}; run omnia_fixup_mac0; run omnia_fixup_mac1; run omnia_fixup_mac2; run omnia_boot_b;'
run omnia_boot
EOF
fi
Expand Down

0 comments on commit 08c1453

Please sign in to comment.