Add the defconfig and default environment for the Xiaomi Mi 9 Pro 5G
(crux, SM8150), based on qcom_defconfig plus the phone settings from
board/qualcomm/qcom-phone.config.

- build the devicetree from arch/arm/dts because CONFIG_OF_UPSTREAM is
  disabled for the board: the crux devicetree is not in dts/upstream
  yet
- disable CONFIG_REQUIRE_SERIAL_CONSOLE: the phone has no externally
  accessible UART and U-Boot would panic before bringing up the USB
  console
- probe UFS and bring up the USB CDC-ACM console during preboot so the
  board is usable without a serial port
- enable the pstore command with the ramoops layout used by the
  downstream kernel (0xB0000000, 4 MiB, console/pmsg 2 MiB each), but
  keep CONFIG_CMD_PSTORE_FDT off because that kernel registers its own
  ramoops device
- enable CONFIG_SUPPORT_RAW_INITRD and CONFIG_OF_LIBFDT_OVERLAY to
  chainload Android recovery images with raw ramdisks and DTBO overlays
- keep the fastboot buffer in normal DRAM: 0x1A000000 is below the crux
  DRAM base and cannot be used for DMA; add fastboot_addr_r to the
  default environment

Signed-off-by: Qing Li <[email protected]>
---
 board/qualcomm/xiaomi-crux.env | 50 ++++++++++++++++++++++++++++++++
 configs/xiaomi-crux_defconfig  | 53 ++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 board/qualcomm/xiaomi-crux.env
 create mode 100644 configs/xiaomi-crux_defconfig

diff --git a/board/qualcomm/xiaomi-crux.env b/board/qualcomm/xiaomi-crux.env
new file mode 100644
index 00000000000..de3cf1e4de5
--- /dev/null
+++ b/board/qualcomm/xiaomi-crux.env
@@ -0,0 +1,50 @@
+# Bring-up environment for Xiaomi Mi 9 Pro 5G (crux)
+#
+# The phone has no external UART, so the first job is to bring the USB
+# (CDC-ACM) console up automatically, then drop to the U-Boot shell.
+
+bootdelay=-1
+loglevel=7
+bootretry=-1
+stdin=serial,button-kbd
+stdout=serial,vidconsole
+stderr=serial,vidconsole
+
+# Probe storage and enable the USB serial gadget console on every boot.
+preboot=log level 6; scsi scan; run serial_gadget
+fastboot_addr_r=0xC0000000
+
+serial_gadget=setenv stdin serial,button-kbd,usbacm; \
+       setenv stdout serial,vidconsole,usbacm; \
+       setenv stderr serial,vidconsole,usbacm; \
+       echo "USB CDC-ACM console enabled"
+
+# Handy shortcuts, mapped to the qcom-phone menu too.
+fastboot=fastboot -l $fastboot_addr_r usb 0
+usb_mass_storage=ums 0 scsi 0
+
+# Keep autoboot disabled; leave the board at the U-Boot shell for bring-up.
+bootcmd=echo "crux U-Boot: starting fastboot mode"; fastboot usb 0
+
+menucmd=bootmenu
+bootmenu_0=Boot first available device=bootefi bootmgr
+bootmenu_1=Enable serial console gadget=run serial_gadget
+bootmenu_2=Enable USB mass storage=echo "Press any key to exit UMS"; ums 0 
scsi 0
+bootmenu_3=Enable fastboot mode=run fastboot
+bootmenu_4=Drop to shell=setenv bootretry -1
+bootmenu_5=Reset device=reset
+bootmenu_6=Dump environment=printenv
+bootmenu_7=Board info=bdinfo
+bootmenu_8=UFS device info=scsi info
+bootmenu_9=Reset device=reset
+
+button_cmd_0_name=Volume Down
+button_cmd_0=run menucmd
+
+# Drop the USB CDC-ACM console (its stop() releases the UDC) and
+# start U-Boot's fastboot gadget instead.
+usb_fastboot=setenv stdin serial,button-kbd; \
+       setenv stdout serial,vidconsole; \
+       setenv stderr serial,vidconsole; \
+       echo "ACM stopped, starting fastboot"; \
+       fastboot usb 0
diff --git a/configs/xiaomi-crux_defconfig b/configs/xiaomi-crux_defconfig
new file mode 100644
index 00000000000..ae545e3b957
--- /dev/null
+++ b/configs/xiaomi-crux_defconfig
@@ -0,0 +1,53 @@
+# Configuration for building U-Boot for Xiaomi Mi 9 Pro 5G (crux)
+#
+# Based on qcom_defconfig plus the phone-oriented settings from
+# board/qualcomm/qcom-phone.config, with a crux-specific environment.
+
+#include "qcom_defconfig"
+
+# The crux devicetree is not in dts/upstream yet; build it from
+# arch/arm/dts like other boards whose DT has not been synced.
+# CONFIG_OF_UPSTREAM is not set
+CONFIG_DEFAULT_DEVICE_TREE="sm8150-xiaomi-crux"
+CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="board/qualcomm/xiaomi-crux.env"
+
+# --- phone settings (mirrors board/qualcomm/qcom-phone.config) ---
+CONFIG_PANIC_HANG=y
+CONFIG_CMD_PAUSE=y
+CONFIG_BOOT_RETRY=y
+CONFIG_BOOT_RETRY_TIME=1
+CONFIG_BUTTON_REMAP_PHONE_KEYS=y
+CONFIG_RETRY_BOOTCMD=y
+# Crux DRAM starts at 0x80000000; keep DMA/fastboot buffers in normal RAM.
+CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_USB_FUNCTION_ACM=y
+CONFIG_CMD_UMS_ABORT_KEYED=y
+CONFIG_CONSOLE_RECORD=y
+CONFIG_CONSOLE_RECORD_INIT_F=y
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000
+CONFIG_FASTBOOT_CMD_OEM_CONSOLE=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_OEM_RUN=y
+CONFIG_CMD_FASTBOOT_ABORT_KEYED=y
+
+# Phones have no serial port; without this U-Boot panics early
+# ("No serial driver found") and PANIC_HANG hides everything.
+# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
+
+# Pstore / ramoops (stock crux kernel uses ramoops_memreserve=4M @ 0xB0000000)
+CONFIG_CMD_PSTORE=y
+# The downstream kernel registers ramoops itself via ramoops_memreserve.
+# CONFIG_CMD_PSTORE_FDT is not set
+CONFIG_CMD_PSTORE_MEM_ADDR=0xB0000000
+CONFIG_CMD_PSTORE_MEM_SIZE=0x400000
+CONFIG_CMD_PSTORE_RECORD_SIZE=0x1000
+CONFIG_CMD_PSTORE_CONSOLE_SIZE=0x200000
+CONFIG_CMD_PSTORE_FTRACE_SIZE=0x0
+CONFIG_CMD_PSTORE_PMSG_SIZE=0x200000
+CONFIG_CMD_PSTORE_ECC_SIZE=0x0
+
+# Chainload helpers: raw (gzip) Android ramdisks + DTBO overlays
+CONFIG_SUPPORT_RAW_INITRD=y
+CONFIG_OF_LIBFDT_OVERLAY=y
-- 
2.50.1 (Apple Git-155)

Reply via email to