立即注册 登录
逆天PCB论坛 返回首页

fuchch的个人空间 https://bbs.ntpcb.com/?17674 [收藏] [复制] [RSS]

日志

(S5PV210)u-boot-2016.07 移植 (一) —— 阅读文档

已有 829 次阅读2016-10-13 18:17 |个人分类:uboot

在doc下有个README.s5pc1xx,内容很少
Summary
=======
This README is about U-Boot support for SAMSUNG's ARM Cortex-A8 based S5PC1xx
family of SoCs (S5PC100 [1] and S5PC110).
Currently the following board is supported:
* SMDKC100 [2]
Toolchain
=========
While ARM Cortex-A8 support ARM v7 instruction set (-march=armv7a) we compile
with -march=armv5 to allow more compilers to work. For U-Boot code this has
no performance impact.
Build
=====
* SMDKC100
make smdkc100_config
make
Interfaces
==========
cpu
To check SoC:
    if (cpu_is_s5pc100())
        printf("cpu is s5pc100\n");
    or
    if (cpu_is_s5pc110())
        printf("cpu is s5pc110\n");
gpio
    struct s5pc100_gpio *gpio = (struct s5pc100_gpio*)S5PC100_GPIO_BASE;
    /* GPA[0] pin set to irq */
    gpio_cfg_pin(&gpio->gpio_a, 0, GPIO_IRQ);
    /* GPA[0] pin set to input */
    gpio_direction_input(&gpio->gpio_a, 0);
    /* GPA[0] pin set to output/high */
    gpio_direction_output(&gpio->gpio_a, 0, 1);
    /* GPA[0] value set to low */
    gpio_set_value(&gpio->gpio_a, 0, 0);
    /* get GPA[0] value */
    value = gpio_get_value(&gpio->gpio_a, 0);
Links
=====
[1] S5PC100:
[url]http://www.samsung.com/global/business/semiconductor/productInfo.do?[/url]
fmly_id=229&partnum=S5PC100
[2] SMDKC100:
[url]http://meritech.co.kr/eng/products/product_view.php?num=28[/url]
第一个,虽然ARM CORTEX-A8支持armv7结构,即可以使用-march=armv7a,但是我们
使用-march=armv5来编译,这样是为了让大多说编译器能够工作。
第二个,编译 make smdkc100_config make
第三个,
[1] S5PC100:
[url]http://www.samsung.com/global/business/semiconductor/productInfo.do?[/url]
fmly_id=229&partnum=S5PC100
[2] SMDKC100:
[url]http://meritech.co.kr/eng/products/product_view.php?num=28[/url] (不能访问了)
还有其他可以看的,比较多,如
README.arm-caches
README.ARM-memory-map
README.arm-relocation
README.commands
......
当然,第一步,其实是要阅读根目录下的README
Board Initialisation Flow:
--------------------------
This is the intended start-up flow for boards. This should apply for both
SPL and U-Boot proper (i.e. they both follow the same rules).
Note: "SPL" stands for "Secondary Program Loader," which is explained in
more detail later in this file.
At present, SPL mostly uses a separate code path, but the function names
and roles of each function are the same. Some boards or architectures
may not conform to this. At least most ARM boards which use
CONFIG_SPL_FRAMEWORK conform to this.
Execution typically starts with an architecture-specific (and possibly
CPU-specific) start.S file, such as:
    - arch/arm/cpu/armv7/start.S
    - arch/powerpc/cpu/mpc83xx/start.S
    - arch/mips/cpu/start.S
and so on. From there, three functions are called; the purpose and
limitations of each of these functions are described below.
lowlevel_init():
    - purpose: essential init to permit execution to reach board_init_f()
    - no global_data or BSS
    - there is no stack (ARMv7 may have one but it will soon be removed)
    - must not set up SDRAM or use console
    - must only do the bare minimum to allow execution to continue to
        board_init_f()
    - this is almost never needed
    - return normally from this function
