How to extend the uboot-menu

newloadenv contains the “env import …”, but had some tests without the “run uenvcmd” and the checksd-part there, seems to work, but have to do some more tests

see https://github.com/frank-w/BPI-R2-4.4/commit/200b8f358a9ad087ac929ba5be60b280abefe04e

but anyway it will be nice if environment is loaded before menu is displayed so uboot can be controlled via uEnv.txt without modifying the code and permanently flash it

@Jackzeng have you looked into it to load uenv.txt before displaying menu?

it is very annoying to patch uboot or using the uboot-console when switching between kernels

Hello, frank, I have looked it before but not deeply, so what do you mean annoying when switching kernels? I probably could work this with you lately.

i have multiple kernels installed in my system and patched uboot to have multiple entries, see commit posted above my last posting.

now i switching between 2 4.16-kernels (wlan/hdmi)… one defined by using kernel-directive (default entry), one using my kernel416-entry

it would be nice setting the names of bootmenu entries via uEnv.txt, so i have not to reflash uboot when doing these things…

any chance getting a newer uboot to work? maybe with hdmi-support? current uboot give only a purple screen…

tried to modify it again…seems i bricked my card…(same with my current github-state)

[PART] load "UBOOT" from 0x0000000000050000 (dev) to 0x81E00000 (mem) [SUCCESS]            
[PART] load speed: 5978KB/s, 300000 bytes, 49ms                                            
[BT_SD_PG] device info 0x8590 0x8A00 0xCB01 0x102                                          
0:dram_rank_size:80000000                                                                  
[PLFM] md_type[0] = 0                                                                      
[PLFM] md_type[1] = 0                                                                      
                                                                                           
[PLFM] boot reason: 0                                                                      
[PLFM] boot mode: 0                                                                        
[PLFM] META COM0: 0                                                                        
[PLFM] <0xFFB7CC10>: 0x0                                                                   
[PLFM] boot time: 1893ms                                                                   
[PLFM] DDR reserve mode: enable = 0, success = 0                                           
                                                                                           
[BLDR] jump to 0x81E00000                                                                  
[BLDR] <0x81E00000>=0xEA00000F                                                             
[BLDR] <0x81E00004>=0xE59FF014

this seems to be a compile-issue…multiple compilations in ubuntu 18.4 (gcc6) failed to boot…compiling in 14.4 works on the first try…

here my logs from build.sh

build_14-4.log (13,7 KB) build_18-4.log (18,6 KB)

in ubuntu 14.4 it works with gcc 4.8.4

in ubuntu 18.4 it does not work…gcc ist 7.3 and arm-linux-gnueabihf-gcc is set to /usr/bin/arm-linux-gnueabihf-gcc-5

i do not work if crosscompiler is really used for uboot…i think it should be

:~$ update-alternatives --config arm-linux-gnueabihf-gcc
There are 2 choices for the alternative arm-linux-gnueabihf-gcc (providing /usr/bin/arm-linux-gnueabihf-gcc).

  Selection    Path                                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/arm-linux-gnueabihf-gcc-5   100       auto mode
  1            /usr/bin/arm-linux-gnueabihf-gcc-5   100       manual mode
  2            /usr/bin/arm-linux-gnueabihf-gcc-7   50        manual mode

i tried to make a manual diff (automatic shows to much differences due to different message formats): diff.txt (5,3 KB)

any idea why uboot compiled in 18.4 fails to boot? @garywang

my uboot-menu looks now like this:

 *** U-Boot Boot Menu ***

     1. Reload Bootmenu.
     2. Load Environment.
     3. Boot Linux from SD.
     4. Boot Kernel 4.4.
     5. Boot Kernel 4.9.
     6. Boot Kernel 4.14.
     7. Boot Kernel 4.16.
     U-Boot console

  Press UP/DOWN to move, ENTER to select

all entries except the 3rd (default, not changed) loading env from sd first.

definitions:

