[BPI-R64] uboot

Hi,

i have made some modifications to r64 uboot and want to separate uboot from kernel (in my uboot-repo).

https://github.com/frank-w/BPI-R64-bsp-4.19/commits/master

https://github.com/frank-w/u-boot/tree/bpi-r64/

currently i hang on

$ make CROSS_COMPILE=arm-linux-gnueabihf- UBOOT_CONFIG=mt7622_evb_config
Makefile:525: *** "System not configured - see README".

i tried to run env.sh before, but no luck

error-message points me to this line in makefile:

any idea whats needed to be done before calling make?

mhm, seems my command-line is wrongā€¦

$ make CROSS_COMPILE=arm-linux-gnueabihf- mt7622_evb_config
Configuring for mt7622_evb board...
$ make CROSS_COMPILE=arm-linux-gnueabihf-

seems to run, but gpio.h is not found

In file included from common/cmd_gpio.c:12:0:
./arch/arm/include/asm/gpio.h:1:27: fatal error: asm/arch/gpio.h: No such file or directory
 #include <asm/arch/gpio.h>

also in original repo i donā€™t see this fileā€¦

$ find -name 'gpio.h' | grep 'asm/arch'

lists only some board-specific files where ā€œarchā€ is part of folder-name (e.g. arch/arm/include/asm/arch-rmobile/gpio.h).

seems that there was anything broken, after make mrproper it compilesā€¦

anybody here having an r64 with mt7531?

have now cleaned my r64-branch a bit and it compiles also with mt7531-driver

just make a clone and then

./build.sh config #change switch to mt7531
./build.sh
./build.sh install

currently i try to figure out how to use SD as flash typeā€¦emmc compiles fine while SD is broken

/media/data_fast/bpi/uboot/u-boot/include/configs/mt7622_evb.h:412:45: error: 'NFI_BASE' undeclared here (not in a function)
 #define CONFIG_SYS_NAND_BASE                NFI_BASE

it looks like there is a missing conditionā€¦or include order is wrong (board before nand)

imho nand != sd-card or is nand-driver needed for sdcard? tried to add include which defines NFI_base (e.g. asm/arch-mt7622/mt6735.h) but this leads to other errorsā€¦any idea about that? @jackzeng @sinovoip @moore

1 Like

There is no need to enable nand driver if we want to boot from emmc or SD.

you can download native uboot code and type ā€œmake menuconfigā€ in home directory. choose boot from sd to see what compile options need to be enabled. thanks.

choice 'Flash Type' "NAND ON_BOARD_NAND_FLASH_COMPONENT \
                 SNAND ON_BOARD_SPI_NAND_FLASH_COMPONENT \
                 SNOR ON_BOARD_SPI_NOR_FLASH_COMPONENT \
                 eMMC ON_BOARD_EMMC_COMPONENT \
                 SD OFF_BOARD_SD_CARD_COMPONENT \
				 NONE ON_BOARD_NO_FLASH_COMPONENT
	    " SNAND
1 Like

The problematic line is from original code

Have you tested sd-option here?

I am not familiar with build.sh build flow. I guess uboot source in bpi github has something different from original one (at least config.in in home directory) . I donā€™t see such problem if use original uboot source with buildroot-gcc492 toolchain (type make menuconfig; make to build uboot image) and uboot partition in below image was also built by this way.

  1. SD card image : as a helper to write demo image files to eMMChttps://drive.google.com/open?id=1Ap7lt-pjpG-pAOAEqpH13-SMOSkRkZI0

Most users donā€™t have buildroot-toolchain. Can you please try with ubuntuā€™s linaro toolchain (gcc6 arm-linux-gnueabihf)?

i have removed buildroot-toolchain from makefile and only call make with linaro-toolchain in my build.sh (also menuconfig) so itā€™s easier to read.

i tried official repo with 4.4 and 4.19, changed flash-type to SD with make menuconfig before and compiled with build.sh and ā€œmake CROSS_COMPILE=arm-linux-gnueabihf-ā€

all ended up with same error

/media/data_fast/bpi/kernel/BPI-R64-BSP-4.19_official/u-boot-mt/include/configs/mt7622_evb.h:412:45: error: ā€˜NFI_BASEā€™ undeclared here (not in a function)
 #define CONFIG_SYS_NAND_BASE                NFI_BASE
                                         ^
drivers/mtd/nand/nand.c:29:37: note: in expansion of macro ā€˜CONFIG_SYS_NAND_BASEā€™
 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
                                 ^~~~~~~~~~~~~~~~~~~~
