Commit Graph

57 Commits

Author SHA1 Message Date
Jason Zhu fc04460b2e common: android: support boot recovery system
In android A/B system, there is no recovery partition, but in the linux
system, we need the recovery to update system.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Idac88720b260791b1ad4c51a5ebc7aae9c66ca67
2021-02-21 14:38:23 +08:00
Joseph Chen 5e0c61290d rockchip: resource: add gpio-v2 support for hw-id dtb
It's for rv1126/rk356x.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Ic5a58483e43154c8ba61be466214f87753e47dd3
2021-01-17 15:36:06 +08:00
Joseph Chen 745aeb1a7d common: android: add boot_img_hdr_v3 and vendor boot support
Android Header v3 and vendor boot partition are introduced
from Android-11(R).

Header populate:
  Header v3 is no longer compatible with v0/1/2 header, we
  add populate_andr_img_hdr() to merge boot and vendor_boot
  partition header into struct andr_img_hdr in order to
  compatible with v0/1/2 header.

resource.img:
  The second_addr and second_size fields are removed in v3,
  so we require resource partition to restore resource.img.

A/B system:
  If not A/B system, the boot.img header version is 3 and
  recovery header is version 2.

AVB load image:
  - If allow verification error: the image is loaded by
    ops->get_preloaded_partition() which auto populates
    boot_img_hdr_v3.
  - If not allow verification error: the image is full loaded
    by ops->read_from_partition() which doesn't populate
    boot_img_hdr_v3, we need to fix it.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2afce53c43d782fc57baa01acf9c05518b580840
2020-09-18 14:41:37 +08:00
Joseph Chen f870210e35 rockchip: resource: add comments
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I45434529a44a5e311af1b693c0af56473c770bf9
2020-09-15 10:55:29 +08:00
Joseph Chen 2031371827 rockchip: resource: initial hash_size as 0
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: If2c7c8890dc1d29610c2ba871e3e9c5a1df57dc7
2020-07-28 09:18:22 +08:00
Joseph Chen c495a36ee4 rockchip: resource: fix reading hw-id dtbs failed
- search order: hw-id dtbs => rk-kernel.dtb.
- initial resource list if empty.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I8f174aad96f1afc4b9792d2fe5cffb841a730233
2020-05-06 10:30:08 +08:00
Joseph Chen 45390edfba rockchip: resource: optimise code
- clean init_resource_list();
- support create resource list and read file from memory

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: If308c1dc6f43d0250d81cfa6fb0898d59efe8975
2020-03-16 15:03:51 +08:00
Joseph Chen bc4ccd5396 rockchip: clean rockchip_read_dtb_file() api to boot_rkimg.c
rockchip_read_dtb_file() is top level api which reads dtb from
resource/fit/uImage/distro image, etc.

only leave code about resource image in resource_img.c.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2157ffc204ebd564aa9171de2b8167fbd6c94bcf
2020-02-28 12:38:42 +08:00
Joseph Chen c01d448924 sysmem: simplify the memblk name
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Icfe908ade21d1d8f568db796298f67ba9f013da6
2020-02-28 11:22:04 +08:00
Joseph Chen 6f3562b04c rockchip: resource: remove rockchip_get_resource_file_offset()
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I5c468d69640f223a78dcff1b11981a0d36f3ad8a
2020-01-08 18:04:09 +08:00
Joseph Chen 07f987d8d4 rockchip: resource: support parse logo_kernel.bmp from logo partition
"logo" partition layout, not change order:

|----------------------| 0x00
| raw logo.bmp         |
|----------------------| N*512-byte aligned
| raw logo_kernel.bmp  |
|----------------------|

N: the sector count of logo.bmp

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I2deba013d3963c99664c5bfd69693835a46ba48f
2019-12-10 12:47:52 +08:00
Joseph Chen 8226ac627b rockchip: board: print DTB hash result
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: Icc622b51b415f8aeaf1333dba1491426b906e806
2019-12-03 13:09:20 +08:00
Joseph Chen a84f21ebb8 rockchip: add misc BCB message offset compatibility
Rockchip platforms defines BCB message at the 16KB offset of
misc partition while the Google defines it at 0x0 offset.

From Android-Q, the 0x0 offset is mandary on Google VTS, so this
patch is a compatibility according to android image 'os_version'.

Android os version >= 10 is at 0x0 offset, otherwise at 16KB offset.

Change-Id: I54a7674e2dc2e0c29fc624f17b4453663c9ea462
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-14 11:08:45 +08:00
Joseph Chen e0cee41234 rockchip: resource: add sha1/256 verify for kernel dtb
This is important and necessary for U-disk firmware upgrade to
avoid loading the bad kernel dtb to init USB driver.

Also helpful for normal boot.

Change-Id: I81629991547ccb2930312278295e9737f4827945
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-07 09:37:18 +08:00
Joseph Chen fcecee42b0 rockchip: resource: update print message
At this moment, we just load file entries but not really load file.

