Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2d475e146bf4^
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 94928020da50
Choose a head ref
  • 3 commits
  • 8 files changed
  • 1 contributor

Commits on Jun 27, 2015

  1. Copy the full SHA
    2d475e1 View commit details
  2. update lwip

    sbourdeauducq committed Jun 27, 2015
    Copy the full SHA
    3bd7f11 View commit details
  3. Copy the full SHA
    9492802 View commit details
Showing with 100 additions and 137 deletions.
  1. +0 −41 artiq/coredevice/comm_serial.py
  2. +7 −6 soc/runtime/flash_storage.c
  3. +0 −6 soc/runtime/kserver.c
  4. +26 −1 soc/runtime/liblwip/Makefile
  5. +6 −0 soc/runtime/liblwip/lwipopts.h
  6. +1 −1 soc/runtime/lwip
  7. +58 −76 soc/runtime/main.c
  8. +2 −6 soc/runtime/moninj.c
41 changes: 0 additions & 41 deletions artiq/coredevice/comm_serial.py

This file was deleted.

13 changes: 7 additions & 6 deletions soc/runtime/flash_storage.c
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
#include <generated/mem.h>
#include <generated/csr.h>

#include "log.h"
#include "flash_storage.h"

#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE)
@@ -62,21 +63,21 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
return 0;

if(record->size < 6) {
printf("flash_storage might be corrupted: record size is %u (<6) at address %08x\n", record->size, record->raw_record);
log("flash_storage might be corrupted: record size is %u (<6) at address %08x", record->size, record->raw_record);
if(fatal)
*fatal = 1;
return 0;
}

if(is->seek > is->buf_len - sizeof(record->size) - 2) { /* 2 is the minimum key length */
printf("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector\n");
log("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector");
if(fatal)
*fatal = 1;
return 0;
}

if(record->size > is->buf_len - is->seek) {
printf("flash_storage might be corrupted: invalid record_size %d at address %08x\n", record->size, record->raw_record);
log("flash_storage might be corrupted: invalid record_size %d at address %08x", record->size, record->raw_record);
if(fatal)
*fatal = 1;
return 0;
@@ -86,7 +87,7 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
record->key_len = strnlen(record->key, record->size - sizeof(record->size)) + 1;

if(record->key_len == record->size - sizeof(record->size) + 1) {
printf("flash_storage might be corrupted: invalid key length at address %08x\n", record->raw_record);
log("flash_storage might be corrupted: invalid key length at address %08x", record->raw_record);
if(fatal)
*fatal = 1;
return 0;
@@ -258,7 +259,7 @@ int fs_write(char *key, void *buffer, unsigned int buf_len)
return 0; // Storage is definitely full.

fatal_error:
printf("fatal error: flash storage might be corrupted\n");
log("fatal error: flash storage might be corrupted");
return 0;
}

@@ -289,7 +290,7 @@ unsigned int fs_read(char *key, void *buffer, unsigned int buf_len, unsigned int
}

if(fatal)
printf("fatal error: flash storage might be corrupted\n");
log("fatal error: flash storage might be corrupted");

return read_length;
}
6 changes: 0 additions & 6 deletions soc/runtime/kserver.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include <generated/csr.h>

#ifdef CSR_ETHMAC_BASE

#include <netif/etharp.h>
#include <netif/liteethif.h>
#include <lwip/init.h>
@@ -211,5 +207,3 @@ void kserver_service(void)
kserver_close(active_cs, active_pcb);
}
}

#endif /* CSR_ETHMAC_BASE */
27 changes: 26 additions & 1 deletion soc/runtime/liblwip/Makefile
Original file line number Diff line number Diff line change
@@ -32,8 +32,33 @@ CORE4OBJS=$(LWIPDIR)/core/ipv4/icmp.o \
NETIFOBJS=$(LWIPDIR)/netif/etharp.o \
netif/liteethif.o