drivers/mtd/nand/nand.c:52:57: note: in expansion of macro ā€˜CONFIG_SYS_NAND_BASE_LISTā€™
 static ulong base_address[CONFIG_SYS_MAX_NAND_DEVICE] = CONFIG_SYS_NAND_BASE_LIST;
                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~

which Value should CONFIG_SYS_NAND_BASE/NFI_BASE have for SD-card? i have found 2 diferent definitions for mt7622

./u-boot-mt/arch/arm/include/asm/arch-mt7622/mt6735.h:43:#define IO_PHYS             (0x10000000)
./u-boot-mt/arch/arm/include/asm/arch-mt7622/mt6735.h:94:#define NFI_BASE            (IO_PHYS + 0x0100D000) //MT6735 no NFI
./u-boot-mt/arch/arm/include/asm/arch-mt7622/nand/mtk_nand.h:16:#define NFI_BASE0x1100D000

same again soc-independ:

./u-boot-mt/arch/arm/include/asm/arch/mt6735.h:43:#define IO_PHYS             (0x10000000)
./u-boot-mt/arch/arm/include/asm/arch/mt6735.h:94:#define NFI_BASE            (IO_PHYS + 0x0100D000) //MT6735 no NFI
./u-boot-mt/arch/arm/include/asm/arch/nand/mtk_nand.h:16:#define NFI_BASE	0x1100D000

i wonder why different toolchain does not show this errorā€¦maybe nand-include is missing for SD? these includes are not used or after the mt7622.h

as far as i see the only include of mt7622_evb.h is in ./arch/arm/lib/bootm.c and here is no include to the nand (i guess itā€™s later in storage-commands)ā€¦isnā€™t it better to define IO_PHYS / NFI_BASE in board-header (to use it there) or some ā€œglobalā€ header-file instead of the NAND-driver?

i wonder why it happens because the call to this value comes from the universal-nand-driverā€¦shouldnā€™t it not include the nand-headers first? havnā€™t found out the order yet

if i add the 2 defines to the board-header, i donā€™t get the expected duplicate definitionā€¦instead i got an undefined reference for board_nand_init in drivers/mtd/nand/nand.c:180

this function is defined in

./drivers/misc/mediatek/nand/mt7622/mtk_nand.c:3945:int board_nand_init(struct nand_chip *nand_chip)
./drivers/misc/mediatek/nand/mt7622/mtk_snand_k.c:3954:int board_nand_init(struct nand_chip *nand_chip)

both are included if CONFIG_MTK_MTD_NAND is setā€¦this is only set if ON_BOARD_*NAND_FLASH_COMPONENT is selectedā€¦not if flashtype set to SD (OFF_BOARD_SD_CARD_COMPONENT)

so i wonder why drivers/mtd/nand/nand.c is used

iā€™ve seen that for flashtype=SD nand and mtd are activated including the CMD_*-options. disabled them and now iā€™m able to compileā€¦strange that you can build without this change

Below is what I did based on original tarball with linaro toolchain for your reference.

1.apt-get install gcc-6-arm-linux-gnueabihf

2.cd /usr/bin; ln -sf arm-linux-gnueabihf-gcc-6 arm-linux-gnueabihf-gcc

  1. copy compiler-gcc6.h include/linux directory. https://gitlab.com/SaberMod/android-kernel-lge-hammerhead/blob/4a98feebe2cb735eef2299bc5512b9c83cc789ce/include/linux/compiler-gcc6.h

  2. vi Makefile

    CROSS_COMPILE = arm-linux-gnueabihf-

  3. vi include/linux/compiler-gcc.h

#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) ||
!defined(CONFIG_OPTIMIZE_INLINING) || (GNUC < 4)

#define inline         inline          __attribute__((always_inline)) __attribute__((__gnu_inline__))
#define __inline__     __inline__      __attribute__((always_inline)) __attribute__((__gnu_inline__))
#define __inline       __inline        __attribute__((always_inline)) __attribute__((__gnu_inline__))
#endif
  1. make menuconfig

(MT7622) Chip ID
(ASIC) Chip Type
(SD) Flash Type

(GMAC1) Use GE1 or GE2
(GE_SGMII_FORCE_2500) GE1 connected to

(MT7531) Switch connected to

  1. make //build successfully.

ā€¦

ā€¦

OBJCOPY examples/standalone/hello_world.srec OBJCOPY examples/standalone/hello_world.bin LDS u-boot.lds LD u-boot OBJCOPY u-boot.srec OBJCOPY u-boot.bin UIMAGE u-boot-mtk.bin