Change-Id: I550e6bd90bcdf81f866c0d5f5c6b71faa0ecde19
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-07 09:37:18 +08:00
Joseph Chen ca6fb2913f rockchip: Kconfig: add CONFIG_ROCKCHIP_HWID_DTB for hw-id dtb
Only a few developers need this feature, disable it by default.

Change-Id: I074594c8e47c34a05324e363d11613383f3528a7
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-07 09:03:38 +08:00
Joseph Chen a6926964ec rockchip: resource: clean rockchip_read_dtb_file()
Remove unused rockchip_get_resource_file_size().

Change-Id: I5fd24f68b226e9b3ae3a36e574f5efd8c8728e65
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-07 09:03:38 +08:00
Joseph Chen f2b98302da rockchip: resource: remove android a/b slot append
The partition disk layer takes over the responsibility of
slot suffix appending.

Change-Id: Ia02f5b8635676d49ec60eec7d3930740f2ba5ee4
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 15:43:46 +08:00
Joseph Chen 6069a2cc24 rockchip: resource: fix/optimise some code logic
- alloc sysmem after load kernel dtb successfully;
- allow distro kernel dtb to be loaded later than other
  resource file, that is not controlled by code condition
  "if (list_empty(&entrys_head))".

Change-Id: If1657289a4f8980ad7d7a5df7da0e061aab21504
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-11-04 14:53:45 +08:00
Bian Jin chen a0614e0a98 rockchip: resource: fix dtb addr error in hdr_v2.
dtb addr should add the size of recovery_dtbo when
recover_dtbo is included.

Change-Id: I97f7bd6e248f61413b530972abe46c3236bd0b01
Signed-off-by: Bian Jin chen <kenjc.bian@rock-chips.com>
2019-09-17 10:40:39 +08:00
Joseph Chen d0f492c85c rockchip: resource: improve comment for init_resource_list()
Change-Id: Ic6ac812976b063c6991e33d128e5abe11832c78e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-09-09 09:17:28 +08:00
Joseph Chen bbe32cd5bf rockchip: resource: support parse dtb from dtb position of android image
- the dtb position was added in boot_img_hdr_v2;
- required for Android Q or later.

Change-Id: Ia0536f0fd68a4cdfc55356c6371d1b781f655a9a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-09-06 11:45:49 +08:00
Joseph Chen 4ebf6738fd rockchip: resource: add function replace_resource_entry()
Change-Id: I4c038c6812eab39fedab96942c4cf389bf9e668e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-09-06 11:45:32 +08:00
Joseph Chen 4f74cb3014 rockchip: resource: add comments and header check
Change-Id: I49b47d8716767014987c5913826ee7217869ae99
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-09-06 11:45:32 +08:00
Joseph Chen e6bda4b2ed rockchip: resource: support parse dtb from second position
If the seconds position is not a resource file, maybe it's a
dtb file.

Change-Id: I819cb0ff9c702c306000bf30fb47891009e4ff32
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-08-29 13:02:58 +08:00
Joseph Chen 0905295234 rockchip: resource: clean up code
Change-Id: If133cba598752ce1a1eeed1e6432e7dffa2c5112
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-08-29 13:02:58 +08:00
Joseph Chen e8b8350080 rockchip: resource: dump android version and build time
It prints like: "Android 8.1, Build 2019.7", maybe helpful
for debugging.

Change-Id: I10acbb6e8d864ae2daa2621bf9cfdf4b902a49b4
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-19 11:30:53 +08:00
Joseph Chen 1d30bcc50c rockchip: resource: support parse "logo" partition picture
We provide a "logo" partition for user to store logo.bmp
and update from kernel user space dynamically.

This patch follows the rkdevelop usage:
- Only support store one picture named "logo.bmp";
- Use "dd" command to generate partition image with logo.img
  eg: "dd if=logo.bmp of=logo.img count=1 bs=19456"

Change-Id: Iffde4d123e303c010d99cd446c241a535bce1dcf
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-07-12 11:58:13 +08:00
Joseph Chen ff21a545f5 rockchip: resource: fix parse gpio base address error
We should parse node name to identify the gpio port before
reading base address, it avoids to use miss match address.

Move out gpio_parse_base_address() from sub string parse is
better.

Set gpio as input mode before reading.

Change-Id: Iffd4ef7f3ceb1bb56a65680265af74ca50b14712
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-29 16:36:08 +08:00
Joseph Chen a0ceee9227 rockchip: support early load dtb from distro images
It is optional to use dtb from distro images to initialize
periph drivers when kernel dtb function is enabled.

Change-Id: I7119962ba61d84c5ccdf2e515e21bb347e50b91b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-04-08 20:55:08 +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 01ff14b054 rockchip: resource: add return value validation
Change-Id: I3ed362564e7aed48fc212f299f3712fdbc19ee53
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-03-07 10:13:40 +08:00
Joseph Chen 2c9d117912 sysmem: fdt: reserve more CONFIG_SYS_FDT_PAD size for fdt
Sometimes, framework or user would call fdt_increase_size() to update
fdt size, it's better reserve more space to avoid sysmem gives the fdt
region overflow report.

The CONFIG_SYS_FDT_PAD default value is sync with bootm framework
in: common/image-fdt.c

