Have you an example for reading and writing partitionconfig to the needed value 0x48?
U-Boot> mmc list
mmc@11230000: 0 (eMMC)
mmc@11240000: 1 (SD)
U-Boot> gpt read mmc 0
gpt - GUID Partition Table
Usage:
gpt <command> <interface> <dev> <partitions_list>
- GUID partition table restoration and validity check
Restore or verify GPT information on a device connected
to interface
Example usage:
gpt write mmc 0 $partitions
gpt verify mmc 0 $partitions
read <interface> <dev>
- read GPT into a data structure for manipulation
guid <interface> <dev>
- print disk GUID
guid <interface> <dev> <varname>
- set environment variable to disk GUID
Example usage:
gpt guid mmc 0
gpt guid mmc 0 varname
as far as i understand does gtp read/write a gpt-partition…the emmc command creates hardware-partitions (separate devices) mmcblkXbootY instead of mmcblkXpY…so i think creaeting this partitions with gpt-command is impossible
Emmc was introduced in 2014 uboot here: https://github.com/BPI-SINOVOIP/BPI-R2-bsp/commit/71d865da906ea1f333b56bf810cb789bad2e8cac
i can read the uenv.txt using definitions from old uboot:
setenv scriptaddr 0x83000000
setenv bpi bananapi
setenv board bpi-r2
setenv service linux
setenv device mmc
setenv partition 1:1
setenv bootenv uEnv.txt
setenv loadbootenv fatload ${device} ${partition} ${scriptaddr} ${bpi}/${board}/${service}/${bootenv}
setenv importenv env import -t ${scriptaddr} ${filesize}
run loadbootenv
run importenv
and got kernel booting with
U-Boot> setenv newboot "fatload mmc ${partition} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm"
U-Boot> run newboot
it seems that emmc (mmc 0) is always default device, also if i boot from sd-card…how can this be changed?
i booted from SD-Card:
U-Boot> mmc dev
switch to partitions #0, OK
mmc0(part 0) is current device
U-Boot> mmc list
mmc@11230000: 0 (eMMC)
mmc@11240000: 1
in old uboot the problem with wrong device is resolved by this 2 definitions:
checksd=fatinfo ${device} 1:1
newchecksd=if run checksd; then echo Boot from SD ; setenv partition 1:1; else echo Boot from eMMC ; mmc init 0 ; setenv partition 0:1 ; fi;
“mmc init” seems to be dropped
also “saveenv” seems to be missing, do i have to enable anything for saving the environment?
i tried to activate CONFIG_ENV_IS_IN_MMC to activate saveenv-command (https://patchwork.ozlabs.org/patch/852568/) results in failed build:
env/mmc.c: In function ‘mmc_get_env_dev’:
env/mmc.c:127:9: error: ‘CONFIG_SYS_MMC_ENV_DEV’ undeclared (first use in this function); did you mean ‘CONFIG_SYS_MALLOC_LEN’?
return CONFIG_SYS_MMC_ENV_DEV;
^~~~~~~~~~~~~~~~~~~~~~
CONFIG_SYS_MALLOC_LEN
env/mmc.c:127:9: note: each undeclared identifier is reported only once for each function it appears in
env/mmc.c:128:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
scripts/Makefile.build:278: recipe for target 'env/mmc.o' failed
make[1]: *** [env/mmc.o] Error 1
this CONST is defined in old uboot here: https://github.com/frank-w/bpi-r2-uboot/blob/master/include/configs/mt7623_evb.h#L263 but surrounded with if/elif
basicly
#elif defined(OFF_BOARD_SD_CARD_COMPONENT)
#define CONFIG_SYS_MMC_ENV_DEV 1
#elif defined(ON_BOARD_EMMC_COMPONENT)
#define CONFIG_SYS_MMC_ENV_DEV 0
are these ON/OFF-Consts available in new uboot? i did not find them in uboot config, in old uboot they are defined in autoconf.h (which is a generated file afaik)
i simly defined
CONFIG_SYS_MMC_ENV_DEV 0
in include/configs/mt7623.h and compile works and i got the saveenv in ubbot…but now target for savenenv is always emmc.
@jackzeng has patched 2014 uboot to use the right mmc. https://github.com/BPI-SINOVOIP/BPI-R2-bsp/commit/0b7eb9e24a66d405970aff1b466bb50b21f925b8
but this modifies global mmc-driver too much in my eyes for a patch…maybe it’s better calling a global function which by default returns CONFIG_SYS_MMC_ENV_DEV and can be overridden by vendor-specific emmc-driver. My c/c++ knowledge is a bit too less to realize this ;(
seems such function exists already for CONFIG_SYS_MMC_ENV_PART but not for CONFIG_SYS_MMC_ENV_DEV:
env/mmc.c:
125 __weak int mmc_get_env_dev(void)
126 {
127 return CONFIG_SYS_MMC_ENV_DEV;
128 }
so we can try to override this function and return the actual boot-device…but how to deal with offset-change (+1MB if SD-Card) from Jacks patch? is this needed?
i tried to override this function in include/configs/mt7623.h, but this leads to some errors…maybe i need to copy this function to a c-file
include/configs/mt7623.h: Assembler messages:
include/configs/mt7623.h:72: Error: bad instruction `int mmc_get_env_dev(void)'
include/configs/mt7623.h:73: Error: junk at end of line, first unrecognized character is `{'
include/configs/mt7623.h:74: Error: bad instruction `return 1'
include/configs/mt7623.h:75: Error: junk at end of line, first unrecognized character is `}'
72 int mmc_get_env_dev(void)
73 {
74 return 1;
75 }
tried also in mtk-sd.c but here i have no access to the defined constant…build without it seems to work…
and can i add the vars somewhere to uboot-code to load it automaticly (and display bootmenu)?
i tried bootcmd, but it is not executed on startup…
bootcmd=run selectmmc; run loadbootenv; run importenv;
added a default environment file to my repo which gets build into uboot (i see the vars with printenv after bootup)