From: Ira Snyder Date: Wed, 16 Jul 2008 15:28:21 -0700 Subject: [U-Boot-Users] Freescale MPC8349EMDS hang on boot Message-ID: <20080716222821.GB29634@ovro.caltech.edu> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello u-boot-users, I am currently in the process of developing a new driver in U-Boot. It is a software "virtual ethernet over PCI" driver. The driver itself is largely irrelevant for this problem. During the development, I noticed that adding and removing certain pieces of debugging code (which did not change any program state) caused the board to hang on boot, like so: ================================================================================ U-Boot 1.3.4-rc1-00001-gb89881c-dirty (Jul 16 2008 - 14:54:56) MPC83XX Reset Status: External/Internal Soft, External/Internal Hard CPU: e300c1, MPC8349EA, Rev: 3.0 at 528 MHz, CSB: 264 MHz Board: Freescale MPC8349EMDS I2C: As opposed to a normal boot: ================================================================================ U-Boot 1.3.4-rc1-00001-g8ff17d3-dirty (Jul 16 2008 - 12:00:01) MPC83XX Reset Status: External/Internal Soft, External/Internal Hard CPU: e300c1, MPC8349EA, Rev: 3.0 at 528 MHz, CSB: 264 MHz Board: Freescale MPC8349EMDS I2C: ready SPI: ready DRAM: 256 MB (DDR2, 64-bit, ECC on, 264 MHz) FLASH: 32 MB In: serial Out: serial Err: serial Net: TSEC0, TSEC1 Type "run flash_nfs" to mount root filesystem over NFS I have tried to narrow the problem down as much as possible, by removing as much of my code as possible. I succeeded in reproducing the problem using code that seemingly "does nothing wrong". The inlined patch is against U-Boot v1.3.4-rc1 During my testing, it seemed that elf section alignment in the image mattered. I took a broken, non-booting image and saved the section offsets. They are reproduced below, generated with: $ powerpc-linux-strip u-boot $ powerpc-linux-readelf -e u-boot Here is the output of the readelf command for my bad image: ================================================================================ ELF Header: Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: PowerPC Version: 0x1 Entry point address: 0xfe000100 Start of program headers: 52 (bytes into file) Start of section headers: 225328 (bytes into file) Flags: 0x8000, relocatable-lib Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 2 Size of section headers: 40 (bytes) Number of section headers: 12 Section header string table index: 11 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS fe000000 000078 032c50 00 AX 0 0 4 [ 2] .reloc PROGBITS fe033000 033078 0014c0 00 WA 0 0 1 [ 3] .data PROGBITS fe0344c0 034538 000bdc 00 WA 0 0 4 [ 4] .data.rel.ro.loca PROGBITS fe03509c 035114 000078 00 WA 0 0 4 [ 5] .data.rel PROGBITS fe035114 03518c 000710 00 WA 0 0 4 [ 6] data PROGBITS fe035824 03589c 000004 00 WA 0 0 4 [ 7] .data.rel.local PROGBITS fe035828 0358a0 000be4 00 WA 0 0 4 [ 8] .u_boot_cmd PROGBITS fe03640c 036484 000570 00 WA 0 0 4 [ 9] .bss NOBITS fe037000 000000 0068e0 00 WA 0 0 8 [10] .comment PROGBITS 00000000 0369f4 0005d6 00 0 0 1 [11] .shstrtab STRTAB 00000000 036fca 000065 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000078 0xfe000000 0xfe000000 0x3697c 0x3697c RWE 0x8 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4 Section to Segment mapping: Segment Sections... 00 .text .reloc .data .data.rel.ro.local .data.rel data .data.rel.local .u_boot_cmd 01 The part I found important was the size of each section. The .bss, .comment, and .shstrtab don't seem to matter (but I may be wrong!) I wrote some code that went into the appropriate sections to get the sizes I needed. This is why there are lots of "a" in the patch (to boost the .data section) and the extern variables (to boost the .reloc section) and the extern variables with values (to boost the data section). I also did my best to trim down the code that was added in board/freescale/mpc8349emds/mpc8394emds.c checkboard(). In my original code, all of the code is there. I left it there in the patch, but #if 0'd out all of the parts that made no difference. Removing the BCSR read does seem to fix the problem (while concurrently adjusting the padding bits until the sections are the correct size). I see nothing wrong with the BCSR read, and it may just be another unrelated symptom. Here is the readelf output on my non-working U-Boot binary (produced from v1.3.4-rc1 + the attached patch), produced using the exact same procedure as above: ================================================================================ ELF Header: Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: PowerPC Version: 0x1 Entry point address: 0xfe000100 Start of program headers: 52 (bytes into file) Start of section headers: 225232 (bytes into file) Flags: 0x8000, relocatable-lib Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 2 Size of section headers: 40 (bytes) Number of section headers: 12 Section header string table index: 11 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS fe000000 000078 032c50 00 AX 0 0 4 [ 2] .reloc PROGBITS fe033000 033078 0014c0 00 WA 0 0 1 [ 3] .data PROGBITS fe0344c0 034538 000bdc 00 WA 0 0 4 [ 4] .data.rel.ro.loca PROGBITS fe03509c 035114 000078 00 WA 0 0 4 [ 5] .data.rel PROGBITS fe035114 03518c 000710 00 WA 0 0 4 [ 6] data PROGBITS fe035824 03589c 000004 00 WA 0 0 4 [ 7] .data.rel.local PROGBITS fe035828 0358a0 000be4 00 WA 0 0 4 [ 8] .u_boot_cmd PROGBITS fe03640c 036484 000558 00 WA 0 0 4 [ 9] .bss NOBITS fe037000 000000 0068f0 00 WA 0 0 8 [10] .comment PROGBITS 00000000 0369dc 00058e 00 0 0 1 [11] .shstrtab STRTAB 00000000 036f6a 000065 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000078 0xfe000000 0xfe000000 0x36964 0x36964 RWE 0x8 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4 Section to Segment mapping: Segment Sections... 00 .text .reloc .data .data.rel.ro.local .data.rel data .data.rel.local .u_boot_cmd 01 I built U-Boot using ELDK-4.2, using the following: $ make mrproper $ make MPC8349EMDS_config My board is a Freescale MPC8349EMDS evaluation board. If you need any more information, I am happy to provide it. I appreciate any help in tracking down this problem, Ira Snyder Here is the patch (I apologize for the 100 character "a" lines, but they made counting the correct number much easier) ================================================================================