Skip to contentSkip to conversation

board: purism: Add support for the Librem5 devkit

PATCH Superseded Guido Günther 2 participants 4 messages May 25 – Jun 12

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: purism: Add support for the Librem5 devkit

Although it has similar naming the Librem 5 Devkit is a completely different design from the Librem 5 phone. It uses an imx8mq SOM from Emcraft, a separate HDMI port instead of DisplayPort, different USB-C chip, panel, etc.

This is based on a Emcraft's SOM documentation, Purism's downstream fork and the available schematics of the devkit.

---
Based on a Emcraft's SOM documentation, Purism's downstream fork¹ and the available schematics² of the devkit.

Booting Debian's 7.0.x kernel (which was upstreamed a while back) via dhcp and from mmc works, so does booting an UKI via bootefi and via bootefi bootmgr.

The RAM timings were taken from the Librem 5 although it uses a slightly different DDR4 chips.

The SOM shipped by Purism uses the B0 revision but we leave timings for later imx8mq revisions in place in case ppl use a newer revision of EmCraft's SOM.

The original bringup was done by Angus Ainslie (based on imx's/Emcraft's tree) so I added him as Co-authored-by: and moved over the copyright notices.

¹) https://source.puri.sm/Librem5/uboot-imx
²) https://source.puri.sm/Librem5/dvk-mx8m-bsb

---
 arch/arm/dts/Makefile                              |   3 +-
 arch/arm/dts/imx8mq-librem5-devkit-u-boot.dtsi     |  11 +
 arch/arm/mach-imx/imx8m/Kconfig                    |   7 +
 board/purism/librem5-devkit/Kconfig                |  18 +
 board/purism/librem5-devkit/MAINTAINERS            |   8 +
 board/purism/librem5-devkit/Makefile               |  13 +
 .../purism/librem5-devkit/imximage-8mq-lpddr4.cfg  |   9 +
 board/purism/librem5-devkit/librem5-devkit.c       | 132 +++
 board/purism/librem5-devkit/librem5-devkit.env     |  20 +
 board/purism/librem5-devkit/lpddr4_timing.c        | 931 +++++++++++++++++++++
 board/purism/librem5-devkit/lpddr4_timing_b0.c     | 794 ++++++++++++++++++
 board/purism/librem5-devkit/spl.c                  | 371 ++++++++
 configs/librem5-devkit_defconfig                   | 175 ++++
 doc/board/purism/index.rst                         |   1 +
 doc/board/purism/librem5-devkit.rst                |  56 ++
 include/configs/librem5-devkit.h                   |  42 +
 16 files changed, 2590 insertions(+), 1 deletion(-)
arch/arm/dts/Makefile +2 -1
index e79cfb4b633..42e4b612363 100644
@@ -893,7 +893,8 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
 	imx8mp-msc-sm2s.dtb \
 	imx8mq-pico-pi.dtb \
 	imx8mq-kontron-pitx-imx8m.dtb \
-	imx8mq-librem5-r4.dtb
+	imx8mq-librem5-r4.dtb \
+	imx8mq-librem5-devkit.dtb
 
 dtb-$(CONFIG_ARCH_IMX9) += \
 	imx93-11x11-frdm.dtb \
arch/arm/dts/imx8mq-librem5-devkit-u-boot.dtsi new file +11 -0
new file mode 100644
index 00000000000..46a4dfe4e8a
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+#include "imx8mq-u-boot.dtsi"
+
+&pinctrl_uart1 {
+	bootph-pre-ram;
+};
+
+&uart1 { /* console */
+	bootph-pre-ram;
+};
arch/arm/mach-imx/imx8m/Kconfig +7 -0
index 8b0d48b07b3..b5af8be1ffc 100644
@@ -427,6 +427,12 @@ config TARGET_LIBREM5
 	select SUPPORT_SPL
 	select IMX8M_LPDDR4
 
+config TARGET_LIBREM5_DEVKIT
+	bool "Purism Librem5 Devkit"
+	select IMX8MQ
+	select SUPPORT_SPL
+	select IMX8M_LPDDR4
+
 endchoice
 
 source "board/advantech/imx8mp_rsb3720a1/Kconfig"
