summaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)Author
2010-08-19fdt: call fdt_parent_offset fewer times while translating addressesScott Wood
fdt_parent_offset() is an expensive operation, so we'd like to reduce unnecessary calls to it. Further, the practice of iterating up to the root if address/size cells aren't found was apparently done for Linux for compatibility with certain buggy Open Firmware implementations, and U-Boot inherited the code. The compliant behavior is to treat a missing #address-cells as 2, and a missing #size-cells as 1 -- never looking anywhere but the immediate parent of the node of interest. Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2010-08-13env_nand: return error when no device is foundMike Frysinger
Currently, if there is an error probing the NAND chip and the env is based in NAND, the readenv() function will use a NULL function pointer and thus jump to address 0. Here I just check for a non-zero value of blocksize as that shouldn't be zero when a valid device is found, but perhaps there is a better way for someone familiar with the NAND internals to suggest. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>
2010-08-12Fixed clobbered output of the "help usb" commandSergei Poselenov
The "usb help" doesn't format the output correctly: => help usb usb - USB sub-system Usage: usb reset - reset (rescan) USB controller usb stop [f] - stop USB [f]=force stop usb tree - show USB device tree usb info [dev] - show available USB devices usb storage - show details of USB storage devices usb dev [dev] - show or set current USB storage device usb part [dev] - print partition table of one or all USB storage devices usb read addr blk# cnt - read `cnt' blocks starting at block `blk#' to memory address `addr'usb write addr blk# cnt - write `cnt' blocks starting at block `blk#' from memory address `addr' => With fix below applied, the output is correct: => help usb usb - USB sub-system Usage: usb reset - reset (rescan) USB controller usb stop [f] - stop USB [f]=force stop usb tree - show USB device tree usb info [dev] - show available USB devices usb storage - show details of USB storage devices usb dev [dev] - show or set current USB storage device usb part [dev] - print partition table of one or all USB storage devices usb read addr blk# cnt - read `cnt' blocks starting at block `blk#' to memory address `addr' usb write addr blk# cnt - write `cnt' blocks starting at block `blk#' from memory address `addr' => Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>
2010-08-10Merge branch 'master' of git://git.denx.de/u-boot-armWolfgang Denk
2010-08-10Merge branch 'master' of git://git.denx.de/u-boot-imxWolfgang Denk
2010-08-10Merge branch 'master' of git://git.denx.de/u-boot-marvellWolfgang Denk
2010-08-10fix cmd_mmc.c, line 136 missing "Reinhard Meyer
Remove warning for missing " at the end of line 136 Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
2010-08-09miiphy: leverage current_mii cache moreMike Frysinger
For code that uses miiphy_{read,write}, every call invokes a full look up of the mii list. There is already a "current_mii" cache that is used by some code, but have the miiphy_{read,write} function use it as well. This does increase the code size slightly, but I think it's worth it. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-08-09miiphy: unify device list lookupMike Frysinger
Rather than have every func re-implement the list walking code, do it one local function. This shrinks the resulting object code a little while making the source much more manageable. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-08-09miiphy: constify device nameMike Frysinger
The driver name does not need to be writable, so constify it. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2010-08-09fdt: Fix bug in size calculation in fdt_resize() with initrd useFeng Wang
Original bug description from Feng (fdt_resize() bug caused "WARNING: could not set linux, initrd-start FDT_ERR_NOSPACE."): What I got is an error: "WARNING: could not set linux,initrd-start FDT_ERR_NOSPACE." after loading Device Tree blob. This in turn caused linux to miss init part. After some digging, I found out the reason for this error, it is caused by fdt_resize(). FDT blob got resized after filling in all board specific information of PowerPC. (in boot_body_linux()). It reduced blob size with only extra space for two fdt_reserve_entry, one for fdt itself, and one for initrd. Then it's aligned to a 0x1000 page boundary. However, later in fdt_initrd(), it could add two more properties, initrd-start AND initrd-end, each one needs at least two fdt_reserve_entry sizes done by _fdt_add_property() (name and value). Thus, the two fdt_reserve_entry extra space is not sufficient. So for some specific fdt size which is just under the page boundary after resizing, this will cause an error of FDT_ERR_NOSPACE in fdt_initrd() when setting those two properties, and failed to pass initrd information to linux. My fix is in fdt_resize(), leave at least 4 fdt_reserve_entry for initrd. So instead of 2*sizeof(struct fdt_reserve_entry) for actual_totalsize, use 5*sizeof(struc fdt_reserve_entry). Stefan: I got this same error on katmai, when trying to boot with initrd (run flash_self). This patch fixes this issue. Signed-off-by: Feng Wang <fwang02@harris.com> Tested-by: Stefan Roese <sr@denx.de> Cc: Jerry Van Baren <gvb.uboot@gmail.com> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2010-08-09various cmd_* files: fixed layout a little bitFrans Meulenbroeks
Most of the files have U_BOOT_CMD on a separate line, but a few didn't and had the first line on the same line as U_BOOT_CMD. This changes these files by adding a line break and a tab Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
2010-08-09various cmd_* files: remove the command name from the help messageFrans Meulenbroeks
removed the command name from the help message as it is already printed. for cmd_mmc also rewrote the message a little bit Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
2010-08-09flash_protect: check for NULL flash infoMike Frysinger
If a flash is unable to be detected, and then someone calls flash_protect on it (like the common code does in flash_init), the flash_protect logic will dereference a NULL pointer. Since flash_protect already does sanity checking on the info structs, add a NULL pointer check in there. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-09getenv_f(): fix handling of too short buffersWolfgang Denk
Fix error handling in getenv_f() when the user provided buffer is too short to hold the variable name; make sure to truncate and NUL-terminate without overwriting the buffer limits. Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-08-09dataflash mmc mux: use common cmd_usage functionMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-09mflash: use common cmd_usage functionMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-09cmd editing: optimize/shrink output blankingMike Frysinger
No need to output spaces 1 char at a time in a loop when the printf code can do the same thing with the right format string. This shrinks things and gives a nice speed up when killing off lines more than a byte or two as printf will send out the buffer in one big chunk. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-08fdt relocate: have more attention to use a bootmap or notStephan Linz
Platforms with flat device tree support can use a bootmap to relocate the fdt_blob. This is not a must. That's why the relocation function boot_relocate_fdt() should be use only if CONFIG_OF_LIBFDT was defined together with CONFIG_SYS_BOOTMAPSZ (see common/cmd_bootm.c). On MicroBlaze platforms there is no need to use a bootmap to relocate a fdt blob. So we need a more precise focus on the compilation and usage of boot_relocate_fdt(). In general it is valid to exclude the function boot_relocate_fdt() if the bootmap size CONFIG_SYS_BOOTMAPSZ is not defined. Signed-off-by: Stephan Linz <linz@li-pro.net>
2010-08-08cmd_ide: add support for KirkwoodPrafulla Wadaskar
Added MVSATAC definitions to Kirkwood. Added support for Kirkwood in cmd_ide. Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
2010-08-08cmd_ide: add support for orion5xAlbert Aribaud
Add MVSATAHC definitions to orion5x. Add support for orion5x in cmd_ide. Signed-off-by: Albert Aribaud <albert.aribaud@free.fr>
2010-08-08ide: add configurationAlbert Aribaud
CONFIG_IDE_SWAP_IO This configuration option replaces a complex conditional in cmd_ide.c with an explicit define to be added to SoC or board configs. Signed-off-by: Albert Aribaud <albert.aribaud@free.fr>
2010-08-07LZMA and LZO causes compile errorMatthias Weisser
If both LZMA and LZO compressions are used there is a compile error in cmd_bootm.c Signed-off-by: Matthias Weisser <weisserm@arcor.de>
2010-08-07Fix condition where bootm_size not set and wrong memory size reportedMatthew McClintock
If the user sets bootm_low and does not set bootm_size, u-boot will report the memory node in the flat device tree incorrectly. Instead of reporting the remaining size of memory, it will report the total available memory which is incorrect. Specifically this fixes the situation when booting a relocatable kernel and the memory is reported as an offset and size in the device tree, and the size needs to be adjusted accordingly. Signed-off-by: Matthew McClintock <msm@freescale.com> Acked-by: Kumar Gala <galak@kernel.crashing.org>
2010-08-04Rename getenv_r() into getenv_f()Wolfgang Denk
While running from flash, i. e. before relocation, we have only a limited C runtime environment without writable data segment. In this phase, some configurations (for example with environment in EEPROM) must not use the normal getenv(), but a special function. This function had been called getenv_r(), with the idea that the "_r" suffix would mean the same as in the _r_eentrant versions of some of the C library functions (for example getdate vs. getdate_r, getgrent vs. getgrent_r, etc.). Unfortunately this was a misleading name, as in U-Boot the "_r" generally means "running from RAM", i. e. _after_ relocation. To avoid confusion, rename into getenv_f() [as "running from flash"] Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Detlev Zundel <dzu@denx.de>
2010-08-04bootm: fix pointer warning with lzmaMike Frysinger
Avoid warning: cmd_bootm.c: In function 'bootm_load_os': cmd_bootm.c:394: warning: passing argument 2 of 'lzmaBuffToBuffDecompress' from incompatible pointer type For 32 bit systems, this change shouldn't make a difference to code size since sizeof(size_t) and sizeof(unsigned int) are equal. But it does fix the warning. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-07-26fdt: Add function to alloc phandle valuesKumar Gala
If we are creating reference (handles) to nodes in a device tree we need to first create a new phandle in node and this needs a new phandle value. So we search through the whole dtb to find the max phandle value and return the next greater value for a new phandle allocation. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2010-07-24fs/fat: Big code cleanup.Wolfgang Denk
- reformat - throw out macros like FAT_DPRINT and FAT_DPRINT - remove dead code Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-24usb_storage.c: change progress output in debug() messageWolfgang Denk
The dots printed by common/usb_storage.c as progress meter corrupt the output for example of "fatls usb" commands like this: => fatls usb 0 . <<==== here 29 file.001 29 file.002 29 file.003 29 file.004 29 file.005 29 file.006 29 file.007 29 file.008 29 file.009 29 file.010 29 file.011 29 file.012 29 file.013 29 file.014 29 file.015 29 file.016 . <<==== here 29 file.017 29 file.018 29 file.019 ... Turn the progress output into a debug message. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Remy Bohmer <linux@bohmer.net>
2010-07-24usb_storage.c: initialize device typeWolfgang Denk
The device type was left uninitialized which caused later tests against DEV_TYPE_UNKNOWN to fail. In the result, "usb part" would attempt to print information about non-existent devices like this: => usb part print_part of 0 Partition Map for USB device 0 -- Partition Type: DOS Partition Start Sector Num Sectors Type 1 0 2031616 f8 print_part of 1 ## Unknown partition table print_part of 2 ## Unknown partition table print_part of 3 ## Unknown partition table print_part of 4 ## Unknown partition table => By initializing the type as DEV_TYPE_UNKNOWN we avoid all the "Unknown partition table" messages. [Note: the "print_part of ?" messages is left over debug code that will be removed in another patch.] Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Remy Bohmer <linux@bohmer.net>
2010-07-24cmd_usage(): simplify return code handlingWolfgang Denk
Lots of code use this construct: cmd_usage(cmdtp); return 1; Change cmd_usage() let it return 1 - then we can replace all these ocurrances by return cmd_usage(cmdtp); This fixes a few places with incorrect return code handling, too. Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-20fdt: Add fdt_node_offset_by_compat_reg helperKumar Gala
Given a compatible string and physical address try and find a node that matches. This is useful when we want to find a specific device node to update (for example if we have multiple PCI nodes we can use the physical address to distinguish them when trying to update the device tree). Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2010-07-20fdt: Add fdt_translate_address to convert reg node to cpu phys addrKumar Gala
This code is extracted out of the Linux Kernel code from arch/powerpc/kernel/prom_parse.c. We maintain some of the same structure to support multiple bus types even though we only have one in the current code. In the future we might want to translate across a PCI bus and thus it will be easier to add that functionality back in. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2010-07-17Drop support for GTH boardWolfgang Denk
The board maintainer states: The GTH board is obsolete and has not been manufactured for several years. To my knowledge, no recent U-Boot build has been tested on that card. So drop support for this board. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Thomas Lange <thomas@corelatus.se> Acked-by: Thomas Lange<thomas@corelatus.se>
2010-07-16Merge branch 'master' of git://git.denx.de/u-boot-mpc85xxWolfgang Denk
2010-07-16mpc85xx: Add reginfo commandBecky Bruce
The new command dumps the TLBCAM, the LAWs, and the BR/OR regs. Add CONFIG_CMD_REGINFO to the config for all MPC85xx parts. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2010-07-16fdt: move fsl specific code from common fdt area to mpc8xxx/fdt.cKim Phillips
Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2010-07-14Enable PXAFB for PXA27X and PXA3XXMarek Vasut
2010-07-12NAND: formatting cleanups from env.oob supportScott Wood
Change if (ok) { bunch of stuff } else { error } to if (error) { get out } proceed with bunch of stuff Plus a few whitespace cleanups. Signed-off-by: Scott Wood <scottwood@freescale.com>
2010-07-12NAND: environment offset in OOB (CONFIG_ENV_OFFSET_OOB)Ben Gardiner
This is a re-submission of the patch by Harald Welte <laforge@openmoko.org> with minor modifications for rebase and changes as suggested by Scott Wood <scottwood@freescale.com> [1] [2]. This patch enables the environment partition to have a run-time dynamic location (offset) in the NAND flash. The reason for this is simply that all NAND flashes have factory-default bad blocks, and a fixed compile time offset would mean that sometimes the environment partition would live inside factory bad blocks. Since the number of factory default blocks can be quite high (easily 1.3MBytes in current standard components), it is not economic to keep that many spare blocks inside the environment partition. With this patch and CONFIG_ENV_OFFSET_OOB enabled, the location of the environment partition is stored in the out-of-band (OOB) data of the first block in flash. Since the first block is where most systems boot from, the vendors guarantee that the first block is not a factory default block. This patch introduces the 'nand env.oob' command, which can be called from the u-boot command line. 'nand env.oob get' reads the address of the environment partition from the OOB data, 'nand env.oob set {offset,partition-name}' allows the setting of the marker by specifying a numeric offset or a partition name. [1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/43916 [2] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/79195 Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca> Acked-by: Harald Welte <laforge@gnumonks.org>
2010-07-04Make sure that argv[] argument pointers are not modified.Wolfgang Denk
The hush shell dynamically allocates (and re-allocates) memory for the argument strings in the "char *argv[]" argument vector passed to commands. Any code that modifies these pointers will cause serious corruption of the malloc data structures and crash U-Boot, so make sure the compiler can check that no such modifications are being done by changing the code into "char * const argv[]". This modification is the result of debugging a strange crash caused after adding a new command, which used the following argument processing code which has been working perfectly fine in all Unix systems since version 6 - but not so in U-Boot: int main (int argc, char **argv) { while (--argc > 0 && **++argv == '-') { /* ====> */ while (*++*argv) { switch (**argv) { case 'd': debug++; break; ... default: usage (); } } } ... } The line marked "====>" will corrupt the malloc data structures and usually cause U-Boot to crash when the next command gets executed by the shell. With the modification, the compiler will prevent this with an error: increment of read-only location '*argv' N.B.: The code above can be trivially rewritten like this: while (--argc > 0 && **++argv == '-') { char *arg = *argv; while (*++arg) { switch (*arg) { ... Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-07-04Redundant environment: move flag definitions to header fileWolfgang Denk
Instead of defining the flags sevaral times in different source files (which is error prone), move them to a central place in a header file. Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-04Make *printf() return "int" instead of "void"Wolfgang Denk
Change the return type of the *printf() functions to the standard "int"; no changes are needed but returning the already available length count. This will save a few additional strlen() calls later... Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-04exports.c: fix warning: 'dummy' defined but not usedWolfgang Denk
Also get rid of the #ifdef's while doing this. Suggested-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-04cmd_ide.c: fix unused variable warning for SC3 boardWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2010-07-04shannon/INFERNO: fix special handling of environment configurationWolfgang Denk
Remove some INFERNO related #ifdef's from common environment code by fixing the board configuration settings (add CONFIG_ENV_SECT_SIZE). While we are at it, fix comment which incorrectly talks about 4 KB environment size, while it's actually 0x4000 = 16 KiB. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Rolf Offermanns <rof@sysgo.de>
2010-06-30add redundant environment for env_sf.cWolfgang Wegner
This patch adds redundant environment for environment in SPI flash. I took env_flash.c as an example and slightly modified it. Apart from adapting things to SF, I also slightly changed the decision logic to use area 2 as a default in case the flags are wrong because not having a default path worried me. I did not add a section for CONFIG_ENV_IS_IN_SPI_FLASH in environment.h because I did not understand if this is desired and/or needed. So to use the feature, one has to set CONFIG_ENV_OFFSET_REDUND _and_ CONFIG_SYS_REDUNDAND_ENVIRONMENT. I checked it by powering off my board several times during flash erase or write, because I do not know if there are other stress test scenarios. Signed-off-by: Wolfgang Wegner <w.wegner@astro-kom.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
2010-06-30Merge branch 'master' into nextWolfgang Denk
2010-06-29Fix #if chain and added AVR32 case in cmd_bdinfo.cReinhard Meyer
AVR32 case was missing in cmd_bdinfo, resulting in compiler warning (bd->bi_baudrate declared unsigned int at AVR32, but printf used %d) At the same time slightly reordered #if #elif #endif to make ARM one of the cases and not an extra case surrounding all others Signed-off-by: Reinhard Meyer <info@emk-elektronik.de> Tested-by: Andreas Bießmann <biessmann@corscience.de>
2010-06-29hwconfig: Add some unit testsAnton Vorontsov
I use this for testing, and I think this might be useful in the future. Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>