Commit Graph

46211 Commits

Author SHA1 Message Date
Jason Zhu 38de3d97e4 avb: add avb config to spl and tpl
Change-Id: Idc5102e29c4b66acacda554f3c61903606314025
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:50 +08:00
Jason Zhu 844d3f39ae libavb_user: add config depended on tipc
In the avb_ops_user.c file, we use some
functions provided by tipc, so excute the
functions may depend on tipc. If the config
is not enable, it may compile fail.

Change-Id: I323f7e8d675407f2ec2f9f5358d1696b3b118880
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:50 +08:00
Kever Yang 10a4cc1b35 rockchip: enable USB_FUNCTION_ROCKUSB
Change-Id: I851b16cad86e723739898ee9e6016271463953be
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:50 +08:00
Kever Yang f70bed3112 rockchip: evb-rk3229: enable RPMB
Change-Id: Id608ebf485b56349f4b7aea47d4077ec7f664ac4
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:50 +08:00
Jason Zhu 6c551138ca avb: create avb function for user use
The libavb_user provide some fuctions to get
a/b and avb information from misc or vbmeta
partitions, which can be use in libavb...

It also can use to enable or disable the verification
function by using avb_user_verity_set in the file
avb_user_verify.c.

Since we use fastboot to program our firmware,
some necessary function is provided to fastboot
to get useful information, like slot number, current
slot and so on.

Some functions in the avb_ops_user.c, like read_rollback_index,
depend on the OpteeClientTest.h.

Change-Id: I94f77db30d5c7896724b5da3d218041ebdc1f46a
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:49 +08:00
Hisping Lin ea5fd1c643 mmc: rpmb: Add interface functions
Add interface functions for external programs,
other functions can use it to read and write
rpmb partitions.

Change-Id: Ie94a6586077e1e9f4fc2924d283029f0a4a3e545
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2017-11-14 10:55:49 +08:00
Hisping Lin 87b8e6decf mmc: add mmc cmd to test tipc functions
input mmc testrpmb to test store data to rpmb.

Change-Id: I0b8361bd7a22fc7854e1a94ae4ae81972e523b3b
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2017-11-14 10:55:49 +08:00
hisping abdd243750 lib: add tipc functions
tipc functions is used for uboot communicate
with TEE. uboot can request service for secure
store or secure algorithm.

Change-Id: Ie44095aff4c044feceb5f362abf6e3d24ceb8d4c
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2017-11-14 10:55:49 +08:00
hisping 97a8a90079 rockchip: rpmb: add support for multi block
add support for uboot read Multi block data from
rpmb partition and write Multi block data to rpmb partition.
The previous patch can only read or write one block one time,
and it affect reading and writing efficiency.

Change-Id: I4b0b19a4a0d985e1d08930fdfbce13ffb847d2f8
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
2017-11-14 10:55:49 +08:00
Jason Zhu 3ccd4bb0b4 avb: support vbmeta key_pub verify
Android Things requires specific public key
metadata and verification logic to correctly
verify vbmeta public keys.

This commit provide fuction avb_atx_validate_vbmeta_public_key
to verify the vbmeta.

Change-Id: I227e93b342671b4395cbaa7dea2121cbf0d7234b
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:48 +08:00
Jason Zhu cf7c71c1bf avb: add functions to choose a/b system
This commit is based on google avb, and it
can be getted by https://android.googlesource.com/platform/external/avb.

This new rk_libavb_ab depend on rk_libavb.

This commit provide some useful functions.
The function of avb_ab_flow can be use to
chose a/b system and flow.The other functions
can be used to debug.

Change-Id: I768272286898b36e9a64749ff30bc6ff0cb019a1
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:48 +08:00
Jason Zhu 5b69db0720 avb: add the google avb to lib
The avb lib is provided by google, and it must be
used in the android things to boot and verify
android system. It can be getted in
https://android.googlesource.com/platform/external/avb.

Then we can use the functions suported by avb to program
the a/b and avb code.

Change-Id: I09371fe53cd50233a69533cfa09d5ebca5b10871
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2017-11-14 10:55:48 +08:00
Kever Yang 03204b06ff common: support static_assert()
The static_assert() is support in C11, which may used in source code,
use _Static_assert for it.

