Skip to content

Commit 5205c0c

Browse files
committed
microchipsw: lan969x: add Microchip EV23X71A
Microchip EV23X71A is a LAN9696 based EVB. Specifications: * CPU: Microchip LAN9696 switch SoC * DRAM: 1GB DDR4 * Storage: * 2MB QSPI NOR * 4GB eMMC * Networking: * 24 x 10/100/1000 RJ45 via LAN8814 Quad PHY-s over QSGMII * 4 x 100/1000/2500/5000/10000 SFP+ ports * 1 x 10/100/1000 management RJ45 via LAN8840 PHY over RGMII (U-Boot too) * USB: 1 x USB2.0 Type-A * Management via USB-C (MCP2200): * UART @ 115200 baud * GPIO-s for bootstrap, reset and clock selection * DIP switch for boostrap configuration * LED-s: * 2 per networking port (Green and Yellow) * Green status LED * Yellow reset LED * Hard reset button * Power: * 12V DC barrel jack * 48/56V DC screw terminal * Selectable via toggle switch * PTP support: * Sync-E DPLL ZL30732B to generate the board required clocks * Two SMAs for PTP and two for Station clock inputs and outputs * Two ITU-T G.8275-compliant RS-422 interfaces for PTP applications * External PoE: * Option for PoE add-on, like EV14Y36A (IEEE 802.3af/at/bt Type 4 standard com-pliant) * Option for external CPU control via SPI and PCIe Installation instructions: 1. Connect to UART via the USB-C port 2. Connect the management port 3. Boot and interrupt U-Boot 4. TFTP the OpenWrt initramfs image and boot it 5. SCP the OpenWrt eMMC GPT image to a running OpenWrt initramfs to /tmp openwrt-microchipsw-lan969x-microchip_ev23x71a-squashfs-emmc-gpt.img.gz And decompress it via: gzip -d /tmp/openwrt-microchipsw-lan969x-microchip_ev23x71a-squashfs-emmc-gpt.img.gz 6. Wipe eMMC with: dd if=/dev/zero of=/dev/mmcblk0 bs=1M 7. Flash OpenWrt eMMC image with: dd if=/tmp/openwrt-microchipsw-lan969x-microchip_ev23x71a-squashfs-emmc-gpt.img of=/dev/mmcblk0 After a restart OpenWrt will boot, and then regular sysupgrade can be used for upgrades. Signed-off-by: Robert Marko <[email protected]>
1 parent 88a404a commit 5205c0c

File tree

13 files changed

+1179
-2
lines changed

13 files changed

+1179
-2
lines changed

