Copying a Kernel and Buildroot to flash ======================================= Ben Dooks, (c) 2006 Simtec Electronics Introduction ------------ You will need a kernel and buildroot to copy files to the system, the next sections explaining some configuration and examples of how to safely do this. Configuring your Kernel ----------------------- You will need the following: - MTD support, with appropriate NAND drivers - JFFS2 support, with compression disabled - USB if the source files are from an USB device The JFFS2 compression must be turned off if you are using ABLE before version 2.27. It is also safer to disable compression if modifying the partition that the initial loader uses to load ABLE from. If in doubt, do not enable JFFS2 compression. The JFFS2 compression options can be found here in the configuration tree: File systems ---> Miscellaneous filesystems ---> <*> Journalling Flash File System v2 (JFFS2) support [*] Advanced compression options for JFFS2 [ ] JFFS2 ZLIB compression support [ ] JFFS2 RTIME compression support [ ] JFFS2 RUBIN compression support To enable the NAND support, the following options will be needed: Device Drivers ---> Memory Technology Devices (MTD) ---> <*> Direct char device access to MTD devices <*> Caching block device access to MTD devices NAND Flash Device Drivers ---> <*> NAND Device Support <*> NAND Flash support for S3C2410/S3C2440 SoC [ ] S3C2410 NAND driver debug [*] S3C2410 NAND Hardware ECC [ ] S3C2410 NAND IDLE clock stop Configuring your buildroot -------------------------- The minimum requirement is a shell and the mtd utiltiies. The minimum configuration options for mtd are as so: [*] mtd/jffs2 utilities MTD package selection ---> Source package selection (Default source) ---> MTD tools selection ---> [*] flash_eraseall [*] flash_info [*] flash_unlock [*] jffs2dump [*] sumtool [*] nandwrite Flash Partitions ---------------- The flash is partitioned into several parts by default, which are used as so: flash0 The initial loader to load ABLE flash1 ABLE image fles flash2 User boot flash This accounts for about 8Mbyte of the flash, with the rest available to be allocated by the user. The mapping from ABLE flash to the Linux MTD partitions is usually as so: flash0 /dev/mtdblock0 /dev/mtd0 flash1 /dev/mtdblock1 /dev/mtd1 flash2 /dev/mtdblock2 /dev/mtd2 The /dev/mtdX are used with the nand tools to issue commands to the mtd layer, and the /dev/mtdblockX are for jffs2 to mount. Example: Copying a kernel and buildroot from an USB to flash2 ------------------------------------------------------------- This example shows copying a kernel from an USB storage device to the flash2 partition. This example assumes that the files have already been copied to the USB device. 1) Boot the programming kernel and buildroot > load (...)kernel (...)buildroot > setargs root=/dev/ram console=ttySAC0,115200 > boot 2) Start a shell 3) Initialise the flash This step only needs to be done if this is the first use of the flash, or the partition has become invalid # flash_eraseall -j /dev/mtd2 4) Mount the flash # mount -t jffs2 /dev/mtdblock2 /mnt 5) Create a second mount directory # mkdir /mnt2 6) Ensure device nodes are created # mknod /dev/sda b 8 0 # mknod /dev/sda1 b 8 1 # mknod /dev/sda2 b 8 2 # mknod /dev/sda3 b 8 3 7) Mount the USB storage device If the device is not already connected, connect now. # mount /dev/sda1 /mnt2 8) Copy the files across Adjust the number of files and their names as necessary # cp /mnt2/kernel_currie /mnt/kernel # cp /mnt2/root_currie /mnt/ramdisc 9) sync and unmount the mounted partitions # sync # umount /mnt2 # umount /mnt 10) reset the system 11) boot the files under ABLE to test > load (flash2)kernel (flash2)ramdisc > setargs root=/dev/ram console=ttySAC0,115200 > boot Example runthrough ------------------ root BusyBox v1.1.0 (2006.08.17-00:08+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. # flash_eraseall -j /dev/mtd2 Erasing 16 Kibyte @ 0 -- 0 % complete. # mount -t jffs2 /dev/mtdblock2 /mnt/ # mkdir /mnt2 # usb 1-1: new full speed USB device using s3c2410-ohci and address 2 usb 1-1: configuration #1 chosen from 1 choice scsi0 : SCSI emulation for USB Mass Storage devices Vendor: OTi Model: Ultra Floppy Rev: 1.11 Type: Direct-Access ANSI SCSI revision: 02 SCSI device sda: 64512 512-byte hdwr sectors (33 MB) sda: Write Protect is off sda: assuming drive cache: write through SCSI device sda: 64512 512-byte hdwr sectors (33 MB) sda: Write Protect is off sda: assuming drive cache: write through sda: sda1 sd 0:0:0:0: Attached scsi removable disk sda sd 0:0:0:0: Attached scsi generic sg0 type 0 # mknod /dev/sda b 8 0 # mknod /dev/sda1 b 8 1 # mknod /dev/sda2 b 8 2 # mknod /dev/sda3 b 8 3 # mount /dev/sda1 /mnt2 # cp /mnt2/kernel_currie /mnt/kernel # cp /mnt2/root_currie /mnt/ramdisc # umount /mnt2 # sync # umount /mnt # sync # selected all-wr for console write selected all-rd for console read DRAM: 128 Mb (134217728 bytes) ABLE 2.27 Copyright 2001-2005,2006 Simtec Electronics NE2000: ne0: ISA/Generic, 00:11:ac:00:02:14 (EEPROM Missing/Unset) Autoboot attempt 1, Press any key to abort Autobooting in 6port 0: new device [0ea0,6803] class 00:00:00, 1 configurations, mps 64 (hd0) on ((usbst0p1):ext2) >ls (flash2) skipping block, ptr 390000: invalid node found (0) kernel ramdisc >load (flash2)kernel (flash2)ramdisc >setargs root=/dev/ram console=ttySAC0,115200 >boot Booting Linux Uncompressing Linux................................................................................................................ done, booting the kernel. Linux version 2.6.16-simtec2 (ben@kira) (gcc version 3.4.2) #3 Thu Aug 17 00:54:36 BST 2006 CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)