[BPI-R64] uboot

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

ah ok, seems to work…now i get linking-errors where i have removed the weak-lines…

  LD      u-boot
arch/arm/lib/built-in.o: In function `clbss_l':
/media/data_fast/bpi/uboot/u-boot/arch/arm/lib/crt0.S:110: undefined reference to `coloured_LED_init'
/media/data_fast/bpi/uboot/u-boot/arch/arm/lib/crt0.S:111: undefined reference to `red_led_on'
arch/arm/lib/built-in.o: In function `bootstage_mark_name':
/media/data_fast/bpi/uboot/u-boot/include/bootstage.h:356: undefined reference to `show_boot_progress'
/media/data_fast/bpi/uboot/u-boot/include/bootstage.h:356: undefined reference to `show_boot_progress'
/media/data_fast/bpi/uboot/u-boot/include/bootstage.h:356: undefined reference to `show_boot_progress'
common/built-in.o: In function `bootstage_mark_name':
/media/data_fast/bpi/uboot/u-boot/include/bootstage.h:356: undefined reference to `show_boot_progress'
common/built-in.o: In function `bootstage_mark':
/media/data_fast/bpi/uboot/u-boot/include/bootstage.h:344: undefined reference to `show_boot_progress'
common/built-in.o:/media/data_fast/bpi/uboot/u-boot/include/bootstage.h:344: more undefined references to `show_boot_progress' follow

ah, ok, copy empty functions to mt7622_evb.c…now compile works with gcc7

BPI-R64> version

U-Boot 2014.04-rc1-00027-g2c83f9c241-dirty (Sep 26 2019 - 10:33:50)
arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
GNU ld (GNU Binutils for Ubuntu) 2.30
BPI-R64>

for gcc8 i need a compiler-gcc8.h, i have not yet found any with google…only other versions…but i have found one in my kernel-repo :slight_smile: compiles fine and seems to work

BPI-R64> version

U-Boot 2014.04-rc1-00028-ge7e4914e34-dirty (Sep 26 2019 - 10:43:27)
arm-linux-gnueabihf-gcc (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0
GNU ld (GNU Binutils for Ubuntu) 2.30
BPI-R64>
1 Like

Now retest it with all three :slight_smile:

Compile allready done…will test them if i have a bit time

1 Like

you can modify include/linux/compiler-gcc.h to fix this issue…

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 9896e54..b5fa76d 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -44,9 +44,13 @@
  */
 #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
-# define inline                inline          __attribute__((always_inline))
+/*# define inline              inline          __attribute__((always_inline))
 # define __inline__    __inline__      __attribute__((always_inline))
-# define __inline      __inline        __attribute__((always_inline))
+# define __inline      __inline        __attribute__((always_inline))*/
+/* XXX: check __GNUC_STDC_INLINE__, fix line length */
+# 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

Thank you

Which issue will be fixed by your change?

gcc8-issue is already solved by header-file from linux-kernel

Currently i try to fix the warnings

most of them fixed…only 2 less

drivers/mmc/mediatek/mt7622/msdc.c:1603:27: warning: comparison of constant '2' with boolean expression is always true [-Wbool-compare]
         if ( host->app_cmd!=2 ) { //Light 20121225, to prevent recursive call path: msdc_tune_cmdrsp->msdc_app_cmd->msdc_cmd->msdc_tune_cmdrsp
                           ^~
drivers/mmc/mediatek/mt7622/msdc.c: In function 'msdc_dma_transfer':
drivers/mmc/mediatek/mt7622/msdc.c:2087:23: warning: comparison of constant '2' with boolean expression is always true [-Wbool-compare]
     if (host->app_cmd != 2)
                       ^~

i wonder why author of this code compares a boolean with numeric value…

so i would suggest change both to

if ( ! host->app_cmd)

will this be right?

i have compiled all 4 versions (sd/emmc,rtl8367/mt7531) with gcc8 for testing:

https://drive.google.com/drive/folders/1Vg3eoHpx3nlZ9pTCZdDpC2l1pJ4rQh5i

please report if there an issues