Change-Id: Id029c4db3a899c9531c481e55541090e0b92e2b6
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:48 +08:00
Kever Yang 2be87fa7ea rockchip: rk3229: use google vid/pid
Change-Id: I385cdbcd0d97a8ae680898aeb3669a6f00a41954
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:48 +08:00
Kever Yang 2a132aff67 rockchip: rk322x: reserve memory for trsut TA
Change-Id: I10f271018b8aaaaeac4f23680b099b2df1947ab4
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:48 +08:00
Kever Yang f5af8671df rockchip: enable fastboot for firefly
Change-Id: I8f0cbe975e8d63de3988bad7fe8593d460372cc9
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:47 +08:00
Kever Yang 16d3892d44 fastboot: mmc: add response for all ack
To pass the build.

Change-Id: Ifafbb3bd586f4ff0a7def210720e4db16064ec4d
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:47 +08:00
Kever Yang 46eed85588 android: do not compile android boot in SPL
Change-Id: I2797754e320255f751aa9d02f168031dcaa50fb9
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:47 +08:00
Alex Deymo a49a055226 android: Pass the ramdisk to the kernel.
Android kernel image format can include an initramfs image in the same
kernel partition. This patch passes the initramfs to the kernel, which
in the normal boot mode ignores it by passing "skip_initramfs" in the
command line.

Bug: 34346003
Test: `am broadcast -a android.intent.action.MASTER_CLEAR` factory
reseted the device.

Change-Id: I21d89e34a0f54badf3b2e3ad8981cef75f6d5edf
2017-11-14 10:55:47 +08:00
Jocelyn Bohr df6f4a1cdf fastboot: Handle getvar for partition-size
Bug: 36889156
Test: Ran 'getvar partition-size:<partition>' for all partitions on rpi3
Change-Id: Id85a1164ab382f43201a08d3f9d86eb42ad1e3cd
2017-11-14 10:55:47 +08:00
Alex Deymo 170e9eb9d1 android: Fix off-by-one error when joining strings
When concatenating the strings to form a new command line in the
android bootloader flow, the null-terminator was placed one byte after
the end of the allocated string.

Bug: None
Test: booted a rpi3.
Change-Id: I120e09a77bb1c27980e7ce2b5f9b8961424ed0c3
2017-11-14 10:55:47 +08:00
Alex Deymo 180cc7c601 android: Implement A/B slot select.
The android_bootloader_control struct defined in bootloader_message.h
stored the A/B metadata used to decide which slot should we use to boot
the device. This patch implements the bootloader side of the slot
selection in a new "android_ab_select" command which decides the
current slot and updates the metadata as needed.

Bug: 32707546
Test: Booted a rpi3, updated to the other slot.
Change-Id: I9344ff5b76194160d2b466a50e84f4f423b1a98a
2017-11-14 10:55:46 +08:00
Alex Deymo df7cce4361 boot_android: Drop the "mmc" restriction on the partition name.
part_get_info_by_name() was extended to support more than just mmc/efi
partitions. This patch remove this restriction from the
part_get_info_by_dev_and_name() function.

Bug: 32707546
Test: Booted rpi3.
Change-Id: If6399f7d24e99911b3b14a125a6bc1f472b7eecf
2017-11-14 10:55:46 +08:00
Alex Deymo 8062224026 boot_android: Pass the slot from the command.
In order to support booting from either slot, this patch passes the
slot name from the command line.

Bug: 32707546
Test: Booted rpi3.
Change-Id: I30582bd8b1b95dc0f25b0c6624e7909ee4118bd0
2017-11-14 10:55:46 +08:00
Alex Deymo 06f4a8746e Add "boot_android" command.
The new "boot_android" command simply executes the Android Bootloader
flow. This receives the location (interface, dev, partition) of the
Android "misc" partition which is then used to lookup and infer the
kernel and system images that should be booted.

Bug: 32707546
Test: Booted a rpi3 build with Android Things.
Signed-off-by: Alex Deymo <deymo@google.com>