PPPOBJS=$(LWIPDIR)/netif/ppp/auth.o \
$(LWIPDIR)/netif/ppp/ccp.o \
$(LWIPDIR)/netif/ppp/chap-md5.o \
$(LWIPDIR)/netif/ppp/chap_ms.o \
$(LWIPDIR)/netif/ppp/chap-new.o \
$(LWIPDIR)/netif/ppp/demand.o \
$(LWIPDIR)/netif/ppp/eap.o \
$(LWIPDIR)/netif/ppp/ecp.o \
$(LWIPDIR)/netif/ppp/eui64.o \
$(LWIPDIR)/netif/ppp/fsm.o \
$(LWIPDIR)/netif/ppp/ipcp.o \
$(LWIPDIR)/netif/ppp/ipv6cp.o \
$(LWIPDIR)/netif/ppp/lcp.o \
$(LWIPDIR)/netif/ppp/magic.o \
$(LWIPDIR)/netif/ppp/mppe.o \
$(LWIPDIR)/netif/ppp/multilink.o \
$(LWIPDIR)/netif/ppp/ppp.o \
$(LWIPDIR)/netif/ppp/pppcrypt.o \
$(LWIPDIR)/netif/ppp/pppoe.o \
$(LWIPDIR)/netif/ppp/pppol2tp.o \
$(LWIPDIR)/netif/ppp/pppos.o \
$(LWIPDIR)/netif/ppp/upap.o \
$(LWIPDIR)/netif/ppp/utils.o \
$(LWIPDIR)/netif/ppp/vj.o

# LWIPOBJS: All the above.
LWIPOBJS=$(COREOBJS) $(CORE4OBJS) $(NETIFOBJS)
LWIPOBJS=$(COREOBJS) $(CORE4OBJS) $(NETIFOBJS) $(PPPOBJS)
OBJS_LIB+=$(LWIPOBJS)

LWIPLIB=liblwip.a
6 changes: 6 additions & 0 deletions soc/runtime/liblwip/lwipopts.h
Original file line number Diff line number Diff line change
@@ -178,4 +178,10 @@ a lot of data that needs to be copied, this should be set high. */
#define SYS_STATS
#endif /* STATS */

/* ---------- PPP ---------- */

#define PPP_SUPPORT 1
#define PPPOS_SUPPORT 1
#define PPP_IPV4_SUPPORT 1

#endif /* __LWIPOPTS_H__ */
2 changes: 1 addition & 1 deletion soc/runtime/lwip
Submodule lwip updated from 737a69 to d32177
134 changes: 58 additions & 76 deletions soc/runtime/main.c
Original file line number Diff line number Diff line change
@@ -8,9 +8,6 @@
#include <generated/csr.h>
#include <hw/flags.h>

#ifdef CSR_ETHMAC_BASE
#include <netif/etharp.h>
#include <netif/liteethif.h>
#include <lwip/init.h>
#include <lwip/memp.h>
#include <lwip/ip4_addr.h>
@@ -19,7 +16,14 @@
#include <lwip/sys.h>
#include <lwip/tcp.h>
#include <lwip/timers.h>

#ifdef CSR_ETHMAC_BASE
#include <netif/etharp.h>
#include <netif/liteethif.h>
#endif
#include <netif/ppp/ppp.h>
#include <netif/ppp/pppos.h>
#include <lwip/sio.h>

#include "bridge_ctl.h"
#include "kloader.h"
@@ -30,32 +34,39 @@
#include "session.h"
#include "moninj.h"

static void common_init(void)
u32_t sys_now(void)
{
clock_init();
brg_start();
brg_ddsinitall();
kloader_stop();
return clock_get_ms();
}

#ifdef CSR_ETHMAC_BASE

u32_t sys_now(void)
u32_t sys_jiffies(void)
{
return clock_get_ms();
}

static struct netif netif;
#ifdef CSR_ETHMAC_BASE
static struct netif eth_netif;
#endif
static struct netif ppp_netif;
static ppp_pcb *ppp;

static void lwip_service(void)
{
sys_check_timeouts();
#ifdef CSR_ETHMAC_BASE
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
liteeth_input(&netif);
liteeth_input(&eth_netif);
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
}
#endif
if(uart_read_nonblock()) {
u8_t c;
c = uart_read();
pppos_input(ppp, &c, 1);
}
}

