Extreme Guide to Kill NEEK with u-boot
STOP! This guide is dangerous. You may kill your NEEK. You are warned.
This is a guide to program your NEEK with u-boot and linux images. It won't really kill the hardware. But the GUI selector will be destroyed though you may recover GUI later when you want.
Please setup DasUBoot first.
This is based on the neek_ocm_spi_mmu.zip example design. All the image files are attached, so you may try out without any compilation. For more examples of u-boot usages, you may check the blackfin wiki.
1. Study the memory map of cfi flash on the user guide.
0x20000 is the first fpga configuration data, which was the rbf of selector.
0x0 +0x8000 is the boot loader.
We will use the top 3 MB for u-boot and kernel image. You may have 12MB of 0x100000-0xd00000 for jffs2 or other images.
2. we will place u-boot at,
0xfe0000 +0x20000 , top - 1 sector (128K) the u-boot env
0xfa0000 +0x40000, top - 3 sector the u-boot binary code (256KB)
in u-boot dir, put NEEK.h in include/configs/, put neek_ocm_spi_mmu.h in board/altera/nios2-generic/. Then add an entry NEEK to the NIOS2_GENERIC list in Makefile.
make NEEK_config
make
You will get u-boot elf and u-boot.bin.
3. we will place a tiny boot jump code to u-boot at
0x0 the neek.s binary, which will clear icache and jump to 0xc4fa0000
The source of neek.s is attached. Run ./mneek to build neek.bin
4. we will erase the GUI selector and program our neek_ocm_spi_mmu rbf at 0x20000.
Open quartus, convert programming file,
change file type to Raw binary file, rbf
name the output as neek_ocm.rbf
change mode to active parallel
click configuration master, add file, the sof of neek_ocm_spi_mmu.
generate the neek_ocm.rbf.
5. copy the above, u-boot.bin, neek.bin, output_file.rbf to your tftp server.
Use nios2-configure-sof and nios2-download to configure and run u-boot on NEEK.
nios2-configure-sof cycloneIII_embedded_evaluation_kit_standard.sof
nios2-download -g u-boot
nios2-terminal
U-Boot 2010.06-rc1-00023-g9bb3b3d-dirty (May 31 2010 - 10:52:15)
CPU : Nios-II
SYSID : 5f316e28, Mon Oct 05 10:56:53 2009
BOARD : NEEK
MMC:
Net: ETHOC-0
==>
Set your ipaddr and server ip, burn these images,
setenv ethaddr 08:00:3e:26:0a:5b # set MAC of nios2 board
setenv ipaddr 192.168.4.2 # set ip of nios2 board
setenv serverip 192.168.4.254 # set to your tftp server saveenv
tftp c1000000 neek.bin
protect off e4000000 +20000
erase e4000000 +20000
cp.b c1000000 e4000000 $filesize
tftp c1000000 u-boot.bin
protect off e4fa0000 +40000
erase e4fa0000 +40000
cp.b c1000000 e4fa0000 $filesize
tftp c1000000 neek_ocm.rbf
protect off e4020000 +e0000
erase e4020000 +e0000
cp.b c1000000 e4020000 $filesize
Diconnect nios2-terminal, power cycle, you should see led1 blinking at 1Hz. Then you can connect nios2-terminal again.
6. the uClinux-dist will build images/vmImage, which is u-boot image. We will enable MTD command line partition table parsing,fs jffs2 support. We will copy the vmImage and rootfs.jffs2 to your $(TFTPDIR) dir, which is specified in the uClinux-dist/Makefile.
The header generated using sopc-create-header-files is already in the boards dir, linux-2.6/arch/nios2/boards/neek/include/asm/neek_ocm_fpga.h.
cd nios2-linux/uClinux-dist/vendors/Altera
cp -a nios2 neek
And copy Makefile; , config.linux-2.6.x and config.vendor-2.6.x to this neek dir.
Then build,
cd nios2-linux/uClinux-dist
make menuconfig # Select vendor/product, Altera/neek.
make
7. program the linux kernel image and jffs2 using u-boot,
tftp c1000000 vmImage
protect off e4d00000 +200000
erase e4d00000 +200000
cp.b c1000000 e4d00000 $filesize
imi e4d00000
tftp c1000000 rootfs.jffs2
protect off e4100000 +c00000
erase e4100000 +c00000
cp.b $fileaddr e4100000 $filesize
Set the u-boot env for booting linux with,
setenv mtdparts 'mtdparts=physmap-flash.0:128k(boot),896k(fpga),12m(fs),2688k(kernel),384k(uboot)'
setenv bootcmd 'set bootargs $mtdparts root=/dev/mtdblock2 rootfstype=jffs2 rw ip=dhcp;bootm e4d00000'
Boot linux with jffs2
run bootcmd
- Booting kernel from Legacy Image at e4d00000 ...
Image Name: Linux-2.6.30-00514-ge7e25ac-dirt
Image Type: NIOS II Linux Kernel Image (gzip compressed)
Data Size: 1274277 Bytes = 1.2 MiB
Load Address: c0000000
Entry Point: c0000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Linux version 2.6.30-00514-ge7e25ac-dirty (49.25 BogoMIPS (lpj=246272)
Mount-cache hash table entries: 512
net_namespace: 296 bytes
NET: Registered protocol family 16
init_BSP(): registering device resources
bio: create slab <bio-0> at 0
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
NET: Registered protocol family 1
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 57
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
fb0: altfb frame buffer device at 0x1e00000+0x177000
ttyJ0 at MMIO 0x8001410 (irq = 7) is a Altera JTAG UART
console handover: boot [early0] -> real [ttyJ0]
ethoc-mdio: probed
physmap platform flash device: 01000000 at 04000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Intel/Sharp Extended Query Table at 0x010A
Using buffer write method
Using auto-unlock on power-up/resume
cfi_cmdset_0001: Erase suspend on write enabled
5 cmdlinepart partitions found on MTD device physmap-flash.0
Creating 5 MTD partitions on "physmap-flash.0":
0x000000000000-0x000000020000 : "boot"
0x000000020000-0x000000100000 : "fpga"
0x000000100000-0x000000d00000 : "fs"
0x000000d00000-0x000000fa0000 : "kernel"
0x000000fa0000-0x000001000000 : "uboot"
altps2 : base e8001420 irq 9
mice: PS/2 mouse device common for all mice
ads7846 spi1.0: touchscreen, irq 4
input: ADS784x Touchscreen as /devices/platform/altspi.1/spi1.0/input/input0
i2c /dev entries driver
i2c-gpio i2c-gpio.0: using pins 7 (SDA) and 6 (SCL, no clock stretching)
i2c-gpio i2c-gpio.1: using pins 1 (SDA) and 0 (SCL, no clock stretching)
i2c-gpio i2c-gpio.2: using pins 5 (SDA) and 4 (SCL, no clock stretching)
mmc_spi spi2.0: ASSUMING SPI bus stays unshared!
mmc_spi spi2.0: ASSUMING 3.2-3.4 V slot power
mmc_spi spi2.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
Registered led device: led0
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
atkbd.c: keyboard reset failed on altps2.0
Sending DHCP requests ., OK
IP-Config: Got DHCP answer from 192.168.4.254, my address is 192.168.4.17
IP-Config: Complete:
VFS: Mounted root (jffs2 filesystem) readonly on device 31:2.
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org
BusyBox v1.16.1 (2010-05-31 10:32:41 CST) hush - the humble shell
Enter 'help' for a list of built-in commands.
root:/>
- Booting kernel from Legacy Image at e4d00000 ...
Connect a keyboard. And you may try out mmc/sd, and microwin.
modprobe vfat
modprobe mmc_spi
export TSLIB_TSDEVICE=/dev/event0
export CONSOLE=/dev/tty1
ts_calibrate
nano-X &
nanowm &
nxclock &
nxterm &
If you want u-boot start Linux automatically after power on, add this to the end of NEEK.h and reprogram u-boot.
- define CONFIG_BOOTDELAY 3
Optioal,
8. You can boot with initramfs.
We will need to convert the initramfs image.
mkimage -A nios2 -O linux -T ramdisk -d images/rootfs.initramfs.gz ramdisk.img
tftp c1000000 ramdisk.img
protect off e4100000 +600000
erase e4100000 +600000
cp.b c1000000 e4100000 $filesize
Copy ramdisk to ram, and boot linux with initrd.
cp.l e4100000 c1000000 200000
bootm e4d00000 c1000000
9. You may use mmc/sd flash card, (NOTE, these patches are not merged to mainline yet. I will update on this)
==> mmc_spi 0
Create MMC Device
MMC_SPI: 0 at 0:0 30000000 3
==> mmcinfo
Device: MMC_SPI
Manufacturer ID: 17
OEM: 5457
Name: TWTTI
Tran Speed: 25000000
Rd Block Len: 512
SD version 1.10
High Capacity: No
Capacity: 127664128
Bus Width: 1-bit
==> fatls mmc 0
4063232 rootfs.jffs2
129376 u-boot.bin
1219091 vmimage
3 file(s), 0 dir(s)
Download
- File:Config.linux-2.6.x - v2.6.34
- File:Config.vendor-2.6.x - v2.6.34
- File:Custom fpga.h - NEEK linux fpga header
- File:CycloneIII embedded evaluation kit standard.sof - NEEK sof
- File:Makefile.gz - NEEK vendor Makefile
- File:Mneek.txt - compile neek boot loader
- File:Neek-4-extrme-neek.bin.gz - boot loader, jump to u-boot
- File:NEEK.h - NEEK u-boot config with mmc_spi
- File:Neek.s.gz - neek boot loader source
- File:Neek ocm.rbf - rbf of neek
- File:Neek ocm spi mmu.h - NEEK fpga parameter file with mmc_spi
- File:Ramdisk.img - initrd image
- File:Rootfs.jffs2 - v2.6.34
- File:U-boot-4-extreme-neek.gz - NEEK u-boot elf with mmc_spi
- File:U-boot-4-extreme-neek.bin.gz - NEEK u-boot binary with mmc_spi
- File:VmImage-4-extreme-neek.gz - v2.6.34
- File:ZImage-4-extreme-neek.gz - v2.6.34
Changelog:
20100630: update to v2.6.34, use mdev