Change-Id: Ibf3f31e38b159d42db7a0835b99ad7ec260fc2a7
2017-11-14 10:55:46 +08:00
Alex Deymo 67dac67453 Initial support for the Android Bootloader flow
An Android Bootloader must comply with certain boot modes and change
the kernel command line accordingly. This patch introduces the Android
boot mode concept which determines whether the device should boot to
one of the following:
 * recovery: which should boot to the recovery image,
 * bootloader: which should boot to the "bootloader" (fastboot) and
 * normal: which should boot to the system image.

The boot mode is determined in part by the Boot Control Block (BCB)
which is stored at the beginning of the "misc" partition. The BCB
is defined in the "bootloader_message.h" file in AOSP, now copied
here as android_bootloader_message.h with minor modifications.

This patch implements the basic boot flow that loads and boots an
Android kernel image assuming an A/B device which implies that it uses
boot as recovery (BOARD_USES_RECOVERY_AS_BOOT in the BoardConfig.mk).
This means that the recovery image shares the same kernel with the
normal boot system image, but stores the recovery image as a ramdisk
which is not used in normal mode.

Among the limitations, this patch doesn't implement the A/B slot
selection, it only boots from the slot "a".

Bug: 31887729
Test: Booted a rpi3 with this flow.

Signed-off-by: Alex Deymo <deymo@google.com>
Change-Id: Ia2932c6f398f1ae713f0cd9670828f84103dca38
update setenv/getenv to env_set/env_get.
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2017-11-14 10:55:46 +08:00
Alex Deymo 76e2a5a6c6 Move Android Image loading logic to image-android.c
This patch moves the Android Image loading logic from the load_android
command to a new android_load_image() function in image-android.c so it
can be re-used from other commands.

Bug: 32707546
Test: Booted the rpi3 with this patch.
Signed-off-by: Alex Deymo <deymo@google.com>
Change-Id: I12d206141ead1b94ebbcc90ee05512a276c7595a
2017-11-14 10:55:46 +08:00
Alex Deymo 95916cf3d6 Add PREUPLOAD.cfg.
Add a PREUPLOAD.cfg file to check the patches before uploading them.

Bug: None
Test: repo upload
Change-Id: I6266360503f5360f968fd0d83bbf209b6f72e43c
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 9ec8daff33 Handle all commands and variables for "fastboot flashall"
Implement the rest of the variables and fastboot commands for flashall.
For A/B related commands, slot A is always selected.

Bug: 31887729
Test: "fastboot flashall" does not result in any unknown commands or
      variables

Change-Id: Iec794a0a0805aeb744157ab25b417443a3fc7f5a
2017-11-14 10:55:45 +08:00
Jocelyn Bohr aba554cc34 Handle slow MMC writes
Flashing a 400Mb sparse system image takes ~10 minutes. The fastboot UDP
protocol expects a response within 1 minute, so during long flash
operations, the device must send fastboot "INFO" packets.

This patch does the following:
  - Separate large writes into writes of size FASTBOOT_MAX_BLK_WRITE.
    This parameter was tuned by hand to result in a ~10 second write.
  - Keep a timer and send an INFO packet every 30 seconds.
  - Adjust the sequence number in the header of the fastboot OKAY packet
    to account for any INFO packets sent during flashing.
  - Reduce busywaiting in the bcm2835 MMC driver. This change is based on
    what the kernel does, and doesn't seem to corrupt the MMC. Without
    this change, "flashall" takes 25 minutes.

Bug: 31887729
Test: "fastboot -s udp:$RPI_IP flashall" works, rpi3 boots
      - Compute CRC checksum over every write to verify written data
        was not corrupted.

Change-Id: Ib17ef6a85715705a8b5f722a8b7d3e5fd1a6625d
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 0eda6822d0 Implement fastboot continue, reboot, reboot-bootloader, boot.
Add functions to respond to fastboot continue, reboot, and
reboot-bootloader. Continue continues the normal android boot process.
Reboot-bootloader writes a message to the start of the fastboot
buffer, to be parsed at the start of the android boot process. Boot
boots the previously downloaded image from memory.

Bug: 31887729
Test: - Sending "continue" boots into android.
      - Sending "reboot" reboots the device.
      - Sending "reboot-bootloader" reboots the device, and the
        message persists in memory.
      - Sending "boot boot.img" boots into kernel.

