Skip to content

Commit

Permalink
Allow each target to define the way to obtain its MAC address
Browse files Browse the repository at this point in the history
At the moment only 2 targets defines it:
PandABlocks: MAC from a qspi memory
PAndABrick: MAC from a secure EEPROM

This is part of a solution for issue #67
  • Loading branch information
EmilioPeJu committed Mar 15, 2024
1 parent 55f26d9 commit d3b3ca2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/fpga.make
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ carrier_ip: $(APP_IP_DEPS)
ps_core: $(PS_CORE)
devicetree : $(DEVTREE_DTB)
fsbl : $(FSBL)
boot : $(BOOT_ZIP) $(IMAGE_DIR)/boot.bin $(DEVTREE_DTB)
boot : $(BOOT_ZIP) $(IMAGE_DIR)/boot.bin $(DEVTREE_DTB) $(IMAGE_DIR)/target-functions
u-boot: $(U_BOOT_ELF)
atf: $(ATF_ELF)
dtc: $(DEVTREE_DTC)
Expand Down Expand Up @@ -247,6 +247,9 @@ $(DEVTREE_DTB): $(SDK_EXPORT) $(TARGET_DTS) $(DEVTREE_DTC)
@echo "Building DEVICE TREE blob ..."
$(DEVTREE_DTC) -f -I dts -O dtb -o $@ $(DEVTREE_DTS)/$(notdir $(TARGET_DTS))

$(IMAGE_DIR)/target-functions: $(TARGET_DIR)/etc/target-functions
cp $< $@

$(DEVTREE_DTC): $(DTC_SRC)
$(MAKE) -C $(SRC_ROOT)/dtc-$(DTC_TAG) NO_PYTHON=1

Expand Down
6 changes: 6 additions & 0 deletions targets/PandABox/etc/target-functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

get_mac_address()
{
cat /qspi/MAC
}
14 changes: 14 additions & 0 deletions targets/PandABrick/etc/target-functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

get_mac_address() {
# Trying to address 0 sends a 0 byte which wakes up the EEPROM
i2ctransfer -a -y 0 r1@0x0 &>/dev/null
# Send command to read 32 bytes of OTP zone starting at offset 0
i2ctransfer -y 0 w8@0x64 0x3 0x7 0x2 0x81 0x0 0x0 0x0a 0x27
resp=$(i2ctransfer -y 0 r35@0x64)
# Extract the MAC address and format it
resp=${resp:85:29}
resp=${resp//0x/}
resp=${resp// /:}
echo $resp
}
Empty file.
Empty file.

0 comments on commit d3b3ca2

Please sign in to comment.