Commit Graph

648 Commits

Author SHA1 Message Date
zain wang d38ae1a6d6 fastboot: export CONFIG_RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK
Relate to commit 46a8a26905
("fastboot: add RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK config")
Export config can help us select it easily.

Change-Id: I43a210f1efb35ff679102c8686cbca219d2def97
Signed-off-by: zain wang <wzz@rock-chips.com>
2019-08-20 11:00:56 +08:00
Jon Lin c4d5fc6337 cmd: mtd: fix compiler error
Change-Id: Idc4bcd902c02b5dbd6f5aac631f3977f257f606f
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2019-08-07 17:37:14 +08:00
Jon Lin b99d850cbd Revert "cmd: mtd: Use the subcmd infrastructure to declare mtd sub-commands"
This reverts commit 9671243e8d10defb06f2ea24fac138c87697d7fc.

Change-Id: Ie34f9feb06aa0525c9fa59d79ecf687a9a572491
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2019-08-07 17:37:09 +08:00
Jon Lin b62a0f65a9 Revert "cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n"
This reverts commit a645831ca0962532660e4db3155a8be85e5ca312.

Change-Id: Ida32a1a893b88503cffe432705d5d02921dfab09
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2019-08-07 17:37:05 +08:00
Lin Jinhan e7b6c6a93f dm: crypto: add SHA512 test
Change-Id: If7bb7bb559a9d4d5e70e1f27eabb8995c85872d9
Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
2019-08-05 17:51:21 +08:00
Lin Jinhan 2061474232 cmd: Kconfig: CMD_CRYPTO select SHA512
when CMD_CRYPTO is enabled, SHA512 will be selected.

Change-Id: I2a4dfa1ed024b9a6cc39417836e45ee1309fdfa1
Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
2019-08-05 17:46:03 +08:00
Joseph Chen fbf99d9116 cmd: add "download" to enter rockusb/bootrom mode
Effect order: rockusb => bootrom.

Change-Id: Ie206f565e1c79e72c173c25f6970c93c8306332f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-08-01 10:05:41 +08:00
Adam Ford 1490eb89f4 UPSTREAM: Convert CONFIG_SPI to Kconfig
This converts the following to Kconfig:
   CONFIG_SPI

This partly involves updating code that assumes that CONFIG_SPI implies
things that are specific to the MPC8xx SPI driver.  For now, just update
the CONFIG tests.  This also involves reworking the default for
CONFIG_SYS_DEF_EEPROM_ADDR so that we don't set it when we cannot make a
reasonable default, as it does not cause any compile failures.

Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
(cherry picked from commit f1b1f77060beadbfe9f42a3be00019bd025afbd6)
Change-Id: Ie9f15ada869105eb407f41d4df7eecbaa916b940
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2019-07-23 17:15:32 +08:00
Christophe Leroy 87e4c6020e UPSTREAM: powerpc: mpc8xx: Change CONFIG_8xx to CONFIG_MPC8xx
CONFIG_8xx doesn't mean much outside of arch/powerpc/
This patch renames it CONFIG_MPC8xx just like CONFIG_MPC85xx etc ...
It also renames 8xx_immap.h to immap_8xx.h to be consistent with
other file names.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
(cherry picked from commit ee1e600c13d16febd517ab7d0d2c243db174789b)
Change-Id: I564708bb6517b699749e8a54c013d032f785e459
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2019-07-23 17:15:32 +08:00
Joseph Chen eae0a6b103 cmd: add command "android_print_hdr" support
This is useful for debug.

Change-Id: I6e56255d6e32e692031c6c3226d0dc041433dd48
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-22 19:24:57 +08:00
Joseph Chen 1476830723 cmd: bootrkp: clean up code
Change-Id: Ic76a6cabca67263a792eece7ecc7ee46e521ef97
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-19 11:29:56 +08:00
Hisping Lin b9a7e756c4 lib: optee_client: change the condition for eMMC devices
1.dev_desc->if_type == IF_TYPE_MMC for SD and eMMC device,
  dev_desc->devnum == 1 is SD devices,
  dev_desc->devnum == 0 is eMMC devices
2.SD devices do not have rpmb
3.we prefer to use rpmb for eMMC devices, use security
  partition for nand or SD devices

Change-Id: Ifc21bd4da7c3ee91e2ecc845c343182c78d52dc1
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-07-15 17:06:52 +08:00
Quentin Schulz fb504314e8 UPSTREAM: cmd: mtd: fix compilation warning for help when SYS_LONGHELP=n
cmd/mtd.c:447:13: warning: ‘mtd_help_text’ defined but not used [-Wunused-variable]
static char mtd_help_text[] =
            ^~~~~~~~~~~~~

When SYS_LONGHELP is not defined. After looking at how other commands
work, we should surround the whole help text (even its declaration) with
an #ifdef CONFIG_SYS_LONGHELP, since it's compiled out when calling
_CMD_HELP[1] on the help text variable argument to U_BOOT_CMD.

[1] https://elixir.bootlin.com/u-boot/latest/source/include/command.h#L181

