to port U-Boot to your hardware platform. To do this, follow these
1. Add a new configuration option for your board to the toplevel
entries as examples. Note that here and at many other places
boards and other names are listed in alphabetical sort order. Please
keep this order.
2. Create a new directory to hold your board specific code. Add any
files you need. In your board directory, you will need at least
3. Create a new configuration file "include/configs/.h" for
3. If you're porting U-Boot to a new CPU, then also create a new
directory to hold your CPU specific code. Add any files you need.
4. Run "make _config" with your new name.
5. Type "make", and you should get a working "u-boot.srec" file
to be installed on your target system.
6. Debug and solve any problems that might arise.
[Of course, this last step is much harder than it sounds.]
U-Boot编译方式By default the build is performed locally and the objects are saved
in the source directory. One of the two methods can be used to change
this behavior and build U-Boot to some external directory:
1. Add O= to the make command line invocations:
make O=/tmp/build distclean
make O=/tmp/build NAME_config
make O=/tmp/build all
2. Set environment variable BUILD_DIR to point to the desired location:
export BUILD_DIR=/tmp/build
make distclean
make NAME_config
make all
Note that the command line "O=" setting overrides the BUILD_DIR environment variable.
U-Boot常用宏配置以下均在开发板的配置文件中修改。
实现命令Tab补齐、命令历史查询
#define CONFIG_CMDLINE_EDITING
#define CONFIG_AUTO_COMPLETE
增加JFFS2支持
//jffs2 partitions support
#define CONFIG_CMD_JFFS2 //增加JFFS2相关命令
#if 0 //单分区
/* No command line, one static partition */
#undef CONFIG_CMD_MTDPARTS
#define CONFIG_JFFS2_DEV "nor1"
#define CONFIG_JFFS2_PART_SIZE 0x400000 //分区大小
#define CONFIG_JFFS2_PART_OFFSET 0x0 //相对于flash物理地址的偏移
#else //多分区 可传递给kernel
#define CONFIG_CMD_MTDPARTS //增加mtd相关命令
#define CONFIG_FLASH_CFI_MTD /*这个很重要,初始化添加设备名信息*/
#define CONFIG_MTD_DEVICE /* needed for mtdparts commands */
#define MTDIDS_DEFAULT "nor1=flash1,nor2=flash2"
#define MTDPARTS_DEFAULT "mtdparts=flash1:50m@0(system-1),-(config-1);" \
"flash2:50m@0(system-2),-(config-2)"
#endif
U-Boot内存分布以上内存布局在u-boot第一阶段内完成,然后返回start.S中执行relocate汇编代码,最后将PC指针跳转至RAM中u-boot地址中执行。U-Boot的mkimge使用如:mkimage -A powerpc -O linux -T ramdisk -C none -a 00000000 -e 00000000 -n "PPC RAMDISK" -d ramdisk.gz ramdisk.img U-Boot之log buffer1.u-boot预留一定大小的kernel log buffer,可以使用cmd_log.c文件中log命令查看buffer信息。(log info、log show)
2.linux kernel需要配置相应的log buffer大小,并加入log buffer patch,配置config文件后重新编译即可。
What's the CONFIG_LOGBUFFER?
It's a feature so that both U-Boot and Linux can use the same memory as log buffer.
How to use the CONFIG_LOGBUFFER in U-Boot and Linux Kernel?
In U-Boot, for example the POST code can output messages to the log
buffer. Or you can redirect the standard output of (some or all)
commands to be stored in the log buffer.
In Linux, the syslog mechanism makes use of the log buffer.
This way you can for example have the standard Linux systlog toolset
process the boot messages or the POST diagnosis. Or you can use
U-Boot to print the Linux kernels log buffer after a crash.
Why that excluded log buffer in linux system memory?
This is to make sure that the log buffer is kept intact over reboots.
Even after a Linux crash you can use U-Boot (or Linux after the next
boot) to print the log buffer contents.
Further Reading
linux-2.6.x/Documentation/kernel-parameters.txt
t actually works round-trip: i. e. you can see in U-Boot the last
log messages of the previously running kernel, which may be helpful if
messages were written to the log buffer, but the kernel crashed before
these could be processed otherwise. And as long as you don't clear
the log buffer, you can still read these messages in Linux after
rebooting (assuming sane hardware which does not lose memory content
during a warmboot - U-Boot takes care to preserve this information
during a reboot).
Support same log buffer or tracing buffer in both bootloader and kernel.
U-Boot环境变量u-boot将环境变量保存到flash中,linux也可以读取设置该flash中的环境变量,
可以使用u-boot源码目录下的tool/env中的fw_printenv 、fw_setenv及fw_env.config。
分析发现uboot env的存储格式是,开始4个字节是crc32,后面是一个接一个\0结束的字符串,每个串都是envname=enavalue的格式。
U-Boot默认命令Monitor Commands - Overview:
============================
go - start application at address 'addr'
run - run commands in an environment variable
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
tftpboot- boot image via network using TFTP protocol
and env variables "ipaddr" and "serverip"
(and eventually "gatewayip")
rarpboot- boot image via network using RARP/TFTP protocol
diskboot- boot from IDE devicebootd - boot default, i.e., run 'bootcmd'
loads - load S-Record file over serial line
loadb - load binary file over serial line (kermit mode)
md - memory display
mm - memory modify (auto-incrementing)
nm - memory modify (constant address)
mw - memory write (fill)
cp - memory copy
cmp - memory compare
crc32 - checksum calculation
i2c - I2C sub-system
sspi - SPI utility commands
base - print or set address offset
printenv- print environment variables
setenv - set environment variables
saveenv - save environment variables to persistent storage
protect - enable or disable FLASH write protection
erase - erase FLASH memory
flinfo - print FLASH memory information
bdinfo - print Board Info structure
iminfo - print header information for application image
coninfo - print console devices and informations
ide - IDE sub-system
loop - infinite loop on address range
loopw - infinite write loop on address range
mtest - simple RAM test
icache - enable or disable instruction cache
dcache - enable or disable data cache
reset - Perform RESET of the CPU
echo - echo args to console
version - print monitor version
help - print online help
? - alias for 'help'