Commit Graph

963 Commits

Author SHA1 Message Date
Joseph Chen fc474da559 lib: sha256: add sha256_csum()
Change-Id: I3b053f9c07df0d124cdbde9f905e309bcd11c84e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-05 12:24:10 +08:00
Joseph Chen eb89f0a81d lib: avb: add partition slot append interface
Dump current slot information is helpful.

Change-Id: I872c29b9a67860703951a4e88e9549be17b94eed
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 15:43:46 +08:00
Joseph Chen 5704c899ed fdtdec: support pack "kern.dtb" to the end of u-boot.bin
- It provides a way to promise kernel dtb can be loaded successfully
  even when the image is damaged.
- This makes developers easily to add what they what just like a "U-Boot" dtb.
- The kern.dtb file is pack into the end of u-boot.bin while ./dts/kern.dtb
  is exist.

Change-Id: I93a36a9c65ea8719e5610cdcbcc7708e5337c53f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 14:53:45 +08:00
Joseph Chen bcf005ba08 lib: sysmem: no need to increase alloc size when base is 0
Change-Id: Ia716956e1a0e980330d6a7f7eb6c89f91e133ddf
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 10:23:52 +08:00
Joseph Chen d65bf0c630 lib: sysmem: fix alloc failed at 0x0 address
The 0x0 address is usually allocated by 32-bit uncompressed kernel
and this alloc action is just a peek. Due to LMB core doesn't support
alloc at 0x0 address, we have to alloc the memblk backword a few bytes.

This patch is mainly to avoid fail message from sysmem/LMB.

Change-Id: I894ae2252a30a7690d10899484266191dfb12d15
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-10-31 16:39:43 +08:00
Jason Zhu 69fdc5969f lib: avb: update and modify the avb library
The commit point is updated to google external/avb/
which commit point is 868db2a514bbb02e166fb55b1592b27de8c9680c.

Change-Id: I10f7c0ac356a7666b518b62e59ccb62277668578
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-09-20 08:50:37 +08:00
Jason Zhu c2bb0fd141 lib: avb: print the permanent attribute certificate is exist or not
Change-Id: I10775dd06a6fb1bfdddcfda37fe2e1178c3fde21
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-09-18 10:34:40 +08:00
Joseph Chen 2227535d49 lib: add sha512 support
Porting from: https://tls.mbed.org/sha-512-source-code.

Update and follow sha1/256.c function name and coding style.

Change-Id: Idbe70b71e54e0e56a88aac5ec306c75fb2237f4f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-08-02 10:34:33 +08:00
Joseph Chen acffe33271 lib: sysmem: add sysmem_alloc_by_name() interface
Change-Id: I9e2fd6d99fdc487396dd9619dc54567bcd2ba242
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-22 14:23:50 +08:00
Joseph Chen 50226c8f95 lib: sysmem: optimise alloc policy
- Allow request region alloc within the first invisiable region reserved by
  bidram when request region has flags M_ATTR_IGNORE_INVISIBLE. This is a
  workaround for some firmware memory layout, eg: on RK3308-AArch32, the ATF
  region is 0~1M(same as RK3308-AArch64), but the kernel would like to alloc
  at 0x00058000.

- Always make kernel reserved-memory alloc successfully and check overlap
  with invisible and sysmem allocated regions in sysmem_overflow_check()
  before bootm. This makes alloc policy more easier.

Change-Id: I533c710a6e69bd930befda441b9ec64415e3f408
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-22 14:23:50 +08:00
Joseph Chen fc7ff0f015 lib: bidram: add bidram_reserved_is_overlap() interface
Check if the region is overlap with reserved regions.

Change-Id: Ifd9b6a4438dcf954b7e48930e31d0c6cd5d1274c
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-22 14:23:49 +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
Hisping Lin 0202ee8aef lib: optee_client: vboot enable if read bootflag == 1 for rk3288
Change-Id: Ic59341a3bd386a5d05cc501a6841556a6375572a
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-07-15 14:33:40 +08:00
Jason Zhu 3120d9d50e avb: do not use lastboot if enable CONFIG_ANDROID_AVB
The avb process have verify next level firmware to ensure its
availability. So there is no need to support lastboot in avb
process.

