Skip to contentSkip to conversation

board: amlogic: add MMC boot device detection for environment load

PATCH New Marek Szyprowski 3 participants 3 messages Dec 18, 2020 – Dec 29, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20201218142657eucas1p1834b72338d1cd92f59738e7e3e0c875d@eucas1p1.samsung.com

#1 lore raw

PATCH 1/1 board: amlogic: add MMC boot device detection for environment load

Detect eMMC or SD card boot on Odroid-C4/N2 and Khadas VIM3(l) boards and report proper MMC device for the environment loading code. This allows to automatically load and store environment variables on the FAT partition or RAW offset of the MMC device without the need to use different configurations on eMMC and SD card.

To use this feature with environment stored on FAT partition, one has to specify an empty device part (i.e. ":1" for the first partition) in CONFIG_ENV_FAT_DEVICE_AND_PART to let the code to set the device to the value returned by mmc_get_env_dev() function.

---
 board/amlogic/odroid-n2/odroid-n2.c | 8 ++++++++
 board/amlogic/vim3/vim3.c           | 8 ++++++++
 2 files changed, 16 insertions(+)
board/amlogic/odroid-n2/odroid-n2.c +8 -0
index caf7fd6810..12ee5d3abc 100644
@@ -10,6 +10,7 @@
 #include <init.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/arch/boot.h>
 #include <asm/arch/sm.h>
 #include <asm/arch/eth.h>
 
@@ -17,6 +18,13 @@
 #define EFUSE_MAC_SIZE		12
 #define MAC_ADDR_LEN		6
 
+int mmc_get_env_dev(void)
+{
+	if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+		return 1;
+	return 0;
+}
+
 int misc_init_r(void)
 {
 	u8 mac_addr[MAC_ADDR_LEN];
board/amlogic/vim3/vim3.c +8 -0
index 09ef39ff30..f9049e0172 100644
@@ -10,10 +10,18 @@
 #include <init.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/arch/boot.h>
 #include <asm/arch/eth.h>
 #include <i2c.h>
 #include "khadas-mcu.h"
 
+int mmc_get_env_dev(void)
+{
+	if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+		return 2;
+	return 1;
+}
+
 /*
  * The VIM3 on-board  MCU can mux the PCIe/USB3.0 shared differential
  * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/1 board: amlogic: add MMC boot device detection for environment load

Quoted 6 lines · Marek Szyprowski

Detect eMMC or SD card boot on Odroid-C4/N2 and Khadas VIM3(l) boards and report proper MMC device for the environment loading code. This allows to automatically load and store environment variables on the FAT partition or RAW offset of the MMC device without the need to use different configurations on eMMC and SD card.

Quoted 6 lines

To use this feature with environment stored on FAT partition, one has to specify an empty device part (i.e. ":1" for the first partition) in CONFIG_ENV_FAT_DEVICE_AND_PART to let the code to set the device to the value returned by mmc_get_env_dev() function.

Best Regards,
Jaehoon Chung

Quoted 55 lines
---
 board/amlogic/odroid-n2/odroid-n2.c | 8 ++++++++
 board/amlogic/vim3/vim3.c           | 8 ++++++++
 2 files changed, 16 insertions(+)
board/amlogic/odroid-n2/odroid-n2.c +8 -0
index caf7fd6810..12ee5d3abc 100644
@@ -10,6 +10,7 @@
 #include <init.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/arch/boot.h>
 #include <asm/arch/sm.h>
 #include <asm/arch/eth.h>
 
@@ -17,6 +18,13 @@
 #define EFUSE_MAC_SIZE		12
 #define MAC_ADDR_LEN		6
 
+int mmc_get_env_dev(void)
+{
+	if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+		return 1;
+	return 0;
+}
+
 int misc_init_r(void)
 {
 	u8 mac_addr[MAC_ADDR_LEN];
board/amlogic/vim3/vim3.c +8 -0
index 09ef39ff30..f9049e0172 100644
@@ -10,10 +10,18 @@
 #include <init.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/arch/boot.h>
 #include <asm/arch/eth.h>
 #include <i2c.h>
 #include "khadas-mcu.h"
 
+int mmc_get_env_dev(void)
+{
+	if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+		return 2;
+	return 1;
+}
+
 /*
  * The VIM3 on-board  MCU can mux the PCIe/USB3.0 shared differential
  * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between
#3 lore raw

PATCH 1/1 board: amlogic: add MMC boot device detection for environment load

In reply to Marek Szyprowski
Quoted 57 lines · Marek Szyprowski

Detect eMMC or SD card boot on Odroid-C4/N2 and Khadas VIM3(l) boards and report proper MMC device for the environment loading code. This allows to automatically load and store environment variables on the FAT partition or RAW offset of the MMC device without the need to use different configurations on eMMC and SD card.

To use this feature with environment stored on FAT partition, one has to specify an empty device part (i.e. ":1" for the first partition) in CONFIG_ENV_FAT_DEVICE_AND_PART to let the code to set the device to the value returned by mmc_get_env_dev() function.

---
 board/amlogic/odroid-n2/odroid-n2.c | 8 ++++++++
 board/amlogic/vim3/vim3.c           | 8 ++++++++
 2 files changed, 16 insertions(+)
board/amlogic/odroid-n2/odroid-n2.c +8 -0
index caf7fd6810..12ee5d3abc 100644
@@ -10,6 +10,7 @@
 #include <init.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/arch/boot.h>
 #include <asm/arch/sm.h>
 #include <asm/arch/eth.h>
 
@@ -17,6 +18,13 @@
 #define EFUSE_MAC_SIZE		12
 #define MAC_ADDR_LEN		6
 
+int mmc_get_env_dev(void)
+{
+	if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+		return 1;
+	return 0;
+}
+
 int misc_init_r(void)
 {
 	u8 mac_addr[MAC_ADDR_LEN];
board/amlogic/vim3/vim3.c +1 -0
index 09ef39ff30..f9049e0172 100644
@@ -10,10 +10,18 @@
 #include <init.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/arch/boot.h>
 #include <asm/arch/eth.h>
 #include <i2c.h>
 #include "khadas-mcu.h"
 

board/amlogic/vim3/vim3.c line 27

Quoted 10 lines
board/amlogic/vim3/vim3.c +7 -0
+int mmc_get_env_dev(void)
+{
+	if (meson_get_boot_device() == BOOT_DEVICE_EMMC)
+		return 2;
+	return 1;
+}
+
 /*
  * The VIM3 on-board  MCU can mux the PCIe/USB3.0 shared differential
  * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between

Thanks,
I would have hoped to have something more generic... but for now it's ok !

Applying to u-boot-amlogic-next

Neil