config/Config-images.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ menu "Target Images"
336336
int "Root filesystem partition size (in MiB)"
337337
depends on USES_ROOTFS_PART || TARGET_ROOTFS_EXT4FS
338338
default 232 if TARGET_loongarch64
339-
default 448 if TARGET_mediatek
339+
default 448 if TARGET_mediatek || TARGET_microchipsw
340340
default 104
341341
help
342342
Select the root filesystem partition size.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=arm-trusted-firmware-microchipsw
4+
PKG_RELEASE:=1
5+
6+
PKG_SOURCE_PROTO:=git
7+
PKG_SOURCE_URL=https://github.com/microchip-ung/arm-trusted-firmware.git
8+
PKG_SOURCE_DATE:=2024-08-13
9+
PKG_SOURCE_VERSION:=67fcfcab71f78ac7d4af834c37b29f8c98dd5ff1
10+
PKG_MIRROR_HASH:=777c68273e84028de77750f3fe8a1219b02f01d43ce35948893ac642d8eb10d7
11+
12+
PKG_MAINTAINER:=Robert Marko <[email protected]>
13+
14+
include $(INCLUDE_DIR)/kernel.mk
15+
include $(INCLUDE_DIR)/trusted-firmware-a.mk
16+
include $(INCLUDE_DIR)/package.mk
17+
18+
define Trusted-Firmware-A/Default
19+
BUILD_TARGET:=microchipsw
20+
TFA_IMAGE:=fip.bin fwu_fip.bin fwu.html
21+
endef
22+
23+
define Trusted-Firmware-A/ev23x71a
24+
NAME:=Microchip EV23X71A
25+
BUILD_SUBTARGET:=lan969x
26+
BUILD_DEVICES:=microchip_ev23x71a
27+
PLAT:=lan969x_a0
28+
DEPENDS:=+u-boot-ev23x71a
29+
endef
30+
31+
TFA_TARGETS:= ev23x71a
32+
33+
MBEDTLS_NAME:=mbedtls
34+
MBEDTLS_RELEASE:=2.28.10
35+
MBEDTLS_SOURCE:=$(MBEDTLS_NAME)-$(MBEDTLS_RELEASE).tar.zst
36+
37+
define Download/mbedtls
38+
FILE:=$(MBEDTLS_SOURCE)
39+
PROTO:=git
40+
URL:=https://github.com/Mbed-TLS/mbedtls.git
41+
SOURCE_VERSION:=2fc8413bfcb51354c8e679141b17b3f1a5942561
42+
MIRROR_HASH:=40b94a76572ad1ca89738929ab81d6024f678f22691eb3bd633c076ac18a334a
43+
SUBDIR:=$(MBEDTLS_NAME)
44+
endef
45+
46+
define Build/Prepare
47+
# Download mbedtls
48+
$(eval $(call Download,mbedtls))
49+
50+
$(call Build/Prepare/Default,)
51+
52+
$(TAR) -C $(PKG_BUILD_DIR) -xf $(DL_DIR)/$(MBEDTLS_SOURCE)
53+
endef
54+
55+
# We must not pass OPENSSL_DIR as locally built mbedtls is used
56+
define Build/Compile
57+
+unset CC; \
58+
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
59+
CROSS_COMPILE=$(TARGET_CROSS) \
60+
$(if $(DTC),DTC="$(DTC)") \
61+
PLAT=$(PLAT) \
62+
BUILD_STRING="OpenWrt $(PKG_VERSION_PREFIX)$(PKG_VERSION)-$(PKG_RELEASE) ($(VARIANT))" \
63+
$(TFA_MAKE_FLAGS)
64+
endef
65+
66+
TFA_MAKE_FLAGS += \
67+
MBEDTLS_DIR=$(PKG_BUILD_DIR)/$(MBEDTLS_NAME) \
68+
BL33=$(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-u-boot.bin \
69+
KEY_ALG=ecdsa GENERATE_COT=1 TRUSTED_BOARD_BOOT=1 \
70+
all fip fwu_fip
71+
72+
define Package/trusted-firmware-a/install
73+
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
74+
$(INSTALL_DATA) $(PKG_BUILD_DIR)/build/$(PLAT)/release/fip.bin $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-fip.bin
75+
$(CP) $(patsubst %,$(PKG_BUILD_DIR)/build/$(PLAT)/release/%,$(TFA_IMAGE)) $(1)/
76+
endef
77+
78+
$(eval $(call BuildPackage/Trusted-Firmware-A))
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_RELEASE:=1
4+
5+
PKG_SOURCE_PROTO:=git
6+
PKG_SOURCE_URL:=https://github.com/microchip-ung/u-boot.git
7+
PKG_SOURCE_DATE:=2025-09-22
8+
PKG_SOURCE_VERSION:=c1abab62a00a6b8f43f663a0a30dd0a7fd6a4e95
9+
PKG_MIRROR_HASH:=6405c426afd8bacbb4cc985da4ca1bd04b54a0d2aa3bb3ba8f7571dbe5913055
10+
11+
PKG_MAINTAINER:=Robert Marko <[email protected]>
12+
13+
include $(INCLUDE_DIR)/u-boot.mk
14+
include $(INCLUDE_DIR)/package.mk
15+
include $(INCLUDE_DIR)/kernel.mk
16+
17+
define U-Boot/Default
18+
BUILD_TARGET:=microchipsw
19+
HIDDEN:=1
20+
UBOOT_IMAGE:=u-boot.bin
21+
endef
22+
23+
define U-Boot/ev23x71a
24+
NAME:=Microchip EV23X71A
25+
BUILD_DEVICES:=microchip_ev23x71a
26+
BUILD_SUBTARGET:=lan969x
27+
UBOOT_CONFIG:=mchp_lan969x
28+
endef
29+
30+
UBOOT_TARGETS:= ev23x71a
31+
32+
define Build/InstallDev
33+
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
34+
$(CP) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-$(UBOOT_IMAGE)
35+
endef
36+
37+
$(eval $(call BuildPackage/U-Boot))
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
--- a/cmd/bootm.c
2+
+++ b/cmd/bootm.c
3+
@@ -260,6 +260,76 @@ U_BOOT_CMD(
4+
/* iminfo - print header info for a requested image */
5+
/*******************************************************************/
6+
#if defined(CONFIG_CMD_IMI)
7+
+#define SECTOR_SHIFT 9
8+
+static int image_totalsize(struct cmd_tbl *cmdtp, int flag, int argc,
9+
+ char *const argv[], short int in_blocks)
10+
+{
11+
+ ulong addr;
12+
+ void *hdr;
13+
+ uint32_t bsize, tsize = 0;
14+
+ char buf[16];
15+
+
16+
+ if (argc >= 2)
17+
+ addr = simple_strtoul(argv[1], NULL, 16);
18+
+ else
19+
+ addr = image_load_addr;
20+
+
21+
+ hdr = (void *)map_sysmem(addr, 0);
22+
+
23+
+ switch (genimg_get_format(hdr)) {
24+
+ case IMAGE_FORMAT_LEGACY:
25+
+ if(CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT))
26+
+ tsize = image_get_image_size(hdr);
27+
+ break;
28+
+ case IMAGE_FORMAT_FIT:
29+
+ if(CONFIG_IS_ENABLED(FIT))
30+
+ tsize = fit_get_totalsize(hdr);
31+
+ break;
32+
+ }
33+
+
34+
+ unmap_sysmem(hdr);
35+
+ if (tsize == 0)
36+
+ return 1;
37+
+
38+
+ bsize = (tsize >> SECTOR_SHIFT) + ((tsize & ((1 << SECTOR_SHIFT) - 1))?1:0);
39+
+
40+
+ if (!in_blocks)
41+
+ snprintf(buf, sizeof(buf), "%x", tsize);
42+
+ else
43+
+ snprintf(buf, sizeof(buf), "%x", bsize);
44+
+
45+
+ if (argc >= 3)
46+
+ return env_set(argv[2], buf);
47+
+ else
48+
+ printf("%s\n", buf);
49+
+
50+
+ return 0;
51+
+}
52+
+
53+
+static int do_imsz(struct cmd_tbl *cmdtp, int flag, int argc,
54+
+ char *const argv[])
55+
+{
56+
+ return image_totalsize(cmdtp, flag, argc, argv, 0);
57+
+}
58+
+
59+
+static int do_imszb(struct cmd_tbl *cmdtp, int flag, int argc,
60+
+ char *const argv[])
61+
+{
62+
+ return image_totalsize(cmdtp, flag, argc, argv, 1);
63+
+}
64+
+
65+
+U_BOOT_CMD(
66+
+ imsz, CONFIG_SYS_MAXARGS, 1, do_imsz,
67+
+ "get image total size (in bytes)",
68+
+ "addr [maxhdrlen] [varname]\n"
69+
+);
70+
+
71+
+U_BOOT_CMD(
72+
+ imszb, CONFIG_SYS_MAXARGS, 1, do_imszb,
73+
+ "get image total size (in blocks)",
74+
+ "addr [maxhdrlen] [varname]\n"
75+
+);
76+
+
77+
static int do_iminfo(struct cmd_tbl *cmdtp, int flag, int argc,
78+
char *const argv[])
79+
{
80+
--- a/boot/image-fit.c
81+
+++ b/boot/image-fit.c
82+
@@ -2054,6 +2054,47 @@ static const char *fit_get_image_type_pr
83+
return "unknown";
84+
}
85+
86+
+size_t fit_get_totalsize(const void *fit)
87+
+{
88+
+ int ret, ndepth, noffset, images_noffset;
89+
+ size_t data_size, hdrsize, img_total, max_size = 0;
90+
+ const void *data;
91+
+
92+
+ ret = fdt_check_header(fit);
93+
+ if (ret) {
94+
+ debug("Wrong FIT format: not a flattened device tree (err=%d)\n",
95+
+ ret);
96+
+ return 0;
97+
+ }
98+
+
99+
+ hdrsize = fdt_totalsize(fit);
100+
+
101+
+ /* take care of simple FIT with internal images */
102+
+ max_size = hdrsize;
103+
+
104+
+ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
105+
+ if (images_noffset < 0)
106+
+ goto out;
107+
+
108+
+ for (ndepth = 0,
109+
+ noffset = fdt_next_node(fit, images_noffset, &ndepth);
110+
+ (noffset >= 0) && (ndepth > 0);
111+
+ noffset = fdt_next_node(fit, noffset, &ndepth)) {
112+
+ if (ndepth == 1) {
113+
+ ret = fit_image_get_data(fit, noffset, &data, &data_size);
114+
+ if (ret)
115+
+ goto out;
116+
+
117+
+ img_total = data_size + (data - fit);
118+
+
119+
+ max_size = (max_size > img_total) ? max_size : img_total;
120+
+ }
121+
+ }
122+
+
123+
+out:
124+
+ return max_size;
125+
+}
126+
+
127+
int fit_image_load(struct bootm_headers *images, ulong addr,
128+
const char **fit_unamep, const char **fit_uname_configp,
129+
int arch, int ph_type, int bootstage_id,
130+
--- a/include/image.h
131+
+++ b/include/image.h
132+
@@ -1113,6 +1113,7 @@ int fit_parse_subimage(const char *spec,
133+
ulong *addr, const char **image_name);
134+
135+
int fit_get_subimage_count(const void *fit, int images_noffset);
136+
+size_t fit_get_totalsize(const void *fit);
137+
void fit_print_contents(const void *fit);
138+
void fit_image_print(const void *fit, int noffset, const char *p);
139+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
2+
3+
fdt_high=0xffffffff
4+
baudrate=115200
5+
bootdelay=3
6+
loadaddr=0x64000000
7+
bootargs=console=ttyAT0,115200 root=PARTLABEL=rootfs rootwait
8+
mmc_read_kernel=mmc read $loadaddr $part_addr 0x100 && imszb $loadaddr image_size && test 0x$image_size -le 0x$part_size && mmc read $loadaddr $part_addr $image_size
9+
boot_system=part start mmc 0 kernel part_addr && part size mmc 0 kernel part_size && run mmc_read_kernel && bootm
10+
bootcmd=run boot_system

0 commit comments

Comments
 (0)