Change-Id: I1623a2bd93c54802ce0067cad7061ade6cc56313
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-07-09 16:38:02 +08:00
Alexey Brodkin 28386b6dc6 UPSTREAM: lib: Add hexdump
Often during debugging session it's very interesting to see
what data we were dealing with. For example what we write or read
to/from memory or peripherals.

This change introduces functions that allow to dump binary
data with one simple function invocation like:
------------------->8----------------
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len);
------------------->8----------------

which gives us the following:
------------------->8----------------
00000000: f2 b7 c9 88 62 61 75 64 72 61 74 65 3d 31 31 35  ....baudrate=115
00000010: 32 30 30 00 62 6f 6f 74 61 72 67 73 3d 63 6f 6e  200.bootargs=con
00000020: 73 6f 6c 65 3d 74 74 79 53 33 2c 31 31 35 32 30  sole=ttyS3,11520
00000030: 30 6e 38 00 62 6f 6f 74 64 65 6c 61 79 3d 33 00  0n8.bootdelay=3.
00000040: 62 6f 6f 74 66 69 6c 65 3d 75 49 6d 61 67 65 00  bootfile=uImage.
00000050: 66 64 74 63 6f 6e 74 72 6f 6c 61 64 64 72 3d 39  fdtcontroladdr=9
00000060: 66 66 62 31 62 61 30 00 6c 6f 61 64 61 64 64 72  ffb1ba0.loadaddr
00000070: 3d 30 78 38 32 30 30 30 30 30 30 00 73 74 64 65  =0x82000000.stde
00000080: 72 72 3d 73 65 72 69 61 6c 30 40 65 30 30 32 32  rr=serial0@e0022
00000090: 30 30 30 00 73 74 64 69 6e 3d 73 65 72 69 61 6c  000.stdin=serial
000000a0: 30 40 65 30 30 32 32 30 30 30 00 73 74 64 6f 75  0@e0022000.stdou
000000b0: 74 3d 73 65 72 69 61 6c 30 40 65 30 30 32 32 30  t=serial0@e00220
000000c0: 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00  00..............
...
------------------->8----------------

Source of hexdump.c was copied from Linux kernel v4.7-rc2.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Mario Six <mario.six@gdsys.cc>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Stefan Roese <sr@denx.de>

Change-Id: I038b41f51d45d1b853da499578bf8ef384a63730
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit f8c987f8f127f867d96ca74bcd1fcb11d8265b67)
2019-07-05 19:33:39 +08:00
Jason Zhu 63a580aed3 lib: avb: the rsa_key.c is used when enable CONFIG_ROCKCHIP_CRYPTO_V1
Change-Id: If266df70d0969d5a3556e505f39b853cf818a338
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-07-03 09:34:10 +08:00
Jason Zhu c46b3f6d96 lib: add stdlib.c
Since we need to realize standard library function other than use them
with gcc tool chain in U-Boot. So add standard library function here.

Change-Id: I10009c5bbe31fabacd929df3c44218ae9c6a885f
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-07-01 19:17:50 +08:00
Hisping Lin 266906806d lib: optee_client: init rpmb before find_mmc_device
Change-Id: I1f2c3d76c9015f1a59822314df5e92b6355c7827
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-06-26 11:23:32 +08:00
Joseph Chen 2c66f6f37e lib: sysmem: add sysmem overflow check support
Change-Id: Ifcb6e8cd59656b133f56115d104a1bba017c7c1b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-06-26 11:23:12 +08:00
Joseph Chen 556bbbe436 lib: sysmem: add M_ATTR_CACHELINE_ALIGN support
If alloc buffer for storage read/write should be aligned to
cacheline size, please add the M_ATTR_CACHELINE_ALIGN flag
for this region.

