cmd: new mac_from_mmc command
This commit is contained in:
parent
c5b92986b5
commit
cfea650c68
3 changed files with 54 additions and 0 deletions
|
@ -1288,6 +1288,12 @@ config CMD_MMC_REG
|
||||||
Enable the commands for reading card registers. This is useful
|
Enable the commands for reading card registers. This is useful
|
||||||
mostly for debugging or extracting details from the card.
|
mostly for debugging or extracting details from the card.
|
||||||
|
|
||||||
|
config CMD_MAC_FROM_MMC
|
||||||
|
bool "mac form mmc cid"
|
||||||
|
depends on CMD_MMC
|
||||||
|
help
|
||||||
|
Enable command for forming a MAC address from the CID of a eMMC device.
|
||||||
|
|
||||||
config CMD_MMC_RPMB
|
config CMD_MMC_RPMB
|
||||||
bool "Enable support for RPMB in the mmc command"
|
bool "Enable support for RPMB in the mmc command"
|
||||||
depends on SUPPORT_EMMC_RPMB
|
depends on SUPPORT_EMMC_RPMB
|
||||||
|
|
|
@ -115,6 +115,7 @@ obj-$(CONFIG_CMD_MDIO) += mdio.o
|
||||||
obj-$(CONFIG_CMD_PAUSE) += pause.o
|
obj-$(CONFIG_CMD_PAUSE) += pause.o
|
||||||
obj-$(CONFIG_CMD_SLEEP) += sleep.o
|
obj-$(CONFIG_CMD_SLEEP) += sleep.o
|
||||||
obj-$(CONFIG_CMD_MMC) += mmc.o
|
obj-$(CONFIG_CMD_MMC) += mmc.o
|
||||||
|
obj-$(CONFIG_CMD_MAC_FROM_MMC) += mac_from_emmc.o
|
||||||
obj-$(CONFIG_CMD_OPTEE_RPMB) += optee_rpmb.o
|
obj-$(CONFIG_CMD_OPTEE_RPMB) += optee_rpmb.o
|
||||||
obj-$(CONFIG_CMD_MP) += mp.o
|
obj-$(CONFIG_CMD_MP) += mp.o
|
||||||
obj-$(CONFIG_CMD_MTD) += mtd.o
|
obj-$(CONFIG_CMD_MTD) += mtd.o
|
||||||
|
|
47
cmd/mac_from_emmc.c
Normal file
47
cmd/mac_from_emmc.c
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Alchemilla Ventures Private Limited <hayzam@alchemilla.io>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
#include <command.h>
|
||||||
|
#include <console.h>
|
||||||
|
#include <mmc.h>
|
||||||
|
|
||||||
|
static int do_mac_from_mmc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) {
|
||||||
|
if (argc != 2) {
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentDevice = simple_strtoul(argv[1], NULL, 10);
|
||||||
|
struct mmc *mmc = find_mmc_device(currentDevice);
|
||||||
|
|
||||||
|
if (!mmc) {
|
||||||
|
printf("No MMC device at slot %d\n", currentDevice);
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_SD(mmc)) {
|
||||||
|
printf("SD registers are not supported\n");
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char mac[6];
|
||||||
|
mac[0] = (mmc->cid[0] >> 24) & 0xFE;
|
||||||
|
mac[1] = (mmc->cid[1] >> 16) & 0xFF;
|
||||||
|
mac[2] = (mmc->cid[2] >> 8) & 0xFF;
|
||||||
|
mac[3] = (mmc->cid[3]) & 0xFF;
|
||||||
|
mac[4] = (mmc->cid[0] >> 8) & 0xFF;
|
||||||
|
mac[5] = (mmc->cid[1] >> 24) & 0xFF;
|
||||||
|
|
||||||
|
printf("MAC Address: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||||
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
|
|
||||||
|
return CMD_RET_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_BOOT_CMD(
|
||||||
|
mac_from_mmc, 2, 0, do_mac_from_mmc,
|
||||||
|
"Get MAC address from MMC CID",
|
||||||
|
"mmc"
|
||||||
|
);
|
Loading…
Reference in a new issue