@@ -459,6 +465,7 @@ source "board/phytec/phycore_imx8mm/Kconfig"
 source "board/phytec/phycore_imx8mp/Kconfig"
 source "board/polyhex/imx8mp_debix_model_a/Kconfig"
 source "board/purism/librem5/Kconfig"
+source "board/purism/librem5-devkit/Kconfig"
 source "board/ronetix/imx8mq-cm/Kconfig"
 source "board/technexion/pico-imx8mq/Kconfig"
 source "board/variscite/imx8mn_var_som/Kconfig"
board/purism/librem5-devkit/Kconfig new file +18 -0
new file mode 100644
index 00000000000..3e069690142
@@ -0,0 +1,18 @@
+if TARGET_LIBREM5_DEVKIT
+
+config SYS_BOARD
+	default "librem5-devkit"
+
+config SYS_VENDOR
+	default "purism"
+
+config SYS_CONFIG_NAME
+	default "librem5-devkit"
+
+config ENV_SOURCE_FILE
+	default "librem5-devkit"
+
+config IMX_CONFIG
+	default "board/purism/librem5-devkit/imximage-8mq-lpddr4.cfg"
+
+endif
board/purism/librem5-devkit/MAINTAINERS new file +8 -0
new file mode 100644
index 00000000000..95bdc17cc8f
@@ -0,0 +1,8 @@
+PURISM LIBREM5 DEVKIT
+M:	Guido Günther
+R:	[email protected]
+S:	Supported
+F:	arch/arm/dts/imx8mq-librem5-devkit-u-boot.dtsi
+F:	board/purism/librem5-devkit/
+F:	configs/librem5-devkit_defconfig
+F:	include/configs/librem5-devkit.h
board/purism/librem5-devkit/Makefile new file +13 -0
new file mode 100644
index 00000000000..95044811186
@@ -0,0 +1,13 @@
+#
+# Copyright 2017 NXP
+# Copyright 2026 Phosh.mobi e.V.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-y += librem5-devkit.o
+
+ifdef CONFIG_XPL_BUILD
+obj-y += spl.o
+obj-$(CONFIG_IMX8M_LPDDR4) += lpddr4_timing.o lpddr4_timing_b0.o
+endif
board/purism/librem5-devkit/imximage-8mq-lpddr4.cfg new file +9 -0
new file mode 100644
index 00000000000..d102e70a954
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 NXP
+ */
+
+FIT
+BOOT_FROM	sd
+SIGNED_HDMI	signed_hdmi_imx8m.bin
+LOADER		u-boot-spl-ddr.bin	0x7E1000
board/purism/librem5-devkit/librem5-devkit.c new file +132 -0

132 lines not on this page · raw message

board/purism/librem5-devkit/librem5-devkit.env new file +20 -0
new file mode 100644
index 00000000000..62a0cfdc5d3
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+
+boot_fdt=try
+boot_targets=mmc0 dhcp
+bootm_size=0x10000000
+console=ttymxc0,115200
+fdt_addr_r=0x43000000
+fdtfile=DEFAULT_FDT_FILE
+initrd_addr=0x43800000
+image=Image
+kernel_addr_r=CONFIG_SYS_LOAD_ADDR
+loadaddr=CONFIG_SYS_LOAD_ADDR
+mmcautodetect=yes
+mmcdev=CONFIG_ENV_MMC_DEVICE_INDEX
+mmcpart=1
+mmcroot=/dev/mmcblk0p1
+scriptaddr=CONFIG_SYS_LOAD_ADDR
+mmcargs=setenv bootargs console=${console} root=${mmcroot} rootwait rw
+loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
board/purism/librem5-devkit/lpddr4_timing.c new file +931 -0

931 lines not on this page · raw message

board/purism/librem5-devkit/lpddr4_timing_b0.c new file +794 -0

794 lines not on this page · raw message

board/purism/librem5-devkit/spl.c new file +371 -0

371 lines not on this page · raw message

configs/librem5-devkit_defconfig new file +175 -0

175 lines not on this page · raw message

