-
Notifications
You must be signed in to change notification settings - Fork 29
Add NXP LPC54S018M-EVK port #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aidangarske
wants to merge
3
commits into
master
Choose a base branch
from
nxp-LPC54S-port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: LPC54S018 Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ 'master', 'main', 'release/**' ] | ||
| pull_request: | ||
| branches: [ '*' ] | ||
|
|
||
| jobs: | ||
| lpc54s018_build: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install ARM toolchain | ||
| run: | | ||
| set -euo pipefail | ||
| sudo apt-get update | ||
| sudo apt-get install -y gcc-arm-none-eabi | ||
|
|
||
| - name: Build LPC54S018 firmware | ||
| run: | | ||
| set -euo pipefail | ||
| make -C src/port/lpc54s018 | ||
|
|
||
| - name: Verify binary | ||
| run: | | ||
| set -euo pipefail | ||
| test -f src/port/lpc54s018/app.bin | ||
| arm-none-eabi-size src/port/lpc54s018/app.elf |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| CC := arm-none-eabi-gcc | ||
| OBJCOPY := arm-none-eabi-objcopy | ||
| SIZE := arm-none-eabi-size | ||
|
|
||
| ROOT := ../../.. | ||
|
|
||
| CFLAGS := -mcpu=cortex-m4 -mthumb -mfloat-abi=soft | ||
| CFLAGS += -Os -ffreestanding -fdata-sections -ffunction-sections | ||
| CFLAGS += -g -ggdb -Wall -Wextra -Werror | ||
| CFLAGS += -I. -I$(ROOT) -I$(ROOT)/src -I$(ROOT)/src/port/lpc_enet | ||
|
|
||
| CFLAGS_EXT := $(filter-out -Werror,$(CFLAGS)) | ||
| CFLAGS_EXT += -Wno-unused-variable -Wno-unused-function -Wno-unused-parameter | ||
| CFLAGS_EXT += -Wno-sign-compare -Wno-missing-field-initializers | ||
|
|
||
| LDSCRIPT ?= target_ram.ld | ||
| LDFLAGS := -nostdlib -T $(LDSCRIPT) -Wl,-gc-sections | ||
|
|
||
| APP_SRCS := startup.c ivt.c syscalls.c main.c | ||
| APP_OBJS := $(patsubst %.c,%.o,$(APP_SRCS)) | ||
|
|
||
| # Shared LPC ENET driver (src/port/lpc_enet/) | ||
| LPC_ENET_SRC := $(ROOT)/src/port/lpc_enet/lpc_enet.c | ||
| LPC_ENET_OBJ := lpc_enet.o | ||
|
|
||
| # wolfIP core | ||
| WOLFIP_SRC := $(ROOT)/src/wolfip.c | ||
| WOLFIP_OBJ := wolfip.o | ||
|
|
||
| ALL_OBJS := $(APP_OBJS) $(LPC_ENET_OBJ) $(WOLFIP_OBJ) | ||
|
|
||
| all: app.bin | ||
| @echo "Built LPC54S018M-EVK wolfIP port" | ||
| @$(SIZE) app.elf | ||
|
|
||
| app.elf: $(ALL_OBJS) $(LDSCRIPT) | ||
| $(CC) $(CFLAGS) $(ALL_OBJS) $(LDFLAGS) \ | ||
| -Wl,--start-group -lc -lm -lgcc -lnosys -Wl,--end-group -o $@ | ||
|
|
||
| app.bin: app.elf | ||
| $(OBJCOPY) -O binary $< $@ | ||
| python3 fix_checksum.py $@ | ||
|
|
||
| %.o: %.c | ||
| $(CC) $(CFLAGS) -c $< -o $@ | ||
|
|
||
| # Shared LPC ENET driver (include board header for LPC_ENET_* defines) | ||
| $(LPC_ENET_OBJ): $(LPC_ENET_SRC) | ||
| $(CC) $(CFLAGS) -include lpc54s018_eth.h -c $< -o $@ | ||
|
|
||
| $(WOLFIP_OBJ): $(WOLFIP_SRC) | ||
| $(CC) $(CFLAGS_EXT) -c $< -o $@ | ||
|
|
||
| clean: | ||
| rm -f *.o app.elf app.bin | ||
|
|
||
| size: app.elf | ||
| @$(SIZE) app.elf | ||
|
|
||
| .PHONY: all clean size help | ||
|
|
||
| help: | ||
| @echo "LPC54S018M-EVK wolfIP Build System" | ||
| @echo "" | ||
| @echo " make Build app.bin" | ||
| @echo " make clean Remove build artifacts" | ||
| @echo " make size Show memory usage" | ||
| @echo "" | ||
| @echo "Flashing (on-board Link2 CMSIS-DAP):" | ||
| @echo " pyocd flash -t lpc54608 app.elf" | ||
| @echo "" | ||
| @echo "Testing:" | ||
| @echo " ping 192.168.0.200" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| # wolfIP LPC54S018M-EVK Port | ||
|
|
||
| Bare-metal port of wolfIP for the NXP LPCXpresso54S018M development board, featuring an Ethernet driver and TCP/IP echo server example. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| 1. **Build:** | ||
| ```bash | ||
| cd src/port/lpc54s018 | ||
| make | ||
| ``` | ||
|
|
||
| 2. **Flash to board (RAM-loaded via on-board Link2):** | ||
| ```bash | ||
| bash flash.sh | ||
| ``` | ||
aidangarske marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 3. **Monitor UART output** (115200 baud on /dev/ttyACM0): | ||
| ```bash | ||
| screen /dev/ttyACM0 115200 | ||
| ``` | ||
| Get the device IP address from the DHCP output. | ||
|
|
||
| 4. **Test** (replace `<device-ip>` with IP from step 3): | ||
| ```bash | ||
| # TCP Echo | ||
| echo "Hello" | nc <device-ip> 7 | ||
|
|
||
| # Ping | ||
| ping <device-ip> | ||
| ``` | ||
|
|
||
| ## Hardware Requirements | ||
|
|
||
| - LPCXpresso54S018M development board (NXP OM40003) | ||
| - Ethernet connection (RMII, RJ45 at J4) | ||
| - USB cable for debug (J8, on-board Link2 CMSIS-DAP) | ||
|
|
||
| ## Software Requirements | ||
|
|
||
| - ARM GCC toolchain (`arm-none-eabi-gcc`) | ||
| - pyocd (`pip install pyocd`) | ||
| - Serial terminal (screen, minicom, picocom) | ||
|
|
||
| ### Installing Dependencies (Ubuntu/Debian) | ||
|
|
||
| ```bash | ||
| sudo apt install gcc-arm-none-eabi | ||
| pip install pyocd | ||
| ``` | ||
|
|
||
| ## Building | ||
|
|
||
| ```bash | ||
| cd src/port/lpc54s018 | ||
| make | ||
| ``` | ||
|
|
||
| This produces `app.elf` and `app.bin`. | ||
|
|
||
| ### Checking Memory Usage | ||
|
|
||
| ```bash | ||
| make size | ||
| ``` | ||
|
|
||
| ``` | ||
| text data bss dec hex filename | ||
| 52000 1732 53076 106808 1a138 app.elf | ||
| ``` | ||
|
|
||
| ## Flashing | ||
|
|
||
| ```bash | ||
| bash flash.sh | ||
| ``` | ||
|
|
||
| The flash script loads `app.elf` into SRAM via pyocd and starts execution. Uses `-t lpc54608` as target type since `lpc54s018` is not in pyocd's built-in list. | ||
|
|
||
| ## Serial Console | ||
|
|
||
| Connect to the USB serial port at 115200 baud: | ||
|
|
||
| ```bash | ||
| screen /dev/ttyACM0 115200 | ||
| ``` | ||
|
|
||
| ## Example Output | ||
|
|
||
| ``` | ||
| === wolfIP LPC54S018M-EVK === | ||
| PHY addr=0 link=UP | ||
| Starting DHCP... | ||
| Ready! ping <ip> / echo test | nc <ip> 7 | ||
| DHCP bound: 192.168.0.138 | ||
| ``` | ||
|
|
||
| ## Network Configuration | ||
|
|
||
| ### DHCP (Default) | ||
|
|
||
| DHCP is enabled by default. The board obtains its IP automatically and prints it to UART. Falls back to static IP after 30 seconds if no DHCP server responds. | ||
|
|
||
| ### Static IP | ||
|
|
||
| Set `WOLFIP_ENABLE_DHCP` to `0` in `config.h`: | ||
|
|
||
| ```c | ||
| #define WOLFIP_ENABLE_DHCP 0 | ||
| #define WOLFIP_IP "192.168.1.10" | ||
| #define WOLFIP_NETMASK "255.255.255.0" | ||
| #define WOLFIP_GW "192.168.1.1" | ||
| ``` | ||
|
|
||
| ## Testing TCP Echo Server | ||
|
|
||
| ```bash | ||
| # Test ICMP | ||
| ping <device-ip> | ||
|
|
||
| # Test TCP echo (port 7) | ||
| echo "Hello wolfIP!" | nc <device-ip> 7 | ||
|
|
||
| # Interactive | ||
| nc <device-ip> 7 | ||
| ``` | ||
|
|
||
| ## Jumper Settings | ||
|
|
||
| | Jumper | Position | Function | | ||
| |--------|----------|----------| | ||
| | JP11 | 1-2 (default) | Ethernet TXD/RXD | | ||
| | JP12 | 1-2 (default) | Ethernet TXD/RXD | | ||
| | JP14 | 1-2 (EN) | ENET MDC | | ||
| | JP15 | 1-2 (EN) | ENET MDIO | | ||
| | JP5 | Open (default) | Link2 normal boot | | ||
|
|
||
| ## Files | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `main.c` | Application entry, wolfIP init, echo server | | ||
| | `../lpc_enet/lpc_enet.c` | Ethernet MAC/DMA driver (shared) | | ||
| | `../lpc_enet/lpc_enet.h` | Ethernet driver header (shared) | | ||
| | `lpc54s018_eth.h` | Board-specific ENET parameters | | ||
| | `startup.c` | Startup code and data initialization | | ||
| | `ivt.c` | Interrupt vector table + SPIFI config | | ||
| | `syscalls.c` | Newlib syscall stubs | | ||
| | `target_ram.ld` | Linker script (RAM execution) | | ||
| | `target.ld` | Linker script (SPIFI flash boot) | | ||
| | `config.h` | wolfIP stack configuration | | ||
| | `fix_checksum.py` | LPC boot ROM vector checksum tool | | ||
| | `Makefile` | Build system | | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### No Serial Output | ||
| - Check J8 (USB Debug-Link) is connected, not J1 | ||
| - Check JP5 is open (not shunted) | ||
| - Verify baud rate is 115200 | ||
|
|
||
| ### Ethernet Not Responding | ||
| - Verify cable is in J4, check RJ45 link LEDs are lit | ||
| - Check JP14 and JP15 are both in EN position | ||
| - If using static IP, ensure host is on the same subnet | ||
|
|
||
| ### pyocd Cannot Find Target | ||
| - Use `-t lpc54608` as target type | ||
| - Add udev rule: `SUBSYSTEM=="usb", ATTR{idVendor}=="1fc9", MODE="0666"` | ||
|
|
||
| ## License | ||
|
|
||
| This code is part of wolfIP and is licensed under GPLv3. See the LICENSE file in the repository root for details. | ||
|
|
||
| Copyright (C) 2026 wolfSSL Inc. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* config.h | ||
| * | ||
| * wolfIP configuration for LPC54S018M-EVK | ||
| * | ||
| * Copyright (C) 2026 wolfSSL Inc. | ||
| * | ||
| * This file is part of wolfIP TCP/IP stack. | ||
| * | ||
| * wolfIP is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * wolfIP is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
| #ifndef WOLF_CONFIG_H | ||
| #define WOLF_CONFIG_H | ||
|
|
||
| #ifndef CONFIG_IPFILTER | ||
| #define CONFIG_IPFILTER 0 | ||
| #endif | ||
|
|
||
| #define ETHERNET | ||
| #define LINK_MTU 1536 | ||
|
|
||
| #define MAX_TCPSOCKETS 2 | ||
| #define MAX_UDPSOCKETS 1 | ||
| #define MAX_ICMPSOCKETS 1 | ||
| #define RXBUF_SIZE LINK_MTU | ||
| #define TXBUF_SIZE LINK_MTU | ||
|
|
||
| #define MAX_NEIGHBORS 4 | ||
| #define WOLFIP_ARP_PENDING_MAX 2 | ||
|
|
||
| #ifndef WOLFIP_MAX_INTERFACES | ||
| #define WOLFIP_MAX_INTERFACES 1 | ||
| #endif | ||
|
|
||
| #ifndef WOLFIP_ENABLE_FORWARDING | ||
| #define WOLFIP_ENABLE_FORWARDING 0 | ||
| #endif | ||
|
|
||
| #ifndef WOLFIP_ENABLE_LOOPBACK | ||
| #define WOLFIP_ENABLE_LOOPBACK 0 | ||
| #endif | ||
|
|
||
| #ifndef WOLFIP_ENABLE_DHCP | ||
| #define WOLFIP_ENABLE_DHCP 1 | ||
| #endif | ||
|
|
||
| /* Static IP fallback (used when DHCP is disabled or times out) */ | ||
| #define WOLFIP_IP "192.168.1.10" | ||
| #define WOLFIP_NETMASK "255.255.255.0" | ||
| #define WOLFIP_GW "192.168.1.1" | ||
| #define WOLFIP_STATIC_DNS_IP "8.8.8.8" | ||
|
|
||
| #if WOLFIP_ENABLE_DHCP | ||
| #define DHCP | ||
| #endif | ||
|
|
||
| #endif /* WOLF_CONFIG_H */ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.