Change-Id: I363e9a4182e13b1628a76666acd8272d25db659d
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-02-19 14:37:36 +08:00
Joseph Chen 5315192f60 rockchip: resource: add resource hdr magic validation
It fixes the dead loop issue of "bootrkp" command:
	......
	=Booting Rockchip format image=
	boot: invalid image tag(0x0)
	boot_rockchip_image ramdisk part boot read error
	bad resource image magic:
	DTB: rk-kernel.dtb
	invalid entry tag
	invalid entry tag
	invalid entry tag
	invalid entry tag
	......

Change-Id: Ia15f315eee94dce06800139ff547ebeee3847cae
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-02-12 17:40:24 +08:00
Joseph Chen 6bc040a32c rockchip: resource: import sysmem to alloc fdt buffer
sysmem avoids memory block overlap with each other.

Change-Id: I0013c3d05c69e19286cf1c76f936a17eaab1db49
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-24 15:33:12 +08:00
Joseph Chen 4ec36d6839 rockchip: resource: add interface to get resource file size
clean up code and add comment for other interfaces.

Change-Id: Ibc64978d8db595c4fe76432faca77cdad9c949e6
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-01-24 15:33:12 +08:00
Joseph Chen 5af94f7887 android: get fdt by suitable ways
We may have special operations for fdt(optional):
- apply fdt overlay;
- select fdt by adc or gpio;

We can't read default rk-kernel.dtb and pass it to kernel,
call rockchip_read_dtb_file() to get dtb.

Change-Id: I3aba002b0cfe324cc7c3852bf8b9561575590fd4
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-10-07 09:19:03 +08:00
Joseph Chen 48898c5011 rockchip: resource: print fdt from which partition
it's mainly for debug.

Change-Id: I4627c8a3f636ac226bcb2d7ac7d0b60a1019b038
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-09-29 10:33:04 +08:00
Joseph Chen b15a0aa284 rockchip: resource: add CONFIG_ADC for rockchip_read_dtb_by_adc()
Change-Id: I77ccb8b7a18995e913e69fea2eba955ef0ae848c
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-09-17 09:32:28 +08:00
Dayao Ji 9f9a9f6d1f rockchip: resource: get resource from boot partition when AB is enable
In AB system, build recovery as boot, there is no recovery partition
any more.

Change-Id: I434102d589b369a48ed71c6be3635a9a84f788e0
Signed-off-by: Dayao Ji <jdy@rock-chips.com>
2018-09-10 11:14:19 +08:00
Joseph Chen 10660eccef rockchip: resource: improve error and debug message
Change-Id: I35cb6229048952f35701e33b30fb30fcca93a7ca
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-09-04 09:23:05 +08:00
Joseph Chen 1c2bd90493 rockchip: resource: fix read dtb by gpio hw id failed
- every bank is 8 pins, i.e. A0~A7, B0~B7, ...;
- add more quote for "cached_v[]";

Change-Id: I0e6a3ec5e66b95074894c893acd767ce83d34fec
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-20 10:15:20 +08:00
Joseph Chen edac97f481 android: dtbo: enable depends on CONFIG_CMD_DTIMG
Change-Id: I04ba7d39fed1b5c6950a3882f04de5420dfcff2e
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-09 14:23:17 +08:00
Joseph Chen b4a9471978 rockchip: add fdt overlay after read kernel dtb
Change-Id: If8d6f9d8efa735514e9152dd9d4cda43436f7d18
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-06 11:15:19 +08:00
Joseph Chen b498696e73 rockchip: resource: add more quote
Change-Id: I4a9a25cacd032977f952956af83e4c1d91e239a9
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-08-02 14:24:30 +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
Joseph Chen c5ffdb29c3 rockchip: resource: fix resource double found issue
It should not try to find dtb from resource partition depends
on boot mode, otherwiser in boot normal mode, it try to load
dtb from resource partition when we use boot.img(AOSP).

Change-Id: Ic27bb76ecbf80794e8c7298d209f139176ccef78
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-06-06 17:55:12 +08:00
Joseph Chen 740107bb19 rockchip: support alternative kernel dtb depends on adc/gpio
1. support adc value recognize;
2. support gpio value recognize;

Change-Id: I8bcbdd914405184d46029c4995c09b09e36c7ea3
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-05-11 11:12:35 +08:00
Kever Yang 3bea61eda0 rockchip: resource: try resource part if no boot part found
In some project, eg.Linux OS, RKIMG do not have a ramdisk, we don't
need boot.img and boot partition in this case, so we need to get
the resource from resource.img instead of error return.

Change-Id: I88a1f8d7c532e9021f7dfa6c320049ed99f8f764
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-05-07 17:38:51 +08:00
Jason Zhu 2301a6f51c rockchip: resrouce_img: support a/b
If apply the a/b system, open the macro CONFIG_ANDROID_AB.
Then get the dtb from the boot '_a' or '_b' image.

Change-Id: I21ad9d5a5e6e63e26bc16b1aeeb2e690c669a535
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
2018-03-05 14:42:53 +08:00