BPI-IoT>  printenv                                                                                                                                           
arch=arm                                                                                                                                                     
baudrate=115200                                                                                                                                              
board=bpi-r2                                                                                                                                                 
board_name=mt7623_evb                                                                                                                                        
boot0=tftpboot; bootm                                                                                                                                        
boot1=tftpboot;run boot_wr_img;run boot_rd_img;bootm                                                                                                         
boot10=mmc init; run boot_normal; bootm                                                                                                                      
boot2=run boot_rd_img;run rescue;bootm                                                                                                                       
boot3=tftpboot ${loadaddr} u-boot-mtk.bin;run wr_uboot                                                                                                       
boot4=loadb;run boot_wr_img;run boot_rd_img;bootm                                                                                                            
boot414=run newloadenv; setenv kernel ${kernel414}; printenv; run newboot                                                                                    
boot416=run newloadenv; setenv kernel ${kernel416}; printenv; run newboot                                                                                    
boot44=run newloadenv; setenv kernel ${kernel44}; printenv; run newboot                                                                                      
boot49=run newloadenv; setenv kernel ${kernel49}; printenv; run newboot                                                                                      
boot5=loadb;run wr_uboot                                                                                                                                     
boot6=usb start;run boot_wr_img;bootm                                                                                                                        
boot7=http_upgrade 10.10.10.3;run boot_wr_img;run boot_rd_img;bootm                                                                                          
boot8=mmc init; fatload mmc 0:1 ${loadaddr} "root_uImage";run boot_wr_img; bootm                                                                             
boot9=mmc init; fatload mmc 0:1 ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm                                                                      
boot_normal=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; if run loadboom
boot_rd_img=mmc device 0;mmc read ${loadaddr} 0xA00 1;image_blks 512;mmc read ${loadaddr} 0xA00 ${img_blks}                                                  
boot_rd_sec_img=mmc device 0;mmc read ${loadaddr} 0x10A00 1;image_blks 512;mmc read ${loadaddr} 0x10A00 ${img_blks}                                          
boot_wr_img=image_check; if test ${img_result} = good; then image_blks 512 ${filesize};mmc device 0;mmc write ${loadaddr} 0xA00 ${img_blks}; fi              
boot_wr_sec_img=image_check; if test ${img_result} = good; then image_blks 512 ${filesize};mmc device 0;mmc write ${loadaddr} 0x10A00 ${img_blks}; fi        
bootargs=board=bpi-r2 earlyprintk console=tty1 fbcon=map:0 console=ttyS0,115200 vmalloc=496M debug=7 initcall_debug=0 root=/dev/mmcblk0p2 rootfstype=ext4 rot
bootcmd=No                                                                                                                                                   
bootdelay=3                                                                                                                                                  
bootenv=uEnv.txt                                                                                                                                             
bootfile=iverson_uImage                                                                                                                                      
bootmenu_0=1. Reload Bootmenu.=run reloadmenu                                                                                                                
bootmenu_1=2. Load Environment.=run newloadenv                                                                                                               
bootmenu_2=3. Boot Linux from SD.=run boot10                                                                                                                 
bootmenu_3=4. Boot Kernel 4.4.=run boot44                                                                                                                    
bootmenu_4=5. Boot Kernel 4.9.=run boot49                                                                                                                    
bootmenu_5=6. Boot Kernel 4.14.=run boot414                                                                                                                  
bootmenu_6=7. Boot Kernel 4.16.=run boot416                                                                                                                  
bootmenu_delay=30                                                                                                                                            
bpi=bananapi                                                                                                                                                 
bpiver=1                                                                                                                                                     
checksd=fatinfo ${device} 1:1                                                                                                                                
chip=MT7623N                                                                                                                                                 
cpu=armv7                                                                                                                                                    
debug=7                                                                                                                                                      
device=mmc                                                                                                                                                   
duimage_backup=mmc device 0;mmc read ${loadaddr} 0x10A00 1;image_check; if test ${img_result} = bad;then run boot_rd_img; serious_image_check; if test ${imgi
duimage_recovery=serious_image_check; if test ${img_result} = bad; then run boot_rd_sec_img;serious_image_check; if test ${img_result} = good; then reco_mesi
ethact=mtk_eth                                                                                                                                               
ethaddr=00:0C:E7:11:22:33                                                                                                                                    
ipaddr=10.10.10.254                                                                                                                                          
kernel=uImage                                                                                                                                                
kernel414=uImage_4.14                                                                                                                                        
kernel416=uImage_4.16                                                                                                                                        
kernel44=uImage_4.4                                                                                                                                          
kernel49=uImage_4.9                                                                                                                                          
loadaddr=0x84000000                                                                                                                                          
loadbootenv=fatload ${device} ${partition} ${scriptaddr} ${bpi}/${board}/${service}/${bootenv} || fatload ${device} ${partition} ${scriptaddr} ${bootenv}    
newboot=fatload mmc ${partition} ${loadaddr} ${bpi}/${board}/${service}/${kernel}; bootm                                                                     
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;                 
newloadenv=mmc init; run loadbootenv; env import -t ${scriptaddr} ${filesize};                                                                               
partition=1:1                                                                                                                                                
reloadmenu=run newloadenv;bootmenu                                                                                                         
rescue=serious_image_check;                                                                                                                                  
root=/dev/mmcblk0p2                                                                                                                                          
scriptaddr=0x83000000                                                                                                                                        
serverip=10.10.10.3                                                                                                                                          
service=linux                                                                                                                                                
soc=mt7623                                                                                                                                                   
stderr=serial                                                                                                                                                
stdin=serial                                                                                                                                                 
stdout=serial                                                                                                                                                
vendor=mediatek                                                                                                                                              
wr_uboot=uboot_check;if test ${uboot_result} = good; then mmc device 0;mmc write ${loadaddr} 0x200 0x200;reset; fi                                           
                                                                                                                                                             
Environment size: 3937/4092 bytes

Uboot does not work if i compile it in ubuntu 18.4 using linaeo gcc arm-gnueabihf 5.5. Any idea why?

Kernel with wifi-driver cannot be compiled with gcc7

is it possible to set the default entry via an environment-variable from uEnv.txt?

@Jackzeng

what do you mean default entry?

entry what process?

the numer that is selected in the bootmenu…currently it is always the 3rd

imho in code it is done via a const:

but imho there should be a way to set this via uenv.txt

maybe we can modify this to use a env-variable:

currently i don’t know how to access env-vars here, bit the code should look like this:

#if defined(CONFIG_MENU_ACTIVE_ENTRY)
	menu->active = CONFIG_MENU_ACTIVE_ENTRY;
#else
	menu->active = 0;
#endif
if (ENV_MENU_ACTIVE_ENTRY) {menu->active = ENV_MENU_ACTIVE_ENTRY;}

this seems to be the key:

i can add a new env-var like it’s done for bootmenu-delay…maybe i have to change the header of bootmenu_create and bootmenu_show to pass the new var like delay

Hello, frank, after I checked, I will post you.

hoping it works :slight_smile: testing tomorrow, just for you to see how i mean (no need for param-moving over different functions)

Basicly this works. I’ve set the env-var in uboot-console and run bootmenu. If i go again in console, change this var and run bootmenu again it is not recognized. In code it looks like bootmenu is created everytime it is shown so it should work everytime

mhm…last param of simple_strtol is “base”…here so decimal not the default value i thought :slight_smile: try to change it back to 10 => works now as expected :slight_smile:

1 Like

@Jackzeng have you find a way to load uenv.txt before display menu?

hi, frank, I need some time, haha:grinning: