From a186fabb56c333b6531fe3046920ec5cf6f5b5b5 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Tue, 30 Mar 2021 12:27:53 +0200 Subject: [PATCH] arm: ip_k66f: Introduce board specific linker.ld file This patch introduces linker.ld file specific for ip_k66f board. It reuses the "common" linker script for other NXP SoCs with defined NETWORK_RAM_SECTIONS() macro for explicit placement of network interfaces on ip_k66f board. grep -A13 net_if_area zephyr/zephyr.map net_if_area 0x00000000200012a0 0x820 load address 0x0000000000024ac4 0x00000000200012a0 _net_if_list_start = . *(SORT_BY_ALIGNMENT(._net_if.static.dts*)) ._net_if.static.dts_ord_51 0x00000000200012a0 0x208 zephyr/libzephyr.a(eth_mcux.c.obj) *(SORT_BY_NAME(SORT_BY_ALIGNMENT(._net_if.static.dsa_slave*))) ._net_if.static.dsa_slave_port_DT_N_S_soc_S_spi_4002d000_S_dsa_0_S_lan_1 0x00000000200014a8 0x208 zephyr/libzephyr.a(dsa_ksz8794.c.obj) ._net_if.static.dsa_slave_port_DT_N_S_soc_S_spi_4002d000_S_dsa_0_S_lan_2 0x00000000200016b0 0x208 zephyr/libzephyr.a(dsa_ksz8794.c.obj) ._net_if.static.dsa_slave_port_DT_N_S_soc_S_spi_4002d000_S_dsa_0_S_lan_3 0x00000000200018b8 0x208 zephyr/libzephyr.a(dsa_ksz8794.c.obj) 0x0000000020001ac0 _net_if_list_end = . As a result the eth0 (master DSA interface) is explicitly placed as the first one (with the 'dts_ord_51' automatically assigned name) followed by lan{123} interfaces (with 'dsa_slave_port' name assigned in dsa_ksz8794.c). After this patch network interfaces are explicitly placed in correct order, so 'net_if_get_by_index()' will work correctly. Signed-off-by: Lukasz Majewski --- boards/arm/ip_k66f/linker.ld | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 boards/arm/ip_k66f/linker.ld diff --git a/boards/arm/ip_k66f/linker.ld b/boards/arm/ip_k66f/linker.ld new file mode 100644 index 00000000000..9641df553e1 --- /dev/null +++ b/boards/arm/ip_k66f/linker.ld @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 DENX Software Engineeering GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Linker command/script file + * + * This is the linker script for ip_k66f board to allow ethernet + * interfaces placement. + */ + +/* + * Explicit placement of the ethernet interfaces + * + * eth0 is the "master" port for the DSA switch and hence shall be + * placed on the index (position) 1 (as net_if_get_by_index() uses + * internally '_net_if_list_start[index - 1]' linker generated symbol). + * + * lan{123} shall be placed afterwards (sorted) so the order will be + * correctly preserved. + * + * If ip_k66f have had eth1 interface - it shall be placed afterwards + * + * The last entry with `._net_if.static.*` is to accommodate ethernet + * interfaces created in tests/samples - like e.g. _net_if.static.eth_test) + * in tests/net/vlan/src/main.c + */ + +#define NETWORK_RAM_SECTIONS \ +SECTION_DATA_PROLOGUE(net_if_area,,SUBALIGN(4)) \ +{ \ + _net_if_list_start = .; \ + KEEP(*(._net_if.static.dts*)); \ + KEEP(*(SORT_BY_NAME(._net_if.static.dsa_slave*))); \ + KEEP(*(SORT_BY_NAME(._net_if.static.*))); \ + _net_if_list_end = .; \ +} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) \ +Z_ITERABLE_SECTION_RAM(net_if_dev, 4) \ +Z_ITERABLE_SECTION_RAM(net_l2, 4) + +#include