Change-Id: If84aae3167fd8826e33f717b7debefe32920dd0b
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit a645831ca0962532660e4db3155a8be85e5ca312)
2019-07-12 11:02:53 +08:00
Boris Brezillon b3d8fba6e0 cmd: mtd: Use the subcmd infrastructure to declare mtd sub-commands
It's way simpler this way, and we also gain auto-completion support for
free (MTD name auto-completion has been added with mtd_name_complete())

change-Id: I4292fde7affaddd8eb5a51fe8ec4265ae4984a21
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 9671243e8d10defb06f2ea24fac138c87697d7fc)
2019-07-12 11:02:53 +08:00
Jason Zhu 65eeaea569 cmd: cmd_blk: rename the command mtd to mtd_blk
Since the command mtd is used in the file cmd/mtd.c, rename
the command mtd to mtd_blk.

Change-Id: I3a76aa8cc1da3f4b098f376d13fb0cdcf76ab246
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-07-09 15:06:41 +08:00
Patrick Delaunay ee9b3572a4 UPSTREAM: dm: spi: Read default speed and mode values from DT
This patch update the behavior introduced by
commit 96907c0fe5 ("dm: spi: Read default speed and mode values from DT")

In case of DT boot, don't read default speed and mode for SPI from
CONFIG_* but instead read from DT node. This will make sure that boards
with multiple SPI/QSPI controllers can be probed at different
bus frequencies and SPI modes.

Remove also use in boards of the value speed=0 (no more supported)
for ENV in SPI by using CONFIG_ENV_SPI_MAX_HZ=0.

DT values will be always used when available (full DM support of
SPI slave with available DT node) even if speed and mode are requested;
for example in splash screen support (in splash_sf_read_raw)
or in SPL boot (in spl_spi_load_image).
The caller of spi_get_bus_and_cs() no more need to force speed=0.

But the current behavior don't change if the SPI slave is not
present (device with generic driver is created automatically)
or if platdata is used (CONFIG_OF_PLATDATA).

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Acked-by: Jagan Teki <jagan@amarulasolutions.com>
Change-Id: I6f5990b73f33815a7acb9b5da9c90dce48b6211d
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit b0cc1b846fcb310c0ac2f8cbeb4ed5947dc52912)
2019-07-05 19:33:50 +08:00
Miquel Raynal f87151b325 UPSTREAM: cmd: mtd: add 'mtd' command
There should not be a 'nand' command, a 'sf' command and certainly not
a new 'spi-nand' command. Write a 'mtd' command instead to manage all
MTD devices/partitions at once. This should be the preferred way to
access any MTD device.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Change-Id: I68bcf4f0126c3a9d6ae0481dafcfcaab0506bd3f
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 5db66b3aee6f2c057706d8715f7e5c472e82f047)
2019-07-05 19:33:44 +08:00
Jon Lin fe85de89e4 cmd: mtd: rename mtd.c to mtd_blk.c
Change-Id: Ie35d54afdbc0580af06805eca9f0db813db2dfe5
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2019-07-05 19:33:44 +08:00
Adam Ford 577968e566 UPSTREAM: Convert CONFIG_MTD_PARTITIONS et al to Kconfig
This converts the following to Kconfig:
   CONFIG_MTD_PARTITIONS
   CONFIG_MTD_DEVICE

Signed-off-by: Adam Ford <aford173@gmail.com>
Change-Id: I90c45c7716965009c00d18a19f5491f19b1ab8b3
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 9c5b00973bceb7c0192bd6b03672d69b092700b4)
2019-07-05 19:33:40 +08:00
Masahiro Yamada 331c237568 UPSTREAM: mtd: nand: Rename nand.h into rawnand.h
This header was renamed to rawnand.h in Linux.

The following is the corresponding commit in Linux.

  commit d4092d76a4a4e57b65910899948a83cc8646c5a5
  Author: Boris Brezillon <boris.brezillon@free-electrons.com>
  Date:   Fri Aug 4 17:29:10 2017 +0200

      mtd: nand: Rename nand.h into rawnand.h

      We are planning to share more code between different NAND based
      devices (SPI NAND, OneNAND and raw NANDs), but before doing that
      we need to move the existing include/linux/mtd/nand.h file into
      include/linux/mtd/rawnand.h so we can later create a nand.h header
      containing all common structure and function prototypes.

Change-Id: Ia387c26297c268a449e3451c7adfabcd6417b278
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 6ae3900a86b52429bf7a73ad832f0ad02acc2282)
2019-07-05 19:21:04 +08:00
Jason Zhu 06c1e1b3ae cmd: rockusb: fix usb serial number bug
Some special characters will be treated as a path in windows environment,
such as '\\' and '/'. If the usb upload its serial number with these
special characters, the usb drive will unwork. So use '_' to replace them.

Change-Id: Ic249316f2b03b0dcb73680078f122e23003e6e3d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-06-27 08:31:20 +08:00
Jason Zhu b75a3992f5 cmd: mmc: find current device first before find mmc device
Find the current device before find mmc device, otherwise '-1'
will be use as curr_device and error occur. The error log is
"MMC Device -1 not found".

Change-Id: Id6157f73d006f4bbe1c4d105244eb59ca7290c13
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-06-26 10:59:13 +08:00
Jason Zhu de8452aebf cmd: mtd: support mtd command
Change-Id: I5d5548e97535c6d928d2ff84f055de259577c11a
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-06-18 18:02:29 +08:00
Lin Jinhan 5d8287bf26 dm: crypto: support crypto v2 test
Change-Id: Ia6247f9d91780cebf7806a3c7fb606fe0a2de004
Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
2019-06-06 15:00:04 +08:00
Joseph Chen 2ba7147f80 env: add a common env driver for block device
The driver implementation refers to env/mmc.c, the storage media
binding to block layer can use it(Nand/Nor Flash...).

Support configure:
	- CONFIG_ENV_OFFSET
	- CONFIG_ENV_SIZE
	- CONFIG_ENV_OFFSET_REDUND (optional)
	- CONFIG_ENV_SIZE_REDUND (optional)
	- CONFIG_SYS_MMC_ENV_PART (optional)

Change-Id: Ibb16f0dd7af1331f454784968fbdc9002f4b769c
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-24 11:35:28 +08:00
Joseph Chen cc6ac5d64f dm: add crypto uclass and cmd support
Change-Id: I2241c90aca9695cd28bb9ca2a220d0e1af8ca932
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-16 15:27:48 +08:00
Joseph Chen 94cf1096ee power: charge animation: fix cmd compile error
cmd depends on DM_CHARGE_DISPLAY and default y.

Change-Id: I5e685e0020c4aa1da80ffc27e5a576bc8969c3be
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-30 11:38:48 +08:00
Joseph Chen 6213b40154 cmd: CMD_DTMIG: select OF_LIBFDT_OVERLAY
Change-Id: I67d7040d477712169c815273dfaf913a4cf258e7
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-30 10:41:57 +08:00
Joseph Chen c5449fd30c dm: dvfs: don't print fail message when there is no device
Change-Id: I8ec8920972261e8009dfd9306d8ab898460a71df
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-27 08:59:47 +08:00
Joseph Chen 6e15146eff lib: sysmem: refactor code
- import memblk id to manage memory blocks;
- change "sysmem_property" to generic "memblock";
- use alloc instead of reserve for all memory blocks;
- clean up and fix some logic;
- add U-Boot cmd for sysmem;

Change-Id: I614223ce3bf97a7b3566412a9d1864fb30b68fd8
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-26 11:04:33 +08:00
Shunqian Zheng 957c1cf2af usb: rockusb: Forbid data beyond 32MB reading
Simply return magic char if one is trying to read data beyond 32MB.

Fixes: 628c827 ("usb: rockusb: forbid reading data beyond addr 32MB")

Change-Id: If2cdf05dbf9d6dcdd4cf8f9605ab84480fbca32d
Signed-off-by: Shunqian Zheng <zhengsq@rock-chips.com>
2019-03-14 19:24:48 +08:00
Andy Yan 4701d790f4 cmd: bootrkp: return CMD_RET_FAILURE on error
A cmd only returned with CMD_RET_XXX defined
by command_ret_t can ensure it work well when
called from shell.

Change-Id: I16e76ed62928380eaaf3c352efb4df9463b7e72d
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2019-03-08 16:50:55 +08:00
Hisping Lin f4e1db9544 lib: optee_client: add judgment of return value
Change-Id: If616f89ffb2c3ea30afb7bced56a1ca28b1232b2
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-03-06 18:44:39 +08:00
Jason Zhu 562a66d432 cmd: fastboot: test the fastboot memory space availability
Use the sysmem to test fastboot memory is available or not.

Change-Id: I021152827b6948fabd5ea41e111ea20adf43167f
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-05 11:19:41 +08:00
Jason Zhu 628c827194 usb: rockusb: forbid reading data beyond addr 32MB
Forbid reading data beyong addr 32MB to protect user data & firmware. Excess
partial is filled with 0xcc. The addr 32MB is quoted from pre-loader.

Change-Id: I96f4fb3bb0d88a309fef20650863011cd9f0dfd9
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-02-25 17:14:46 +08:00
Jason Zhu b68be486b3 cmd: optee: remove write data to efuse
Preventing customer misoperation causing efuse unused.

Change-Id: Ie0fc3e5d73fb005d73beb0c035580ca13b9b3ba1
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-02-25 09:01:35 +08:00
Joseph Chen deebadb707 cmd: fastboot: print mode state
This avoids user misunderstanding the system is hang
when enter fastboot mode without any warning message.

Change-Id: Ie6238c825342c8e322b2a5be746e4bba020e1ec9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-02-19 11:51:02 +08:00
Tang Yun ping a492b30692 cmd: ddr_tool: update ddr tool to version 1.01
Change-Id: I05ffb164dfa6bb8aa997ab5783c274215dc938f5
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2019-02-15 11:34:03 +08:00
Tang Yun ping fa65566613 cmd: memtester: fix print available address bug
Available address for testing may start from 0x00.

Change-Id: If3468c11a096c55cf7fff93dff0034679791b3a9
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2019-02-15 11:34:03 +08:00
Tang Yun ping d0c76e678b cmd: memtester: add each DQ mask function
Fix DQ to exact level when doing memtester by argument fix_bit and
fix_level.

