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
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
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
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
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
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>
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
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
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
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
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
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
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
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
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
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
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>
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>
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>
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>
If failed, we fall back to bootrom download mode.
Change-Id: I003a496d1162e56c459ed54b7d69930a48d91210
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
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>
clean up conditons that allow do rsoc initialization:
1. PMIC is first power on;
2. dsoc or voltage is under threshold value.
Change-Id: Icd5fb5eb72653a38f901b95a3d5e07cfac8c8a7b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
The definition of function configure_cpu() need before rkclk_init().
Change-Id: I791fe6d670af6f36e755978c144c47aaabd8e1b6
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
In file included from drivers/phy/phy-rockchip-inno-usb2.c:8:0:
./arch/arm/include/asm/arch/clock.h:93:29: warning: 'struct udevice'
declared inside parameter list [enabled by default]
./arch/arm/include/asm/arch/clock.h:93:29: warning: its scope is only
this definition or declaration, which is probably not what you want
[enabled by default]
Change-Id: I2a17d469c70897b2a2024c71054b72c76b409f4e
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Support reading start LBA from test command and so that
the developer could understand which area is cleared by
the emmc write test, and he/she recovery the image respectively
from the flashing tool by looking into the parameter file.
Change-Id: Ie050c44bb7ef5c4f0edd5f80370da12420500f08
Suggested-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Theoretically, the UDC register need not reconfig when GINTSTS.USBRst
is set, and only do core reset if the devices was connected before.
This change adds _connected_ flag to check the devices was really
connected or not. As an optimization, reset device address to zero
while GINTSTS.USBRst is set.
This patch fix usb connect failed when continuously perform the
'fastboot reboot-bootloader' command.
Change-Id: I6a78228e147d2274329d922ac3f3ffef19492e7e
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Just like linux, it supports cpu save and restore context
during enter and exit low power mode. With this patch, cpu
is able to suspend with core power off.
Workflow for trap into ATF for system suspend:
cpu_suspend
-> cpu_do_suspend
-> arch specific fn: int (*fn)(unsigned long)
-> psci_system_suspend(deliver 'cpu_resume()' address to ATF)
-> ATF system suspend
<- ATF system resume
<- cpu_resume
<- cpu_do_resume
next instruction
Notice: If needed, you should remember to save and restore GIC by yourself.
Change-Id: I7a7c4989ba0845f5b6880c55a6ea6c47724c99df
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Just like linux, it supports cpu save and restore context
during enter and exit low power mode. With this patch, cpu
is able to suspend with core power off.
Workflow for trap into ATF for system suspend:
cpu_suspend
-> cpu_do_suspend
-> arch specific fn: int (*fn)(unsigned long)
-> psci_system_suspend(deliver 'cpu_resume()' address to ATF)
-> ATF system suspend
<- ATF system resume
<- cpu_resume
<- cpu_do_resume
next instruction
Notice: If needed, you should remember to save and restore GIC by yourself.
Change-Id: I5cb6fb6ac5b6a7f4ec4a975b0fc38250b000b28e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
The underlying drivers should be responsible
for the cache operation.
Change-Id: Iff19807fc5f72295e721511081846e34291d7770
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
This enable bootrkp command to boot a system from
rockchip format partition.
Change-Id: Ia7a1bdaccafc85393cc5156e41d8f44d500af7b8
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Most the current rockchip based boards use adc channel
1 detect the download key, but there ares also some
boards like rk312x base plaform use adc channel2.
So we parse the adc channel from dts if we can get
it, otherwise we use the channel 1 as default.
Change-Id: I2fccb7bf73db67100d7e800f87ac34ac651bba34
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Enter download mode if the download key pressed.
Change-Id: I4827884e1b974bf42d5a38c138c827d079d5983f
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Rockchip bootrom will enter download mode if it returns from
spl/tpl with a non-zero value and couldn't find a valid image
in the backup partition.
This patch provide a method to instruct the system to back to
bootrom download mode by checking the BROM_DOWNLOAD_FLAG register.
As the bootrom download function relys on some modules such as
interrupts, so we need to back to bootrom as early as possbile
before the tpl/spl code override the interrupt configurations.
Change-Id: Ib07315127573f1cc38e158f69679ba4e27857cf2
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
setup_boot_mode function use the same logic but different
mode register address across all the rockchip platforms,
so it's better to make this function reused across all the
platforms, and let the mode register address setting from
the config file.
Also add support for rk312x soc which is a little
special: the bootrom download flag is stored in
a grf register but the other boot mode flags are
stored in anohter pmugrf register.
Change-Id: I2e6a0ba870626adb837975c08094250d47767dac
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
With all targets converted to generate prepadded images, this removes
the spl_boot0 field from our config structure and removes the unused
code-path (for images that are not prepadded): i.e. spl_boot0 is now
implied as 'true' and the code is specialised by removing the other
case.
Change-Id: Ib3d90539acb72e01c31a9da819ba8b46134bcb5e
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
There still are a few CONFIG_SPL_* options selected using defines from
rk3188_common.h instead of via Kconfig. This migrates those over to
Kconfig.
Change-Id: Ib5190f8478a38613879a0182503ad1c720640384
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
The BROM supports forcing it to enter download-mode, if an appropriate
result/cmd-word is returned to it. There already is a series to
support this in review, so this prepares the (newly C-version) of the
back-to-bootrom code to accept a cmd to passed on to the BROM.
All the existing call-sites are adjusted to match the changed function
signature.
Also sync the support to rk3036 / rk3228
Change-Id: I1ea9bc12d6d84a75c043754b0eba7b8959e81d69
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Andy Yan <andy.yan@rock-chips.com>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
The back-to-bootrom implementation for Rockchip has always relied on
the stack-pointer being valid on entry, so there was little reason to
have this as an assembly implementation.
This provides a new C-only implementation of save_boot_params and
back_to_bootrom (relying on setjmp/longjmp) and removes the older
assembly-only implementation.
Change-Id: Ic20320dbbb71744386107686120475943442cdd7
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Andy Yan <andy.yan@rock-chips.com>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>