which repo do you build exactly? i expect that you are not using (untouched) this:

because at least the option for switch in menuconfig is missing (have added it in my repo).

it uses always rtl8367s for ethernet:

also i donā€™t need to add compiler-gcc6.h because it is already there

btw. do you know anything about mt7622 upstream-support?

BPI do have original/up-to-date uboot source code, but they missed some changes in above github. I guess they just extracted related patch/files from up-to-date uboot to current uboot codebase. Iā€™ll suggest they can put original code to github as reference, thanks.

ok,as i expected you use another repoā€¦is this public? This github-repo (v2014-04) was my only source. Or are you talking about upstream-code (actual uboot v2019-xx)?

btw. my uboot does not boot ;( compiled with gcc6 and 5.5, maybe same problem as with older r2-ubootā€¦which does also not boot with gcc5.5+

[EMI]rank0 size: 0x40000000                                                                                           
[MEM] complex R/W mem test pass                                                                                       
RAM_CONSOLE wdt status (0x0)=0x0                                                                                      
[mmc_init]: msdc1 start mmc_init_host() in PL...                                                                      
[msdc_init]: msdc1 Host controller intialization start                                                                
[SD1] Pins mode(1), none(0), down(1), up(2), keep(3)                                                                  
[SD1] Pins mode(2), none(0), down(1), up(2), keep(3)                                                                  
[info][msdc_config_clksrc] input clock is 200000kHz                                                                   
[SD1] Bus Width: 1                                                                                                    
[info][msdc_config_clksrc] input clock is 200000kHz                                                                   
[SD1] SET_CLK(260kHz): SCLK(259kHz) MODE(0) DDR(0) DIV(193) DS(0) RS(0)                                               
[msdc_init]: msdc1 Host controller intialization done                                                                 
[mmc_init]: msdc1 start mmc_init_card() in PL...                                                                      
[mmc_init_card]: start                                                                                                
[SD1] Bus Width: 4                                                                                                    
[SD1] Size: 30436 MB, Max.Speed: 25000 kHz, blklen(512), nblks(62333952), ro(0)                                       
[mmc_init_mem_card 3140][SD1] Initialized, SD10                                                                       
before host->cur_bus_clk(259067)                                                                                      
[info][msdc_config_clksrc] input clock is 200000kHz                                                                   
[SD1] SET_CLK(25000kHz): SCLK(25000kHz) MODE(0) DDR(0) DIV(2) DS(0) RS(0)                                             
host->cur_bus_clk(25000000)                                                                                           
[mmc_init_card]: finish successfully                                                                                  
[PLFM] Init Boot Device: OK(0)                                                                                        
[GPT_PL](BPI)Parsing Primary GPT now...                                                                               
[GPT_PL]check header, err(signature 0x00000054594C5242!=0x5452415020494645)                                           
[GPT_PL]Success to find valid GPT.                                                                                    
                                                                                                                      
[PART] blksz: 512B                                                                                                    
[PART] [0x0000000000020000-0x000000000007FFFF] "preloader" (768 blocks)                                               
[PART] [0x0000000000080000-0x00000000000BFFFF] "tee1" (512 blocks)                                                    
[PART] [0x00000000000C0000-0x000000000013FFFF] "lk" (1024 blocks)                                                     
                                                                                                                      
Device APC domain init setup:                                                                                         
                                                                                                                      
Domain Setup (0x0)                                                                                                    
Domain Setup (0x0)                                                                                                    
Device APC domain after setup:                                                                                        
Domain Setup (0x0)                                                                                                    
Domain Setup (0x0)                                                                                                    
[get_part] part->nr_sects=768, part->info->name=preloader                                                             
[get_part] part->nr_sects=512, part->info->name=tee1                                                                  
[get_part] part->nr_sects=1024, part->info->name=lk                                                                   
[PART] Image with part header                                                                                         
[PART] name : LK                                                                                                      
[PART] addr : FFFFFFFFh mode : -1                                                                                     
[PART] size : 299016                                                                                                  
[PART] magic: 58881688h                                                                                               
                                                                                                                      
[PART] load "lk" from 0x00000000000C0200 (dev) to 0x41E00000 (mem) [SUCCESS]                                          
[PART] load speed: 3475KB/s, 299016 bytes, 84ms                                                                       
load lk (ret=0)                                                                                                       
[get_part] part->nr_sects=768, part->info->name=preloader                                                             
[get_part] part->nr_sects=512, part->info->name=tee1                                                                  
[PART] Image with part header                                                                                         
[PART] name : atf                                                                                                     
[PART] addr : FFFFFFFFh mode : -1                                                                                     
[PART] size : 62032                                                                                                   
[PART] magic: 58881688h                                                                                               
                                                                                                                      
[PART] load "tee1" from 0x0000000000080200 (dev) to 0x43000DC0 (mem) [SUCCESS]                                        
[PART] load speed: 2752KB/s, 62032 bytes, 22ms                                                                        
load tee1 (ret=0)                                                                                                     
[BLDR] bldr load tee part ret=0x0, addr=0x43001000                                                                    
[get_part] part->nr_sects=768, part->info->name=preloader                                                             
[get_part] part->nr_sects=512, part->info->name=tee1                                                                  
[get_part] part->nr_sects=1024, part->info->name=lk                                                                   
[BLDR] boot part. not found                                                                                           
[BLDR] part_load_images ret=0x0                                                                                       
[BLDR] Others, jump to ATF                                                                                            
                                                                                                                      
[BLDR] jump to 0x41E00000                                                                                             
[BLDR] <0x41E00000>=0xEA00000F                                                                                        
[BLDR] <0x41E00004>=0xE59FF014                                                                                        
                                                                                                                      
                                                                                                                      
                                                                                                                      
                                                                                                                      
DRAM:  112 MiB

Is your inlining-patch for this issue? edit: tried it, but same result (gcc6.5 with inline-patch)

have now compiled with gcc 4.8 (ubuntu 14.4) and here it boots, only strange message:

DRAM:  112 MiB                                                                                                        
WARNING: Caches not enabled                                                                                           
dev_num = 1                                                                                                           
***size=4096, offset=1310720, blk_start=2560, blk_cnt=8                                                               
*** Error - default environment is too large                                                                          
                                                                                                                      
In:    serial                                                                                                         
Out:   serial                                                                                                         
Err:   serial                                                                                                         
dev_num = 1                                                                                                           
***size=4096, offset=1310720, blk_start=2560, blk_cnt=8                                                               
*** Error - default environment is too large                                                                          
                                                                                                                      
Net:   mtk_eth                                                                                                        
Uip activated                                                                                                         
Hit any key to stop autoboot:  0                                                                                      
Unknown command 'No' - try 'help'                                                                                     
BPI-R64>                                                                                                              
BPI-R64>                                                                                                              
BPI-R64> printenv                                                                                                     
                                                                                                                      
Environment size: 1/4092 bytes                                                                                        
BPI-R64>

ok, fixed by setting CONFIG_ENV_SIZE to 8K

network works with rtl8367-switch, load from my menu currently not (because service is set to linux-4.19 instead of linux), ls works on the partition 1:1 (=sd)

fixed versions uploaded here: https://drive.google.com/open?id=1Vg3eoHpx3nlZ9pTCZdDpC2l1pJ4rQh5i

Thread for emmc-boot:

btw. does anybody know memory-location of uboot? i want to add tftp-option for loading uboot, but did not find uboots memory-position (before relocation)

[PART] load "tee1" from 0x0000000000080200 (dev) to 0x43000DC0 (mem) [SUCCESS]  
[PART] load speed: 2752KB/s, 62032 bytes, 22ms                                  
load tee1 (ret=0)                                                               
[BLDR] bldr load tee part ret=0x0, addr=0x43001000                              
[get_part] part->nr_sects=768, part->info->name=preloader                       
[get_part] part->nr_sects=512, part->info->name=tee1                            
[get_part] part->nr_sects=1024, part->info->name=lk                             
[BLDR] boot part. not found                                                     
[BLDR] part_load_images ret=0x0                                                 
[BLDR] Others, jump to ATF                                                      
                                                                                
[BLDR] jump to 0x41E00000                                                       
[BLDR] <0x41E00000>=0xEA00000F                                                  
[BLDR] <0x41E00004>=0xE59FF014                                                  
                                                                                
                                                                                
U-Boot 2014.04-rc1-00018-g7a9081b-dirty (Sep 21 2019 - 20:15:23) 

maybe 0x41E00004 is ubootā€™s address, but on r2 this is printed more cleanly

just a small update on gcc-issue (does not boot if compiled with linaro gcc 5.5+)

if i enable debug in mt7622_evb.h i see this:

U-Boot code: FFFFFFFF -> FFFFFFFF  BSS: -> FFFFFFFF
monitor len: 00000000
ramsize: 3F000000
TLB table from 7eff0000 to 7eff4000
Top of RAM usable for U-Boot at: 7eff0000
Reserving 0k for U-Boot at: 7eff0000  <<<<<<<<<<<<<<< 0k is a little bit, right? :)
Reserving 32772k for malloc() at: 7cfef000
Reserving 32 Bytes for Board Info at: 7cfeefe0
Reserving 160 Bytes for Global Data at: 7cfeef40
New Stack Pointer is: 7cfeef30
RAM Configuration:
Bank #0: 40000000 1008 MiB
relocation Offset is: 7eff0001  <<<<<<<<<<<<<< not aligned, last 1 is strange

