Commit Graph

435 Commits

Author SHA1 Message Date
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
Frank Wang 1bca07a1ff usb: gadget: composite: add null pointer check
The cdev->config means the currently active configuration and
it might be null, fix it by adding null pointer check.

Change-Id: I18261653436186c342b447c24ef46a8acc42825f
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2019-06-28 14:42:13 +08:00
Frank Wang 19652be07e gadget: rockusb: fix cmd exception for r/w vendor storage
It should be marked sense_data error when r/w vendor storage failed.

Change-Id: I7e298d4f700ac3ca9648e973258cff521c41ec03
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2019-06-17 14:24:47 +08:00
Jason Zhu 41386edd8d fastboot: add oem command to init ab metadata
The command is: fastboot oem init-ab-metadata

Change-Id: I879929a8a6e1c133725267c94492b2f2495ba5b4
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-05-09 16:48:12 +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 3cf641a815 fastboot: support write&read perm attr rsa certificate
Change-Id: Iab2ca981dedc188c61c60cd8cebd0f01c5896d44
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-03-08 15:32:09 +08:00
Jason Zhu af5a201234 usb: gadget: rockusb: test IF_TYPE_SD when read capacity
Since the sd card is similar to mmc device.

Change-Id: Ifb21a58f96f806388f5e2bb50b607678fce0d97b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2019-02-22 14:52:48 +08:00
Tony Xu 700a366893 drivers: usb: Add readback check when write keybox
Change-Id: I969012e391bd8b6b764d259379d610853cd163b5
Signed-off-by: Tony Xu <tony.xu@rock-chips.com>
2019-01-31 11:08:44 +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
Tony Xu dfbf26e839 lib: optee_client: move keybox code to write_keybox.c
Change-Id: Ifcd9962a8b802ee2bcbdbd0e88effb4485e5963a
Signed-off-by: Tony Xu <tony.xu@rock-chips.com>
2019-01-16 18:10:16 +08:00
William Wu 26dd3474b3 usb: gadget: add SuperSpeed support to the Gadget Framework
This patch implements the Binary Device Object Store (BOS)
Descriptor for SuperSpeed. It also add SuperSpeed Endpoint
Descriptors for fastboot and rockusb gadget.

Change-Id: I7d858e1b5117d403919f5fdacb40072a5fad336f
Signed-off-by: William Wu <william.wu@rock-chips.com>
2018-10-16 15:22:02 +08:00
Tony Xu f18b06fb49 lib: optee_clientApi: Optimze the function write_keybox_to_secure_storage
Change-Id: Icb88355494eb23c9403fc078adb5f2f46c4a870c
Signed-off-by: Tony Xu <tony.xu@rock-chips.com>
2018-10-16 09:22:57 +08:00
Frank Wang 8659d08d2b usb: dwc2: amend the maximum request length
Amend the maximum request length equate to the maximum transfer
size of endpoind.

Change-Id: I926c23ddf347f33cf166c51c80d099441978ca7e
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-09-12 17:36:57 +08:00
Frank Wang 5b2bcb4f48 usb: dwc2: fix the maximum dieptsizn/doeptsizn
The maximum transfer size supported should be 2^19 bytes
from Table 5-79 (P372) of the DWC OTG Databook V3.10.

Change-Id: I258b6c2119270fa2f31453af86f7eb179359e171
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-09-12 17:36:57 +08:00
tony.xu 6f0347c8c3 usb: gadget: rockusb: write keybox to RPMB
invoke function:
write_keybox_to_secure_storage(uint8_t *uboot_data, uint32_t len).
it only work when the chip support OPTEE_V1

Change-Id: If010b7cab6bab87485d9542af8c04544d27162cc
Signed-off-by: tony.xu <tony.xu@rock-chips.com>
2018-08-20 17:33:46 +08:00
Jason Zhu 90d27e7fed fastboot: split cb_getvar into dedicate functions
The old implementation of cb_getvar is programed in one functions, this
make the cb_getvar huge. So separate cb_getvar in several functions.

Functions:
fb_getvar_all: Get all parameters by cmd fastboot
               getvar all.
fb_getvar_single: Get one parameter by cmd fastboot
                  getvar xxx.
fb_read_var: Parse parameters

Change-Id: I1e795228f8129af82702f8f315cbad349ceec451
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-08-17 11:45:16 +08:00
Frank Wang 0d0c32481d usb: gadget: rockusb: add vendor storage r/w cmd support
At present the vendor storage partition is small than 64K in the
design, so vendor storage r/w commands do not take multi-packet
into consideration, if it is needed, the codes should do a little
change in future. Besides, the RPMB r/w support need to be added
when its APIs get ready.

Change-Id: I621604c99b44c69eb3aff3e01b28a18f35303040
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-08-13 10:25:21 +08:00
Jason Zhu 46a8a26905 fastboot: add RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK config
add RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK config so we can
disable authenticated unlock function when we debug
and unlock devices quickly.

Change-Id: Id60be9ae6c17b59e107709a8041e8940743e5725
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-08-13 09:37:26 +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
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
Kever Yang 5fb597c27d rockchip: rockusb: only fix cmd for WL10/RL10
The definition of cmnd[7] is different for different cmd, so
we can not use the fixup for all cmd.

