Skip to content

Commit

Permalink
spider: add lwip example with NO_SYS undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
fsylvestre committed Nov 15, 2023
1 parent 570ea98 commit 62d47e9
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/cortex-a-r/armv8/spider/lwip/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

#stop on errors
set -e

if [[ ! -d "_build" ]]
then
mkdir _build
fi

echo "*** Run Goil ***"
goil --target=cortex-a-r/armv8/spider --templates=../../../../../goil/templates/ lwip.oil

echo "*** Run Make ***"
./make.py
57 changes: 57 additions & 0 deletions examples/cortex-a-r/armv8/spider/lwip/lwip.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "tpl_os.h"

#include "spider_serial.h"
#include "printf.h"
#include "utils.h"

#include "ethif.h"

/* lwIP core includes */
#include "lwip/opt.h"
#include "lwip/dhcp.h"
#include "lwip/tcpip.h"

struct netif this_netif;

FUNC(int, OS_APPL_CODE) main(void)
{
Serial_Init();
StartOS(OSDEFAULTAPPMODE);
return 0;
}

#define DHCP 0

TASK(lwip)
{
debug_msg("init: call");
struct netif this_netif;
ip4_addr_t ip4_addr, net_mask, gateway;

debug_msg("init ethernet low level");
rswitch_enable_clock_and_reset();
port_init();

debug_msg("ethernet_init_inside_thread");
tcpip_init(NULL,NULL);

IP4_ADDR(&ip4_addr, 192, 168, 1, 2);
IP4_ADDR(&net_mask, 255, 255, 255, 0);
IP4_ADDR(&gateway, 192, 168, 1, 255);
#if DHCP==1
netif_add( &this_netif, NULL, &net_mask, NULL, NULL, ethif_init, tcpip_input);
#else
netif_add( &this_netif, &ip4_addr, &net_mask, NULL, NULL, ethif_init, tcpip_input);
#endif

netif_set_up(&this_netif);

#if DHCP==1
dhcp_start(&this_netif);
#endif

debug_msg("init: done");

TerminateTask();
}

108 changes: 108 additions & 0 deletions examples/cortex-a-r/armv8/spider/lwip/lwip.oil
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
OIL_VERSION = "4.0";

IMPLEMENTATION trampoline {

/* This fix the default STACKSIZE of tasks */
TASK {
UINT32 STACKSIZE = 2000 ;
} ;

/* This fix the default STACKSIZE of ISRs */
ISR {
UINT32 STACKSIZE = 2000 ;
} ;
};

CPU lwip {
OS config {
STATUS = EXTENDED;

BUILD = TRUE {
TRAMPOLINE_BASE_PATH = "../../../../..";
APP_SRC = "lwip.c";

APP_NAME = "lwip_exe.elf";
CFLAGS = "-O0 -DHSCIF_1843200BPS -ggdb";
LDFLAGS = "-Map=lwip.map";
COMPILER = "arm-none-eabi-gcc";
CPPCOMPILER = "arm-none-eabi-g++";
ASSEMBLER = "arm-none-eabi-as";
LINKER = "arm-none-eabi-ld";
COPIER = "arm-none-eabi-objcopy";
SYSTEM = PYTHON;

LIBRARY = serial;
LIBRARY = lwip;
};
SYSTEM_CALL = TRUE;
MEMMAP = TRUE {
COMPILER = gcc;
LINKER = gnu_ld { SCRIPT = "script.ld"; };
ASSEMBLER = gnu_as;
MEMORY_PROTECTION = FALSE;
};
};

APPMODE std {};

TASK lwip {
PRIORITY = 1;
AUTOSTART = TRUE { APPMODE = std; };
ACTIVATION = 1;
SCHEDULE = FULL;
};

/* LWIP needs */
EVENT lwip_sync {
MASK = AUTO;
};

TASK tcpip_task {
PRIORITY = 1;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
EVENT = lwip_sync;
};

/* eth driver needs */
TASK gwca1_rx_tx_task {
PRIORITY = 2;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
EVENT = lwip_sync;
};

ISR gwca1_rx_tx_int {
CATEGORY = 1;
PRIORITY = 3;
SOURCE = GWCA1_RX_TX_INT;
};

ISR gwca1_rx_ts_int {
CATEGORY = 1;
PRIORITY = 4;
SOURCE = GWCA1_RX_TS_INT;
};

ISR coma_err_int {
CATEGORY = 1;
PRIORITY = 5;
SOURCE = COMA_ERR_INT;
};

ISR gwca1_err_int {
CATEGORY = 1;
PRIORITY = 6;
SOURCE = GWCA1_ERR_INT;
};

ISR etha0_err_int {
CATEGORY = 1;
PRIORITY = 7;
SOURCE = ETHA0_ERR_INT;
};

};

0 comments on commit 62d47e9

Please sign in to comment.