Change-Id: I8b14724de4612450ccc382bb7532edb993e6e8a4
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 8b464fa913 Implement fastboot flash and erase.
Add function to respond to fastboot flash and erase. Flash writes the
previously downloaded image to indicated partition. Erase clears the
indicated partition. fb_flash and fb_erase are essentially wrappers
for fb_mmc_flash_write and fb_mmc_erase, which are implemented in
common/fb_mmc.c.

Added common/fb_common.c, where fastboot_okay/fail are implemented.
common/fb_mmc.c assumes fasboot_okay() and fastboot_fail() are
implemented, but they were tied to the fastboot USB implementation.
This refactor adds the response string as a parameter to
fastboot_okay/fail, instead of modifying a global.

Bug: 31887729
Test: FLASH:
      - Create file "foo" containing 2048 chars = "-"
      - Start "fastboot udp" on device and run
        "fastboot -s udp:$RPI_IP flash misc foo" from host
      - From U-boot console, read into memory the first 4 blocks from
        misc partition, observe each byte is "-".

      ERASE
      - Start "fastboot udp" on device and run
        "fastboot -s udp:$RPI_IP erase misc" from host
	  - From U-boot console, read into memory many blocks from misc
        partition, observe each byte is 0x00

	  Configs that use fastboot USB implementation still build.

Change-Id: I5bd54868990bd9d5736d0969b3db240c2926eeec
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 45930fc17b Implement fastboot download.
Adds function to respond to fastboot download, and copy downloaded
image to buffer in RAM.

Bug: 31887729
Test: - Create file "foo" containing 2048 chars = "-"
      - Start "fastboot udp" on device and run
        "fastboot -s udp:$RPI_IP flash boot foo" from host
      - Observe that rpi received 2048 bytes of data, and
        CONFIG_FASTBOOT_BUF_ADDR contains "-"*2048

Change-Id: Ib42378448627b48c629af89f39a0394db93c3824
2017-11-14 10:55:44 +08:00
Jocelyn Bohr 02ad78925c Handle Fastboot packet types, implement getvar.
This patch adds functionality to parse Fastboot packet types, and send
a response to getvar commands.

Bug: 31887729
Test: Responds to getvar commands with correct values for variables
      version, bootloader-version, downloadsize, serialno.

Change-Id: I752a6119d3019745f20defbb1f0c13dba1f24221
2017-11-14 10:55:44 +08:00
Jocelyn Bohr 965eda410b Add support for fastboot command over UDP
The Raspberry Pi does not support USB device mode, so fastboot over
USB does not work. This patch adds support for and partially
implements the device side fastboot UDP protocol as a U-boot command.
It requires an ip address set and ethernet initialized.

- Modify U-boot fastboot command to do fastboot over UDP
- Add net/fastboot.c, which implements fastboot server functions
- Handle QUERY and INIT fastboot packets
- Add CONFIG_UDP_FUNCION_FASTBOOT to enable fastboot over UDP

Bug: 31887729
Test: Tested with fastboot, responds correctly to query and init
      packets.

Change-Id: I4045abaf7a4455d756b7c1c00215afaa90c70a6e
2017-11-14 10:55:44 +08:00
Alex Deymo 83a51ebaaa Add 'load_android' command to load Android images.
Android kernel images include a header that specifies addresses and
kernel size. This patch adds a command to load these images from
storage without specifying the size or address of them, and parsing
them from the header instead.

Bug: 31636643
Change-Id: I84a9cf82cff78ce2299b1981c4f6f9a5720e4d0d
2017-11-14 10:55:44 +08:00
Alex Deymo dd3908179b rpi: Capture the device tree passed from the bootloader.
The Raspberry Pi bootloader (bootcode.bin and start.elf) will load
the device tree from the same FAT partition and combine it with
device tree overlays specified in config.txt. This device tree is then
passed to the kernel (in this case U-Boot) in the r2 register.

This patch retrieves the machine id (r1 register) and the device tree
(r2 register) passed to U-Boot and store those in environment variables
on boot so boot scripts can refer to those and pass them to the kernel.

When CONFIG_OF_BOARD is defined, the same device tree passed to U-Boot
will be used in lieu of bundling one with the U-Boot image at build
time.

