goldstar611 / MyBookLive-buildroot

Build a kernel and root file system for the WD MyBook Live.
https://lwn.net/Articles/861235/
GNU General Public License v3.0
3 stars 0 forks source link

chainboot newer uboots? #2

Open goldstar611 opened 7 months ago

goldstar611 commented 7 months ago

http://bsdimp.blogspot.com/2016/09/chain-booting-u-boot-with-u-boot.html https://archlinuxarm.org/forum/viewtopic.php?f=53&t=4821

Note: U-BOOT doesn't compile with ELDK 5.0 + -Os, -O3, or -O2 OR -O0. Use -O1.

goldstar611 commented 7 months ago

close but not working with stock uboot bin:

setenv serverip 192.168.1.111 && setenv ipaddr 192.168.1.222 && tftp ${kernel_addr_r} u-boot.bin

go 0x01002100

note: requires update to TEXT_BASE to be 0x1000000

goldstar611 commented 7 months ago

a little printf debugging and and some interrupt disabling annnnnddd

=> setenv serverip 192.168.1.111 && setenv ipaddr 192.168.1.222 && tftp ${kernel_addr_r} u-boot.bin
Waiting for PHY auto negotiation to complete.... done                           
ENET Speed is 1000 Mbps - FULL duplex connection (EMAC0)                        
Using ppc_4xx_eth0 device                                                       
TFTP from server 192.168.1.159; our IP address is 192.168.1.199                 
Filename 'u-boot.bin'.                                                          
Load address: 0x1000000                                                         
Loading: ##########################                                             
done                                                                            
Bytes transferred = 378000 (5c490 hex)                                          
=> go 0x01002100                                                                
## Starting application at 0x01002100 ...                                       

U-Boot 2009.08 (Mar 03 2024 - 08:52:31), CUSTOM Build: 0.0.13                   

CPU:   AMCC PowerPC APM82181 Rev. D at 800 MHz (PLB=200, OPB=100, EBC=100 MHz)  
       Security support                                                         
       Bootstrap Option E - Boot ROM Location NOR/SRAM (8 bits)                 
       32 kB I-Cache 32 kB D-Cache                                              
Tony was here                                                                   
Board: Apollo-3G - APM82181 Board, 2*SATA, 1*USB                                
I2C:   ready                                                                    
DRAM:  256 MB                                                                   
Top of RAM usable for U-Boot at: 10000000                                       
Reserving 689k for U-Boot at: 0ff53000                                          
Reserving 1024k for malloc() at: 0fe53000                                       
Reserving 128 Bytes for Board Info at: 0fe52f80                                 
Reserving 64 Bytes for Global Data at: 0fe52f40                                 
Stack Pointer at: 0fe52f28                                                      
New Stack Pointer is: 0fe52f28                                                  
Now running in RAM - U-Boot at: 0ff53000                                        
FLASH: 512 kB                                                                   
env_relocate ()env_relocate[228] offset = 0xef53000                             
env_relocate[236] embedded ENV at 0ff52000                                      
*** Warning - bad CRC, using default environment                                

doneU-Boot relocated to 0ff53000                                                
not enabling interruptsdtt_init()DTT:   1 FAILED INIT                           
Net:   PHY EC1 Register: 0x2c8c                                                 
ppc_4xx_eth0                                                                    

Type run flash_nfs to mount root filesystem over NFS                            

p=============================================================================q 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::WWWWWWWWW::::WWWWWWW::::::::WWWWWWW::DDDDDDDDDDDDDDDDD::::::::::::| 
|:::::::::::WWWWWWWW::::WWWWWWWW:::::::WWWWWWW::DDDDDDDDDDDDDDDDDDDD::::::::::| 
|:::::::::::WWWWWWWW:::WWWWWWWWW::::::WWWWWWW::DDDDDDDDDDDDDDDDDDDDDD:::::::::| 
|::::::::::::::::::::::::::::::::::::::::::::::::::::::::::DDDDDDDDDDD::::::::| 
|:::::::::::WWWWWWW:::WWWWWWWWWW::::WWWWWWW::DDDDDDDDD:::::::DDDDDDDDD::::::::| 
|:::::::::::WWWWWWW::WWWWWWWWWWW:::WWWWWWW::DDDDDDDDD::::::::DDDDDDDDD::::::::| 
|:::::::::::WWWWWW::WWWWWW::WWWWW:WWWWWWW::DDDDDDDDDD:::::::DDDDDDDDDD::::::::| 
|:::::::::::WWWWWWWWWWWWW:::WWWWWWWWWWWW::DDDDDDDDDD::::::DDDDDDDDDDD:::::::::| 
|:::::::::::WWWWWWWWWWWW::::WWWWWWWWWWW::DDDDDDDDDDD:::DDDDDDDDDDDDD::::::::::| 
|:::::::::::WWWWWWWWWWW:::::WWWWWWWWWW::DDDDDDDDDDDDDDDDDDDDDDDDDD::::::::::::| 
|:::::::::::WWWWWWWWWW::::::WWWWWWWWW::DDDDDDDDDDDDDDDDDDDDDDDDD::::::::::::::| 
|:::::::::::WWWWWWWWW:::::::WWWWWWWW::DDDDDDDDDDDDDDDDDDDDDDDD::::::::::::::::| 
|:::::::::::WWWWWWWW::::::::WWWWWWW::DDDDDDDDDDDDDDDDDDDD:::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::| 
b=============================================================================d 
Hit any key to stop autoboot:  0                                                
=>                                                                              
=> version                                                                      

