From owner-freebsd-mips@FreeBSD.ORG Fri Apr 8 07:57:26 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64F18106564A; Fri, 8 Apr 2011 07:57:26 +0000 (UTC) (envelope-from freebsd-mips@dino.sk) Received: from loki.netlab.sk (ns3.netlab.sk [84.245.65.11]) by mx1.freebsd.org (Postfix) with ESMTP id 1810B8FC15; Fri, 8 Apr 2011 07:57:25 +0000 (UTC) Received: from atom.dino.sk (fw1.dino.sk [84.245.95.252]) (AUTH: LOGIN milan, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by loki.netlab.sk with ESMTPSA; Fri, 08 Apr 2011 09:57:23 +0200 id 00033C18.4D9EBFE3.000053D1 Date: Fri, 8 Apr 2011 09:57:12 +0200 From: Milan Obuch To: Aleksandr Rybalko Message-ID: <20110408095712.1fc36066@atom.dino.sk> In-Reply-To: <20110401005733.3598e82c.ray@ddteam.net> References: <20110331101554.68171eed@atom.dino.sk> <20110331142640.07f2101b@atom.dino.sk> <20110401005733.3598e82c.ray@ddteam.net> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.1; amd64-portbld-freebsd8.2) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEX+/v7++v6YOTrq8PCcuIX989UvOSj++v0BNCbpAAAAB3RJTUUHsQwfFzs7RBhzUQAAAhJJREFUOI1dU8GOqzAMNKIoV1bvwD1i0ysqrHplIdBrVSX7ATSbd03VVvn9tQNtQy0hjAdn7LED4AAcPtWm9RV+MPSfxhBLx9ajd6X/ngB6/mTwnRSZua7i7Ca+0ctZKo4Qmz+JY13X6I3nFZBxIYW1PbgfQ5RP8g0XlltEWGf3cV03joYpRnFbvYDKbXjZlXyyhEZA4lI+cN3NaVXE4VKjSwTExO10eTEkkJVqIAD5z0nUBQJluQDRSQjcrBiHAJxZlAH5CUMBMC7OcJ4LMQNnxhZ1HYPscMc6J4UlWRMNwzOpCcAHKSICd1EDn83abdREIbXsHkD1OinP1aCUCOEVRaa1lMcvywUWdYgk13JQUpYNKmvXQ8Kw5ML9YI5h8SakctBc7E/IYuLhYd/zZIk+1gM1vNweQBvHE0j+oYah3sMqAytQYlZk6+ANaaawJdu3OFzYGMZ3iGpa3qMlq9ZH0VZTgrCtw/ngdYkEIIpSbP1bWQAdFdX9vocBdkH2qVjVmuMu3gI5rjs814EUdrCZgWlPaxZZ3RiLFUtr+ud0PXwp2dnQSNXgePt6AZpBj6UMJ7VQkzN4utVeaSW1Dhn/kblGrKeMvNGnzwX4zuEDarYz1KdPtR60Gul0Gued+515SJXhCsl+Tx/3kY/UDvicPll9mfu50t3tvQ/thZpJYgeuwdSKNJ6tCD98MCgoxLDaPxbwqqwPWaWiAAAAAElFTkSuQmCC X-Face: ak5rwz4-aUa>hPFZlcg,bXxn.(TN}e9DGFrKU\.i_'B[&5=pAd9o"j)5VSUYW:BRQG#^42Ev$Il|; Ztn=,C X-Operating-System: FreeBSD/amd64 8.2-STABLE Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-mips@freebsd.org Subject: Re: [RFC] Re: TP link MR3220 status, boot from flash via u-boot question X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2011 07:57:26 -0000 On Fri, 1 Apr 2011 00:57:33 +0300, Aleksandr Rybalko wrote: > On Thu, 31 Mar 2011 14:26:40 +0200 > Milan Obuch wrote: > > > On Thu, 31 Mar 2011 18:39:36 +0800, Adrian Chadd > > wrote: [ snip ] > > Hi, > > I am watching freebsd-wifi-build on googlecode and just noticed new > > config there... Is your 11n wifi already working too? I would be > > glad to compare your results with mine, so we could unify our > > efforts. Right now, kernel load from flash in u-boot is a show > > stopper for me, so if you could address this one first, it would > > help me really much. > > Draft for wiki page 'Run from NOR flash with U-Boot' > In my case, to be exact, there is SPI flash, actually... > Keywords: U-Boot, embedded > > 1. Ask U-Boot: "what do you support to boot?" > > Normally, U-Boot use special image for kernel/ramfs packing. But we > need to know which compression support U-Boot that fleshed to our > target board. > This one is easy - I can use gzip packed kernel only. If I try other compressing method, u-boot complains with 'bad gzip data' message so this one is clear in this case, I think. > First way: > use mkimage utility (/usr/ports/devel/u-boot) and make test > images for all supported by mkimage compression types. > > mkimage -A ${TARGET} -O linux -T kernel \ > -C ${COMPRESSION_TYPE} \ > -a ${RAM_START_ADDRESS} \ > -e ${RAM_START_ADDRESS} \ > -n 'FreeBSD Kernel Image' \ > -d SOME_SMALL_FILE_NAME \ > test.uboot > > Then for each file, do transfer to board and run from image with > `bootm' command. And check what U-Boot answer you, if answer like > "Unimplemented compression type ?", then you know :). > > Second way: > From running Linux or U-Boot get first 64k block from kernel partition > in flash. > > Break your mkimage utility: avoid exit when we do "show info" (key -i) > CRC failed. And check compression type of 64k file we get from device. > > Or just delete U-Boot image header from file > > dd if=64k.file of=just_kern bs=64 skip=1 > > and check with file(1) utility > > 2. Create image > 2.1. More canonical way, we have mkimage, gzip or bz2 and compiled > kernel, maybe kernel.bin also. > > > gzip --best --force vmlinux.bin > > > for ELF kernel: > > mkimage -A mips -O linux -T kernel \ > -C gzip \ > -a ${LOAD_ADDRESS} \ > -e ${START_ADDRESS} \ > -n 'FreeBSD Kernel Image' \ > -d kernel \ > kernel.uboot > > LOAD_ADDRESS - in most cases this is RAM base address > START_ADDRESS = LOAD_ADDRESS + ELF_HEADER_SIZE (0x1000 for ELF image) > > for kernel.bin: > > LOAD_ADDRESS = RAM_BASE_ADDRESS + 0x1000 > START_ADDRESS = RAM_BASE_ADDRESS + 0x1000 > > Don't forget to check/change KERNLOADADDR of kernel config file. > KERNLOADADDR must be equal to START_ADDRESS. > I tried it various way, no success yet. When I load kernel via TFTP to address set in kernel config (0x80050000 in my case) I can issue a go command to 'start' address, usually 0x80050100, but sometimes it is 0x80050120 - I am checking for this after kernel is built - and kernel boots correctly and works. As already mentioned, there is a mktplinkfw utility, which combines kernel and root fs (or uses kernel with embedded root fs), prepends a required header and pads generated image to full size of flash minus 128 kB for u-boot itself. I am able to flash such image into flash, but bootm tells only about success uncompressing kernel, starting kernel and that's all. ## Booting image at 9f020000 ... Uncompressing Kernel Image ... OK Starting kernel ... Nothing more, powerdown necessary to start again. > 2.2. Longest way, but have smallest footprint, used only if > U-Boot support LZMA. > > Problem 1: Current version of mkimage from ports, don't support LZMA. > So we need new: http://my.ddteam.net/files/u-boot.new.tar.gz > > Problem 2: Devices I know support only old LZMA. > I use LZMA 4.17. > > Then mkimage, like in 2.2., but -C lzma. > > 3. Now we have kernel U-Boot image, so transfer it to device and try > with `bootm' command. > > 4. If all fine, write image to flash kernel partition. > > > Hope this help :) > [ snip ] Not much yet, unfortunatelly... On a side note, there is one thing to be addressed. As my device has only 4 MB flash, I still need to shrink the image I would like to use there. I could put there working kernel, when flash boot issue is solved, but root fs not yet, together they do not fit. I still need to save as much as 600 kB of space... Do you have any tips to share? In some older mails here I saw you managed to do it for other device... Regards, Milan