Change-Id: I1e5d46405ddacfadd1cdb4670f943996d9b66426
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-06-26 11:23:03 +08:00
Yifeng Zhao e91ae64f65 lib: rockchip: nand: modify udevice_id to compatible with NAND driver include FTL
Modify the opensource nandc driver to compatible with
the NAND driver include FTL,which used udevice_id
"rockchip,rk-nandc".

Change-Id: I67b9beb43b9935f88c98802f6df3507248324a12
Signed-off-by: Yifeng Zhao <zyf@rock-chips.com>
2019-06-25 11:23:21 +08:00
Jason Zhu 4a7c178034 lib: avb: change the hardware rsa verified interface
Change-Id: Id42cf3a829a35514b75f3c5990ce7e00b94f712e
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-06-24 18:31:36 +08:00
Hisping Lin d47d99649e lib: optee_client: v1 add security partition offset when backup data
Change-Id: I331b95c1df8c0124568aad5ee7351bc270946af6
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-06-05 12:30:21 +08:00
Hisping Lin e8c34540a6 lib: optee_client: v2 add security partition offset when backup data
Change-Id: I9abbef68e56c0b2870426e91138bb110240ed69c
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-06-05 12:30:21 +08:00
Joseph Chen 598774ec05 lib: sysmem: add optimization for input base and M_ATTR_PEEK
- handle the case: the input base is 0;
- ignore the head region which can't visible for M_ATTR_PEEK;

Change-Id: I2c3609b9457a5e2e429e849228301bfee0e4c9b0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-28 20:30:36 +08:00
Joseph Chen 89151b4aad lib: avb: use sysmem alloc to load image
Using malloc buffer to load image makes CONFIG_SYS_MALLOC_LEN must be
large enough, sysmem alloc is a better way.

Change-Id: I24e2b86c53b8d3307c0d155fc37cb499c321e1c6
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-22 15:30:20 +08:00
Joseph Chen 661cbb0b92 lib: sysmem: goto out when alloc failed
Change-Id: I8f6fd82f7367c49596475a88bafd19137e2f2f7c
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-15 11:02:14 +08:00
Joseph Chen 3bee194f53 lib: sysmem: add sysmem_can_alloc() interface
Check if the region can be sysmem allocated.

Change-Id: I26a524c1597bee65ab1282da5ec373b9603866ba
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-07 19:46:37 +08:00
Joseph Chen f6e1530165 lib: sysmem: support avb android memblk sysmem alloc
Because avb android image usually needs a large memory buffer,
always alloc avb android memblk right after U-Boot stack is a
better choice to avoid memblk overlap with others.

Since we have overflow protect magic for U-Boot stack, so we add
a pad(4KB) between them.

Change-Id: I72655d022f7e82f1ed9fbb381424d04bc86ccf6a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-07 19:46:37 +08:00
Joseph Chen dcb404a677 lib: sysmem: add sysmem_alloc() interface
Change-Id: I3ae1fe618ba1bb9c7924bb9816884eb26927dc1e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-07 19:46:37 +08:00
Joseph Chen efda1f1db3 lib: sysmem: support M_ATTR_PEEK for memblk
- always return successful for M_ATTR_PEEK;
- add code comments;

Change-Id: I3c7f939ac61d8da5948978de4e70f17576748c91
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-05-07 17:08:36 +08:00
Hisping Lin efb93541fe lib: optee_client: add module name in print func
Change-Id: I6cdcb0870bf5a3915009421e5c8b09584ac2bb6c
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-04-29 11:09:18 +08:00
Jason Zhu 4f2523c3a0 lib: avb: load full partition if allow verification error
Change-Id: I506676512a46ec09d6c617f555f735a24fc4a594
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-04-29 11:08:08 +08:00
Jason Zhu 813227ad54 lib: avb: add init ab metadata interface
Change-Id: Ifad6c8ca70568c2dc8eea0a4ead23e3e7a2a0e74
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-04-29 11:05:35 +08:00
Joseph Chen 305d8903e0 lib: sysmem: improve kernel reserved-memory alloc
- If the region is out of avaiable dram bank, return success;
- region can override allocated memblk with attr M_ATTR_OVERLAP;