Change-Id: I4b67b5e499f3e0c4d500d658bc05574f5e50543a
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2019-02-15 11:34:03 +08:00
Hisping Lin df99e5808c cmd: add test case for secure storage
1.mmc testsecurestorage to test secure storage
2.test secure storage in rpmb and test secure storage in
  security partition when use emmc
3.test secure storage in security partition when use nand

Change-Id: Id6f72893c002c5040cb1790051c9685911878df7
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-02-14 19:58:09 +08:00
Kever Yang 620cb65601 cmd: rbrom: fix to fit the MACRO SCOPE
Both cmd and its implement shoud be in the same MACRO.

Change-Id: I93587c425f999d9701d88b1d278fcc2a70d64133
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2019-02-13 16:43:46 +08:00
Jian Qiu c2ba77d93f lib: optee_client: Extract keymaster CA module
Extract keymaster CA module from OpteeClientInterface
refactoring code for keymaster reads and writes form caller module

Change-Id: I1069fce0d29d9d9815f71e7f3b4d231754382acd
Signed-off-by: Jian Qiu <qiujian@rock-chips.com>
2019-01-18 09:09:34 +08:00
Tang Yun ping c337a3c2b1 cmd: memtester: add test mask for test stuck address
Change-Id: Icbcf7e460befcc098c45e4e3efb7fb3c1bcb73a0
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2019-01-15 17:38:18 +08:00
Joseph Chen c0b4a82d39 cmd: nvedit: add "0x" prefix for hex value
Change-Id: Idab53a89d363a9fae6bf3aa98c99f9ba246e5ff9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-14 14:57:26 +08:00
Tang Yun ping d4eae7f5fe cmd: memtester: move some common code to ddr_tester_common.c
1. Moving some common code to ddr_tester_common.c to share with ddr tool.
2. io_map.c get dram bandwidth by using get_ddr_bw().

Change-Id: I90641f35c4474846a2357f4959415bfaa6230769
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2019-01-11 15:16:57 +08:00
Tang Yun ping 3e19306671 cmd: memtester: add cpu data to io remap
Change-Id: Ia9e2e6014c162cc929f5cbcb1559c91245c273bd
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2018-12-27 20:25:50 +08:00
Tang Yun ping 614eb1970c cmd: memtester: fix dram bandwidth to 32bit
For all rk chip, bandwidth is 32bit. Fix to 32bit to improve test
effect.

Change-Id: I4b7f2f3722d6c820886bec46179badc73719496a
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2018-12-27 20:25:50 +08:00
Tang Yun ping 3decc73706 cmd: ddr_tool: add ddr test tool code
RK3328/RK3326/PX30: enable CONFIG_OF_LIVE, CONFIG_ROCKCHIP_DMC and
CONFIG_CMD_DDR_TEST_TOOL.
RK1808/RK3399pro npu: enable CONFIG_CMD_DDR_TEST_TOOL.
When enable, it will create a 'ddr_test' command for user in U-Boot shell.

Change-Id: Iaa286e461d53b1caa4bcc069d37a7aad16a3e5e3
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2018-12-27 20:25:50 +08:00
Masahiro Yamada 0e00a84cde UPSTREAM: libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>
Thomas reported U-Boot failed to build host tools if libfdt-devel
package is installed because tools include libfdt headers from
/usr/include/ instead of using internal ones.

This commit moves the header code:
  include/libfdt.h         -> include/linux/libfdt.h
  include/libfdt_env.h     -> include/linux/libfdt_env.h

and replaces include directives:
  #include <libfdt.h>      -> #include <linux/libfdt.h>
  #include <libfdt_env.h>  -> #include <linux/libfdt_env.h>

Change-Id: I6c0f7e50e8b571106627f25ddac008a62bd2994e
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-12-24 17:20:37 +08:00
Joseph Chen 0eea0d250e dm: add dvfs uclass and wide temperature dvfs support
- add dvfs uclass;
- add dvfs command;
- add a simple wide temperature dvfs driver.

About wide temperature dvfs driver policy, see description in:
drivers/power/dvfs/rockchip_wtemp_dvfs.c

Change-Id: I36a8de6e47f8375bf1795b794c77d96b4571a361
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-12-10 18:03:51 +08:00
Jason Zhu fc1a55637d rockush: add serialnumber to usb_device_descriptor
Change-Id: I498be22dd73ffa8e8844bd9ceedb294b5bba72ce
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-11-23 11:06:51 +08:00
Joseph Chen ee465021fe android: support boot images packed with rockchip android hdr
For some legacy reasons, rockchip use mkbootimg tool to pack android
images with special pack parameters(SDK version lower than 8.1) to
assign kernel/ramdisk/seconds address and page size.

Android hdr on RK3399 SDK-7.1:
   kernel size:      1299808
   kernel address:   60408000
   ramdisk size:     1e6b80
   ramdisk addrress: 62000000
   second size:      41c00
   second address:   60f00000
   tags address:     60088000
   page size:        4000
   header_version:   0
   os_version:       e041114 (ver: 1.7.2, level: 2017.4)
   name:
   cmdline:          buildvariant=userdebug

The kernel/ramdisk/seconds address base is not from 0x10000000 and
page size is not 0x800!