U-Boot 2009.08 (Mar 03 2024 - 08:52:31)           
goldstar611 commented 7 months ago

chainboot.patch

diff --git a/Makefile b/Makefile
index 6c1e59e..71f715a 100644
--- a/Makefile
+++ b/Makefile
@@ -140,7 +140,7 @@ endif
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 SUBDIRS    = tools \
-     examples/standalone \
+      \
      examples/api

 .PHONY : $(SUBDIRS)
diff --git a/board/amcc/apollo3g/config.mk b/board/amcc/apollo3g/config.mk
index 551a817..96a3dc3 100644
--- a/board/amcc/apollo3g/config.mk
+++ b/board/amcc/apollo3g/config.mk
@@ -27,7 +27,7 @@
 sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp

 ifndef TEXT_BASE
-TEXT_BASE = 0xFFFA0000
+TEXT_BASE = 0x01000000
 endif

 PLATFORM_CPPFLAGS += -DCONFIG_440=1
diff --git a/build.sh b/build.sh
index 07ec8c2..2d0c951 100755
--- a/build.sh
+++ b/build.sh
@@ -4,9 +4,23 @@

 UBOOT_BUILD_DIR="BUILT_UBOOT"
 SAVED_PATH=$PATH
-export PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin
+
+export PATH=/opt/eldk-5.0/powerpc/sysroots/i686-oesdk-linux/usr/bin:/opt/eldk-5.0/powerpc/sysroots/i686-oesdk-linux/usr/bin/powerpc-linux:$PATH
+export PKG_CONFIG_SYSROOT_DIR=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux
+export PKG_CONFIG_PATH=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux/usr/lib/pkgconfig
+export CONFIG_SITE=/opt/eldk-5.0/powerpc/site-config-powerpc-linux
+export CC=powerpc-linux-gcc
+export CXX=powerpc-linux-g++
+export GDB=powerpc-linux-gdb
+export TARGET_PREFIX=powerpc-linux-
+export CONFIGURE_FLAGS="--target=powerpc-linux --host=powerpc-linux --build=i686-linux --with-libtool-sysroot=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux"
+export CFLAGS="-mhard-float --sysroot=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux"
+export CXXFLAGS="-mhard-float --sysroot=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux"
+export LDFLAGS="--sysroot=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux"
+export CPPFLAGS="--sysroot=/opt/eldk-5.0/powerpc/sysroots/powerpc-linux"
+
 export ARCH=powerpc
-export CROSS_COMPILE=ppc_4xxFP-
+export CROSS_COMPILE=powerpc-

 rm -rf $UBOOT_BUILD_DIR
 mkdir $UBOOT_BUILD_DIR
diff --git a/common/env_common.c b/common/env_common.c
index be64d13..ea66a08 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -37,7 +37,7 @@ DECLARE_GLOBAL_DATA_PTR;
    extern void disable_nvram(void);
 #endif

-#undef DEBUG_ENV
+
 #ifdef DEBUG_ENV
 #define DEBUGF(fmt,args...) printf(fmt ,##args)
 #else
@@ -231,20 +231,13 @@ void env_relocate (void)
    enable_nvram();
 #endif

-#ifdef ENV_IS_EMBEDDED
    /*
     * The environment buffer is embedded with the text segment,
     * just relocate the environment pointer
     */
    env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
    DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