board_init_f():
    - purpose: set up the machine ready for running board_init_r():
        i.e. SDRAM and serial UART
    - global_data is available
    - stack is in SRAM
    - BSS is not available, so you cannot use global/static variables,
        only stack variables and global_data
    Non-SPL-specific notes:
    - dram_init() is called to set up DRAM. If already done in SPL this
        can do nothing
    SPL-specific notes:
    - you can override the entire board_init_f() function with your own
        version as needed.
    - preloader_console_init() can be called here in extremis
    - should set up SDRAM, and anything needed to make the UART work
    - these is no need to clear BSS, it will be done by crt0.S
    - must return normally from this function (don't call board_init_r()
        directly)
Here the BSS is cleared. For SPL, if CONFIG_SPL_STACK_R is defined, then at
this point the stack and global_data are relocated to below
CONFIG_SPL_STACK_R_ADDR. For non-SPL, U-Boot is relocated to run at the top of
memory.
board_init_r():
    - purpose: main execution, common code
    - global_data is available
    - SDRAM is available
    - BSS is available, all static/global variables can be used
    - execution eventually continues to main_loop()
    Non-SPL-specific notes:
    - U-Boot is relocated to the top of memory and is now running from
        there.
    SPL-specific notes:
    - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined and
        CONFIG_SPL_STACK_R_ADDR points into SDRAM
    - preloader_console_init() can be called here - typically this is
        done by defining CONFIG_SPL_BOARD_INIT and then supplying a
        spl_board_init() function containing this call
    - loads U-Boot or (in falcon mode) Linux