Change-Id: I02171cdb51462e9cec3dd955ae3e0aaaa0ee7afd
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-03 10:29:03 +08:00
Joseph Chen 2cb995bc2e lib: sysmem: allow alloc subset of an allocated memblk
Change-Id: I171c5978faf6fc1b3e95cc46c55a2adfe6df0176
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-29 18:29:19 +08:00
Joseph Chen 356575c3e2 lib: bidram: handle only-one dram bank available situation
LMB default init lmb->reserved.region[0] as zero.

Change-Id: Ib46d9630581bb3a03c5846288b16ae805e3e6944
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-29 18:29:19 +08:00
Hisping Lin b86137850e lib: optee_client: change condition for file exist
file not exist if ret < 0, file exist if ret >=0

Change-Id: I1a70b0a41773f03d552c5f6cda82b745d6e81421
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-03-28 14:46:42 +08:00
Joseph Chen a90f2861de lib: sysmem: fix NULL attr.name
Change-Id: I93744c28668d1533ec2bcdaafc9198d8557284a1
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-27 08:59:47 +08:00
Joseph Chen 483d049321 lib: introduce bidram for GD board bi_dram[] memory management
Some platform provides more than one dram banks and reserved firmware
regions (eg. ATF, OP-TEE, etc) by pre-loader dynamically. It means
there are memory holes in board dram layout. What's more, U-Boot will
reserved regions at the late bootflow(eg. firmware reserved for AMP).

So we introduce bidram mechanism to manage GD board bi_dram[], which
provides a way to easily manage memory holes and update bi_dram[]. It
dpends on LMB which provides a good algorithm to manage memory blocks.

What's different from sysmem?
- bidram manage and pass the avaliable memory blocks to kernel;
- sysmem is only for U-Boot memory management to avoid ram overlap,
  it doesn't matter about kernel avaliable memory.

Change-Id: I697cbb80bdc961e4ad5ab94548e2dc93feefde6f
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-26 11:04:33 +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
Joseph Chen ee561e345b lib: avb: AVB_VBMETA_PUBLIC_KEY_VALIDATE select CONSOLE_DISABLE_CTRLC
Clean coding style by the way.

Change-Id: Ib614175e9ea7ceebc49030235b66d82adc57d3a0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-20 15:08:14 +08:00
Hisping Lin b4a0434fc9 lib: optee_client: do not init RK FS if security not exist
Change-Id: I91e780448cee7884c7477cb0b5720f962b2df00d
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-03-15 15:28:38 +08:00
Hisping Lin 472ddf73a4 lib: optee_client: add support for power-off protection
Change-Id: I4babcc1989563a3c707a1cac7e93069031f033dd
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2019-03-15 15:28:38 +08:00
Keerthy e217fe3cbd lib: fdtdec: fdtdec_get_addr_size_fixed remove checks
With 8 bytes addressing even on 32 bit machines these checks
are no longer valid. Remove them.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit f51f6715a5013f37620c38f0430e21d4736e235a)
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>

Change-Id: I07d143dbd4dfeff1ce99d081d1279c4f70fa4e8f
2019-03-12 14:40:07 +08:00
Jason Zhu 74b485fb2b fastboot: delete write perm-attr hash if use pre-loader pub_key
Since we use the pre-loader public key to verify permanent attribute, then
we do not need to write permanent attribute hash to otp & efuse.

Change-Id: Ic5e19fed2fc9405ab5bc7504dd930fd5f02d847c
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 18:12:14 +08:00
Jason Zhu 65f0143b26 lib: avb: verify the perm attr by root public key
Change-Id: I7e06152a21325ffcd785223952fe8ffaff4d5f08
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +08:00
Jason Zhu 1f670f7cc9 lib: avb: get public key by atags
Change-Id: I0d77229585263e81e8be4f5c67a02080c07b0e55
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +08:00
Jason Zhu 9b83ce70a9 lib: avb: add get&set perm-attr cer
Change-Id: I89d3a30f43659ae8c9d107ede5db1590b022440d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +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