Bug: 31636643
Test: Booted a Raspberry Pi3 passing the DT from the bootloader.
Change-Id: Ibf9c754719b3e0f41d20382833abf853ba7613e2
2017-11-14 10:55:44 +08:00
Joseph Chen 8f9ff70555 power: charge animation: exit charge if not boot normal mode
exactly for exit charge when detect boot recovery mode now.

Change-Id: I72cdc6cab58d1a825f6a9f036abc0cf13dbcc443
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-13 09:52:47 +08:00
Joseph Chen 145fcb5cde rockchip: add rockchip_get_boot_mode function
Change-Id: Ie1cc9353f05456ad3965260cb0f72bfb2d8a775b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-13 09:52:16 +08:00
Andy Yan dd9a11eaf4 rockchip: rk3128: check bootmode from pmu_sys_reg0
To keep synchronization with other paltforms, RK312x
will also check all bootmode information from one
register--PMU_SYS_REG0(0x0x100a0038).

This change should based on rk3126_ddr_300MHz_v2.09.bin

Change-Id: Ia09c87a2d55337b4d6f3ddc58f1a8dfcef8bb4a2
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
2017-11-13 09:51:02 +08:00
David Wu bab2d2c360 clk: rockchip: Use common interface for pclk_peri
The peripherals pclk rate is the same, use a common interface
for peripherals like i2c, pwm and etc.

Change-Id: Id9668400f2bb24be397adee312da5365e09c9237
Signed-off-by: David Wu <david.wu@rock-chips.com>
2017-11-13 09:49:26 +08:00
David Wu e630a69b2d rockchip: test: Add ethernet test cases
1. Add phy loopback test
2. Add delayline array scaned
3. Add delayline setting
4. Add dhcp boot from network

Change-Id: I00abc1c7acb4659b78e29bffc12f0964e5d02937
Signed-off-by: David Wu <david.wu@rock-chips.com>
2017-11-13 09:48:59 +08:00
David Wu 1eb9d0643a net: gmac_rockchip: export set_rgmii delayline function
We will use the common interface to set gamc rgmii sometimes,
but the set_rgmii is a private ops. So abstract an exposed
interface out for use.

Change-Id: Ie1cd15033465ff324b77de389e57d32b28c3d389
Signed-off-by: David Wu <david.wu@rock-chips.com>
2017-11-13 09:48:50 +08:00
Joseph Chen 885d92d430 rockchip: boot_mode: add 'reboot charge' support
Change-Id: Id64bedc1d0c0774d809a2aa54947aebe7fb8eebe
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 18:38:37 +08:00
Joseph Chen f21199c15e include: rk3128_common: enable preboot command
Change-Id: Iedf21914fd85ba8d817b7c6fe4cf0920453407fc
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 18:38:34 +08:00
Joseph Chen 55aee569aa rockchip: parameter: mtdpart address uses cmdline directly
1. rename RK_BLK_OFFSET to RK_PARAM_OFFSET;
2. parameter.txt should promise partition address is physical.

Change-Id: Ibadc0589c14f6e48475e4db8526535b8a986d944
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 17:21:28 +08:00
Joseph Chen 4853871c4f rockchip: boot mode: use rockusb download mode as first selection
If failed, we fall back to bootrom download mode.

Change-Id: I003a496d1162e56c459ed54b7d69930a48d91210
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 17:16:31 +08:00
Joseph Chen a8b9d02646 power: charge animation: exit charge if detect preboot command.
charge animation will call fuel gauge to set charge current according
to adapter before exit, it promises lower power battery has enough power
supply during some long time preboot command execution.

Change-Id: I7fe5b19a0a48422528956310d5ee272ef556b840
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 17:16:31 +08:00
Joseph Chen 80d1262bce rk3128: fix typo of CONFIG_DM_CHARGE_DISPLAY
Change-Id: I67b5f5d75fab2d97310b8ff81ee3dd906a160449
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 17:16:31 +08:00
Joseph Chen 0130bb7851 fuel gauge: rk816: initialize charge current at probe
Change-Id: Ia2d9a22b39eecaf5a965971caef5bed953f2bf1b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2017-11-10 17:16:31 +08:00