basicly it hangs after the dram-information, not showing uboot-version (like it does if compiled with gcc4.8)

Answer is the first line:

U-Boot code: FFFFFFFF -> FFFFFFFF BSS: -> FFFFFFFF

it have to be from define CONFIG_SYS_TEXT_BASE

and two vars filled by linker: bss_start, bss_end.

All three eq -1 (0xffffffff - unsigned).

that may explain where it get ā€œ1ā€ for relocation offset.

It looks like a linker-problem or wromg configuration.

This function is called but with empty version_string and wrong adressesā€¦

Anyone have an idea how to fix it?

i see, that bpi-version of uboot changes this relocation-codeā€¦

https://github.com/frank-w/u-boot/commit/97bf4e854831c04549b6cebaf19ca57fbec3db5f#diff-cbf29bee16995d1835259dd185e77dc5

why was this done? i guess this breaks newer linaro gcc toolchains

with the great help of @ray we have fixed the gcc5.5Ā±issue (compile but not boot) by removing object-copy filtering:

so uboot is now compilable with ubuntu 18.4 (gcc6.5) and boots up correctly

for gcc7+ we need to fix some compile-errors

common/main.c:31:6: error: 'show_boot_progress' aliased to external symbol '__show_boot_progress'
 void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
      ^~~~~~~~~~~~~~~~~~