doc/board/purism/index.rst +1 -0
index a9cdc312d46..0225aa7f3aa 100644
@@ -7,3 +7,4 @@ Purism SPC
    :maxdepth: 2
 
    librem5
+   librem5-devkit
doc/board/purism/librem5-devkit.rst new file +56 -0

56 lines not on this page · raw message

include/configs/librem5-devkit.h new file +42 -0

42 lines not on this page · raw message

---
base-commit: 22a285380e35a31d0a882af66278bc1edc1b917e
change-id: 20260521-devkit-d2180dce1637

Best regards,

Signature · 1 line
Guido Günther <[email protected]>
reviewer
#1 lore raw

Hi Guido,

Quoted 59 lines · Guido Günther
board/purism/librem5-devkit/librem5-devkit.c new file +59 -0
+#define UART_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
+
+#define WDOG_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE)
+
+#define UART1_TX IMX_GPIO_NR(5, 23)
+#define UART1_RX IMX_GPIO_NR(5, 22)
+
+static const iomux_v3_cfg_t wdog_pads[] = {
+       IMX8MQ_PAD_GPIO1_IO02__WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL),
+};
+
+static const iomux_v3_cfg_t uart_pads[] = {
+       IMX8MQ_PAD_UART1_RXD__UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
+       IMX8MQ_PAD_UART1_TXD__UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
+};
+
+int board_early_init_f(void)
+{
+       struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
+
+       imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
+       set_wdog_reset(wdog);
+
+       imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
+
+       return 0;
+}
+
+#if IS_ENABLED(CONFIG_FEC_MXC)
+#define FEC_RST_PAD IMX_GPIO_NR(1, 9)
+static const iomux_v3_cfg_t fec1_rst_pads[] = {
+       IMX8MQ_PAD_GPIO1_IO09__GPIO1_IO9 | MUX_PAD_CTRL(NO_PAD_CTRL),
+       IMX8MQ_PAD_GPIO1_IO15__CCM_CLKO2 | MUX_PAD_CTRL(0x1F),
+};
+
+static void setup_iomux_fec(void)
+{
+       imx_iomux_v3_setup_multiple_pads(fec1_rst_pads,
+                                        ARRAY_SIZE(fec1_rst_pads));
+
+       gpio_request(FEC_RST_PAD, "fec1_rst");
+       gpio_direction_output(FEC_RST_PAD, 0);
+       udelay(500);
+       gpio_direction_output(FEC_RST_PAD, 1);
+}
+
+static int setup_fec(void)
+{
+       setup_iomux_fec();
+
+       /* Use 125M anatop REF_CLK1 for ENET1, not from external */
+       clrsetbits_le32(IOMUXC_GPR_BASE_ADDR + 0x04, BIT(13) | BIT(17), 0);
+       return set_clk_enet(ENET_125MHZ);
+}
+
+int board_phy_config(struct phy_device *phydev)
+{
+       /* enable rgmii rxc skew and phy mode select to RGMII copper */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);

board/purism/librem5-devkit/librem5-devkit.c line 87

Quoted 10 lines
board/purism/librem5-devkit/librem5-devkit.c new file +10 -0
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
+
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
+
+       if (phydev->drv->config)
+               phydev->drv->config(phydev);
+       return 0;
+}
+#endif

The UART, watchdog, and Ethernet PHY C code above could be removed, since we're using DM, right?

board/purism/librem5-devkit/librem5-devkit.c line 108