Change-Id: I0020de4974ecca6075e0512456787089139a67fd
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-06-22 11:45:46 +08:00
Jason Zhu aa74b60729 fastboot: fix cb_upload bug
It will run sleep_thread when call
fastboot_tx_write_str. So add wakeup_thread
to function tx_handler_ul when tx_handler okay.

Change-Id: I25996639bbed7228dc9bc4fb5184ddf2ee19a511
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-14 11:04:46 +08:00
Kever Yang e0023032d6 rockchip: rockusb: update for legacy tool
Update data size for get_flash_id() and do_bad_block_test() so that
legacy tool can till work;
Add warning log for those not supported cmds from legacy tool;

Change-Id: I40e7f5d82a138bef6f8b0cef237c04483e663931
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-06-13 14:42:44 +08:00
Jason Zhu 62b1148596 fastboot: support oem at-get-vboot-unlock-challenge
Change-Id: I34785710a3edc80fbc5e98d4a26c98f8bd12a15b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-13 10:50:36 +08:00
Jason Zhu 542316a9d4 fastboot: support authenticated unlock
Change-Id: I1a92652ab031f370ff37b73dfd2d7e4b2ec957e7
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-06-13 10:50:36 +08:00
Kever Yang d23ec8c4ae rockchip: rockusb: add copatible with legacy upgrade tool
Legacy upgrade tool may not set correct transfer size for cmds,
and for get flash info there no size in cmnd[7], fix it.

Change-Id: I4060d72bb1f814903ed3c5b6b13689609dc905c8
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-06-04 18:09:42 +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
Frank Wang e290ced646 usb: gadget: skip receipent setup if usb config has not been set
We found the following errors were reported when the rockusb
command is executed.

=============================
RKUSB: LUN 0, dev 0, hwpart 0, sector 0x0, count 0xe90000
"Synchronous Abort" handler, esr 0x96000010
ELR:     22e5e4
LR:      22e5dc
x0 : 0000000000000000 x1 : 0000000000000064
x2 : 0000000000000000 x3 : 00000000ff0c0000
x4 : 0000000000000000 x5 : 0000000000000037
x6 : 000000000000000a x7 : 0000000000000007
x8 : 0000000000000008 x9 : 0000000000000008
...

Resetting CPU ...

It is caused by the null pointer in bmRequestType.Receipent.Device
setup, theoretically, Receipent.Device setup should be handled after
the set_configuration request was finished, so skip it if the usb
configuration has not been set.

Change-Id: I42caf375e8d842ad626d85a6a2a21dfb07fb557a
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-04-02 17:50:09 +08:00
Frank Wang c0acb0f2ed usb: gadget: use google's vid and pid for fastboot
Using Google's VID and PID default for fastboot command.

Change-Id: I8deb275f0f6a925b8e0b9668b6ba59abd44b74a5
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-03-06 15:39:56 +08:00
Jason Zhu de78ceae23 fastboot: break fastboot 64 bytes limit
Some message can not be complete transmission because
the fastboot can only transmit 64 bytes one time. So add
sleep_thread() to judge whether the data is complete
transmission before call fastboot_complete().

Change-Id: I9057ffc9ca4b92db8c9ab14e4650d386c5d06254
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-06 15:33:28 +08:00
Jason Zhu 2e40c2c11f fastboot: update fastboot commands
1. cb_oem.
2. cb_flashing.
3. cd_flash.

Change-Id: I6348c53c992b794f37d6d1813be04bd3dc63d1b5
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 20:40:00 +08:00
Jason Zhu 2a1017eb24 fastboot: fix compile error in arm64
Change-Id: I935989c0573e12a95fac5e3b92a37b1764fad2fc
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 11:34:55 +08:00
Kever Yang 174b45448e fastboot: fix compile warning
Change-Id: Ife064a098cbec3689790934eae86b4726f5f027d
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-02-11 19:49:52 +08:00
Kever Yang 6fff026f96 rockchip: usb: dwc2: fix compile warning
Change-Id: Ic0b190aa93378faf28147306d195fbc49c28c34d
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-02-11 19:49:52 +08:00
Frank Wang 912bc5c126 usb: gadget: fix bos descriptor for rockusb
A GetDescriptor(BOS) request always requires the Device Capability
descriptors as part of the BOS information. This patch adds a generic
Device Capability descriptor header to fix it.

Fixes: 8ddd5824c ("usb: gadget: add bos descriptor response for rockusb command")
Change-Id: I6b5976c6f13a6991a7d00c8221ece2a740032a07
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-02-11 17:50:43 +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
Frank Wang 829f2b853d usb: gadget: add getting chip-info command for rockusb
This change adds getting chip-info command support for rockusb.

Change-Id: Ie158c94eb0591e658947f3b0c47f4fc0ec0333d1
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-02-06 18:00:30 +08:00
Frank Wang 5b081643b1 usb: gadget: reset to maskrom support for rockusb
Follow the subcode in reset command and add resetting to maskrom support.