This patch makes bootflow to compatible with above legacy packing.

Change-Id: I663a0d1386694658c97586706ff21ed887d6a2e7
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-11-01 08:42:27 +08:00
Kever Yang d61082e9df cmd: part: use MAX_SEARCH_PARTITIONS for part search
Use Macro instead of hard code.

Change-Id: I8a41a762bb16ca77816871b357ededdde0b1c875
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-09-10 11:16:25 +08:00
Tang Yun ping 133266d48d cmd: add memtester code
Enable memtester by config CONFIG_CMD_MEMTESTER=y

Change-Id: I02c873a8b3be5ee3c9a1cf347b7e3e75cb5336f0
Signed-off-by: Tang Yun ping <typ@rock-chips.com>
2018-08-10 17:45:13 +08:00
Joseph Chen f81a9e78e7 env: fix env_exist/append/update() words match issue
solve some words match mistakes due to strstr().

Change-Id: I79ca9bc9ed1e9aeb5472e158650890023afa3da3
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-08 11:53:05 +08:00
Sam Protsenko 2967d2f74d FROMLIST: cmd: Add dtimg command
dtimg command allows user to work with Android DTB/DTBO image format.
Such as, getting the address of desired DTB/DTBO file, printing the dump
of the image in U-Boot shell, etc.

This command is needed to provide Android boot with new Android DT image
format further.