Quoted 9 lines
board/purism/librem5-devkit/librem5-devkit.c new file +9 -0
+int board_init(void)
+{
+       if (IS_ENABLED(CONFIG_USB_DWC3) || IS_ENABLED(CONFIG_USB_XHCI_DWC3))
+               init_usb_clk();
+
+       if (IS_ENABLED(CONFIG_FEC_MXC))
+               setup_fec();
+
+       return 0;

Can board_init() be removed?

board/purism/librem5-devkit/librem5-devkit.env line 3

Quoted 6 lines
board/purism/librem5-devkit/librem5-devkit.env new file +3 -0
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+
+boot_fdt=try

boot_fdt was used long ago, when we supported both DT and non-DT cases.

boot_fdt is no longer needed, as we always boot DT, so it can be removed.

Quoted 7 lines
board/purism/librem5-devkit/librem5-devkit.env new file +7 -0
+boot_targets=mmc0 dhcp
+bootm_size=0x10000000
+console=ttymxc0,115200
+fdt_addr_r=0x43000000
+fdtfile=DEFAULT_FDT_FILE
+initrd_addr=0x43800000
+image=Image

board/purism/librem5-devkit/librem5-devkit.env line 20

Quoted 10 lines
board/purism/librem5-devkit/librem5-devkit.env new file +10 -0
+kernel_addr_r=CONFIG_SYS_LOAD_ADDR
+loadaddr=CONFIG_SYS_LOAD_ADDR
+mmcautodetect=yes
+mmcdev=CONFIG_ENV_MMC_DEVICE_INDEX
+mmcpart=1
+mmcroot=/dev/mmcblk0p1
+scriptaddr=CONFIG_SYS_LOAD_ADDR
+mmcargs=setenv bootargs console=${console} root=${mmcroot} rootwait rw
+loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}

Use the generic load command instead of fatload.

doc/board/purism/index.rst

Quoted 10 lines
doc/board/purism/index.rst +5 -0
index a9cdc312d46..0225aa7f3aa 100644
 
+Get and Build the ARM Trusted firmware
+--------------------------------------
+
+Note: srctree is U-Boot source directory
+Get ATF from: https://source.puri.sm/Librem5/arm-trusted-firmware

Can't the mainline ATF be used instead?

#2 lore raw

Hi Fabio,

Quoted 68 lines · Fabio Estevam

Hi Guido,

Quoted 64 lines · Guido Günther
board/purism/librem5-devkit/librem5-devkit.c new file +64 -0
+#define UART_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
+
+#define WDOG_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE)
+
+#define UART1_TX IMX_GPIO_NR(5, 23)
+#define UART1_RX IMX_GPIO_NR(5, 22)
+
+static const iomux_v3_cfg_t wdog_pads[] = {
+       IMX8MQ_PAD_GPIO1_IO02__WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL),
+};
+
+static const iomux_v3_cfg_t uart_pads[] = {
+       IMX8MQ_PAD_UART1_RXD__UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
+       IMX8MQ_PAD_UART1_TXD__UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
+};
+
+int board_early_init_f(void)
+{
+       struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
+
+       imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
+       set_wdog_reset(wdog);
+
+       imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
+
+       return 0;
+}
+
+#if IS_ENABLED(CONFIG_FEC_MXC)
+#define FEC_RST_PAD IMX_GPIO_NR(1, 9)
+static const iomux_v3_cfg_t fec1_rst_pads[] = {
+       IMX8MQ_PAD_GPIO1_IO09__GPIO1_IO9 | MUX_PAD_CTRL(NO_PAD_CTRL),
+       IMX8MQ_PAD_GPIO1_IO15__CCM_CLKO2 | MUX_PAD_CTRL(0x1F),
+};
+
+static void setup_iomux_fec(void)
+{
+       imx_iomux_v3_setup_multiple_pads(fec1_rst_pads,
+                                        ARRAY_SIZE(fec1_rst_pads));
+
+       gpio_request(FEC_RST_PAD, "fec1_rst");
+       gpio_direction_output(FEC_RST_PAD, 0);
+       udelay(500);
+       gpio_direction_output(FEC_RST_PAD, 1);
+}
+
+static int setup_fec(void)
+{
+       setup_iomux_fec();
+
+       /* Use 125M anatop REF_CLK1 for ENET1, not from external */
+       clrsetbits_le32(IOMUXC_GPR_BASE_ADDR + 0x04, BIT(13) | BIT(17), 0);
+       return set_clk_enet(ENET_125MHZ);
+}
+
+int board_phy_config(struct phy_device *phydev)
+{
+       /* enable rgmii rxc skew and phy mode select to RGMII copper */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
+
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
+
Quoted 8 lines

board/purism/librem5-devkit/librem5-devkit.c line 87

Quoted 5 lines
board/purism/librem5-devkit/librem5-devkit.c new file +5 -0
+       if (phydev->drv->config)
+               phydev->drv->config(phydev);
+       return 0;
+}
+#endif