make[1]: *** [common/main.o] Error 1
make: *** [common] Error 2
make: *** Waiting for unfinished jobs....
arch/arm/lib/board.c:73:6: error: 'coloured_LED_init' aliased to external symbol '__coloured_LED_init'
 void coloured_LED_init(void)
      ^~~~~~~~~~~~~~~~~
arch/arm/lib/board.c:90:6: error: 'blue_led_off' aliased to external symbol '__blue_led_off'
 void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
      ^~~~~~~~~~~~
arch/arm/lib/board.c:88:6: error: 'blue_led_on' aliased to external symbol '__blue_led_on'
 void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
      ^~~~~~~~~~~
arch/arm/lib/board.c:86:6: error: 'yellow_led_off' aliased to external symbol '__yellow_led_off'
 void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
      ^~~~~~~~~~~~~~
arch/arm/lib/board.c:84:6: error: 'yellow_led_on' aliased to external symbol '__yellow_led_on'
 void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
      ^~~~~~~~~~~~~
arch/arm/lib/board.c:82:6: error: 'green_led_off' aliased to external symbol '__green_led_off'
 void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
      ^~~~~~~~~~~~~
arch/arm/lib/board.c:80:6: error: 'green_led_on' aliased to external symbol '__green_led_on'
 void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
      ^~~~~~~~~~~~
arch/arm/lib/board.c:78:6: error: 'red_led_off' aliased to external symbol '__red_led_off'
 void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
      ^~~~~~~~~~~
arch/arm/lib/board.c:76:6: error: 'red_led_on' aliased to external symbol '__red_led_on'
 void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
      ^~~~~~~~~~

i tried to fix them like here by disabling the weak-option (not the best way,right? maybe weak is needed to overwrite these functionsā€¦)

but now i get these:

  LD      lib/built-in.o
lib/time.o: In function `__raw_writesb':
/media/data_fast/bpi/uboot/u-boot/arch/arm/include/asm/io.h:80: multiple definition of `__raw_writesb'
lib/display_options.o:/media/data_fast/bpi/uboot/u-boot/arch/arm/include/asm/io.h:80: first defined here
lib/time.o: In function `__raw_writesw':
/media/data_fast/bpi/uboot/u-boot/arch/arm/include/asm/io.h:88: multiple definition of `__raw_writesw'
...
1 Like

hmmm, ā€œextern inlineā€ looks weird.

Change then to ā€œstatic inlineā€. Hope it will not grow uboot twice :slight_smile:

any idea about the other errors? Without fixing them i get no uboot-binary with gcc 7 for size comparation

copy

show_boot_progress from board/ti/beagle/beagle.c

LED funcs from board/taskit/stamp9g20/led.c

and make them empty.

All that to mt7622_evb.c

1 Like

I mean errors of

__raw_writesb
...

static inline for that one

1 Like