#ifdef CSR_ETHMAC_BASE
unsigned char macadr[6];

static int hex2nib(int c)
@@ -116,7 +127,7 @@ static void fsip_or_default(struct ip4_addr *d, char *key, int i1, int i2, int i
#endif
}

static void network_init(void)
static void network_init_eth(void)
{
struct ip4_addr local_ip;
struct ip4_addr netmask;
@@ -127,85 +138,57 @@ static void network_init(void)
fsip_or_default(&netmask, "netmask", 255, 255, 255, 0);
fsip_or_default(&gateway_ip, "gateway", 192, 168, 0, 1);

lwip_init();

netif_add(&netif, &local_ip, &netmask, &gateway_ip, 0, liteeth_init, ethernet_input);
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
netif_add(&eth_netif, &local_ip, &netmask, &gateway_ip, 0, liteeth_init, ethernet_input);
netif_set_default(&eth_netif);
netif_set_up(&eth_netif);
netif_set_link_up(&eth_netif);
}
#endif

static void regular_main(void)
static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
{
puts("Accepting sessions on Ethernet.");
network_init();
kserver_init();
moninj_init();

session_end();
while(1) {
lwip_service();
kserver_service();
}
}

#else /* CSR_ETHMAC_BASE */

static void reset_serial_session(void)
u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len)
{
int i;

session_end();
/* Signal end-of-session inband with zero length packet. */
for(i=0;i<4;i++)
uart_write(0x5a);
for(i=0;i<4;i++)
uart_write(0x00);
session_start();
for(i=0;i<len;i++)
uart_write(data[i]);
return len;
}

static void serial_service(void)
static void network_init_ppp(void)
{
char *txdata;
int txlen;
static char rxdata;
static int rxpending;
int r, i;

if(!rxpending && uart_read_nonblock()) {
rxdata = uart_read();
rxpending = 1;
}
if(rxpending) {
r = session_input(&rxdata, 1);
if(r > 0)
rxpending = 0;
if(r < 0)
reset_serial_session();
}

session_poll((void **)&txdata, &txlen);
if(txlen > 0) {
for(i=0;i<txlen;i++)
uart_write(txdata[i]);
session_ack_data(txlen);
session_ack_mem(txlen);
} else if(txlen < 0)
reset_serial_session();
ppp = pppos_create(&ppp_netif, NULL, ppp_status_cb, NULL);
ppp_set_auth(ppp, PPPAUTHTYPE_NONE, "", "");
ppp_set_default(ppp);
ppp_connect(ppp, 0);
}

static void regular_main(void)
{
puts("Accepting sessions on serial link.");
clock_init();
brg_start();
brg_ddsinitall();
kloader_stop();
lwip_init();
#ifdef CSR_ETHMAC_BASE
puts("Accepting sessions on Ethernet.");
network_init_eth();
#endif
puts("Accepting sessions on serial (PPP).");
network_init_ppp();
kserver_init();
moninj_init();

/* Open the session for the serial control. */
session_start();
while(1)
serial_service();
session_end();
while(1) {
lwip_service();
kserver_service();
}
}

#endif

static void blink_led(void)
{
int i, ev, p;
@@ -256,7 +239,6 @@ int main(void)
test_main();
} else {
puts("Entering regular mode.");
common_init();
regular_main();
}
return 0;
8 changes: 2 additions & 6 deletions soc/runtime/moninj.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include <generated/csr.h>

#ifdef CSR_ETHMAC_BASE

#include <netif/etharp.h>
#include <lwip/init.h>
#include <lwip/memp.h>
@@ -12,6 +8,8 @@
#include <lwip/udp.h>
#include <lwip/timers.h>

#include <generated/csr.h>

#include "log.h"
#include "moninj.h"

@@ -152,5 +150,3 @@ void moninj_init(void)
udp_bind(listen_pcb, IP_ADDR_ANY, 3250);
udp_recv(listen_pcb, moninj_recv, NULL);
}

#endif /* CSR_ETHMAC_BASE */