The UART, watchdog, and Ethernet PHY C code above could be removed, since we're using DM, right?

Dropped most of it. I needed to keep the board_phy_config to keep ethernet working. I'm still fuzzy what exactly is needed with DT and what not so happy to fix up things where needed.

Quoted 12 lines

board/purism/librem5-devkit/librem5-devkit.c line 108

Quoted 10 lines
board/purism/librem5-devkit/librem5-devkit.c new file +9 -0
+int board_init(void)
+{
+       if (IS_ENABLED(CONFIG_USB_DWC3) || IS_ENABLED(CONFIG_USB_XHCI_DWC3))
+               init_usb_clk();
+
+       if (IS_ENABLED(CONFIG_FEC_MXC))
+               setup_fec();
+
+       return 0;

Can board_init() be removed?

It's an empty function now.

Quoted 10 lines

board/purism/librem5-devkit/librem5-devkit.env line 3

Quoted 7 lines
board/purism/librem5-devkit/librem5-devkit.env new file +3 -0
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+
+boot_fdt=try

boot_fdt was used long ago, when we supported both DT and non-DT cases.

Quoted 2 lines

boot_fdt is no longer needed, as we always boot DT, so it can be removed.

Dropped.

Quoted 12 lines
Quoted 12 lines
board/purism/librem5-devkit/librem5-devkit.env new file +11 -0
+boot_targets=mmc0 dhcp
+bootm_size=0x10000000
+console=ttymxc0,115200
+fdt_addr_r=0x43000000
+fdtfile=DEFAULT_FDT_FILE
+initrd_addr=0x43800000
+image=Image
+kernel_addr_r=CONFIG_SYS_LOAD_ADDR
+loadaddr=CONFIG_SYS_LOAD_ADDR
+mmcautodetect=yes
+mmcdev=CONFIG_ENV_MMC_DEVICE_INDEX
Quoted 8 lines

board/purism/librem5-devkit/librem5-devkit.env line 20

Quoted 6 lines
board/purism/librem5-devkit/librem5-devkit.env new file +6 -0
+mmcpart=1
+mmcroot=/dev/mmcblk0p1
+scriptaddr=CONFIG_SYS_LOAD_ADDR
+mmcargs=setenv bootargs console=${console} root=${mmcroot} rootwait rw
+loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}

Use the generic load command instead of fatload.

Changed and also switched to standard bootflow as mostly we want to use efibootmgr anyway.

Quoted 6 lines
Quoted 5 lines
doc/board/purism/index.rst +0 -0
index a9cdc312d46..0225aa7f3aa 100644
Quoted 7 lines

doc/board/purism/index.rst

Quoted 5 lines
doc/board/purism/index.rst +5 -0
+Get and Build the ARM Trusted firmware
+--------------------------------------
+
+Note: srctree is U-Boot source directory
+Get ATF from: https://source.puri.sm/Librem5/arm-trusted-firmware

Can't the mainline ATF be used instead?

I believe so. The devkit has the B0 revision which wasn't handled in ATF back then but that seems to be there now. I wanted to switch to manline ATF later (and we want to add OP-TEE too) once I'm sure things are stable. So maybe that can be updated in a follow up?

Thanks for the review
-- Guido

#3 lore raw
In reply to Fabio Estevam

Hi Fabio,

(trimmed the cc: list to keep traffic at bay)

On Tue, Jun 09, 2026 at 09:53:08AM -0300, Fabio Estevam wrote:
[..snip..]

Quoted 7 lines

doc/board/purism/librem5-devkit.rst line 19

Quoted 5 lines
doc/board/purism/librem5-devkit.rst new file +5 -0
+Get and Build the ARM Trusted firmware
+--------------------------------------
+
+Note: srctree is U-Boot source directory
+Get ATF from: https://source.puri.sm/Librem5/arm-trusted-firmware

Can't the mainline ATF be used instead?

I wanted to switch to
https://github.com/arm-software/arm-trusted-firmware but most of NXPs boards use ATF from https://github.com/nxp-imx/imx-atf/

What is the recommendation here?

Cheers,
-- Guido