mirror of https://github.com/wolfSSL/wolfBoot.git
turn on ethernet, wolfip, and network test via new network command
parent
2a7a81289a
commit
bf2eb49e8f
|
|
@ -27,8 +27,9 @@ SPMATH?=1
|
|||
RAM_CODE?=1
|
||||
DUALBANK_SWAP?=0
|
||||
|
||||
# Select the MCXE247 variant. SRAM is ECC protected and is not initialized at
|
||||
# reset, so clear it before the stack is used.
|
||||
# Select the MCXE247 variant. SRAM is ECC protected and holds no valid ECC after
|
||||
# power-on. Clearing it at reset keeps the ECC valid, so the ERM records no
|
||||
# errors and its interrupts can be enabled safely.
|
||||
CFLAGS_EXTRA+=-DMCXE247 -DWOLFBOOT_RAM_ECC_INIT
|
||||
|
||||
# 4KB sectors
|
||||
|
|
@ -51,6 +52,22 @@ CFLAGS_EXTRA+=-DDEBUG_UART_TX_MUX=PORT_PCR_MUX_ALT3
|
|||
CFLAGS_EXTRA+=-DDEBUG_UART_RX_PORT=S32K_PORT_D -DDEBUG_UART_RX_PIN=17
|
||||
CFLAGS_EXTRA+=-DDEBUG_UART_RX_MUX=PORT_PCR_MUX_ALT3
|
||||
|
||||
# wolfIP network test in the test-app (optional)
|
||||
# Adds the "network" console command. Needs a wolfIP checkout and an MCUXpresso
|
||||
# SDK (for the fsl_enet driver).
|
||||
ENABLE_WOLFIP?=0
|
||||
WOLFBOOT_LIB_WOLFIP?=../lib/wolfip
|
||||
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
|
||||
# Without WOLFBOOT_TEST_TFTP the command only acquires a DHCP lease. The file
|
||||
# must fit the 40 KB receive buffer.
|
||||
WOLFBOOT_TEST_TFTP?=1
|
||||
CFLAGS_EXTRA+=-DHOST_IP_STR='"192.168.50.1"' -DTFTP_FILENAME='"wolfip_test.bin"'
|
||||
# WOLFIP_SPEED_TEST=1 makes the command run a TCP throughput server on port 9
|
||||
# instead (it never returns; reset the board to stop it). WOLFBOOT_TEST_TFTP
|
||||
# overrides it: with both set to 1 the command runs the TFTP fetch and the speed
|
||||
# server is never started.
|
||||
WOLFIP_SPEED_TEST?=0
|
||||
|
||||
# Debugging options
|
||||
DEBUG?=0
|
||||
DEBUG_SYMBOLS?=0
|
||||
|
|
|
|||
|
|
@ -7346,17 +7346,67 @@ The console is on the MCU-Link VCOM port (LPUART2, PTE12 TX, PTD17 RX, 115200
|
|||
for later versions, and has the same console as the
|
||||
[S32K1xx test application](#nxp-s32k1xx-test-application).
|
||||
|
||||
### NXP MCXE247: Configuration Options
|
||||
|
||||
The [S32K1xx configuration options](#nxp-s32k1xx-configuration-options) also
|
||||
apply to the MCXE247, with these differences:
|
||||
|
||||
- Select the variant with `MCXE247` instead of `S32K144`, `S32K146` or `S32K148`.
|
||||
- The console is on LPUART2, not LPUART1. `mcxe247.config` selects it with
|
||||
`DEBUG_UART_NUM=2` and the `DEBUG_UART_TX_*` and `DEBUG_UART_RX_*` pin
|
||||
settings.
|
||||
- `mcxe247.config` also sets `WOLFBOOT_RAM_ECC_INIT`, which clears SRAM at reset
|
||||
so its ECC is valid.
|
||||
|
||||
### NXP MCXE247: Network test
|
||||
|
||||
The test application can run a wolfIP DHCP and TFTP test over the board's
|
||||
Ethernet port. This is optional and is the only part of the port that needs the
|
||||
MCUXpresso SDK, which provides the `fsl_enet` driver. Set `ENABLE_WOLFIP=1` in
|
||||
`mcxe247.config`, check the wolfIP and SDK paths, then set the TFTP server and
|
||||
file:
|
||||
|
||||
```sh
|
||||
ENABLE_WOLFIP?=1
|
||||
WOLFBOOT_LIB_WOLFIP?=../lib/wolfip
|
||||
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
|
||||
WOLFBOOT_TEST_TFTP?=1
|
||||
CFLAGS_EXTRA+=-DHOST_IP_STR='"192.168.50.1"' -DTFTP_FILENAME='"wolfip_test.bin"'
|
||||
```
|
||||
|
||||
Type `network` on the console to run the test. It acquires a DHCP lease, fetches
|
||||
the file into RAM (40 KB at most), and prints its size and checksum followed by
|
||||
`WOLFIP_TEST: PASS` or `WOLFIP_TEST: FAIL`.
|
||||
|
||||
To measure throughput instead, set `WOLFBOOT_TEST_TFTP=0` and
|
||||
`WOLFIP_SPEED_TEST=1`. After the DHCP lease, the `network` command runs a TCP
|
||||
server on port 9 that discards what it receives and sends data whenever the
|
||||
connection can take it. It prints the receive and transmit rates when the
|
||||
connection closes. Drive it from the PC with `<ip>` set to the address the board
|
||||
printed:
|
||||
|
||||
```sh
|
||||
# board receives
|
||||
dd if=/dev/zero bs=1460 count=10000 | nc <ip> 9
|
||||
# board sends
|
||||
nc <ip> 9 </dev/null | pv -r >/dev/null
|
||||
```
|
||||
|
||||
The server never returns to the console; reset the board to stop it.
|
||||
`WOLFBOOT_TEST_TFTP` takes priority: with both options set to 1, the command
|
||||
runs the TFTP fetch and the speed server is never started.
|
||||
|
||||
### NXP MCXE247: Programming with Lauterbach TRACE32
|
||||
|
||||
Connect the 10-pin debug cable to J14 and short JP4 to disable the onboard
|
||||
MCU-Link SWD. TRACE32 R2024.09 has no MCXE247 entry: use `SYStem.CPU S32K148`
|
||||
and program `factory.bin` at `0x00000000`.
|
||||
MCU-Link SWD. If TRACE32 has no MCXE247 entry, use `SYStem.CPU S32K148`.
|
||||
Program `factory.bin` at `0x00000000`.
|
||||
|
||||
`factory.bin` includes the Flash Configuration Field at `0x400`. Its security
|
||||
byte at `0x40C` must be programmed to `0xFE`: an erased byte secures the chip
|
||||
at the next reset, and only a mass erase recovers it.
|
||||
|
||||
While TRACE32 is attached it halts the CPU at the reset vector on every reset.
|
||||
While TRACE32 is attached, it halts the CPU at the reset vector on every reset.
|
||||
Detach with `SYStem.Down` before testing an update, which relies on a software
|
||||
reset.
|
||||
|
||||
|
|
|
|||
|
|
@ -238,9 +238,10 @@ void isr_reset(void)
|
|||
}
|
||||
void isr_reset_c(void)
|
||||
#elif defined(WOLFBOOT_RAM_ECC_INIT)
|
||||
/* ECC SRAM faults on a sub-word write to a word not written since power-on,
|
||||
* so clear [_start_ecc_ram, _end_ecc_ram) with word stores before the stack
|
||||
* is used. Must be naked: nothing may touch RAM before the loop. */
|
||||
/* ECC SRAM words not written since power-on hold no valid ECC. Depending on
|
||||
* the part, accessing them faults or records an ECC error event. Clear
|
||||
* [_start_ecc_ram, _end_ecc_ram) with word stores before the stack is used so
|
||||
* the ECC is valid. Must be naked: nothing may touch RAM before the loop. */
|
||||
extern void isr_reset_c(void);
|
||||
__attribute__((naked, used, noreturn))
|
||||
void isr_reset(void)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Linker script for the wolfBoot test application on NXP S32K148/MCXE247 with wolfIP
|
||||
*
|
||||
* The application runs from the boot partition after the wolfBoot header.
|
||||
* RAM is all of SRAM_U, which the ENET DMA uses and is outside the code cache.
|
||||
*
|
||||
* SRAM is ECC protected and holds no valid ECC after power-on. .bss runs to the
|
||||
* end of RAM so that startup also clears the heap and stack with word stores,
|
||||
* which keeps the ECC valid and the ERM free of error events.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x1F000 /* 124KB SRAM_U */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_start_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
*(.init*)
|
||||
*(.fini*)
|
||||
. = ALIGN(4);
|
||||
_end_text = .;
|
||||
} > FLASH
|
||||
|
||||
.edidx :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.ARM.exidx*)
|
||||
} > FLASH
|
||||
|
||||
_stored_data = .;
|
||||
|
||||
.data : AT (_stored_data)
|
||||
{
|
||||
_start_data = .;
|
||||
KEEP(*(.data*))
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.ramcode))
|
||||
. = ALIGN(4);
|
||||
_end_data = .;
|
||||
} > RAM
|
||||
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
_start_bss = .;
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_end = .;
|
||||
. = ORIGIN(RAM) + LENGTH(RAM);
|
||||
_end_bss = .;
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
}
|
||||
|
||||
/* Partition info for libwolfboot */
|
||||
_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;
|
||||
_wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@;
|
||||
_wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@;
|
||||
_wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@;
|
||||
|
||||
/* Stack and heap indicators */
|
||||
_start_heap = _end;
|
||||
_end_stack = ORIGIN(RAM) + LENGTH(RAM);
|
||||
|
||||
/* Keep room above .bss for the stack and the heap used by printf */
|
||||
ASSERT(_end_stack - _end >= 0x2000, "not enough RAM left for the stack")
|
||||
|
|
@ -1716,8 +1716,8 @@ WOLFTPM_CFLAGS:=$(CFLAGS)
|
|||
WOLFHSM_CFLAGS:=$(CFLAGS)
|
||||
|
||||
# Optional wolfIP network stack in the test-app.
|
||||
# ENABLE_WOLFIP=1 wolfIP ethernet port (nxp_fman, or nxp_enetc on
|
||||
# LS1028A) + a link/PHY smoke test.
|
||||
# ENABLE_WOLFIP=1 wolfIP ethernet port (nxp_fman, nxp_enetc on LS1028A,
|
||||
# or nxp_mcxe_enet on MCXE247) + a link/PHY smoke test.
|
||||
# WOLFBOOT_TEST_TFTP=1 additionally pull in wolfIP core + TFTP client for
|
||||
# the full network TFTP-fetch test.
|
||||
# Point WOLFBOOT_LIB_WOLFIP at a wolfIP checkout, e.g.
|
||||
|
|
@ -1732,6 +1732,32 @@ ifeq ($(ENABLE_WOLFIP),1)
|
|||
WOLFIP_PORT:=nxp_enetc
|
||||
WOLFIP_PORT_OBJ:=nxp_enetc.o
|
||||
CFLAGS+=-DWOLFIP_PORT_ENETC
|
||||
else ifeq ($(TARGET),s32k1xx)
|
||||
ifeq ($(filter -DMCXE247,$(CFLAGS_EXTRA)),)
|
||||
$(error ENABLE_WOLFIP=1 on s32k1xx is only supported on MCXE247)
|
||||
endif
|
||||
ifeq ($(wildcard $(MCUXPRESSO)/drivers/enet/fsl_enet.c),)
|
||||
$(error ENABLE_WOLFIP=1 on MCXE247 needs MCUXPRESSO set to an MCUXpresso SDK checkout)
|
||||
endif
|
||||
WOLFIP_PORT:=nxp_mcxe_enet
|
||||
WOLFIP_PORT_OBJ:=nxp_mcxe_enet.o
|
||||
LSCRIPT_TEMPLATE=ARM-s32k1xx-wolfip.ld
|
||||
# The generic MCUXPRESSO_* defaults describe a different part
|
||||
MCXE247_DEVICE:=$(MCUXPRESSO)/devices/MCX/MCXE/MCXE247
|
||||
CFLAGS+=-DWOLFIP_PORT_MCXE_ENET -DCPU_MCXE247VLL
|
||||
# The TFTP receive buffer shares the 124KB of SRAM_U
|
||||
CFLAGS+=-DTFTP_RAM_MAX=0xA000U
|
||||
CFLAGS+=-I$(MCXE247_DEVICE) -I$(MCXE247_DEVICE)/drivers
|
||||
CFLAGS+=-I$(MCXE247_DEVICE)/../periph0
|
||||
CFLAGS+=-I$(MCUXPRESSO)/drivers/common -I$(MCUXPRESSO)/drivers/enet
|
||||
CFLAGS+=-I$(MCUXPRESSO)/components/phy
|
||||
CFLAGS+=-I$(MCUXPRESSO)/components/phy/device/phylan8741
|
||||
CFLAGS+=-I$(MCUXPRESSO)/arch/arm/CMSIS/Core/Include
|
||||
APP_OBJS+=$(MCUXPRESSO)/drivers/enet/fsl_enet.o
|
||||
APP_OBJS+=$(MCUXPRESSO)/drivers/common/fsl_common.o
|
||||
APP_OBJS+=$(MCUXPRESSO)/drivers/common/fsl_common_arm.o
|
||||
APP_OBJS+=$(MCXE247_DEVICE)/drivers/fsl_clock.o
|
||||
APP_OBJS+=$(MCUXPRESSO)/components/phy/device/phylan8741/fsl_phylan8741.o
|
||||
else
|
||||
WOLFIP_PORT:=nxp_fman
|
||||
WOLFIP_PORT_OBJ:=nxp_fman.o
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
#include "keystore.h"
|
||||
#include "target.h"
|
||||
#include "image.h"
|
||||
#ifdef ENABLE_WOLFIP
|
||||
#include "wolfip_tftp_test.h"
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_s32k1xx
|
||||
|
||||
|
|
@ -62,6 +65,14 @@ static uint32_t get_time_ms(void)
|
|||
return jiffies;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WOLFIP
|
||||
/* Millisecond timebase for wolfip_tftp_test.c */
|
||||
uint32_t wolfip_test_get_ms(void)
|
||||
{
|
||||
return jiffies;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void delay_ms(uint32_t ms)
|
||||
{
|
||||
uint32_t start = jiffies;
|
||||
|
|
@ -711,6 +722,9 @@ static int cmd_update(const char *args);
|
|||
static int cmd_timestamp(const char *args);
|
||||
static int cmd_trigger(const char *args);
|
||||
static int cmd_status(const char *args);
|
||||
#ifdef ENABLE_WOLFIP
|
||||
static int cmd_network(const char *args);
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int (*fn)(const char *args);
|
||||
|
|
@ -726,6 +740,9 @@ static const console_cmd_t commands[] = {
|
|||
{cmd_trigger, "trigger", "Trigger update (if update image in flash)"},
|
||||
{cmd_update, "update", "Update firmware via XMODEM"},
|
||||
{cmd_timestamp, "timestamp", "Show current system time"},
|
||||
#ifdef ENABLE_WOLFIP
|
||||
{cmd_network, "network", "Run the wolfIP network test"},
|
||||
#endif
|
||||
{cmd_reboot, "reboot", "Reboot the system"},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
|
@ -844,6 +861,15 @@ static int cmd_update(const char *args)
|
|||
return cmd_update_xmodem();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WOLFIP
|
||||
static int cmd_network(const char *args)
|
||||
{
|
||||
(void)args;
|
||||
wolfip_tftp_test_report();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int parse_command(const char* cmd)
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
*
|
||||
* Optional wolfIP network test for the wolfBoot test-app. Ethernet port and ms
|
||||
* timebase are compile-time selected: NXP QorIQ FMan (T2080/T1024/T1040,
|
||||
* big-endian PowerPC) or NXP Layerscape ENETC (LS1028A, AArch64). Modes:
|
||||
* big-endian PowerPC), NXP Layerscape ENETC (LS1028A, AArch64) or the
|
||||
* MCUXpresso fsl_enet driver (MCXE247, Cortex-M4). Modes:
|
||||
* default DHCP lease only
|
||||
* WOLFBOOT_TEST_TFTP + TFTP RRQ fetch into RAM, report size+checksum
|
||||
* (optionally verify them via TFTP_EXPECT_SIZE/SUM)
|
||||
|
|
@ -46,6 +47,13 @@
|
|||
#define WOLFIP_NETDEV_LINK_UP nxp_enetc_link_up
|
||||
#define WOLFIP_NETDEV_SET_LOG nxp_enetc_set_log
|
||||
#define WOLFIP_NETDEV_NAME "ENETC"
|
||||
#elif defined(WOLFIP_PORT_MCXE_ENET)
|
||||
#include "nxp_mcxe_enet.h"
|
||||
#define WOLFIP_NETDEV_INIT nxp_mcxe_enet_init
|
||||
#define WOLFIP_NETDEV_PHY_ADDR nxp_mcxe_enet_phy_addr
|
||||
#define WOLFIP_NETDEV_PHY_READ nxp_mcxe_enet_phy_read
|
||||
#define WOLFIP_NETDEV_LINK_UP nxp_mcxe_enet_link_up
|
||||
#define WOLFIP_NETDEV_NAME "MCXE247 ENET"
|
||||
#else
|
||||
#include "nxp_fman.h"
|
||||
#define WOLFIP_NETDEV_INIT nxp_fman_init
|
||||
|
|
@ -100,6 +108,21 @@ static uint64_t now_ms(void)
|
|||
{
|
||||
return read_tb() / (tb_hz() / 1000ULL);
|
||||
}
|
||||
#elif defined(WOLFIP_PORT_MCXE_ENET)
|
||||
/* 1 ms SysTick count, kept by the target app. */
|
||||
extern uint32_t wolfip_test_get_ms(void);
|
||||
#define SYST_CVR_REG (*(volatile uint32_t *)0xE000E018UL)
|
||||
|
||||
/* Combine the tick count and the SysTick down-counter to seed the RNG. */
|
||||
static uint64_t read_tb(void)
|
||||
{
|
||||
return ((uint64_t)wolfip_test_get_ms() << 24) | (SYST_CVR_REG & 0xFFFFFFU);
|
||||
}
|
||||
|
||||
static uint64_t now_ms(void)
|
||||
{
|
||||
return (uint64_t)wolfip_test_get_ms();
|
||||
}
|
||||
#else
|
||||
/* PowerPC e5500/e6500 Time Base via SPRs (TBL=268, TBU=269) = platform clock
|
||||
* / 16; default is the VPX3-152 value (600 MHz -> 37.5 MHz). Other platform
|
||||
|
|
@ -224,9 +247,21 @@ static struct wolfIP *wolfip_bringup(void)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(WOLFBOOT_TEST_TFTP) || defined(WOLFIP_SPEED_TEST)
|
||||
/* Zero a local struct without pulling in a libc memset (freestanding app). */
|
||||
static void zmem(void *p, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < n; i++)
|
||||
((uint8_t *)p)[i] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFBOOT_TEST_TFTP
|
||||
/* ---- TFTP RRQ fetch into a RAM buffer + integrity check ------------- */
|
||||
#ifndef TFTP_RAM_MAX
|
||||
#define TFTP_RAM_MAX (128U * 1024U)
|
||||
#endif
|
||||
#define TFTP_LOCAL_PORT 6900U
|
||||
|
||||
struct tftp_ram_ctx {
|
||||
|
|
@ -239,14 +274,6 @@ static struct tftp_ram_ctx g_tftp;
|
|||
|
||||
struct tftp_glue { struct wolfIP *s; int sock; };
|
||||
|
||||
/* Zero a local struct without pulling in a libc memset (freestanding app). */
|
||||
static void zmem(void *p, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < n; i++)
|
||||
((uint8_t *)p)[i] = 0;
|
||||
}
|
||||
|
||||
static int tftp_io_open(void *arg, const char *name, int is_write,
|
||||
uint32_t *size_hint, void **handle)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue