imx: cortexa7: add support for TechNexion PICO-PI-IMX7D
authorLech Perczak <lech.perczak@gmail.com>
Sun, 24 Apr 2022 22:42:03 +0000 (00:42 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Mon, 11 Jul 2022 12:26:24 +0000 (14:26 +0200)
TechNexion PICO-PI-IMX7D is a NXP i.MX 7Dual based development board in
the well-known "Raspberry Pi" form factor, comprising of PICO-IMX7 SoM
and the PICO-PI-IMX7D carrier board.

Usually bundled with a 5" 800x480 LVDS display with I2C touchscreen and
an Omnivision OV5645 camera on a MIPI CSI bus, on a daughterboard. The
board was previously used primarily with "Android Things" ecosystem, but
the project was killed by Google.

This would not be possible, if not for the great tutorial of setting up
Debian on this board, by Robert C. Nelson [1].

Hardware highlights:

  CPU: NXP i.MX 7Dual SoC, dual-core Cortex-A7 at 1000 MHz
  RAM: 512 MiB DDR3 SDRAM
  Storage: 4 GB eMMC
  Networking:
    - built-in Gigabit Ethernet with Atheros AR8035 PHY,
    - Broadcom BCM4339 1x1 802.11ac Wi-Fi (over SDIO) + Bluetooth 4.1
      (over SDIO + UART + IS2) combo, with Hirose u.FL connector on the
      board,
    - dual CAN interfaces on the 40-pin connector,
  Interfaces:
    - USB-C power input plus USB 2.0 OTG host/device port,
    - single USB-A host port,
    - serial console over built-in FT232BL USB-UART converter with
      micro-USB connector (configuration: 115200-8-N-1),
    - analog audio interface with TRRS connector in CTIA standard,
    - SPI, I2C and UART interfaces available on the 40-pin,
    - mikroBUS connector,
    - I2C connector for the optional touch panel,
    - parallel LCD output for the optional display,
    - MIPI CSI connector for the optional camera

Installation:

1. Connect the serial console to debug USB connector and the terminal of
   choice in another window, at 115200-8-N-1. Ensure you can switch to
   it quickly after next step.

2. Power-on the board from your PC. Ensure your PC can supply required
   current, the board can take more than 1 A in the peak load during
   booting and brownout will result in power-on reset loop. Preferably,
   use charging-capable USB port or connect through self-powered USB
   hub. If U-Boot is present already on the eMMC, interrupt the booting
   sequence by pressing any key and skip to point 7.

3. Ensure the boot mode jumpers J1 and J2 are in correct position for
   USB recovery:

       2   6  2   6
      --------------
      |o o-o||o-o o|
      |o o-o||o-o o|
   J1 -------------- J2
       1   5  1   5

   The jumpers are located just underneath the 40-pin expansion header
   and are of the smaller 2 mm pitch.

4. Download and build 'imx_usb_loader' from:
   https://github.com/boundarydevices/imx_usb_loader.

5. Power-on the board again from your PC through USB OTG connector.

6. Use 'imx_usb_loader' to load 'SPL' and 'u-boot-dtb.img' to the board:

   $ sudo imx_usb u-boot-pico-pi-imx7d/SPL
   $ sudo imx_usb u-boot-pico-pi-imx7d/u-boot-dtb.img

7. Switch to the terminal from step 2 and interrupt boot sequence by
   pressing any key within 2 seconds.

8. Configure mmc 0 to boot from the data partition and disable access to
   boot partitions:

   => mmc partconf 0 0 7 0

   This only needs to be set once. If you were running Debian previously,
   this is probably already set.

9. Enable USB mass storage passthrough for eMMC from U-boot

   => ums 0 mmc 0

10. Optionally, backup previous eMMC contents by reading out its image.

11. Copy over the factory image to the USB device, for example:

    $ sudo dd if=openwrt-imx-cortexa7-pico-pi-imx7d-squashfs.combined.bin \
      of=/dev/disk/by-id/usb-Linux_UMS_disk_0-0:0 \
      bs=8M status=progress oflag=direct

12. Detach USB MSC interface from your PC and U-Boot by pressing Ctrl+C.

13. Ensure that boot mode jumpers are at the default settings for eMMC
    boot:

       2   6  2   6
      --------------
      |o-o o||o o-o|
      |o-o o||o-o o|
   J1 -------------- J2
       1   5  1   5

   If they are not, power-off the board, restore them and power-on the
   board again. Otherwise, if jumpers are set, just reset the board from
   U-Boot CLI:

   => reset

14. The installation is now complete and board should boot successfully.

Upgrading: just use sysupgrade image, as usual in OpenWrt.

Known issues/current limitations:

- OV5645 camera - not described in upstream device tree as of kernel
  5.15. There are staging drivers present in upstream Linux tree for
  i.MX 7 CSI, MIPI-CSI and video mux, and the configuration is there in
  imx7s.dtsi - so this is expected to get supported eventually,
- on-chip ADCs are disabled in upstream device tree, so the kernel
  driver remains disabled as well.

[1] https://forum.digikey.com/t/debian-getting-started-with-the-pico-pi-imx7/12429

Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
[pepe2k@gmail.com: commit description reworded]
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
target/linux/imx/cortexa7/base-files/etc/board.d/02_network
target/linux/imx/cortexa7/base-files/lib/preinit/79_move_config [new file with mode: 0644]
target/linux/imx/cortexa7/base-files/lib/upgrade/platform.sh
target/linux/imx/image/bootscript-technexion_imx7d-pico-pi [new file with mode: 0644]
target/linux/imx/image/cortexa7.mk

index 75d1c7d1d80e03d52d9b86ea3bc38d386f8bb3f3..8ada58e6c1f6add4e8228de57acb543d8958976c 100644 (file)
@@ -5,6 +5,9 @@ board=$(board_name)
 board_config_update
 
 case "$board" in
+technexion,imx7d-pico-pi)
+       ucidef_set_interface_lan "eth0"
+       ;;
 *)
        ucidef_set_interfaces_lan_wan "eth0" "eth1"
        ;;
diff --git a/target/linux/imx/cortexa7/base-files/lib/preinit/79_move_config b/target/linux/imx/cortexa7/base-files/lib/preinit/79_move_config
new file mode 100644 (file)
index 0000000..7bdb2d5
--- /dev/null
@@ -0,0 +1,15 @@
+. /lib/imx.sh
+. /lib/functions.sh
+. /lib/upgrade/common.sh
+
+move_config() {
+       local board=$(board_name)
+
+       case "$board" in
+       technexion,imx7d-pico-pi)
+               imx_sdcard_move_config
+               ;;
+       esac
+}
+
+boot_hook_add preinit_mount_root move_config
index 9a613c43b1a2a3f1ed32fccaf9ffb50f5c19f23c..1bdc2aa4b930f6ccfea474e80894f782a15a02e9 100644 (file)
@@ -1,16 +1,55 @@
-PART_NAME=firmware
-REQUIRE_IMAGE_METADATA=1
+. /lib/imx.sh
+
+RAMFS_COPY_BIN='blkid jffs2reset'
+
+enable_image_metadata_check() {
+       case "$(board_name)" in
+       technexion,imx7d-pico-pi)
+               REQUIRE_IMAGE_METADATA=1
+               ;;
+       esac
+}
+enable_image_metadata_check
 
 platform_check_image() {
-       return 0
+       local board=$(board_name)
+
+       case "$board" in
+       technexion,imx7d-pico-pi)
+               return 0
+               ;;
+       esac
+
+       echo "Sysupgrade is not yet supported on $board."
+       return 1
 }
 
 platform_do_upgrade() {
        local board=$(board_name)
 
        case "$board" in
-       *)
-               default_do_upgrade "$1"
+       technexion,imx7d-pico-pi)
+               imx_sdcard_do_upgrade "$1"
+               ;;
+       esac
+}
+
+platform_copy_config() {
+       local board=$(board_name)
+
+       case "$board" in
+       technexion,imx7d-pico-pi)
+               imx_sdcard_copy_config
+               ;;
+       esac
+}
+
+platform_pre_upgrade() {
+       local board=$(board_name)
+
+       case "$board" in
+       technexion,imx7d-pico-pi)
+               imx_sdcard_pre_upgrade
                ;;
        esac
 }
diff --git a/target/linux/imx/image/bootscript-technexion_imx7d-pico-pi b/target/linux/imx/image/bootscript-technexion_imx7d-pico-pi
new file mode 100644 (file)
index 0000000..7521cce
--- /dev/null
@@ -0,0 +1,18 @@
+echo "PICO-PI-IMX7 OpenWrt boot script"
+
+# Initial setup, avoid overwriting environment every boot
+if test ${bootm_boot_mode} != nonsec; then setenv bootm_boot_mode nonsec; setenv bootcmd run bootcmd_mmc0; saveenv; fi
+
+# Set console variable for both UART and HDMI
+setenv console "console=ttymxc4,115200 console=tty0 video=DPI-1:800x480-32"
+setenv fdt_name imx7d-pico-pi.dtb
+setenv mmcdev 0
+setenv mmcrootpart 2
+part uuid mmc ${mmcdev}:${mmcrootpart} uuid
+
+# Boot from eMMC is the only supported option
+setenv bootargs "${console} root=PARTUUID=${uuid} rw rootwait"
+mmc dev ${mmcdev}
+load ${devtype} ${mmcdev}:${devplist} ${kernel_addr_r} /uImage
+load ${devtype} ${mmcdev}:${devplist} ${fdt_addr_r} /${fdt_name}
+bootm ${kernel_addr_r} - ${fdt_addr_r}
index 9b2159c5406efd3e9cee5e6249b2765d94a55f37..b4ac1b6904d571d4c0703c32933939f17e8351d2 100644 (file)
@@ -1,3 +1,5 @@
+DEVICE_VARS += UBOOT
+
 include common.mk
 
 define Device/Default
@@ -10,3 +12,19 @@ define Device/Default
   KERNEL_LOADADDR := 0x80008000
   IMAGES :=
 endef
+
+define Device/technexion_imx7d-pico-pi
+  DEVICE_VENDOR := TechNexion
+  DEVICE_MODEL := PICO-PI-IMX7D
+  UBOOT := pico-pi-imx7d
+  DEVICE_DTS := imx7d-pico-pi
+  DEVICE_PACKAGES := kmod-sound-core kmod-sound-soc-imx kmod-sound-soc-imx-sgtl5000 \
+       kmod-can kmod-can-flexcan kmod-can-raw kmod-leds-gpio \
+       kmod-input-touchscreen-edt-ft5x06 kmod-usb-hid kmod-btsdio \
+       kmod-brcmfmac cypress-firmware-4339-sdio cypress-nvram-4339-pico-pi-imx7d
+  FILESYSTEMS := squashfs
+  IMAGES := combined.bin sysupgrade.bin
+  IMAGE/combined.bin := append-rootfs | pad-extra 128k | imx-sdcard-raw-uboot
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += technexion_imx7d-pico-pi