Mainline Linux 2.6 kernel for Microblaze, Linux on Microblaze
Known BUGs
TODO
What is different?
Code is based on the latest code from PetaLogix
Kernel is compatible with latest Linux code
The all code is cleaned according to Linux coding style
There are no driver in pure Linux kernel (only some) but it is compatible with PetaLogix distribution and drivers and it is possible to join it together
Completely redesign initialization part of kernel
Completely redesign memory part of kernel
The code has the same performance as common Microblaze code with static constant - that's amazing
Patch submission
Before sending your patches please do:
Check for-linus, fixes-for-linus and next branch for latest rc changes
Check it with checkpatch.pl script which is in linux kernel and run sparse (make C=1) for checking too. I will reject all patches which break coding style.
Sending only in-line patches (git-send-email is recommended) do not attach them - it is better for reviewing.
Send the smallest patches as possible and fix only one issue separately.
Look at Documentation/SubmittingPatches for proper line.
How to boot Microblaze FDT kernel?
Vocabulary
EDK → Xilinx Embedded Development Kit - development environment where you can create/build your FPGA SoC
Microblaze → Xilinx soft core CPU
BSP
DTS file → text file which contains detailed information about SoC. Currently this file is automatically generated by Device tree BSP.
DTB file → compiled DTS file.
DTC → device tree compiler which create DTB file from DTS.
FDT → flat device tree
OF → open firmware
BRAM → block ram memory → you can stored program there with bitstream
BSP
For working with FDT kernel you need to have DTS file which describes your Microblaze SoC.
BSP updates
This chapter is only for user which wants to update BSP.
Prepared pack contains three BSP
Top BSP which helps you with generation all BSP with one setting. For more information look at this
site.
U-BOOT bsp which generate files for U-BOOT bootloader. For more information look at this
site.
Device tree BSP which generates DTS setting file
Cloning BSP from GIT server
Device tree compiler
For creating DTB which is passing to Linux kernel you need DTC
Hardware design
Hardware requirements
FDT kernel should be able to boot on any HW.
Please do not use Microblaze version 7.00a without tactical patch.
Please do not enable FULL PVR with MMU on Microblaze version 7.00.a/b.
Please check that your FLASH memory baseaddr is on higher address than your Main memory due to U-BOOT bootloader (U-BOOT BSP check it).
I recommend you enable FULL PVR setting - Linux kernel check that your kernel and DTS file is correct for your CPU
Please check your system.xmp (or *.xmp which you use) that ModuleSearchPath is set correctly
cd ~/microblaze-fdt/hardware/hw_design/ml505
grep "ModuleSearchPath" system.xmp
ModuleSearchPath: ../../edk_user_repository/
Please choose TOP BSP and set values there.
For example fragment from *.mss file for ml505
BEGIN OS
PARAMETER OS_NAME = top
PARAMETER OS_VER = 1.00.b
PARAMETER PROC_INSTANCE = microblaze_0
PARAMETER timer = xps_timer_1
PARAMETER ethernet = Hard_Ethernet_MAC
PARAMETER sysace = SysACE_CompactFlash
PARAMETER iic = IIC_EEPROM
PARAMETER gpio = LEDs_8Bit
PARAMETER lmb_memory = dlmb_cntlr
PARAMETER flash_memory = FLASH
PARAMETER main_memory = DDR2_SDRAM
PARAMETER stdin = RS232_Uart_1
PARAMETER stdout = RS232_Uart_1
END
For example fragment from *.mss file for s3e1600
BEGIN OS
PARAMETER OS_NAME = top
PARAMETER OS_VER = 1.00.b
PARAMETER PROC_INSTANCE = microblaze_0
PARAMETER timer = xps_timer_1
PARAMETER ethernet = Ethernet_MAC
PARAMETER gpio = LEDs_6Bit
PARAMETER lmb_memory = dlmb_cntlr
PARAMETER flash_memory = FLASH
PARAMETER main_memory = DDR_SDRAM
PARAMETER stdin = RS232_DTE
PARAMETER stdout = RS232_DTE
END
Bootloader options
Before you start to build hardware you should choose our booting strategy. I would like to give you some options what you can choose.
Create your own bootloader
Use common bootloader
Use small bootloader - FS-BOOT
Use advanced bootloader - U-BOOT
Description | Own | FS-Boot | U-BOOT |
Memory consumption | Depends on your features | 8k BRAM | >128k |
Functions | Depends on what you want to develop | Copy SREC to memory, Boot kernel from Flash - reading | Full Flash, System ACE, Network-emaclite,emac,ll_temac, gpio, booting all kernel and a lot of others |
Time of developing | Depends on your features but it is huge in compare to standard solution | - | Only adding features which are not there |
Source code maintaining | Customer must care about | PetaLogix | me |
Stability | uknown | ~99.9% stable | ~99% stable - Depends on setting |
You can use our own bootloader in all variants but be sure you have time and developer who will do it. Keep in your mind that if you want to use it after some years again someone take care about. Please counted how much money this option cost. You will not have any support of it.
System has no non-volatile memory (without FLASH, SPI flash, SystemACE)
System has FLASH memory - NOR
System has FLASH memory - NAND, Spansion FLASH
System has System.ACE
Create own bootloader which will read file from CF and loads it to memory and boots - it is possible load U-BOOT too
Use .ACE file with FS-BOOT and boots kernel or U-BOOT stored in flash
Use .ACE file with U-BOOT - recommended way
System has SPI flash
Hw build
U-BOOT bootloader
Linux Microblaze FDT kernel
Creating DTB file
FDT Kernel booting
Memory layout
Kernel can be place to almost every position. There are some limitation like. The last instruction of kernel cannot exceed limit which is placed approximately 16 kB from the end of memory. You have to calculate with the size of file system too.
U-BOOT
Booting from others bootloaders
Register R5: command line
Register R6: physical address to ramdisk. (Build in fs == 0)
Register R7: physical address to DTB file
Command line priorities
From the lowest to the highest priority
Passing command line through r5
CONFIG_CMDLINE in menuconfig
dts command line
CONFIG_CMDLINE with CONFIG_CMDLINE_FORCE in menuconfig
NFS rootfs
Command line options summaru
Rootfs on SystemACE | root=/dev/xsa2 |
NFS rootfs | root=/dev/nfs rw nfsroot=192.168.0.102:/tftpboot/rootnfs |
Console on uart16550 or old uartlite | console=ttyS0,115200 |
Console on uarlite | console=ttyUL0,115200 |
Turn off console | silent=off |
Single user mode | single |
tmpfs as root | devfs=mount rw rootfstype=tmpfs root=/dev/ram |
setup ipaddr by dhcp | ip=dhcp |
setup static ipaddr | ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf> |
| ip=192.168.10.2:192.168.10.1:192.168.10.1:255.255.255.0:test:eth0:on |
Serial console
Uartlite
#
# Serial drivers
#
# CONFIG_SERIAL_8250 is not set
#
# Non-8250 serial port support
#
CONFIG_SERIAL_UARTLITE=y
CONFIG_SERIAL_UARTLITE_CONSOLE=y
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
Uart16550
#
# Serial drivers
#
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_8250_NR_UARTS=4
CONFIG_SERIAL_8250_RUNTIME_UARTS=4
# CONFIG_SERIAL_8250_EXTENDED is not set
#
# Non-8250 serial port support
#
# CONFIG_SERIAL_UARTLITE is not set
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y
Showing linux kernel buffer
Via U-BOOT
-
Starting your board
=================================================
FS-BOOT First Stage Bootloader (c) 2006 PetaLogix
=================================================
FS-BOOT: System initialisation completed.
FS-BOOT: Booting from FLASH. Press 's' for image download.
FS-BOOT: Booting image...
U-Boot-mONStR> run d
TFTP from server 192.168.0.5; our IP address is 192.168.0.3
Filename 'system.dtb'.
Load address: 0x21900000
Loading: #
done
Bytes transferred = 6912 (1b00 hex)
TFTP from server 192.168.0.5; our IP address is 192.168.0.3
Filename 'image.ub'.
Load address: 0x20a00000
Loading: #################################################################
#############################################################
done
Bytes transferred = 1847360 (1c3040 hex)
TFTP from server 192.168.0.5; our IP address is 192.168.0.3
Filename 'romfs.ub'.
Load address: 0x21400000
Loading: #################################################################
###########################
done
Bytes transferred = 1341504 (147840 hex)
## Booting kernel from Legacy Image at 20a00000 ...
Image Name: kernel bez FS
Image Type: MicroBlaze Linux Kernel Image (uncompressed)
Data Size: 1847296 Bytes = 1.8 MB
Load Address: 20000000
Entry Point: 20000000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
## Loading init Ramdisk from Legacy Image at 21400000 ...
Image Name: fs v no network
Image Type: MicroBlaze Linux RAMDisk Image (uncompressed)
Data Size: 1341440 Bytes = 1.3 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Transferring control to Linux (at address 20000000) ...
aaaa
bbb
Booting using OF flat tree...root=romfs, 0x21400040, 0x21900000
Something is wrong. -> restart board
=================================================
FS-BOOT First Stage Bootloader (c) 2006 PetaLogix
=================================================
FS-BOOT: System initialisation completed.
FS-BOOT: Booting from FLASH. Press 's' for image download.
FS-BOOT: Booting image...
Show your log buffer
U-Boot-mONStR> md 201c4624
201c4624: 3c353e46 6f756e64 20464454 20617420 <5>Found FDT at
201c4634: 30783231 39303030 30300a3c 353e4c69 0x21900000.<5>Li
201c4644: 6e757820 76657273 696f6e20 322e362e nux version 2.6.
201c4654: 32342d6d 4f4e5374 522d6733 38333939 24-mONStR-g38399
201c4664: 62373720 286d6f6e 73747240 6d6f6e73 b77 (monstr@mons
201c4674: 74722e65 75292028 67636320 76657273 tr.eu) (gcc vers
201c4684: 696f6e20 332e342e 31202820 50657461 ion 3.4.1 ( Peta
201c4694: 4c696e75 7820302e 32302042 75696c64 Linux 0.20 Build
201c46a4: 202d7263 31203035 30363037 20292920 -rc1 050607 ))
201c46b4: 23322046 7269204d 61792031 36203134 #2 Fri May 16 14
201c46c4: 3a32333a 32382043 45535420 32303038 :23:28 CEST 2008
201c46d4: 0a3c363e 73657475 705f6370 75696e66 .<6>setup_cpuinf
201c46e4: 6f3a2069 6e697469 616c6973 696e670a o: initialising.
201c46f4: 3c363e73 65747570 5f6d656d 6f72793a <6>setup_memory:
201c4704: 206d6178 5f6d6170 6e723a20 30783232 max_mapnr: 0x22
201c4714: 3030300a 3c363e73 65747570 5f6d656d 000.<6>setup_mem
U-Boot-mONStR>
201c4724: 6f72793a 206d696e 5f6c6f77 5f70666e ory: min_low_pfn
201c4734: 3a203078 32303030 300a3c36 3e736574 : 0x20000.<6>set
201c4744: 75705f6d 656d6f72 793a206d 61785f6c up_memory: max_l
201c4754: 6f775f70 666e3a20 30783230 30300a3c ow_pfn: 0x2000.<
201c4764: 373e4f6e 206e6f64 65203020 746f7461 7>On node 0 tota
201c4774: 6c706167 65733a20 38313932 0a3c373e lpages: 8192.<7>
201c4784: 20204e6f 726d616c 207a6f6e 653a2036 Normal zone: 6
201c4794: 34207061 67657320 75736564 20666f72 4 pages used for
201c47a4: 206d656d 6d61700a 3c373e20 204e6f72 memmap.<7> Nor
201c47b4: 6d616c20 7a6f6e65 3a203020 70616765 mal zone: 0 page
201c47c4: 73207265 73657276 65640a3c 373e2020 s reserved.<7>
201c47d4: 4e6f726d 616c207a 6f6e653a 20383132 Normal zone: 812
201c47e4: 38207061 6765732c 204c4946 4f206261 8 pages, LIFO ba
201c47f4: 7463683a 300a3c37 3e20204d 6f766162 tch:0.<7> Movab
201c4804: 6c65207a 6f6e653a 20302070 61676573 le zone: 0 pages
201c4814: 20757365 6420666f 72206d65 6d6d6170 used for memmap
U-Boot-mONStR>
201c4824: 0a3c353e 53656c66 206d6f64 69666965 .<5>Self modifie
201c4834: 6420636f 64652065 6e61626c 650a3c34 d code enable.<4
201c4844: 3e427569 6c742031 207a6f6e 656c6973 >Built 1 zonelis
201c4854: 74732069 6e205a6f 6e65206f 72646572 ts in Zone order
201c4864: 2c206d6f 62696c69 74792067 726f7570 , mobility group
201c4874: 696e6720 6f6e2e20 20546f74 616c2070 ing on. Total p
201c4884: 61676573 3a203831 32380a3c 353e4b65 ages: 8128.<5>Ke
201c4894: 726e656c 20636f6d 6d616e64 206c696e rnel command lin
201c48a4: 653a2063 6f6e736f 6c653d74 7479554c e: console=ttyUL
201c48b4: 302c3131 35323030 206c6f67 6c657665 0,115200 logleve
201c48c4: 6c3d3135 0a3c363e 786c6e78 2c787073 l=15.<6>xlnx,xps
201c48d4: 2d696e74 632d312e 30302e61 20233020 -intc-1.00.a #0
201c48e4: 61742030 78343030 30303030 302c206e at 0x40000000, n
201c48f4: 756d5f69 72713d38 2c206564 67653d30 um_irq=8, edge=0
201c4904: 78300a3c 343e5049 44206861 73682074 x0.<4>PID hash t
201c4914: 61626c65 20656e74 72696573 3a203132 able entries: 12
U-Boot-mONStR>
201c4924: 3820286f 72646572 3a20372c 20353132 8 (order: 7, 512
201c4934: 20627974 6573290a 3c363e78 6c6e782c bytes).<6>xlnx,
201c4944: 7870732d 74696d65 722d312e 30302e61 xps-timer-1.00.a
201c4954: 20233020 61742030 78343034 30303030 #0 at 0x4040000
201c4964: 302c2069 72713d30 0a3c363e 44656e74 0, irq=0.<6>Dent
201c4974: 72792063 61636865 20686173 68207461 ry cache hash ta
201c4984: 626c6520 656e7472 6965733a 20343039 ble entries: 409
201c4994: 3620286f 72646572 3a20322c 20313633 6 (order: 2, 163
201c49a4: 38342062 79746573 290a3c36 3e496e6f 84 bytes).<6>Ino
201c49b4: 64652d63 61636865 20686173 68207461 de-cache hash ta
201c49c4: 626c6520 656e7472 6965733a 20323034 ble entries: 204
201c49d4: 3820286f 72646572 3a20312c 20383139 8 (order: 1, 819
201c49e4: 32206279 74657329 0a3c363e 4d656d6f 2 bytes).<6>Memo
201c49f4: 72793a20 32393130 346b2f33 32373732 ry: 29104k/32772
201c4a04: 6b206176 61696c61 626c650a 00000000 k available.....
201c4a14: 00000000 00000000 00000000 00000000 ................
U-Boot-mONStR>
Via XMD
There is second way how to read Linux kernel log buffer via XMD. This features is not available for free users.
Here is the log to show you how this options works. There are new built-in features in xmd called log.
The script find-out log buffer from latest Linux kernel code and you can just type log command to show whole log buffer.
HeartBeat function
Saving value in Microblaze ASM
Store byte
ori r10, r0, 0x12345678
addik r11, r0, r0_ram + 0x300
addik r12, r0, r0_ram + 0x304
sb r10,r0,r11
sbr r10,r0,r12
XMD% mrd 0xd02b602c 10
D02B602C: 00000078
D02B6030: 78000000
D02B6034: 00000000
Half word
ori r10, r0, 0x12345678
addik r11, r0, r0_ram + 0x300
addik r12, r0, r0_ram + 0x304
sh r10,r0,r11
shr r10,r0,r12
XMD% mrd 0xd02b602c 10
D02B602C: 00005678
D02B6030: 78560000
D02B6034: 00000000
Word
ori r10, r0, 0x12345678
addik r11, r0, r0_ram + 0x300
addik r12, r0, r0_ram + 0x304
sw r10,r0,r11
swr r10,r0,r12
XMD% mrd 0xd02b602c 10
D02B602C: 12345678
D02B6030: 78563412
D02B6034: 00000000
Error logs
Initramfs bug
If you write __log_buf, you see these messages on MMU kernel - your problem is that your initramfs is too big that kernel can't do early page alloc.
Found FDT at 0x9e800000
Kernel panic - not syncing: ERROR: Failed to allocate 0x1000 bytes below 0x91000000.
Here you can see that max_mapnr is zero and there is no any mem base + size printk message → means your DTB is wrong.
<5>Found FDT at 0x90780000
<5>Linux version 2.6.29-mONStR-00426-g432b099-dirty (monstr@monstr.eu) (gcc version 3.4.1 ( PetaLinux 0.20 Build -rc1 050607 )) #2 Tue Mar 24 20:49:09 CET 2009
<6>setup_cpuinfo: initialising
<6>setup_cpuinfo: Using full CPU PVR support
<6>setup_memory: kernel addr=0x90000000-0x904c6000 size=0x004c6000
<6>setup_memory: max_mapnr: 0x0
<6>setup_memory: min_low_pfn: 0x20000
<6>setup_memory: max_low_pfn: 0x22000
<4>BUG: failure at mm/bootmem.c:320/mark_bootmem()!
<0>Kernel panic - not syncing: BUG!
<0>Rebooting in 120 seconds..<5>Machine restart...
<6>
<6>Stack:
<6> 90299ec4 90215fc0 902b1318 00090000 00000001 90022c14 90208f6c 00000000
<4> 00000001 00000000 000000e2 000000b7 900127bc 00000001 000904c6 00090000
<4> 00000000 00000000 0001d4bf 902a4360 9020b4b8 00000078 902b3c44 ffffffff
<5>Call Trace: <5>
<4>[<90022c14>] emergency_restart+0xc/0x20
<4>[<900127bc>] panic+0x180/0x224
<4>[<902a4360>] mark_bootmem+0x128/0x17c
<4>[<902a44d0>] reserve_bootmem+0x34/0x48
<4>[<902a0e98>] setup_memory+0x310/0x364
<4>[<9029f9c8>] setup_arch+0x84/0x98
<4>[<90000000>] _start+0x0/0x20
<4>[<9029a5cc>] start_kernel+0xa8/0x41c
<4>[<9000005c>] no_fdt_arg+0x28/0x44
<4>[<90003ef4>] machine_halt+0x0/0x20
<5>
stat.h
It is caused with mishmash in stat.h. Solution is use new toolchain.
Freeing unused kernel memory: 19387k freed
Mounting proc:
/etc/rc: line 6: mount: Value too large for defined data type
Mounting var:
/etc/rc: line 9: mount: Value too large for defined data type
Populating /var:
/etc/rc: line 14: mkdir: Value too large for defined data type
Running local start scripts.
(none) login:
ROMFS on 2.6.29-rc2/rc3
There were bug in ROMFS implementation - for fix this issue please use latest ROMFS version or use this tar.gz.
Broken setgroups syscall
If setgroups syscall is broken, you can see for example this fault reaction when you are trying to login.
Xilinx-SP605-LTP-full-WB-pc-msr-next-22-watch login: root
Password:
login: can't set groups: Invalid argument
noMMU No init found
Enable BINFMT_FLAT.
NET: Registered protocol family 17
Freeing unused kernel memory: 2152k freed
Failed to execute /init
Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
Sparse Installation
Download and install git clone rsync://rsync.kernel.org/pub/scm/devel/sparse/sparse.git
make install PREFIX=/
-