|
|
 |
FPGA design from scratch. Part 46
Installing and running the Linux OS
Now when we have updated our hardware to meet all software requirements it is time to install and bootup the Linux kernel we finished in part 43. Let's go through the following steps:
- Connect everything (see part 29)
- Generate a new netlist (Hardware->Generate Netlist)
- Generate a new bitstream (Hardware->Generate Bitstream)
- Download the bitstream (Device Configuration->Download Bitstream)
Disassembly of the Linux kernel
We use the following command to generate an assembly listing of the Linux kernel code: mb-obdump -d /tftpboot/image.elf > kernel.asm
Here is the start.
44000000 <_start>: 44000000: 94208001 mfs r1, rmsr 44000004: a421fffd andi r1, r1, -3 44000008: 9401c001 mts rmsr, r1 4400000c: b000441f imm 17439 44000010: 31a0c000 addik r13, r0, -16384 // 441fc000 <__init_begin> 44000014: b000441e imm 17438 44000018: 30408000 addik r2, r0, -32768 // 441e8000 <_sdata> 4400001c: b000441f imm 17439 44000020: 3020bffc addik r1, r0, -16388 44000024: b000441e imm 17438 44000028: 33e082a8 addik r31, r0, -32088 // 441e82a8 <init_task> 4400002c: b0004400 imm 17408 44000030: 30c00c84 addik r6, r0, 3204 // 44000c84 <machine_early_init> 44000034: 99fc3000 brald r15, r6 44000038: 80000000 or r0, r0, r0 4400003c: b0004400 imm 17408 44000040: 31e00f68 addik r15, r0, 3944 // 44000f68 <machine_halt>
and here is the end.
4421162c <cleanup_sunrpc>: 4421162c: 3021ffe4 addik r1, r1, -28 44211630: f9e10000 swi r15, r1, 0 44211634: b000fff8 imm -8 44211638: b9f4e828 brlid r15, -6104 // 4419fe60 <cleanup_socket_xprt> 4421163c: 80000000 or r0, r0, r0 44211640: b000fff9 imm -7 44211644: b9f4ecc4 brlid r15, -4924 // 441b0308 <unregister_rpc_pipefs> 44211648: 80000000 or r0, r0, r0 4421164c: b000fff9 imm -7 44211650: b9f4053c brlid r15, 1340 // 441a1b8c <rpc_destroy_mempool> 44211654: 80000000 or r0, r0, r0 44211658: b000441f imm 17439 4421165c: 30a078d4 addik r5, r0, 30932 // 441f78d4 <ip_map_cache> 44211660: b000fff9 imm -7 44211664: b9f4bc30 brlid r15, -17360 // 441ad294 <cache_unregister> 44211668: 80000000 or r0, r0, r0 4421166c: b000441d imm 17437 44211670: 30a006a8 addik r5, r0, 1704 44211674: bc230028 bnei r3, 40 // 4421169c 44211678: b000fff9 imm -7 4421167c: b9f4f8a0 brlid r15, -1888 // 441b0f1c <rpc_unregister_sysctl> 44211680: 80000000 or r0, r0, r0 44211684: b000fff9 imm -7 44211688: b9f4f7b8 brlid r15, -2120 // 441b0e40 <rpc_proc_exit> 4421168c: 80000000 or r0, r0, r0 44211690: e9e10000 lwi r15, r1, 0 44211694: b60f0008 rtsd r15, 8 44211698: 3021001c addik r1, r1, 28 4421169c: b000ffdf imm -33 442116a0: b9f49504 brlid r15, -27388 // 4400aba4 <printk> 442116a4: 80000000 or r0, r0, r0 442116a8: b800ffd0 bri -48 // 44211678 Disassembly of section .init.ivt:
44211e50 <__ivt_start>: 44211e50: b0004400 b80821b0 b0004400 b80821c0 ..D...!...D...!. 44211e60: b0004400 b8081fa0 b0004400 b8082450 ..D.......D...$P 44211e70: b0004400 b80839f0 00000000 00000000 ..D...9......... ... 44211eb0: b0004400 b8082320 ..D...#
Download the Linux kernel
We will use the Xilinx Microprosser Debugger (XMD) to help us download the image file.
-> xmd
Xilinx Microprocessor Debug (XMD) Engine Xilinx EDK 9.1.02 Build EDK_J_SP2.4 Copyright (c) 1995-2006 Xilinx, Inc. All rights reserved.
XMD% connect mb mdm..... ...... JTAG chain configuration -------------------------------------------------- Device ID Code IR Length Part Name 1 0a001093 8 System_ACE 2 05059093 16 XCF32P 3 01e58093 10 XC4VFX12 4 09608093 8 xc95144xl
MicroBlaze Processor Configuration : ------------------------------------- Version............................6.00.b No of PC Breakpoints...............2 No of Read Addr/Data Watchpoints...0 No of Write Addr/Data Watchpoints..0 Instruction Cache Support..........off Data Cache Support.................off Exceptions Support................off FPU Support.......................off Hard Divider Support...............off Hard Multiplier Support............on - (Mul32) Barrel Shifter Support.............off MSR clr/set Instruction Support....on Compare Instruction Support........on
Connected to MDM UART Target Connected to "mb" target. id = 0 Starting GDB server for "mb" target (id = 0) at TCP port no 1234
XMD% dow -data /tftpboot/image.bin 0x44000000
This command will download the Linux kernel image to the SDRAM starting at address 0x44000000
Let's read the first and last memory locations to find out if the download was successful.
XMD% mrd 0x44000000 mrd 0x44000000 44000000: 94208001
XMD% mrd 0x44211EB0mrd 0x44211eb0 44211EB0: B0004400
To start the Linux bootup sequence we use the following command: XMD% con 0x44000000con 0x44000000 Info:Processor started. Type "stop" to stop processor
RUNNING> XMD% stop stop XMD% Info:User Interrupt, Processor Stopped at 0x440044c8
We are having a problem here. It seems like the bootup sequence hangs and never finishes. This is what the code looks like around address 0x440044c8: 440044c4 <early_printk_putc>: 440044c4: 90a50060 sext8 r5, r5 440044c8: b000a000 imm -24576 440044cc: e8600008 lwi r3, r0, 8 440044d0: a4630008 andi r3, r3, 8 440044d4: be23fff4 bneid r3, -12 // 440044c8 440044d8: a46500ff andi r3, r5, 255 440044dc: b000a000 imm -24576 440044e0: f8600004 swi r3, r0, 4 440044e4: b60f0008 rtsd r15, 8 440044e8: 80000000 or r0, r0, r0
Let's set a breakpoint at address 0x440044c4 and start from the beginning.
XMD% bps 0x440044c4 bps 0x440044c4 Setting breakpoint at 0x440044c4
XMD% con 0x44000000 con 0x44000000 Info:Processor started. Type "stop" to stop processor
RUNNING> XMD% Info:Software Breakpoint 0 Hit, Processor Stopped at 0x440044c4
Let's single step and see what happens.
XMD% stp stp 440044C8: B000A000 imm -24576
XMD% stp stp 440044D0: A4630008 andi r3 , r3 , 8
XMD% stp stp 440044D4: BE23FFF4 bneid r3 , -12
XMD% stp stp 440044C8: B000A000 imm -24576
XMD% stp stp 440044D0: A4630008 andi r3 , r3 , 8
XMD% stp stp 440044D4: BE23FFF4 bneid r3 , -12
We are caught in this loop. Here are the register values:
XMD% rr rr r0: 00000000 r8: 00000000 r16: 440044c4 r24: 00000000 r1: 441fbd94 r9: 00000000 r17: 00000000 r25: 00000000 r2: 441e8000 r10: 00000008 r18: ffffffda r26: 00000000 r3: 00000046 r11: ffffffff r19: 441fbdd4 r27: 00000000 r4: 441e8ee0 r12: 0000002d r20: 00000000 r28: 00000000 r5: 00000046 r13: 441fc000 r21: 00000000 r29: 00000000 r6: 441fbdd4 r14: 00000000 r22: 00000024 r30: 00000000 r7: 00000026 r15: 44004514 r23: 00000046 r31: 441e82a8 pc: 440044c8 msr: 00000000 XMD%
I am building a new kernel. See part 43.
Top Next Previous
Posted at 03:37 pm by svenand
|