通常是从start.S开始运行的。下面三个函数将会被调用
lowlevel_init()、board_init_f()、board_init_r()
lowlevel_init() 初始化以运行board_init_f()
没有stack栈,绝不能设置SDRAM、不能使用console控制台
必须是最小设置来运行board_init_f()
正常返回
board_init_f() 设置板子(如SDRAM,UART)以能够运行board_init_r()
stack栈在SRAM中
BSS不可用,因此不能使用全局/静态变量,只能使用stack栈里的变量和global_data的数据
非SPL阶段,调用dram_init()来设置DRAM,如果SPL阶段已经做了,不会做任何事
SPL阶段,如果需要,可以重写board_init_f()来做你想要做的事,调用
preloader_console_init(),需要设置SDRAM及其他让UART能够工作的事,不需要清除BSS,在crt0.S会
做这件事情的。必须正常返回,不能直接调用board_init_r()
board_init_r()
global_data、SDRAM、BSS 、所有static/global变量均可使用,然后执行main_loop()
非SPL阶段,U-Boot被重定位到内存顶部,然后从这里开始运行。
SPL阶段,SDRAM中的stack栈可操作,前提是CONFIG_SPL_STACK_R定义了
,CONFIG_SPL_STACK_R_ADDR指向SDRAM,preloader_console_init() 被调用,然后加载U-Boot或
者Linux
后面还有一大堆东西,最主要的是U-Boot已经把Linux内核的那套Kconfig机制拿过来了
,所以以后可以像linux那样make menuconfig来配置了。具体的可以执行make help来查看。现在UBoot越来越强大,其实可以看成是纯粹做裸机程序,把linux下能驱动起来的,这里也驱动起来,所
以用linux的Kconfig这样的机制非常好。所以后面一大堆是将CONFIG选项的,以后移植的时候会看
的。
接下来就是BUILD相关的了
Building the Software:
======================
Building U-Boot has been tested in several native build environments
and in many different cross environments. Of course we cannot support
all possibly existing versions of cross development tools in all
(potentially obsolete) versions. In case of tool chain problems we
recommend to use the ELDK (see [url]http://www.denx.de/wiki/DULG/ELDK[/url])
which is extensively used to build and test U-Boot.
注意这一段话。
首先执行make NAME_defconfig,然后make all
- "u-boot.bin" is a raw binary image
- "u-boot" is an image in ELF binary format
- "u-boot.srec" is in Motorola S-Record format
有两种方式可以改变编译输出目录
1. Add O= to the make command line invocations:
make O=/tmp/build distclean
make O=/tmp/build NAME_defconfig
make O=/tmp/build all
2. Set environment variable KBUILD_OUTPUT to point to the desired location:
export KBUILD_OUTPUT=/tmp/build
make distclean
make NAME_defconfig
make all
注意 “O=”会覆盖“KBUILD_OUTPUT=”
然后列出了添加的步骤
If the system board that you have is not listed, then you will need
to port U-Boot to your hardware platform. To do this, follow these
steps:
1. Create a new directory to hold your board specific code. Add any
files you need. In your board directory, you will need at least
the "Makefile" and a "<board>.c".
2. Create a new configuration file "include/configs/<board>.h" for
your board.
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 <board>_defconfig" 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 默认支持的命令
onitor 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
bootz - boot zImage from memory
tftpboot- boot image via network using TFTP protocol
and env variables "ipaddr" and "serverip"
(and eventually "gatewayip")
tftpput - upload a file via network using TFTP protocol
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
nand - NAND memory operations (see doc/README.nand)
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'
支持的环境变量
List of environment variables (most likely not complete):
baudrate - see CONFIG_BAUDRATE
bootdelay - see CONFIG_BOOTDELAY
bootcmd - see CONFIG_BOOTCOMMAND
bootargs - Boot arguments when booting an RTOS image
bootfile - Name of the image to load with TFTP
bootm_low - Memory range available for image processing in the bootm
command can be restricted. This variable is given as
a hexadecimal number and defines lowest address allowed
for use by the bootm command. See also "bootm_size"
environment variable. Address defined by "bootm_low" is
also the base of the initial memory mapping for the Linux
kernel -- see the description of CONFIG_SYS_BOOTMAPSZ and
bootm_mapsize.
bootm_mapsize - Size of the initial memory mapping for the Linux kernel.
This variable is given as a hexadecimal number and it
defines the size of the memory region starting at base
address bootm_low that is accessible by the Linux kernel
during early boot. If unset, CONFIG_SYS_BOOTMAPSZ is used
as the default value if it is defined, and bootm_size is
used otherwise.
bootm_size - Memory range available for image processing in the bootm
command can be restricted. This variable is given as
a hexadecimal number and defines the size of the region
allowed for use by the bootm command. See also "bootm_low"
environment variable.
updatefile - Location of the software update file on a TFTP server, used
by the automatic software update feature. Please refer to
documentation in doc/README.update for more details.
autoload - if set to "no" (any string beginning with 'n'),
"bootp" will just load perform a lookup of the
configuration from the BOOTP server, but not try to
load any image using TFTP
autostart - if set to "yes", an image loaded using the "bootp",
"rarpboot", "tftpboot" or "diskboot" commands will
be automatically started (by internally calling
"bootm")
If set to "no", a standalone image passed to the
"bootm" command will be copied to the load address
(and eventually uncompressed), but NOT be started.
This can be used to load and uncompress arbitrary
data.
fdt_high - if set this restricts the maximum address that the
flattened device tree will be copied into upon boot.
For example, if you have a system with 1 GB memory
at physical address 0x10000000, while Linux kernel
only recognizes the first 704 MB as low memory, you
may need to set fdt_high as 0x3C000000 to have the
device tree blob be copied to the maximum address
of the 704 MB low memory, so that Linux kernel can
access it during the boot procedure.
If this is set to the special value 0xFFFFFFFF then
the fdt will not be copied at all on boot. For this
to work it must reside in writable memory, have
sufficient padding on the end of it for u-boot to
add the information it needs into it, and the memory
must be accessible by the kernel.
fdtcontroladdr- if set this is the address of the control flattened
device tree used by U-Boot when CONFIG_OF_CONTROL is
defined.
i2cfast - (PPC405GP|PPC405EP only)
if set to 'y' configures Linux I2C driver for fast
mode (400kHZ). This environment variable is used in
initialization code. So, for changes to be effective
it must be saved and board must be reset.
initrd_high - restrict positioning of initrd images:
If this variable is not set, initrd images will be
copied to the highest possible address in RAM; this
is usually what you want since it allows for
maximum initrd size. If for some reason you want to
make sure that the initrd image is loaded below the
CONFIG_SYS_BOOTMAPSZ limit, you can set this environment
variable to a value of "no" or "off" or "0".
Alternatively, you can set it to a maximum upper
address to use (U-Boot will still check that it
does not overwrite the U-Boot stack and data).
For instance, when you have a system with 16 MB
RAM, and want to reserve 4 MB from use by Linux,
you can do this by adding "mem=12M" to the value of
the "bootargs" variable. However, now you must make
sure that the initrd image is placed in the first
12 MB as well - this can be done with
setenv initrd_high 00c00000
If you set initrd_high to 0xFFFFFFFF, this is an
indication to U-Boot that all addresses are legal
for the Linux kernel, including addresses in flash
memory. In this case U-Boot will NOT COPY the
ramdisk at all. This may be useful to reduce the
boot time on your system, but requires that this
feature is supported by your Linux kernel.
ipaddr - IP address; needed for tftpboot command
loadaddr - Default load address for commands like "bootp",
"rarpboot", "tftpboot", "loadb" or "diskboot"
loads_echo - see CONFIG_LOADS_ECHO
serverip - TFTP server IP address; needed for tftpboot command
bootretry - see CONFIG_BOOT_RETRY_TIME
bootdelaykey - see CONFIG_AUTOBOOT_DELAY_STR
bootstopkey - see CONFIG_AUTOBOOT_STOP_STR
ethprime - controls which interface is used first.
ethact - controls which interface is currently active.
For example you can do the following
=> setenv ethact FEC
=> ping 192.168.0.1 # traffic sent on FEC
=> setenv ethact SCC
=> ping 10.0.0.1 # traffic sent on SCC
ethrotate - When set to "no" U-Boot does not go through all
available network interfaces.
It just stays at the currently selected interface.
netretry - When set to "no" each network operation will
either succeed or fail without retrying.
When set to "once" the network operation will
fail when all the available network interfaces
are tried once without success.
Useful on scripts which control the retry operation
themselves.
npe_ucode - set load address for the NPE microcode
silent_linux - If set then Linux will be told to boot silently, by
changing the console to be empty. If "yes" it will be
made silent. If "no" it will not be made silent. If
unset, then it will be made silent if the U-Boot console
is silent.
tftpsrcp - If this is set, the value is used for TFTP's
UDP source port.
tftpdstp - If this is set, the value is used for TFTP's UDP
destination port instead of the Well Know Port 69.
tftpblocksize - Block size to use for TFTP transfers; if not set,
we use the TFTP server's default block size
tftptimeout - Retransmission timeout for TFTP packets (in milliseconds, minimum value is 1000 = 1 second). Defines
when a packet is considered to be lost so it has to
be retransmitted. The default is 5000 = 5 seconds.
Lowering this value may make downloads succeed
faster in networks with high packet loss rates or
with unreliable TFTP servers.
tftptimeoutcountmax - maximum count of TFTP timeouts (no
unit, minimum value = 0). Defines how many timeouts
can happen during a single file transfer before that
transfer is aborted. The default is 10, and 0 means
'no timeouts allowed'. Increasing this value may help
downloads succeed with high packet loss rates, or with
unreliable TFTP servers or client hardware.
vlan - When set to a value < 4095 the traffic over
Ethernet is encapsulated/received over 802.1q
VLAN tagged frames.
bootpretryperiod - Period during which BOOTP/DHCP sends retries.
Unsigned value, in milliseconds. If not set, the period will
be either the default (28000), or a value based on
CONFIG_NET_RETRY_COUNT, if defined. This value has
precedence over the valu based on CONFIG_NET_RETRY_COUNT.
关于Command Line Parsing:
There are two different command line parsers available with U-Boot:
the old "simple" one, and the much more powerful "hush" shell
这里提到“hush”,这个之前都没看到过,后面做历史命令及扩展命令时再说。
关于Image Formats:
New uImage format (FIT)
Flexible and powerful format based on Flattened Image Tree -- FIT (similar
to Flattened Device Tree). It allows the use of images with multiple
components (several kernels, ramdisks, etc.), with contents protected by
SHA1, MD5 or CRC32. More details are found in the doc/uImage.FIT directory.
基于FIT,说简单点就是多功能镜像
Old uImage format
基于二进制文件
Linux Support:
虽然U-Boot能够支持任何系统或者应用程序,但其设计的主要焦点还是在Linux上。
Note that U-Boot now has a driver model, a unified model for drivers.
If you are adding a new driver, plumb it into driver model. If there
is no uclass available, you are encouraged to create one. See
doc/driver-model.
这就是前面我说的多功能裸机程序
Building a Linux Image:
-----------------------
With U-Boot, "normal" build targets like "zImage" or "bzImage" are
not used. If you use recent kernel source, a new build target
"uImage" will exist which automatically builds an image usable by
U-Boot. Most older kernels also have support for a "pImage" target,
which was introduced for our predecessor project PPCBoot and uses a
100% compatible format.
要使用U-Boot启动linux,不能使用zImage或者bzImage,可以使用uImage
The "uImage" build target uses a special tool (in 'tools/mkimage') to
encapsulate a compressed Linux kernel image with header information,
CRC32 checksum etc. for use with U-Boot. This is what we are doing:
* build a standard "vmlinux" kernel image (in ELF binary format):
* convert the kernel into a raw binary image:
${CROSS_COMPILE}-objcopy -O binary \
-R .note -R .comment \
-S vmlinux linux.bin
* compress the binary image:
gzip -9 linux.bin
* package compressed binary image for U-Boot:
mkimage -A ppc -O linux -T kernel -C gzip \
-a 0 -e 0 -n "Linux Kernel Image" \
-d linux.bin.gz uImage
所以需要注意的是,在编译内核生成uImage时需要mkimage,它是u-boot的
tools/mkimage。
Boot Linux:
The "bootm" command is used to boot an application that is stored in
memory (RAM or Flash). In case of a Linux kernel image, the contents
of the "bootargs" environment variable is passed to the kernel as
parameters. You can check and modify this variable using the
"printenv" and "setenv" commands:
=> printenv bootargs
bootargs=root=/dev/ram
=> setenv bootargs root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2
=> printenv bootargs
bootargs=root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2
Boot Linux and pass a flat device tree:
First, U-Boot must be compiled with the appropriate defines. See the section
titled "Linux Kernel Interface" above for a more in depth explanation. The
following is an example of how to start a kernel and pass an updated
flat device tree:
=> print oftaddr
oftaddr=0x300000
=> print oft
oft=oftrees/mpc8540ads.dtb
=> tftp $oftaddr $oft
Speed: 1000, full duplex
Using TSEC0 device
TFTP from server 192.168.1.1; our IP address is 192.168.1.101
Filename 'oftrees/mpc8540ads.dtb'.
Load address: 0x300000
Loading: #
done
Bytes transferred = 4106 (100a hex)
=> tftp $loadaddr $bootfile
Speed: 1000, full duplex
Using TSEC0 device
TFTP from server 192.168.1.1; our IP address is 192.168.1.2
Filename 'uImage'.
Load address: 0x200000
Loading:############
done
Bytes transferred = 1029407 (fb51f hex)
=> print loadaddr
loadaddr=200000
=> print oftaddr
oftaddr=0x300000
=> bootm $loadaddr - $oftaddr
On ARM, the following registers are used:
R0: function argument word/integer result
R1-R3: function argument word
R9: platform specific
R10: stack limit (used only if stack checking is enabled)
R11: argument (frame) pointer
R12: temporary workspace
R13: stack pointer
R14: link register
R15: program counter
==> U-Boot will use R9 to hold a pointer to the global data
Note: on ARM, only R_ARM_RELATIVE relocations are supported.  

路过

雷人

握手

鲜花

鸡蛋

发表评论 评论 (3 个评论)

回复 oo隐雪oo 2016-10-14 09:01
不明觉厉
回复 fuchch 2016-10-14 16:14
都是无聊时做的,这个只是发一篇看看会不会有积分。u-boot-2016.07已经移植完了,但移植linux-4.3却一直停滞着,现在也没业余时间整S5PV210了。
回复 905377346 2016-10-19 08:57
不错的分享

facelist

您需要登录后才可以评论 登录 | 立即注册

Copyright ©2011-2024 NTpcb.com All Right Reserved.  Powered by Discuz! (NTpcb)

本站信息均由会员发表,不代表NTpcb立场,如侵犯了您的权利请发帖投诉

( 闽ICP备2024076463号-1 ) 论坛技术支持QQ群171867948 ,论坛问题,充值问题请联系QQ1308068381

平平安安
TOP
返回顶部