Change-Id: I15bedef6b83b7282f3e1a9ff3663ec56cd3affc8
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-02-02 16:49:57 +08:00
Frank Wang d7386f60fc usb: gadget: amend flash type for rockusb
Add more flash type support for rockusb command.

Change-Id: I8f2a2f6b5d1c3c5fb8824ce726cc3f0b6443d8ef
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-01-31 18:15:07 +08:00
Joseph Chen 866d7966e2 usb: rockusb: set boot normal mode before reset
Change-Id: I7b72a06fbf73a2dbf87fd7d1761dc036f3c40159
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-01-24 18:17:35 +08:00
Frank Wang d015bf411a usb: gadget: correct the capacity value for upgrade tools
Correct the current capacity to support the different storage
devices upgrade.

Change-Id: I2c96183f317f42944887d02af097ff8a8d29cd4e
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-01-23 09:35:09 +08:00
Kever Yang 6f3eb47422 fastboot: fix compile warning
cb_flashing() should be in the same MACRO of cb_flash().

Change-Id: Ic5641a1bf1fb0ab53ad98bdececd028f1e75a5e2
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-01-22 17:52:48 +08:00
Marek Vasut 14595d815a UPSTREAM: usb: gadget: storage: Increase FSG_BUFLEN
Increase the buffer length to be just above maximum permissible value
of 128 kiB . This increases the performance of the UMS and alike by a
factor of 2 - 2.5 as the buffers are less fragmented.

Change-Id: I8b285031fd251b2ebf672c2295a19bfcba77d8c6
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Lukasz Majewski <lukma@denx.de>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit a8c402f45c758235916615757ac537db8e96fc31)
2018-01-17 15:27:28 +08:00
Masahiro Yamada 90aa625c9a treewide: replace with error() with pr_err()
U-Boot widely uses error() as a bit noisier variant of printf().

This macro causes name conflict with the following line in
include/linux/compiler-gcc.h:

  # define __compiletime_error(message) __attribute__((error(message)))

This prevents us from using __compiletime_error(), and makes it
difficult to fully sync BUILD_BUG macros with Linux.  (Notice
Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)

Let's convert error() into now treewide-available pr_err().

Done with the help of Coccinelle, excluing tools/ directory.

The semantic patch I used is as follows:

// <smpl>
@@@@
-error
+pr_err
 (...)
// </smpl>

Change-Id: I921807c1770d36a91e692c48ab477558bb2ed0b8
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[trini: Re-run Coccinelle]
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 9b643e312d528f291966c1f30b0d90bf3b1d43dc)
2018-01-17 15:27:28 +08:00
Seung-Woo Kim 80553dd1d8 UPSTREAM: usb: dwc2: Align size of invalidating dcache before starting DMA
During using dwc2 usb gadget, if usb message size is too small,
following cache misaligned warning is shown:

   CACHE: Misaligned operation at range [bfdbcb00, bfdbcb04]

Align size of invalidating dcache before starting DMA to remove the
warning.

Change-Id: Ibd9040be45da03174d63313e302b994720c7edd3
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit a939af0c748e2ea1eeb8cf47fa9771a95786de70)
2018-01-16 18:17:07 +08:00
Andy Ye 4d0fc66534 fastboot:support attestation commands
Change-Id: I984a107270991a9e9d60e907b9be4e0d0d462671
Signed-off-by: Andy Ye <andy.ye@rock-chips.com>
2017-11-20 10:32:55 +08:00
Jason Zhu 0916e43b54 fastboot: support fuse at-perm-attr writting efuse
In the android things system, the command of fuse at-perm-attr
is used to program the permanent attributes and its hash.The
permanent attributes is written in eMMC RPMB, and its hash is
writen in efuse.

Change-Id: Ib0745100063d18b56e2dfcb638e0c9f7e2ef9b0a
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-20 10:29:57 +08:00
Cody Xie 374a999563 fastboot: usb: Add fastboot cmds to pass bootloadertest.
TEST:
python system/extra/tests/bootloader/bootloader.py --device-type iot

TODO:
"fastboot getvar all" is still NOT implemnted.
Functions should be implemented with actual state.

Change-Id: Ic757694622a5038a9766cedfde26c22935446347
Signed-off-by: Cody Xie <cody.xie@rock-chips.com>
2017-11-20 10:26:12 +08:00
Frank Wang 8ddd5824c5 usb: gadget: add bos descriptor response for rockusb command
Rockchip upgrade tool use bcdUSB (0x0201) field distinguishing maskrom
or loader device at present. Unfortunately, it conflict with Windows 8
and beyond which request BOS descriptor in this case that bcdUSB is set
to 0x0201. This patch adds the HACK codes to fix it.

Change-Id: I6a186139f79ba27f5d9e099493e9e742a29bbe40
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2017-11-16 11:35:33 +08:00
Frank Wang ba437c8c98 usb: gadget: force rockchip vid and pid for rockusb
This change amend USB VID & PID to Rockchip for rockusb.

Change-Id: I3c94e442cc0190d2d3f13424470dd2d84af55eb0
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2017-11-14 12:43:08 +08:00