Change-Id: I2a626f333f604b6f0424aa03feaddab4e8506a3f
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
(am from http://patchwork.ozlabs.org/patch/925871/)
2018-08-06 11:15:19 +08:00
Dingqiang Lin aa16b1f803 cmd: rksfc: change dev if_type
1.In rkflash driver, SPI Nand and SPI Nor are registered as two
different if_type
block dev. They are both the child_dev of sfc;
2.Here we send cmd to "rksfc" to operate it's child-dev spi flash device.

Change-Id: I9314ef9c556f8cfbe023021bd66bebec137a4e71
Signed-off-by: Dingqiang Lin <jon.lin@rock-chips.com>
2018-07-31 14:51:32 +08:00
Kever Yang 2bbf102863 cmd: mmc: do not force init HW in 'mmc dev' cmd
This is a revert to :
a5710920b7 cmd_mmc: make mmc dev always re-probe the HW

For emmc device, we should not re-init the HW with 'mmc dev' cmd,
please use 'mmc rescan' when need HW re-init.

Change-Id: I994d12beb7215db568e7a0ed58be3e36dfda5744
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-07-19 10:18:48 +08:00
Jason Zhu cc527546d3 androidboot: nodify cmd bootavb
1.printf necessary information
2.delete useless function: do_avb_write,
    do_avb_write_ab_metada

Change-Id: I5f932e7774ecf9b383358b3c081369cdc7db0167
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-07-19 09:57:37 +08:00
Jian Qiu 65413a00f9 fastboot: add FASTBOOT_OEM_UNLOCK option
This enables the following fastboot commands:
  fastboot oem unlock
  fastboot oem unlock_accept
  fastboot oem lock
  fastboot getvar oem-unlock

Android 8.1 need the oem unlock status attach to bootargs on boot.

Change-Id: Icc83451336a4dea2cbcf4927287de23bc8e28cb1
Signed-off-by: Jian Qiu <qiujian@rock-chips.com>
2018-07-19 09:56:14 +08:00
Andy Yan 008aee876a boot_android: add runtime compatible for un/compressed kernel image
This patch add auto parse the compress format of kernel image.
Then decompress the compressed kernel image for arm64, as for
arm32 zImage, we only need to load it to a higher memory, then
the kernel will handle the decompress itself.

Test on RK3308 AARCH64 mode (Cortex A35 816 MHZ) boot with eMMC:

------------------------------------------------------------------
Format    |  Size(Byte) | Ratio | Decomp time(ms) | Boot time(ms) |
-------------------------------------------------------------------
Image     | 7720968     |       |                 |     488       |
-------------------------------------------------------------------
Image.lz4 | 4119448     | 53%   |       59        |     455       |
-------------------------------------------------------------------
Image.lzo | 3858322     | 49%   |       141       |     536       |
-------------------------------------------------------------------
Image.gz  | 3529108     | 45%   |       222       |     609       |
-------------------------------------------------------------------
Image.bz2 | 3295914     | 42%   |       2940      |               |
-------------------------------------------------------------------
Image.lzma| 2683750     | 34%   |                 |               |
-------------------------------------------------------------------

Note: the boot time is counted from first ddr init log to first Kernel log.

Change-Id: I73b12ec944fbc8238b0e061a37e2f31aa3093231
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2018-07-14 11:39:04 +08:00
Joseph Chen 00129fb35e env: add env_update_filter()
provide ignore option to filter unused key words from a
list of new string which is ready to be appended.

Change-Id: I82d61ee21ec658e73549de42ad94ed259582cb7a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-07-09 14:18:03 +08:00
Jason Zhu 6651d4c0fb dev_desc: judge dev_desc whether NULL or not before use it
Change-Id: I9d0e2d207a143a02949fbdff2d9ad39f154e4f3e
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-07-04 09:31:05 +08:00
Dingqiang Lin 300175f79e cmd: rknand: add rockchip spi nand u-boot command support
Change-Id: I8e3e6bab2d419b5fe0ab35c3985d1ff88efc5778
Signed-off-by: Dingqiang Lin <jon.lin@rock-chips.com>
2018-06-14 11:06:55 +08:00
Hisping Lin 69285f9ef7 cmd: mmc: remove test vboot hash code
trusty_write_vbootkey_hash will set secure boot flag
when we write vboot key hash success, we should remove it

Change-Id: I7b45739918b10b6847a7f5bf6b7c740f3b802870
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2018-06-06 09:19:41 +08:00
Dingqiang Lin d5f538dc02 cmd: rksfc: add sfc u-boot command
rksfc driver with block interface

Change-Id: I395cf78e939ce9ddbd07a9afad794474f0482542
Signed-off-by: Dingqiang Lin <jon.lin@rock-chips.com>
2018-05-11 11:08:38 +08:00
Jason Zhu 3671d25201 cmd: bootrkp: fix check blk_dread return value error
Change-Id: Ib283c2eeb982479914f8c806f7b54bf081f4c9be
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-05-08 16:02:43 +08:00
Kever Yang 6caa033365 rockchip: add rkimgtest cmd to get boot dev
We need to check if the storage(sdmmc) have IDB data so that
we can use it as boot device.

Change-Id: I7373b8f1a6c4c41c1d2cb1c94cd5d20c0780b5db
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-05-08 11:20:43 +08:00
qiujian 9e68721b27 bootargs : read oem unlock status
Read oem unlock status from optee_client api
and attach it to bootargs

Change-Id: Ib8b1a9bc115ec9cb7e5ce09dc50845cfd7c1c81b
Signed-off-by: Qiu Jian <qiujian@rock-chips.com>
2018-04-03 10:30:56 +08:00
qiujian f61a997e29 fastboot: implement oem unlock commands for bootrkp
Read-write oem unlock status from optee client api.

Implement the following fastboot commands:
  fastboot oem unlock
  fastboot oem unlock_accept
  fastboot oem lock
  fastboot getvar oem-unlock

Change-Id: I99edcee7b60c6d9529e6687291d87f22bf97b771
Signed-off-by: Qiu Jian <qiujian@rock-chips.com>
2018-04-03 10:30:56 +08:00
Andy Yan 4715d15e17 cmd: sf: add test count
Change-Id: I06c0783998152ef5d32f95f6813d5dfe315b4cc2
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2018-03-22 08:55:24 +08:00
Andy Yan a3d7c00b32 cmd: boot: add brom cmd to reboot to brom dnl mode
Change-Id: I797491ebe25af1013732aeee87e61e3ba4bc1689
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2018-03-22 08:55:24 +08:00
qiujian 91c73fb4d1 lib: optee_client:Support attestation
Add methods to read attestation key from the misc partition of
 last 64K, store key and certificate chain data in secure storage.

 When CONFIG_OPTEE_CLIENT is defined,
 uboot support load attestation data.

Change-Id: I8f3bd7096a7856de9e58d294822a818d5fe380ba
Signed-off-by: qiujian <qiujian@rock-chips.com>
2018-03-21 16:38:08 +08:00
Jason Zhu d9d5eb7401 androidboot: add cmd bootavb perm_attr_test
Read and print the perm_attr.

Change-Id: I1e2b73afa1e872eea7abf75d55570b1c8b19c311
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-07 08:59:46 +08:00
Jason Zhu 326572ea3b androidboot: fix compile error in arm64
Change-Id: I68bff703ffbf8ef9a65e4d62a5cf1052bc49ac9b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 11:34:47 +08:00
Hisping Lin 8159cb4fb4 mmc: fix bug in function do_mmc_testrpmb
Change-Id: I35aebe3aefc512928281e2f17ef020b36befc36e
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2018-02-24 15:41:54 +08:00
Kever Yang 3f251879bf boot_android: fix load address for boot image
The kernel image follows the header(default 0x800) in boot.img, we need to fix
the load address for boot.img so that kernel image can align to 0x80000 as
required by ARM64 kernel booting.

Change-Id: I526ff38bfce2d8fd1571aff817ade11086f196e3
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-02-23 10:28:26 +08:00
Jason Zhu 37a7bc39c0 lib: avb: update and modify the avb library
The commit point is updated to google external/avb/
which commit point is cf8c56208d2d9643804a7f123b196c7ebc9af276.

Change-Id: I5a10a8a45d3e9e2c9d20d9b3d44946073c9a49ff
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-02-10 10:41:04 +08:00
Joseph Chen ac1dc0c37a charge animation: export struct charge_animation_pdata
This is the most flexsible way for all fuel gauge driver to get
fdt config info from charge animation platdata.

Change-Id: I33aa52c34f2c62c10b58003a10e5a8d1d6e5d7d3
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-02-09 14:28:54 +08:00
Joseph Chen 3c9ee70130 env: add env_delete()
Change-Id: I3a94942b1670e641c8558c64dabca0155e53e2ea
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-01-31 18:13:53 +08:00
Joseph Chen 046a931055 env: add env_exist()
Change-Id: I153c700ff45a678832b72031787531efadcdb47b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-01-29 17:29:55 +08:00
Joseph Chen 526c692b8e env: add more debug message for env_update() and env_append()
Change-Id: I0d798d91f2bc132accac882ccfeec76d2f6a747e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-01-17 16:28:51 +08:00
Simon Glass 73991b074b log: Add a test command
Add a command which exercises the logging system.

Change-Id: I4eb139b69937c752d7f6fc42dde3f757260b832b
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit ef11ed8239bf02b347e7fb9fc6d980aec0c7810a)
2018-01-17 15:27:28 +08:00
Simon Glass 923fc48db4 log: Add a 'log level' command
Add a command for adjusting the log level.