-#else
-   /*
-    * We must allocate a buffer for the environment
-    */
-   env_ptr = (env_t *)malloc (CONFIG_ENV_SIZE);
-   DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
-#endif
+

    if (gd->env_valid == 0) {
 #if defined(CONFIG_GTH)    || defined(CONFIG_ENV_IS_NOWHERE)   /* Environment not changable */
diff --git a/common/main.c b/common/main.c
index 9af567b..17322c0 100644
--- a/common/main.c
+++ b/common/main.c
@@ -56,7 +56,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * Board-specific Platform code can reimplement show_boot_progress () if needed
  */
 void inline __show_boot_progress (int val) {}
-void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
+void inline show_boot_progress (int val) {}

 #if defined(CONFIG_BOOT_RETRY_TIME) && defined(CONFIG_RESET_TO_RETRY)
 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);      /* for do_reset() prototype */
diff --git a/config.mk b/config.mk
index 8852157..145aa6a 100644
--- a/config.mk
+++ b/config.mk
@@ -109,7 +109,7 @@ ARFLAGS = crv
 endif
 RELFLAGS= $(PLATFORM_RELFLAGS)
 DBGFLAGS= -g # -DDEBUG
-OPTFLAGS= -Os #-fomit-frame-pointer
+OPTFLAGS= -O1 #-fomit-frame-pointer
 ifndef LDSCRIPT
 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
 ifeq ($(CONFIG_NAND_U_BOOT),y)
diff --git a/cpu/ppc4xx/44x_spd_ddr2.c b/cpu/ppc4xx/44x_spd_ddr2.c
index f57b234..cf1a4e9 100644
--- a/cpu/ppc4xx/44x_spd_ddr2.c
+++ b/cpu/ppc4xx/44x_spd_ddr2.c
@@ -3408,6 +3408,8 @@ static void test(void)
  *---------------------------------------------------------------------------*/
 phys_size_t initdram(int board_type)
 {
+   return (CONFIG_SYS_MBYTES_SDRAM << 20);
+#if 0
    /*
     * Only run this SDRAM init code once. For NAND booting
     * targets like Kilauea, we call initdram() early from the
@@ -3581,6 +3583,7 @@ phys_size_t initdram(int board_type)
 #endif

    return (CONFIG_SYS_MBYTES_SDRAM << 20);
+#endif
 }
 #endif /* CONFIG_SPD_EEPROM */

diff --git a/cpu/ppc4xx/config.mk b/cpu/ppc4xx/config.mk
index baa97a4..8295dc4 100644
--- a/cpu/ppc4xx/config.mk
+++ b/cpu/ppc4xx/config.mk
@@ -22,7 +22,7 @@
 #

 PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi -fno-strict-aliasing
-PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -mstring -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -msoft-float

 cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
 is440:=$(shell grep CONFIG_440 $(TOPDIR)/include/$(cfg))
diff --git a/include/configs/apollo3g.h b/include/configs/apollo3g.h
index ecf33f0..d4eb62f 100755
--- a/include/configs/apollo3g.h
+++ b/include/configs/apollo3g.h
@@ -41,6 +41,8 @@
 #define CONFIG_464FP       1   /* New 464 core with FP */
 #define CONFIG_4xx     1   /* ... PPC4xx family */

+#define DEBUG_ENV 1
+
 #ifndef xstr
 #define xstr(s)    str(s)
 #define str(s) #s
@@ -367,7 +369,7 @@
 #endif

-
+#if 0
 #if !defined(CONFIG_NAND_U_BOOT)
 /*
  * Apollo3g does not use DIMMs. Static DDR2 config with calibration.
@@ -389,7 +391,7 @@
 #define CONFIG_SYS_SDRAM0_RQDC     0x80000038
 #define CONFIG_SYS_SDRAM0_RFDC     0x003f0220
 #endif /* !defined(CONFIG_NAND_U_BOOT) */
-
+#endif

 /*-----------------------------------------------------------------------
  * I2C
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index da58b42..d03af17 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  * MA 02111-1307 USA
  */
-/*#define DEBUG*/
+#define DEBUG

 #include <common.h>
 #include <watchdog.h>
@@ -424,6 +424,7 @@ void board_init_f (ulong bootflag)

    for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
        if ((*init_fnc_ptr) () != 0) {
+           puts ("init_fnc_ptr failed; hanging\n");
            hang ();
        }
    }
@@ -884,7 +885,9 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #endif

    /* relocate environment function pointers etc. */
+   puts("env_relocate ()\n");
    env_relocate ();
+   puts("env_relocate done\n");

    /*
     * Fill in missing fields of bd_info.
@@ -1011,7 +1014,8 @@ void board_init_r (gd_t *id, ulong dest_addr)
    /*
     * Enable Interrupts
     */
-   interrupt_init ();
+    puts("not enabling interrupts\n");
+   //interrupt_init ();

    /* Must happen after interrupts are initialized since
     * an irq handler gets installed