Random mac address after reboot with SPI Flash and NVME

I’m following this instruction: https://wiki.radxa.com/Rock3/install/spi
After flashing loader and uboot from https://dl.radxa.com/rock3/images/loader/rock-3a/, and dd https://github.com/radxa/debos-radxa/releases/download/main-7f328c0c/rock-3a-debian-buster-xfce4-arm64-20220117-0251-gpt.img.xz to nvme ssd, I can boot into the NVME SSD, but after every reboot the eth0 mac address changes.
This won’t happen when I boot from SD card.

I can see error in uboot log “rockchip_set_ethaddr: vendor_storage_write failed -5”.
I tried SPI Flash + SD card, the mac address is also static, maybe there is something wrong with the SSD partition.
Since I use dd to create my bootable NVME SSD, I will try etcher after my USB NVME reader arrives.

I did some research and printed some logs in uboot. Finally I found that:

1,
uboot tried to read lan mac address from vendor storage with api vendor_storage_read, if it can’t read lan mac address from this api, it will generate a random mac address and call vendor_storage_write to wirte a mac address in the vendor storage.

2,
when uboot is in spi nor flash, vendor_storage_read and vendor_storage_write would fail because vendor_storage_init failed;
vendor_storage_init failed because part_driver_lookup_type failed;
part_driver_lookup_type failed because it can’t get the partition type of spi flash(should be mtd block device)

3,
In the uboot log I can see a log output like “GUID Partition Table Header signature is wrong: 0xFFFFFFFFFFFFFFFF != 0x5452415020494645”, maybe it is related.

4,
I also take a look at the uboot code of rockpi 4, it should use IF_TYPE_SPINOR, not IF_TYPE_MTD as rock 3a. So there should be some work for radxa to do to finally support SPI Flash vendor storage on rock 3a.

I use this script to create a 16M spi image and finally get it works:

dd if=/dev/zero of=spi_image.img bs=1M count=0 seek=16
/usr/sbin/parted -s spi_image.img mklabel gpt
/usr/sbin/parted -s spi_image.img unit s mkpart idbloader 64 7167
/usr/sbin/parted -s spi_image.img unit s mkpart vnvm 7168 7679
/usr/sbin/parted -s spi_image.img unit s mkpart reserved_space 7680 8063
/usr/sbin/parted -s spi_image.img unit s mkpart reserved1 8064 8127
/usr/sbin/parted -s spi_image.img unit s mkpart uboot_env 8128 8191
/usr/sbin/parted -s spi_image.img unit s mkpart reserved2 8192 16383
/usr/sbin/parted -s spi_image.img unit s mkpart uboot 16384 32734
dd if=../repos/out/u-boot/idbloader.img of=spi_image.img seek=64 conv=notrunc
dd if=../repos/out/u-boot/u-boot.itb of=spi_image.img seek=16384 conv=notrunc

FYI: https://github.com/radxa/debos-radxa/issues/11

2 Likes