Change-Id: I51e15c61e860f4f0bdb980f1d7aa88c492f55d49
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit d5f61f272d5b7b86bf6321512ba6326c7c075e72)
2018-01-17 15:27:28 +08:00
Simon Glass 785b4fbf6c Drop the log buffer
This does not appear to be used by any boards. Before introducing a new
log system, remove this old one.

Change-Id: I798cd4aff50b7136ae9f84362185f9f73b04f710
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit c5404b64fb5a35d41f7eff6d12b8ffdb0c851040)
2018-01-17 15:27:28 +08:00
Nobuhiro Iwamatsu 51b432dabb UPSTREAM: cmd: i2c: Fix use sdram sub command with CONFIG_DM_I2C
sdram sub command of i2c command does not support Drivers Model.
This adds Drivers Model support to sdram sub command.

Change-Id: I405d05b9b697715759a68ba71597cd9ae63d9565
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 28df8ed07f2ae936e9af28c146d555ed4d0c122a)
2018-01-17 15:27:28 +08:00
Heinrich Schuchardt 6ff3d5909f UPSTREAM: cmd: blk: remove unreachable code
Remove an unreachable return statement.

Change-Id: I523a83571eade593a08b685519757c1df4ffab25
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 254eedee7f383066b70ac4da01bc792a3256a4b3)
2018-01-17 15:27:28 +08:00
Suneel Garapati 1c7b1b4b19 UPSTREAM: cmd: usb: ignore blk, emulation devices in usb tree/info display
Usb tree/info commands iterate over all usb uclass devices recursively.
Blk uclass devices based on struct blk_desc are created for mass storage
device, treating them as usb uclass devices based on struct usb_device
and referencing usb config interface descriptors cause crash.
To fix, ignore blk and usb_emul uclass devices in usb_show_info
and usb_tree_graph. Also avoid addition of preamble for blk uclass
child devices, otherwise tree dump gets messed up.

Change-Id: If25ca43b08c0918c44583f71282a07c928e5bf53
Signed-off-by: Suneel Garapati <suneelglinux@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit abd7cedb19ab7979467734b3933a39879bd8935a)
2018-01-17 15:27:28 +08:00
Bernhard Messerklinger 853f31c42c UPSTREAM: cmd/fdt.c align data buffer to avoid unaligned word access
Since the compiler is free to place a char array to any address in
memory (in this case the stack), also to a non word aligned address the
function "fdt_prop_parse" runs into troubles upon it wants to write some
(fdt32_t *) to such a variable (if it has been placed to a none word
aligned address).

To avoid this we tell the compiler to always align this scratchpad to a
word aligned address.

Change-Id: I6ea64827a9c245db4ba2a2ff522aaddea647c2f2
Signed-off-by: Bernhard Messerklinger <bernhard.messerklinger@br-automation.com>
Reviewed-by: Hannes Schmelzer <oe5hpm@oevsv.at>
Tested-by: Hannes Schmelzer <oe5hpm@oevsv.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 6dfd65f81fd060a85c961a84f85a286e8e96332c)
2018-01-17 15:27:28 +08:00
Tom Rini c9bf1d5a23 UPSTREAM: cmd/pxe.c: Rework bootargs construction to clarify string checks
As the code currently stands, we first check that the length of the
given command line, along with ip_str/mac_str along with an additional 1
for the NULL termination will fit within the buffer we have, and if not,
we return an error.  The way this code was originally written however
left Coverity "unhappy" due to using strcat rather than strncat.
Switching this to strncat however causes clang to be unhappy that we
aren't enforcing the "1" portion within strncat.  Rather than further
re-work the code to include a "- 1" in this case as well, make the
strcat code only be done within the else side of the length test.  This
keeps both clang and Coverity happy.

Fixes: 48ee0a87bc46 ("cmd/pxe.c: Rework initrd and bootargs handling slightly")
Change-Id: I6a3d3ea54d6b7e1f3c2aed200b2f706f42d570d4
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 59ee8f83b6e77550d5697fced4899e9b5173981f)
2018-01-17 15:27:28 +08:00
Tuomas Tynkkynen b0ec94428e UPSTREAM: Drop CONFIG_HAS_DATAFLASH
Last user of this option went away in commit:

fdc7718999 ("board: usb_a9263: Update to support DT and DM")

Change-Id: Id05869deccb88c1102700dd5af58a8c249e3e9e2
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit c68c03f52badc90951dbf8a054c0e500e04bf365)
2018-01-17 15:27:28 +08:00
Tuomas Tynkkynen 9a544e36a8 UPSTREAM: env: Drop CONFIG_ENV_IS_IN_DATAFLASH
Last user of this option went away in commit:

fdc7718999 ("board: usb_a9263: Update to support DT and DM")

Change-Id: Ie6cec28e4daf26b669f3f35db026427bdb47a5b6
Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 7b7341d7f3ee915c89a7f8ab7054e39872057d90)
2018-01-17 15:27:28 +08:00
York Sun f9b2adb5dc UPSTREAM: cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not defined
CONFIG_CMD_SPL_WRITE_SIZE is used for writing parameters to non-volatile
storage. So far it is only used for NAND. Fix compiling error when this
macro is not used for SD.

Change-Id: I879971e42fb333e1e0ff4e21ce6b34caf8498aa5
Signed-off-by: York Sun <york.sun@nxp.com>
CC: Anatolij Gustschin <agust@denx.de>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit b65ac633f52da596cfa573bb4a597e2edd2318c8)
2018-01-17 15:27:28 +08:00
Tom Rini fafa35c559 UPSTREAM: cmd: Make CMD_LZMA / CMD_UNZIP default y if CMD_BOOTI
In the Linux Kernel on ARM64, the Image.COMPRESSION file is not
self-extracting in the way that x86 and ARM images are.  So when
CMD_BOOTI is enabled we should also default to enabling CMD_UNZIP and
CONFIG_LZMA in order for the user to be able to decompress many of the
common compressions that will be done to an Image file.

Change-Id: Ic7958458ddc16c8b78ea40ff56d380d02883d76a
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 99e46dfc6a9176f6f0680c9dfdf33c97d56336ce)
2018-01-17 15:27:28 +08:00
Sam Protsenko 70c6966892 UPSTREAM: scripts: Move Kconfig contents to cmd/Kconfig
On case-insensitive file systems we have collision between
scripts/kconfig/ directory and scripts/Kconfig file. This patch moves
scripts/Kcofnig contents to cmd/Kconfig to fix that.

Change-Id: Ia60682a7eb9c3379e6e257b07e799b06e304c95f
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 610eec7f0593574c034054ba54fc1c934755e208)
2018-01-17 15:27:28 +08:00
Tom Rini 017aad0449 UPSTREAM: cmd/gpt.c, cmd/nvedit.c, tools/fit_image.c: Rework recent fixes for Coverity
The recent changes to these files did not completely fix the previous
issues, or introduced different (minor) issues.  In cmd/gpt.c we need to
dereference str_disk_guid to be sure that malloc worked.  In
cmd/nvedit.c we need to be careful that we can also fit in that leading
space when adding to the string.  And in tools/fit_image.c we need to
re-work the error handling slightly in fit_import_data() so that we only
call munmap() once.  We have two error paths here, one where we have an
fd to close and one where we do not.  Adjust labels to match this.

Change-Id: I66fafd0ed8d1c290a7773bba5ece8d11bfc15b50
Reported-by: Coverity (CID: 167366, 167367, 167370)
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit bf52fcdef4aac242b5e6b6b9827acf6d69ce1951)
2018-01-17 15:27:28 +08:00
Tom Rini 8ab67e0d6c UPSTREAM: cmd/time.c: Initialize 'repeatable' variable
We cannot leave this uninitialized, set it to 0.

Change-Id: Ic8f3dd4d7395921bf4269a618aaf92a717dbfe46
Reported-by: Coverity (CID: 144426)
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 146dda391126d4f199c7692f2342efcc34b45ebd)
2018-01-17 15:27:28 +08:00
Tom Rini 7f2f366160 UPSTREAM: cmd/pxe.c: Rework initrd and bootargs handling slightly
For the initrd portion of handling our bootm arguments we do not have a
sufficiently long enough buffer for some improbable 64bit cases.  Expand
this buffer to allow for a 64bit address and almost 256MB initrd to be
used.  Make use of strncpy/strncat when constructing the values here
since we know what the worst case valid values are, length wise.

Similarly for bootargs themselves, we need to make use of strlen/sizeof
and strncpy/strncat to ensure that we don't overflow bootargs itself.

Cc: Simon Glass <sjg@chromium.org>
Cc: Alexander Graf <agraf@suse.de>
Change-Id: I86151e4bde53972d9b6105f3a85db93b114e22d8
Reported-by: Coverity (CID: 131256)
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 48ee0a87bc46a6f863ffd9e0396b7a068dd68c50)
2018-01-17 15:27:28 +08:00
Tom Rini bc846a8c08 UPSTREAM: cmd/nvedit.c: Update input handling to cover overflow cases
When we have multiple messages provided, we need to be sure that we do
not exceed the length of our 'message' buffer.  In the for loop, make
sure that pos is not larger than message.  Only copy in at most however
much of the message buffer remains.  Finally, if we have not reached the
end of the message buffer, put in a space and NULL, and if we have,
ensure the buffer is now NULL termined.

Change-Id: I0c4f88803f8525eb6ef0207a6b7fdbec2b43e9ff
Reported-by: Coverity (CID: 165116)
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit c667723ffb50b00585b729ee0da7b0e8c93ffa13)
2018-01-17 15:27:28 +08:00