From 84a38361a5d2bb97ac831f785329f4bcb2ce448b Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 29 Sep 2015 18:15:21 -0700 Subject: [PATCH 1/7] Update sdramp driver for the new i/o framework. --- rootfs.manifest | 47 ++++++++- sys/pic32/32mxsdram/Config | 16 ++- sys/pic32/32mxsdram/Makefile | 4 +- sys/pic32/Config.generic | 41 ++++---- sys/pic32/devices.kconf | 7 ++ sys/pic32/files.kconf | 11 +- sys/pic32/picadillo/Config-rambo | 5 +- sys/pic32/sd.c | 2 +- sys/pic32/sd.h | 4 +- sys/pic32/sdramp.c | 169 ++++++++++++++++++++++++++----- sys/pic32/sdramp.h | 12 +-- tools/kconfig/mkswapconf.c | 15 ++- 12 files changed, 252 insertions(+), 81 deletions(-) diff --git a/rootfs.manifest b/rootfs.manifest index 01826a2..73cc98a 100644 --- a/rootfs.manifest +++ b/rootfs.manifest @@ -22,8 +22,31 @@ dir /u # # Block devices. # +# Major Minor Name Device +# ------------------------- +# 0 0 sd0 Main SD card +# 0 1 sd0a Partition 1: root file system +# 0 2 sd0b Partition 2: swap space +# 0 3 sd0c Partition 3 +# 0 4 sd0d Partition 4 +# 0 8 sd1 Second SD card +# 0 9 sd1a Partition 1 +# 0 10 sd1b Partition 2 +# 0 11 sd1c Partition 3 +# 0 12 sd1d Partition 4 +# 1 0 rc0 Volatile disk - SRAM connected via CPLD (sramc) +# 2 0 dr0 Volatile disk - SDRAM on external memory bus (sdramp) +# 2 1 dr0a Partition 1: filesystem +# 2 2 dr0b Partition 2: swap space +# 3 0 mr0 Volatile disk - MRAM on SPI port (mrams) +# 4 64 swap Virtual swap device, mapped to real swap partition +# 4 0 swap0 Virtual i/o area, allocated from swap space +# 4 1 swap1 Virtual i/o area, allocated from swap space +# 4 2 swap2 Virtual i/o area, allocated from swap space +# 5 0 sr0 Volatile disk - serial RAM on SPI port (spirams) +# bdev /dev/sd0 -major 0 +major 0 # Main SD card minor 0 bdev /dev/sd0a major 0 @@ -38,7 +61,7 @@ bdev /dev/sd0d major 0 minor 4 bdev /dev/sd1 -major 0 +major 0 # Second SD card minor 8 bdev /dev/sd1a major 0 @@ -52,8 +75,23 @@ minor 11 bdev /dev/sd1d major 0 minor 12 +bdev /dev/rc0 +major 1 # Volatile disk - SRAM connected via CPLD (sramc) +minor 0 +bdev /dev/dr0 +major 2 # Volatile disk - SDRAM on external memory bus (sdramp) +minor 0 +bdev /dev/dr0a +major 2 +minor 1 +bdev /dev/dr0b +major 2 +minor 2 +bdev /dev/mr0 +major 3 # Volatile disk - MRAM on SPI port (mrams) +minor 0 bdev /dev/swap -major 4 +major 4 # Virtual swap device, mapped to real swap partition minor 64 bdev /dev/swap0 major 4 @@ -64,6 +102,9 @@ minor 1 bdev /dev/swap2 major 4 minor 2 +bdev /dev/sr0 +major 5 # Volatile disk - serial RAM on SPI port (spirams) +minor 0 # # Character devices. diff --git a/sys/pic32/32mxsdram/Config b/sys/pic32/32mxsdram/Config index a230067..b2dc183 100644 --- a/sys/pic32/32mxsdram/Config +++ b/sys/pic32/32mxsdram/Config @@ -32,7 +32,7 @@ signal "LED_TTY" pin RA14 # tty activity indicator # Root filesystem at /dev/sd0a, swap at /dev/sd0b config unix root on sd0a - swap on sd0b + swap on dr0b # swap on SDRAM # Serial UART ports device uart3 @@ -57,13 +57,11 @@ device adc # PWM driver device pwm -# Use SDRAM driver for the external ramdisk -device sdramp0 # SDRAM on external memory bus +# Use SDRAM driver for the external ramdisk. +# The volume is divided into two partitions: A and B. +# Size of partition B is specified as option SDR_SWAP_KBYTES. +# The rest is partition A. +device dr0 # SDRAM on external memory bus +options "SDR_SWAP_KBYTES=2048" # size of partition B options "KERNEL_EXECUTABLE_RAM" # allow kernel code in RAM area - -# This defines the swap size and a fs partition size on the external ramdisk. -# When the sa@XXXX is larger than the SWAP_KBYTES, the system will use -# the swap located on the external ramdisk automatically. -# (sd@xxxx + fs@xxxx) <= ramdisk_size -options "PARTITION='sdramp0:sa@2048,fs@14000'" options "NMOUNT=3" diff --git a/sys/pic32/32mxsdram/Makefile b/sys/pic32/32mxsdram/Makefile index b0e7a1f..d47fb22 100644 --- a/sys/pic32/32mxsdram/Makefile +++ b/sys/pic32/32mxsdram/Makefile @@ -5,15 +5,15 @@ PARAM += -DSPI4_ENABLED PARAM += -DSD_ENABLED PARAM += -DADC_ENABLED PARAM += -DPWM_ENABLED -PARAM += -DSDRAMP_ENABLED +PARAM += -DDR_ENABLED PARAM += -DSD_ENA_PORT=TRISB -DSD_ENA_PIN=13 PARAM += -DLED_TTY_PORT=TRISA -DLED_TTY_PIN=14 PARAM += -DLED_SWAP_PORT=TRISC -DLED_SWAP_PIN=14 PARAM += -DLED_DISK_PORT=TRISC -DLED_DISK_PIN=13 PARAM += -DLED_KERNEL_PORT=TRISA -DLED_KERNEL_PIN=15 PARAM += -DNMOUNT=3 -PARAM += -DPARTITION='sdramp0:sa@2048,fs@14000' PARAM += -DKERNEL_EXECUTABLE_RAM +PARAM += -DSDR_SWAP_KBYTES=2048 PARAM += -DSD_MHZ=10 PARAM += -DCONS_MINOR=2 PARAM += -DCONS_MAJOR=UART_MAJOR diff --git a/sys/pic32/Config.generic b/sys/pic32/Config.generic index d0d13dc..83f7c03 100644 --- a/sys/pic32/Config.generic +++ b/sys/pic32/Config.generic @@ -37,7 +37,6 @@ options "NMOUNT=2" # Number of mounted filesystems, def options "SMAPSIZ=NPROC" # Size of swap map, default NPROC options "HALTREBOOT" # Reboot the processor on halt() options "KERNEL_HIGHLIGHT" # Highlight kernel messages -options "PARTITION='%1'" # Partition schema for RAM device # LEDs signal "LED_DISK" pin RF0 invert # disk activity indicator @@ -125,30 +124,34 @@ signal "POWER_LED" pin RA3 signal "POWER_SWITCH" pin RA4 signal "POWER_CONTROL" pin RA5 -#-------------------------------------------- -# Custom RAM disk devices -# - -# sdramp - SDRAM block device -device sdramp0 # SDRAM on external memory bus -options "KERNEL_EXECUTABLE_RAM" # allow kernel code in RAM area - -# sramc - SRAM block device -device sramc0 # SRAM via 4-wire CPLD interface -signal "SRAMC_DATA" pin RE0 -signal "SRAMC_LDA" pin RC13 -signal "SRAMC_RD" pin RF1 -signal "SRAMC_WR" pin RF0 - -# picga - SPI block device +# picga controller spi1 # RAM disk: picga device picga0 at spi1 pin RA4 # chip select signal options "PICGA_BUS=SPI1CON" # TODO: delete this option signal "PICGA_CS" pin RA4 # TODO: delete +#-------------------------------------------- +# Custom RAM disk devices +# + +# sdramp - SDRAM block device +# The volume is divided into two partitions: A and B. +# Size of partition B is specified as option SDR_SWAP_KBYTES. +# The rest is partition A. +device dr0 # SDRAM on external memory bus +options "SDR_SWAP_KBYTES=2048" # size of partition B +options "KERNEL_EXECUTABLE_RAM" # allow kernel code in RAM area + +# sramc - SRAM block device +device rc0 # SRAM via 4-wire CPLD interface +signal "SRAMC_DATA" pin RE0 +signal "SRAMC_LDA" pin RC13 +signal "SRAMC_RD" pin RF1 +signal "SRAMC_WR" pin RF0 + # mrams - SPI block device controller spi1 # RAM disk: mrams -device mrams0 at spi1 +device mr0 at spi1 pins RA4, RA2, RB14, RB12, # chip select signals RB10, RB11 options "MRAMS_CHIPS=6" # number of chips @@ -170,7 +173,7 @@ signal "MRAMS_LED5" pin RF5 # spirams - SPI block device controller spi1 # RAM disk: spirams -device spirams0 at spi1 # chip select signals: +device sr0 at spi1 # chip select signals: pins RF0, RF1, RF2, RF3, # chip select signals RF4, RF5, RF6, RF7, RF8, RF9, RF10, RF11, diff --git a/sys/pic32/devices.kconf b/sys/pic32/devices.kconf index 20f486e..e1be1ce 100644 --- a/sys/pic32/devices.kconf +++ b/sys/pic32/devices.kconf @@ -1 +1,8 @@ +# +# List of block devices and majors +# sd 0 +rc 1 # sramc - SRAM connected via CPLD +dr 2 # sdramp - SDRAM at external memory bus +mr 3 # mrams - MRAM at SPI port +sr 5 # spirams - serial RAM at SPI port diff --git a/sys/pic32/files.kconf b/sys/pic32/files.kconf index c0943a1..7e43ad4 100644 --- a/sys/pic32/files.kconf +++ b/sys/pic32/files.kconf @@ -24,7 +24,6 @@ kernel/kern_subr.c standard kernel/kern_synch.c standard kernel/kern_sysctl.c standard kernel/kern_time.c standard -#kernel/rdisk.c standard kernel/subr_log.c optional log kernel/subr_prf.c standard kernel/subr_rmap.c standard @@ -76,12 +75,12 @@ pic32/hx8357.c optional hxtft pic32/picga.c optional picga pic32/power_control.c optional power pic32/pwm.c optional pwm -pic32/mrams.c optional mrams +pic32/mrams.c optional mr pic32/sd.c optional sd -pic32/sdramp.c optional sdramp -pic32/spirams.c optional spirams -pic32/sramc.c optional sramc -pic32/sdram.S optional sdramp +pic32/sdramp.c optional dr +pic32/sdram.S optional dr +pic32/spirams.c optional sr +pic32/sramc.c optional rc pic32/skel.c optional skel pic32/spi.c optional spi pic32/spi_bus.c optional spi diff --git a/sys/pic32/picadillo/Config-rambo b/sys/pic32/picadillo/Config-rambo index 57adc9b..8b1b9f8 100644 --- a/sys/pic32/picadillo/Config-rambo +++ b/sys/pic32/picadillo/Config-rambo @@ -25,7 +25,7 @@ options "BUS_DIV=1" # Bus clock divisor 1/2/4/8 # Root filesystem at /dev/sd0a, swap at /dev/sd0b config unix root on sd0a - swap on sd0b + swap on sr0 # Swap on SPI RAM # Serial UART ports device uart1 # Serial-to-USB converter @@ -51,8 +51,7 @@ device pwm device hxtft # spirams - SPI block device -device spirams0 at spi4 -options "PARTITION='spirams0:sa@2040'" # Partition schema +device sr0 at spi4 options "SPIRAMS_PORT=SPI4CON" # TODO: delete this option options "SPIRAMS_CHIPSIZE=128" # chip size in kbytes options "SPIRAMS_CHIPS=16" # number of chips diff --git a/sys/pic32/sd.c b/sys/pic32/sd.c index 8c8ad6c..ee95443 100644 --- a/sys/pic32/sd.c +++ b/sys/pic32/sd.c @@ -772,7 +772,7 @@ void sdstrategy(struct buf *bp) { /* Write to partition table not allowed. */ bp->b_error = EROFS; -bad: bp->b_flags |= B_ERROR; +bad: bp->b_flags |= B_ERROR; biodone(bp); return; } diff --git a/sys/pic32/sd.h b/sys/pic32/sd.h index d0b9d2e..74302aa 100644 --- a/sys/pic32/sd.h +++ b/sys/pic32/sd.h @@ -5,8 +5,8 @@ extern int sdopen(dev_t dev, int flag, int mode); extern int sdclose(dev_t dev, int flag, int mode); extern daddr_t sdsize(dev_t dev); -extern void sdstrategy(register struct buf *bp); -extern int sdioctl (dev_t dev, register u_int cmd, caddr_t addr, int flag); +extern void sdstrategy(struct buf *bp); +extern int sdioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif diff --git a/sys/pic32/sdramp.c b/sys/pic32/sdramp.c index 7f932b4..bae9ea5 100644 --- a/sys/pic32/sdramp.c +++ b/sys/pic32/sdramp.c @@ -1,6 +1,5 @@ /* * Driver for external SDRAM-based swap device. - * TODO: Modify this driver to be able to function without rdisk layer. * * See sdram.S for information on interface to sdram * @@ -11,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -20,7 +21,7 @@ */ #include -int sw_dkn = -1; /* Statistics slot number */ +int sdramp_dkindex = -1; /* Statistics slot number */ /* * physical specs of SDRAM chip @@ -54,6 +55,11 @@ int sw_dkn = -1; /* Statistics slot number */ #define BLOCKS_PER_ROW (RAM_COLS / CHUNK_SIZE) +/* + * Size of the whole disk in kbytes. + */ +#define SDR_TOTAL_KBYTES ((1<latclr = (1<b_addr, 512); - brelse(bp); - } -} - -int sdramp_open(int unit, int flag, int mode) +int sdramp_open(dev_t dev, int flag, int mode) { return 0; } -int sdramp_size(int unit) +int sdramp_close(dev_t dev, int flag, int mode) { - return (1<b_blkno; + long nblk = btod(bp->b_bcount); + int part_offset, part_size, s; + + /* Compute partition size and offset. */ + part_size = sdramp_size(bp->b_dev); + if (minor(bp->b_dev) < 2) { + /* Partition A or a whole disk. */ + part_offset = 0; + } else { + /* Partition B: swap space. */ + part_offset = SDR_TOTAL_KBYTES - part_size; + } + + /* + * Determine the size of the transfer, and make sure it is + * within the boundaries of the partition. + */ + offset += part_offset; + if (bp->b_blkno + nblk > part_size) { + /* if exactly at end of partition, return an EOF */ + if (bp->b_blkno == part_size) { + bp->b_resid = bp->b_bcount; + biodone(bp); + return; + } + /* or truncate if part of it fits */ + nblk = part_size - bp->b_blkno; + if (nblk <= 0) { + bp->b_error = EINVAL; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + bp->b_bcount = nblk << DEV_BSHIFT; + } + + if (bp->b_dev == swapdev) { + led_control(LED_SWAP, 1); + } else { + led_control(LED_DISK, 1); + } + + s = splbio(); +#ifdef UCB_METER + if (sdramp_dkindex >= 0) { + dk_busy |= 1 << sdramp_dkindex; + dk_xfer[sdramp_dkindex]++; + dk_bytes[sdramp_dkindex] += bp->b_bcount; + } +#endif + + if (bp->b_flags & B_READ) { + sdramp_read(offset, bp->b_addr, bp->b_bcount); + } else { + sdramp_write(offset, bp->b_addr, bp->b_bcount); + } + + biodone(bp); + if (bp->b_dev == swapdev) { + led_control(LED_SWAP, 0); + } else { + led_control(LED_DISK, 0); + } +#ifdef UCB_METER + if (sdramp_dkindex >= 0) + dk_busy &= ~(1 << sdramp_dkindex); +#endif + splx(s); +} + +int sdramp_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag) +{ + int error = 0; + + switch (cmd) { + + case DIOCGETMEDIASIZE: + /* Get disk size in kbytes. */ + *(int*) addr = sdramp_size(dev); + break; + + default: + error = EINVAL; + break; + } + return error; } /* @@ -382,7 +486,20 @@ static int sdrampprobe(config) struct conf_device *config; { - //TODO + /* Only one device unit is supported. */ + if (config->dev_unit != 0) + return 0; + + printf("dr0: total %u kbytes, swap space %u kbytes\n", + SDR_TOTAL_KBYTES, SDR_SWAP_KBYTES); + + int x = mips_intr_disable(); + sdram_init_c(); + mips_intr_restore(x); + +#ifdef UCB_METER + dk_alloc(&sdramp_dkindex, 1, "dr0"); +#endif return 1; } diff --git a/sys/pic32/sdramp.h b/sys/pic32/sdramp.h index 61a9196..c0cac2f 100644 --- a/sys/pic32/sdramp.h +++ b/sys/pic32/sdramp.h @@ -2,13 +2,11 @@ #define _SDRAMP_H #ifdef KERNEL - -extern int sdramp_write(int unit, unsigned blockno, char* data, unsigned nbytes); -extern int sdramp_read (int unit, unsigned blockno, char *data, unsigned nbytes); -extern void sdramp_preinit(int unit); -extern int sdramp_size(int unit); -extern int sdramp_open(int unit, int a, int b); - +extern int sdramp_open(dev_t dev, int flag, int mode); +extern int sdramp_close(dev_t dev, int flag, int mode); +extern daddr_t sdramp_size(dev_t dev); +extern void sdramp_strategy(struct buf *bp); +extern int sdramp_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index d93e302..29d886c 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -124,7 +124,7 @@ static struct devdescription { void initdevtable() { - char buf[BUFSIZ]; + char buf[BUFSIZ], name[BUFSIZ], *p; int maj; register struct devdescription **dp = &devtable; FILE *fp; @@ -135,9 +135,18 @@ void initdevtable() fprintf(stderr, "config: can't open %s\n", buf); exit(1); } - while (fscanf(fp, "%s\t%d\n", buf, &maj) == 2) { + while (fgets(buf, sizeof(buf), fp)) { + for (p=buf; *p; p++) + if (*p != ' ' && *p != '\t') + break; + if (*p == '#' || *p == '\n' || *p == '\r') + continue; + if (sscanf(p, "%s %d", name, &maj) != 2) { + fprintf(stderr, "../devices.kconf: unrecognized line %s\n", buf); + exit(1); + } *dp = (struct devdescription *)malloc(sizeof (**dp)); - (*dp)->dev_name = strdup(buf); + (*dp)->dev_name = strdup(name); (*dp)->dev_major = maj; dp = &(*dp)->dev_next; } From 09112b6b7a81db0539f08f324c16df4cf1888f2a Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 29 Sep 2015 18:45:48 -0700 Subject: [PATCH 2/7] Update sramc driver. --- rootfs.manifest | 8 ++ sys/pic32/Config.generic | 4 + sys/pic32/devsw.c | 16 +-- sys/pic32/fubarino/Config-uart-sramc | 9 +- sys/pic32/sdramp.c | 2 +- sys/pic32/sramc.c | 205 ++++++++++++++++++++++----- sys/pic32/sramc.h | 12 +- 7 files changed, 203 insertions(+), 53 deletions(-) diff --git a/rootfs.manifest b/rootfs.manifest index 73cc98a..03273f4 100644 --- a/rootfs.manifest +++ b/rootfs.manifest @@ -35,6 +35,8 @@ dir /u # 0 11 sd1c Partition 3 # 0 12 sd1d Partition 4 # 1 0 rc0 Volatile disk - SRAM connected via CPLD (sramc) +# 1 1 rc0a Partition 1: filesystem +# 1 2 rc0b Partition 2: swap space # 2 0 dr0 Volatile disk - SDRAM on external memory bus (sdramp) # 2 1 dr0a Partition 1: filesystem # 2 2 dr0b Partition 2: swap space @@ -78,6 +80,12 @@ minor 12 bdev /dev/rc0 major 1 # Volatile disk - SRAM connected via CPLD (sramc) minor 0 +bdev /dev/rc0a +major 1 +minor 1 +bdev /dev/rc0b +major 1 +minor 2 bdev /dev/dr0 major 2 # Volatile disk - SDRAM on external memory bus (sdramp) minor 0 diff --git a/sys/pic32/Config.generic b/sys/pic32/Config.generic index 83f7c03..2c71967 100644 --- a/sys/pic32/Config.generic +++ b/sys/pic32/Config.generic @@ -143,11 +143,15 @@ options "SDR_SWAP_KBYTES=2048" # size of partition B options "KERNEL_EXECUTABLE_RAM" # allow kernel code in RAM area # sramc - SRAM block device +# The volume is divided into two partitions: A and B. +# Size of partition B is specified as option SRAMC_SWAP_KBYTES. +# The rest is partition A. device rc0 # SRAM via 4-wire CPLD interface signal "SRAMC_DATA" pin RE0 signal "SRAMC_LDA" pin RC13 signal "SRAMC_RD" pin RF1 signal "SRAMC_WR" pin RF0 +options "SRAMC_SWAP_KBYTES=2048" # size of partition B # mrams - SPI block device controller spi1 # RAM disk: mrams diff --git a/sys/pic32/devsw.c b/sys/pic32/devsw.c index 148fe3d..1685045 100644 --- a/sys/pic32/devsw.c +++ b/sys/pic32/devsw.c @@ -26,16 +26,16 @@ extern int strcmp(char *s1, char *s2); #ifdef SD_ENABLED # include #endif -#ifdef SRAMC_ENABLED +#ifdef RC_ENABLED # include #endif -#ifdef SDRAMP_ENABLED +#ifdef DR_ENABLED # include #endif -#ifdef MRAMS_ENABLED +#ifdef MR_ENABLED # include #endif -#ifdef SPIRAMS_ENABLED +#ifdef SR_ENABLED # include #endif #ifdef UARTUSB_ENABLED @@ -124,7 +124,7 @@ const struct bdevsw bdevsw[] = { #endif }, { /* 1 - sramc */ -#ifdef SRAMC_ENABLED +#ifdef RC_ENABLED sramc_open, sramc_close, sramc_strategy, sramc_size, sramc_ioctl, #else @@ -132,7 +132,7 @@ const struct bdevsw bdevsw[] = { #endif }, { /* 2 - sdramp */ -#ifdef SDRAMP_ENABLED +#ifdef DR_ENABLED sdramp_open, sdramp_close, sdramp_strategy, sdramp_size, sdramp_ioctl, #else @@ -140,7 +140,7 @@ const struct bdevsw bdevsw[] = { #endif }, { /* 3 - mrams */ -#ifdef MRAMS_ENABLED +#ifdef MR_ENABLED mrams_open, mrams_close, mrams_strategy, mrams_size, mrams_ioctl, #else @@ -152,7 +152,7 @@ const struct bdevsw bdevsw[] = { swsize, swcioctl, }, { /* 5 - spirams */ -#ifdef SPIRAMS_ENABLED +#ifdef SR_ENABLED spirams_open, spirams_close, spirams_strategy, spirams_size, spirams_ioctl, #else diff --git a/sys/pic32/fubarino/Config-uart-sramc b/sys/pic32/fubarino/Config-uart-sramc index 27c6a22..95b8d16 100644 --- a/sys/pic32/fubarino/Config-uart-sramc +++ b/sys/pic32/fubarino/Config-uart-sramc @@ -33,7 +33,7 @@ signal "LED_KERNEL" pin RE5 # kernel activity indicator # Root filesystem at /dev/sd0a, swap at /dev/sd0b config unix root on sd0a - swap on sd0b + swap on rc0b # Swap on SRAM disk # Console options options "CONS_MAJOR=UART_MAJOR" # UART device @@ -70,5 +70,8 @@ device adc device pwm # sramc - SRAM block device -device sramc0 # SRAM via 4-wire CPLD interface -options "PARTITION='sramc0:sa@2048,fs@6140'" # Partition schema +# The volume is divided into two partitions: A and B. +# Size of partition B is specified as option SRAMC_SWAP_KBYTES. +# The rest is partition A. +device rc0 # SRAM via 4-wire CPLD interface +options "SRAMC_SWAP_KBYTES=2048" # size of partition B diff --git a/sys/pic32/sdramp.c b/sys/pic32/sdramp.c index bae9ea5..bce81fb 100644 --- a/sys/pic32/sdramp.c +++ b/sys/pic32/sdramp.c @@ -460,7 +460,7 @@ void sdramp_strategy(struct buf *bp) splx(s); } -int sdramp_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag) +int sdramp_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int error = 0; diff --git a/sys/pic32/sramc.c b/sys/pic32/sramc.c index 2dbe5c1..1c14f31 100644 --- a/sys/pic32/sramc.c +++ b/sys/pic32/sramc.c @@ -22,10 +22,18 @@ #include #include #include -#include +#include +#include +#include +#include #include -int sw_dkn = -1; /* Statistics slot number */ +int sramc_dkindex = -1; /* Statistics slot number */ + +/* + * Size of RAM disk. + */ +#define SRAMC_TOTAL_KBYTES 8192 /* 4096 for 4MB ramdisk */ // Ramdisk v.1.1. wiring // PMP RAMDISK @@ -77,13 +85,13 @@ typedef union { * */ inline static void -dev_load_address (addr) +dev_load_address(addr) unsigned addr; { nybbles temp; temp.value = addr; - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMADDR = 1; // set ADR mode (1) to write the Address @@ -91,45 +99,58 @@ dev_load_address (addr) PMDIN = temp.nib6; /* write 4 bits */ - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib5; /* write 4 bits */ - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib4; /* write 4 bits */ - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib3; /* write 4 bits */ - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib2; /* write 4 bits */ - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib1; /* write 4 bits */ } /* - * Get number of kBytes on the disk. - * Return nonzero if successful. + * Return a size of partition in kbytes. + * The memory is divided into two partitions: A and B. + * Size of partition B is specified in the kernel config file + * as option SRAMC_SWAP_KBYTES. */ -int sramc_size ( int unit ) +daddr_t sramc_size(dev_t dev) { - return 8192; // 4096 for 4MB ramdisk + switch (minor(dev)) { + case 0: + /* Whole disk. */ + return SRAMC_TOTAL_KBYTES; + case 1: + /* Partition A: filesystem. */ + return SRAMC_TOTAL_KBYTES - SRAMC_SWAP_KBYTES; + case 2: + default: + /* Partition B: swap space. */ + return SRAMC_SWAP_KBYTES; + } } /* * Read a block of data. */ -inline int sramc_read (int unit, unsigned int blockno, char *data, unsigned int nbytes) +static int sramc_read(unsigned int blockno, char *data, unsigned int nbytes) { int i; //DEBUG9("sramc%d: read block %u, length %u bytes, addr %p\n", major(dev), blockno, nbytes, data); - dev_load_address (blockno * DEV_BSIZE); + dev_load_address(blockno * DEV_BSIZE); /* Read data. */ - while(PMMODE & 0x8000); // Poll - if busy, wait + while (PMMODE & 0x8000); // Poll - if busy, wait PMADDR = 0; // set DATA mode (0) @@ -138,7 +159,7 @@ inline int sramc_read (int unit, unsigned int blockno, char *data, unsigned int PMDIN; // Read the PMDIN to clear previous data and latch new data for (i=0; ib_addr, 512); - brelse(bp); - } + DEBUG3("sramc: init done\n"); } /* * Open the disk. */ -int sramc_open (int unit) +int sramc_open(dev_t dev, int flag, int mode) { - DEBUG3("sramc%d: open\n",unit); + DEBUG3("sramc: open\n"); return 0; } + +int sramc_close(dev_t dev, int flag, int mode) +{ + return 0; +} + +void sramc_strategy(struct buf *bp) +{ + int offset = bp->b_blkno; + long nblk = btod(bp->b_bcount); + int part_offset, part_size, s; + + /* Compute partition size and offset. */ + part_size = sramc_size(bp->b_dev); + if (minor(bp->b_dev) < 2) { + /* Partition A or a whole disk. */ + part_offset = 0; + } else { + /* Partition B: swap space. */ + part_offset = SRAMC_TOTAL_KBYTES - part_size; + } + + /* + * Determine the size of the transfer, and make sure it is + * within the boundaries of the partition. + */ + offset += part_offset; + if (bp->b_blkno + nblk > part_size) { + /* if exactly at end of partition, return an EOF */ + if (bp->b_blkno == part_size) { + bp->b_resid = bp->b_bcount; + biodone(bp); + return; + } + /* or truncate if part of it fits */ + nblk = part_size - bp->b_blkno; + if (nblk <= 0) { + bp->b_error = EINVAL; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + bp->b_bcount = nblk << DEV_BSHIFT; + } + + if (bp->b_dev == swapdev) { + led_control(LED_SWAP, 1); + } else { + led_control(LED_DISK, 1); + } + + s = splbio(); +#ifdef UCB_METER + if (sramc_dkindex >= 0) { + dk_busy |= 1 << sramc_dkindex; + dk_xfer[sramc_dkindex]++; + dk_bytes[sramc_dkindex] += bp->b_bcount; + } +#endif + + if (bp->b_flags & B_READ) { + sramc_read(offset, bp->b_addr, bp->b_bcount); + } else { + sramc_write(offset, bp->b_addr, bp->b_bcount); + } + + biodone(bp); + if (bp->b_dev == swapdev) { + led_control(LED_SWAP, 0); + } else { + led_control(LED_DISK, 0); + } +#ifdef UCB_METER + if (sramc_dkindex >= 0) + dk_busy &= ~(1 << sramc_dkindex); +#endif + splx(s); +} + +int sramc_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) +{ + int error = 0; + + switch (cmd) { + + case DIOCGETMEDIASIZE: + /* Get disk size in kbytes. */ + *(int*) addr = sramc_size(dev); + break; + + default: + error = EINVAL; + break; + } + return error; +} + +/* + * Test to see if device is present. + * Return true if found and initialized ok. + */ +static int +sramcprobe(config) + struct conf_device *config; +{ + /* Only one device unit is supported. */ + if (config->dev_unit != 0) + return 0; + + printf("rc0: total %u kbytes, swap space %u kbytes\n", + SRAMC_TOTAL_KBYTES, SRAMC_SWAP_KBYTES); + + sramc_init(); + +#ifdef UCB_METER + dk_alloc(&sramc_dkindex, 1, "rc0"); +#endif + return 1; +} + +struct driver rcdriver = { + "sramc", sramcprobe, +}; diff --git a/sys/pic32/sramc.h b/sys/pic32/sramc.h index 2c68f19..9a02e4a 100644 --- a/sys/pic32/sramc.h +++ b/sys/pic32/sramc.h @@ -2,13 +2,11 @@ #define _SRAMC_H #ifdef KERNEL - -extern int sramc_read(int unit, unsigned int offset, char *data, unsigned int bcount); -extern int sramc_write(int unit, unsigned int offset, char *data, unsigned int bcount); -extern int sramc_open(int unit, int flag, int mode); -extern void sramc_init(int unit); -extern int sramc_size(int unit); - +extern int sramc_open(dev_t dev, int flag, int mode); +extern int sramc_close(dev_t dev, int flag, int mode); +extern daddr_t sramc_size(dev_t dev); +extern void sramc_strategy(struct buf *bp); +extern int sramc_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif From 644b6c2112746e6d1439a22128be5d5bd6f24297 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 29 Sep 2015 19:43:33 -0700 Subject: [PATCH 3/7] Update mrams driver. --- sys/pic32/Config.generic | 14 +-- sys/pic32/fubarino/Config-mrams | 74 ++++++++++++ sys/pic32/mrams.c | 198 ++++++++++++++++++++++++++------ sys/pic32/mrams.h | 11 +- sys/pic32/sramc.c | 1 - 5 files changed, 249 insertions(+), 49 deletions(-) create mode 100644 sys/pic32/fubarino/Config-mrams diff --git a/sys/pic32/Config.generic b/sys/pic32/Config.generic index 2c71967..4140a85 100644 --- a/sys/pic32/Config.generic +++ b/sys/pic32/Config.generic @@ -156,24 +156,14 @@ options "SRAMC_SWAP_KBYTES=2048" # size of partition B # mrams - SPI block device controller spi1 # RAM disk: mrams device mr0 at spi1 - pins RA4, RA2, RB14, RB12, # chip select signals - RB10, RB11 -options "MRAMS_CHIPS=6" # number of chips + pins RA4, RA2, RB14, RB12 # chip select signals +options "MRAMS_CHIPS=4" # number of chips options "MRAMS_CHIPSIZE=512" # chip size in kbytes options "MRAMS_MHZ=10" # speed 10 MHz -options "MRAMS_PORT=SPI1CON" # TODO: delete this option -signal "MRAMS_CS0" pin RA4 # TODO: delete -signal "MRAMS_CS1" pin RA2 # TODO: delete -signal "MRAMS_CS2" pin RB14 # TODO: delete -signal "MRAMS_CS3" pin RB12 # TODO: delete -signal "MRAMS_CS4" pin RB10 # TODO: delete -signal "MRAMS_CS5" pin RB11 # TODO: delete signal "MRAMS_LED0" pin RF0 # optional LED indicators signal "MRAMS_LED1" pin RF1 signal "MRAMS_LED2" pin RF2 signal "MRAMS_LED3" pin RF3 -signal "MRAMS_LED4" pin RF4 -signal "MRAMS_LED5" pin RF5 # spirams - SPI block device controller spi1 # RAM disk: spirams diff --git a/sys/pic32/fubarino/Config-mrams b/sys/pic32/fubarino/Config-mrams new file mode 100644 index 0000000..9f3066a --- /dev/null +++ b/sys/pic32/fubarino/Config-mrams @@ -0,0 +1,74 @@ +# +# Fubarino SD board +# ================= +# Console on USB. +# For details, see https://github.com/RetroBSD/retrobsd/wiki/Board-Fubarino-SD +# +# To build the kernel, use: +# cd sys/pic32/fubarino +# kconfig Config +# make clean +# make +# +# Format of this file is described on page: +# http://retrobsd.org/wiki/doku.php/doc/kconfig +# +architecture "pic32" +cpu "PIC32MX7" # Processor variant +board "FUBARINO" # Board type +ldscript "max32/bootloader.ld" # Linker script + +# Standard system options +options "CPU_KHZ=80000" # Oscillator frequency of CPU core +options "BUS_KHZ=80000" # Frequency of peripheral bus +options "BUS_DIV=1" # Bus clock divisor 1/2/4/8 + +# LED +signal "LED_KERNEL" pin RE5 # kernel activity indicator + +# Root filesystem at /dev/sd0a, swap at /dev/sd0b +config unix root on sd0a + swap on sd0b + +# Console options +options "CONS_MAJOR=UARTUSB_MAJOR" # UARTUSB device + +# Virtual UART on USB +device uartusb +options "USB_MAX_EP_NUMBER=3" +options "USB_NUM_STRING_DESCRIPTORS=3" + +# UART ports +device uart2 # Pins RF4, RF5 + +# SPI ports +controller spi2 # SD card +controller spi3 # Pins RD1, RD2, RD3 + +# microSD card +device sd0 at spi2 pin RG9 # select pin + +# General purpose I/O ports +# Flags define a mask of available pins +# The following pins excluded: +# RG6, RG7, RG8, RG9 - spi2, SD card +# RD1, RD2, RD3 - spi3 +# RF4, RF5 - uart2 +device gpio1 flags 0xffff # port B +device gpio2 flags 0xf000 # port C +device gpio3 flags 0x0ff1 # port D +device gpio4 flags 0x00ff # port E +device gpio5 flags 0x000b # port F +device gpio6 flags 0x000c # port G + +# ADC driver +device adc + +# PWM driver +device pwm + +# mrams - SPI block device +device mr0 at spi3 + pins RD4, RD5, RD6, RD7 # chip select signals +options "MRAMS_CHIPS=4" # number of chips +options "MRAMS_CHIPSIZE=512" # chip size in kbytes diff --git a/sys/pic32/mrams.c b/sys/pic32/mrams.c index 6dd80cc..5c6e2a0 100644 --- a/sys/pic32/mrams.c +++ b/sys/pic32/mrams.c @@ -1,5 +1,5 @@ /* - * TODO: Modify this driver to be able to function without rdisk layer. + * Disk driver for serial MRAM chips connected via SPI port. */ #include #include @@ -8,7 +8,8 @@ #include #include #include -#include +#include +#include #include #define MRAM_WREN 0x06 @@ -26,10 +27,12 @@ struct spiio mrams_io[MRAMS_CHIPS]; -int mrams_size(int unit) -{ - return MRAMS_CHIPS * MRAMS_CHIPSIZE; -} +int mrams_dkindex; /* disk index for statistics */ + +/* + * Size of RAM disk. + */ +#define MRAMS_TOTAL_KBYTES (MRAMS_CHIPS * MRAMS_CHIPSIZE) #define MRBSIZE 1024 #define MRBLOG2 10 @@ -108,7 +111,7 @@ unsigned int mr_read_block(unsigned int chip, unsigned int address, unsigned int return cs; } -int mrams_read(int unit, unsigned int offset, char *data, unsigned int bcount) +int mrams_read(unsigned int offset, char *data, unsigned int bcount) { register unsigned int chip; register unsigned int toread; @@ -211,7 +214,7 @@ unsigned int mr_write_block(unsigned int chip, unsigned int address, unsigned in return cs; } -int mrams_write(int unit, unsigned int offset, char *data, unsigned bcount) +int mrams_write(unsigned int offset, char *data, unsigned bcount) { register unsigned int chip; register unsigned int address; @@ -240,27 +243,33 @@ int mrams_write(int unit, unsigned int offset, char *data, unsigned bcount) return 1; } -void mrams_preinit(int unit) +static unsigned *gpio_base(int cs) +{ + int port = (cs >> 4) - 1; + struct gpioreg *base = port + (struct gpioreg*) &TRISA; + + return (unsigned int*) base; +} + +/* + * Initialize hardware. + */ +static int mrams_init(int spi_port, int cs0, int cs1, int cs2, int cs3) { struct spiio *io = &mrams_io[0]; - struct buf *bp; - - if (unit >= 1) - return; - - /* Initialize hardware. */ - - if (spi_setup(io, MRAMS_PORT, (unsigned int *)&MRAMS_CS0_PORT, MRAMS_CS0_PIN) != 0) - return; + if (spi_setup(io, spi_port, gpio_base(cs0), cs0 & 15) != 0) { + printf("mr0: cannot open SPI%u port\n", spi_port); + return 0; + } spi_brg(io, MRAMS_MHZ * 1000); spi_set(io, PIC32_SPICON_CKE); spi_select(io); spi_transfer(io, MRAM_WREN); spi_deselect(io); -#ifdef MRAMS_CS1_PORT - spi_setup(io+1, MRAMS_PORT, (unsigned int *)&MRAMS_CS1_PORT, MRAMS_CS1_PIN); +#if MRAMS_CHIPS >= 1 + spi_setup(io+1, spi_port, gpio_base(cs1), cs1 & 15); spi_brg(io+1, MRAMS_MHZ * 1000); spi_set(io+1, PIC32_SPICON_CKE); @@ -268,8 +277,8 @@ void mrams_preinit(int unit) spi_transfer(io+1, MRAM_WREN); spi_deselect(io+1); #endif -#ifdef MRAMS_CS2_PORT - spi_setup(io+2, MRAMS_PORT, (unsigned int *)&MRAMS_CS2_PORT, MRAMS_CS2_PIN); +#if MRAMS_CHIPS >= 2 + spi_setup(io+2, spi_port, gpio_base(cs2), cs2 & 15); spi_brg(io+2, MRAMS_MHZ * 1000); spi_set(io+2, PIC32_SPICON_CKE); @@ -277,8 +286,8 @@ void mrams_preinit(int unit) spi_transfer(io+2, MRAM_WREN); spi_deselect(io+2); #endif -#ifdef MRAMS_CS3_PORT - spi_setup(io+3, MRAMS_PORT, (unsigned int *)&MRAMS_CS3_PORT, MRAMS_CS3_PIN); +#if MRAMS_CHIPS >= 3 + spi_setup(io+3, spi_port, gpio_base(cs3), cs3 & 15); spi_brg(io+3, MRAMS_MHZ * 1000); spi_set(io+3, PIC32_SPICON_CKE); @@ -287,12 +296,137 @@ void mrams_preinit(int unit) spi_deselect(io+3); #endif - printf("mrams0: port %s, size %dKB, speed %d Mbit/sec\n", - spi_name(MRAMS_PORT), MRAMS_CHIPS * MRAMS_CHIPSIZE, - spi_get_brg(io) / 1000); - bp = prepartition_device("mrams0"); - if (bp) { - mrams_write(0, 0, bp->b_addr, 512); - brelse(bp); - } + printf("mr0: size %dKB, speed %d Mbit/sec\n", + MRAMS_CHIPS * MRAMS_CHIPSIZE, spi_get_brg(io) / 1000); + return 1; } + +/* + * Open the disk. + */ +int mrams_open(dev_t dev, int flag, int mode) +{ + return 0; +} + +int mrams_close(dev_t dev, int flag, int mode) +{ + return 0; +} + +/* + * Return the size of the device in kbytes. + */ +daddr_t mrams_size(dev_t dev) +{ + return MRAMS_TOTAL_KBYTES; +} + +void mrams_strategy(struct buf *bp) +{ + int offset = bp->b_blkno; + long nblk = btod(bp->b_bcount); + int s; + + /* + * Determine the size of the transfer, and make sure it is + * within the boundaries of the partition. + */ + if (bp->b_blkno + nblk > MRAMS_TOTAL_KBYTES) { + /* if exactly at end of partition, return an EOF */ + if (bp->b_blkno == MRAMS_TOTAL_KBYTES) { + bp->b_resid = bp->b_bcount; + biodone(bp); + return; + } + /* or truncate if part of it fits */ + nblk = MRAMS_TOTAL_KBYTES - bp->b_blkno; + if (nblk <= 0) { + bp->b_error = EINVAL; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + bp->b_bcount = nblk << DEV_BSHIFT; + } + + led_control(LED_SWAP, 1); + + s = splbio(); +#ifdef UCB_METER + if (mrams_dkindex >= 0) { + dk_busy |= 1 << mrams_dkindex; + dk_xfer[mrams_dkindex]++; + dk_bytes[mrams_dkindex] += bp->b_bcount; + } +#endif + + if (bp->b_flags & B_READ) { + mrams_read(offset, bp->b_addr, bp->b_bcount); + } else { + mrams_write(offset, bp->b_addr, bp->b_bcount); + } + + biodone(bp); + led_control(LED_SWAP, 0); +#ifdef UCB_METER + if (mrams_dkindex >= 0) + dk_busy &= ~(1 << mrams_dkindex); +#endif + splx(s); +} + +int mrams_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) +{ + int error = 0; + + switch (cmd) { + + case DIOCGETMEDIASIZE: + /* Get disk size in kbytes. */ + *(int*) addr = MRAMS_TOTAL_KBYTES; + break; + + default: + error = EINVAL; + break; + } + return error; +} + +/* + * Test to see if device is present. + * Return true if found and initialized ok. + */ +static int +mrams_probe(config) + struct conf_device *config; +{ + int cs0 = config->dev_pins[0]; + int cs1 = config->dev_pins[1]; + int cs2 = config->dev_pins[2]; + int cs3 = config->dev_pins[3]; + + /* Only one device unit is supported. */ + if (config->dev_unit != 0) + return 0; + + printf("mr0: port SPI%d, pins cs0=R%c%d/cs1=R%c%d/cs2=R%c%d/cs3=R%c%d\n", + config->dev_ctlr, + gpio_portname(cs0), gpio_pinno(cs0), + gpio_portname(cs1), gpio_pinno(cs1), + gpio_portname(cs2), gpio_pinno(cs2), + gpio_portname(cs3), gpio_pinno(cs3)); + + if (mrams_init(config->dev_ctlr, cs0, cs1, cs2, cs3) != 0) + return 0; + +#ifdef UCB_METER + dk_alloc(&mrams_dkindex, 1, "mr0"); +#endif + return 1; +} + +struct driver mrdriver = { + "mr", mrams_probe, +}; diff --git a/sys/pic32/mrams.h b/sys/pic32/mrams.h index 4530f20..f56c433 100644 --- a/sys/pic32/mrams.h +++ b/sys/pic32/mrams.h @@ -1,9 +1,12 @@ #ifndef _MRAMS_H #define _MRAMS_H -extern int mrams_size(int unit); -extern int mrams_read(int unit, unsigned int offset, char *data, unsigned int bcount); -extern int mrams_write (int unit, unsigned offset, char *data, unsigned bcount); -extern void mrams_preinit (int unit); +#ifdef KERNEL +extern int mrams_open(dev_t dev, int flag, int mode); +extern int mrams_close(dev_t dev, int flag, int mode); +extern daddr_t mrams_size(dev_t dev); +extern void mrams_strategy(struct buf *bp); +extern int mrams_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); +#endif #endif diff --git a/sys/pic32/sramc.c b/sys/pic32/sramc.c index 1c14f31..ef503a3 100644 --- a/sys/pic32/sramc.c +++ b/sys/pic32/sramc.c @@ -1,6 +1,5 @@ /* * Driver for external SRAM-CPLD based Swap and Filesystem devices - * TODO: Modify this driver to be able to function without rdisk layer. * * This version is for 8MB RAMDISK v.1.1 and compatible * Pito 7.4.2014 - PIC32MX PMP bus version From d68b2f2dc1df5f5c8ae890d593444bb6c5b70e3c Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 29 Sep 2015 20:23:53 -0700 Subject: [PATCH 4/7] Update spirams driver. --- sys/pic32/Config.generic | 2 +- sys/pic32/fubarino/Config-mrams | 8 +- sys/pic32/fubarino/Config-spirams | 77 +++++++++ sys/pic32/fubarino/Config-uart-sramc | 8 +- sys/pic32/spirams.c | 247 +++++++++++++++++++++------ sys/pic32/spirams.h | 11 +- 6 files changed, 284 insertions(+), 69 deletions(-) create mode 100644 sys/pic32/fubarino/Config-spirams diff --git a/sys/pic32/Config.generic b/sys/pic32/Config.generic index 4140a85..a04fb70 100644 --- a/sys/pic32/Config.generic +++ b/sys/pic32/Config.generic @@ -167,7 +167,7 @@ signal "MRAMS_LED3" pin RF3 # spirams - SPI block device controller spi1 # RAM disk: spirams -device sr0 at spi1 # chip select signals: +device sr0 at spi1 pins RF0, RF1, RF2, RF3, # chip select signals RF4, RF5, RF6, RF7, RF8, RF9, RF10, RF11, diff --git a/sys/pic32/fubarino/Config-mrams b/sys/pic32/fubarino/Config-mrams index 9f3066a..6ea1c56 100644 --- a/sys/pic32/fubarino/Config-mrams +++ b/sys/pic32/fubarino/Config-mrams @@ -1,12 +1,12 @@ # -# Fubarino SD board -# ================= +# Fubarino SD board with MRAM swap disk +# ===================================== # Console on USB. # For details, see https://github.com/RetroBSD/retrobsd/wiki/Board-Fubarino-SD # # To build the kernel, use: # cd sys/pic32/fubarino -# kconfig Config +# kconfig Config-mrams # make clean # make # @@ -28,7 +28,7 @@ signal "LED_KERNEL" pin RE5 # kernel activity indicator # Root filesystem at /dev/sd0a, swap at /dev/sd0b config unix root on sd0a - swap on sd0b + swap on mr0 # Swap on MRAM disk # Console options options "CONS_MAJOR=UARTUSB_MAJOR" # UARTUSB device diff --git a/sys/pic32/fubarino/Config-spirams b/sys/pic32/fubarino/Config-spirams new file mode 100644 index 0000000..f0e5d5b --- /dev/null +++ b/sys/pic32/fubarino/Config-spirams @@ -0,0 +1,77 @@ +# +# Fubarino SD board with RAM disk on SPI port +# =========================================== +# Console on USB. +# For details, see https://github.com/RetroBSD/retrobsd/wiki/Board-Fubarino-SD +# +# To build the kernel, use: +# cd sys/pic32/fubarino +# kconfig Config-spirams +# make clean +# make +# +# Format of this file is described on page: +# http://retrobsd.org/wiki/doku.php/doc/kconfig +# +architecture "pic32" +cpu "PIC32MX7" # Processor variant +board "FUBARINO" # Board type +ldscript "max32/bootloader.ld" # Linker script + +# Standard system options +options "CPU_KHZ=80000" # Oscillator frequency of CPU core +options "BUS_KHZ=80000" # Frequency of peripheral bus +options "BUS_DIV=1" # Bus clock divisor 1/2/4/8 + +# LED +signal "LED_KERNEL" pin RE5 # kernel activity indicator + +# Root filesystem at /dev/sd0a, swap at /dev/sd0b +config unix root on sd0a + swap on sr0 # Swap on SPI RAM disk + +# Console options +options "CONS_MAJOR=UARTUSB_MAJOR" # UARTUSB device + +# Virtual UART on USB +device uartusb +options "USB_MAX_EP_NUMBER=3" +options "USB_NUM_STRING_DESCRIPTORS=3" + +# UART ports +device uart2 # Pins RF4, RF5 + +# SPI ports +controller spi2 # SD card +controller spi3 # Pins RD1, RD2, RD3 + +# microSD card +device sd0 at spi2 pin RG9 # select pin + +# General purpose I/O ports +# Flags define a mask of available pins +# The following pins excluded: +# RG6, RG7, RG8, RG9 - spi2, SD card +# RD1, RD2, RD3 - spi3 +# RF4, RF5 - uart2 +device gpio1 flags 0xffff # port B +device gpio2 flags 0xf000 # port C +device gpio3 flags 0x0ff1 # port D +device gpio4 flags 0x00ff # port E +device gpio5 flags 0x000b # port F +device gpio6 flags 0x000c # port G + +# ADC driver +device adc + +# PWM driver +device pwm + +# spirams - SPI block device +device sr0 at spi3 + pins RD4, RD5, RD6, RD7, # chip select signals + RD8, RD9, RD10, RD11, + RE0, RE1, RE2, RE3, + RE4, RE5, RE6, RE7 +options "SPIRAMS_CHIPS=16" # number of chips +options "SPIRAMS_CHIPSIZE=128" # chip size in kbytes diff --git a/sys/pic32/fubarino/Config-uart-sramc b/sys/pic32/fubarino/Config-uart-sramc index 95b8d16..617c915 100644 --- a/sys/pic32/fubarino/Config-uart-sramc +++ b/sys/pic32/fubarino/Config-uart-sramc @@ -1,13 +1,13 @@ # -# Fubarino SD board SRAMC swap disk -# ================================= +# Fubarino SD board with SRAMC swap disk +# ====================================== # Console on UART2. # Overclocked to 120MHz. # Clock rate increased to 1000Hz. # # To build the kernel, use: -# cd sys/pic32/fubarino-uart-sramc -# kconfig Config +# cd sys/pic32/fubarino +# kconfig Config-uart-sramc # make clean # make # diff --git a/sys/pic32/spirams.c b/sys/pic32/spirams.c index fa04623..90056b4 100644 --- a/sys/pic32/spirams.c +++ b/sys/pic32/spirams.c @@ -1,13 +1,15 @@ /* - * TODO: Modify this driver to be able to function without rdisk layer. + * Disk driver for serial RAM chips connected via SPI port. */ #include #include #include #include #include +#include #include -#include +#include +#include #include #define SPIRAM_WREN 0x06 @@ -25,10 +27,12 @@ struct spiio spirams_io[SPIRAMS_CHIPS]; -int spirams_size(int unit) -{ - return SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE; -} +int spirams_dkindex; /* disk index for statistics */ + +/* + * Size of RAM disk. + */ +#define SPIRAMS_TOTAL_KBYTES (SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE) #define MRBSIZE 1024 #define MRBLOG2 10 @@ -179,7 +183,7 @@ unsigned int spir_read_block(unsigned int chip, unsigned int address, unsigned i return cs; } -int spirams_read(int unit, unsigned int offset, char *data, unsigned int bcount) +int spirams_read(unsigned int offset, char *data, unsigned int bcount) { register unsigned int chip; register unsigned int toread; @@ -282,7 +286,7 @@ unsigned int spir_write_block(unsigned int chip, unsigned int address, unsigned return cs; } -int spirams_write (int unit, unsigned int offset, char *data, unsigned bcount) +int spirams_write (unsigned int offset, char *data, unsigned bcount) { register unsigned int chip; register unsigned int address; @@ -311,119 +315,250 @@ int spirams_write (int unit, unsigned int offset, char *data, unsigned bcount) return 1; } -void spirams_preinit (int unit) +static unsigned *gpio_base(int cs) +{ + int port = (cs >> 4) - 1; + struct gpioreg *base = port + (struct gpioreg*) &TRISA; + + return (unsigned int*) base; +} + +/* + * Initialize hardware. + */ +static int spirams_init(int spi_port, char cs[]) { struct spiio *io = &spirams_io[0]; - struct buf *bp; - - if (unit >= 1) - return; - - /* Initialize hardware. */ - - if (spi_setup(io, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS0_PORT,SPIRAMS_CS0_PIN) != 0) - return; + if (spi_setup(io, spi_port, gpio_base(cs[0]), cs[0] & 15) != 0) { + printf("sr0: cannot open SPI%u port\n", spi_port); + return 0; + } spi_brg(io, SPIRAMS_MHZ * 1000); spi_set(io, PIC32_SPICON_CKE); -#ifdef SPIRAMS_CS1_PORT - spi_setup(io+1, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS1_PORT,SPIRAMS_CS1_PIN); +#if SPIRAMS_CHIPS >= 1 + spi_setup(io+1, spi_port, gpio_base(cs[1]), cs[1] & 15); spi_brg(io+1, SPIRAMS_MHZ * 1000); spi_set(io+1, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS2_PORT - spi_setup(io+2, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS2_PORT,SPIRAMS_CS2_PIN); +#if SPIRAMS_CHIPS >= 2 + spi_setup(io+2, spi_port, gpio_base(cs[2]), cs[2] & 15); spi_brg(io+2, SPIRAMS_MHZ * 1000); spi_set(io+2, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS3_PORT - spi_setup(io+3, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS3_PORT,SPIRAMS_CS3_PIN); +#if SPIRAMS_CHIPS >= 3 + spi_setup(io+3, spi_port, gpio_base(cs[3]), cs[3] & 15); spi_brg(io+3, SPIRAMS_MHZ * 1000); spi_set(io+3, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS4_PORT - spi_setup(io+4, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS4_PORT,SPIRAMS_CS4_PIN); +#if SPIRAMS_CHIPS >= 4 + spi_setup(io+4, spi_port, gpio_base(cs[4]), cs[4] & 15); spi_brg(io+4, SPIRAMS_MHZ * 1000); spi_set(io+4, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS5_PORT - spi_setup(io+5, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS5_PORT,SPIRAMS_CS5_PIN); +#if SPIRAMS_CHIPS >= 5 + spi_setup(io+5, spi_port, gpio_base(cs[5]), cs[5] & 15); spi_brg(io+5, SPIRAMS_MHZ * 1000); spi_set(io+5, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS6_PORT - spi_setup(io+6, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS6_PORT,SPIRAMS_CS6_PIN); +#if SPIRAMS_CHIPS >= 6 + spi_setup(io+6, spi_port, gpio_base(cs[6]), cs[6] & 15); spi_brg(io+6, SPIRAMS_MHZ * 1000); spi_set(io+6, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS7_PORT - spi_setup(io+7, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS7_PORT,SPIRAMS_CS7_PIN); +#if SPIRAMS_CHIPS >= 7 + spi_setup(io+7, spi_port, gpio_base(cs[7]), cs[7] & 15); spi_brg(io+7, SPIRAMS_MHZ * 1000); spi_set(io+7, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS8_PORT - spi_setup(io+8, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS8_PORT,SPIRAMS_CS8_PIN); +#if SPIRAMS_CHIPS >= 8 + spi_setup(io+8, spi_port, gpio_base(cs[8]), cs[8] & 15); spi_brg(io+8, SPIRAMS_MHZ * 1000); spi_set(io+8, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS9_PORT - spi_setup(io+9, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS9_PORT,SPIRAMS_CS9_PIN); +#if SPIRAMS_CHIPS >= 9 + spi_setup(io+9, spi_port, gpio_base(cs[9]), cs[9] & 15); spi_brg(io+9, SPIRAMS_MHZ * 1000); spi_set(io+9, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS10_PORT - spi_setup(io+10, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS10_PORT,SPIRAMS_CS10_PIN); +#if SPIRAMS_CHIPS >= 10 + spi_setup(io+10, spi_port, gpio_base(cs[10]), cs[10] & 15); spi_brg(io+10, SPIRAMS_MHZ * 1000); spi_set(io+10, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS11_PORT - spi_setup(io+11, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS11_PORT,SPIRAMS_CS11_PIN); +#if SPIRAMS_CHIPS >= 11 + spi_setup(io+11, spi_port, gpio_base(cs[11]), cs[11] & 15); spi_brg(io+11, SPIRAMS_MHZ * 1000); spi_set(io+11, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS12_PORT - spi_setup(io+12, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS12_PORT,SPIRAMS_CS12_PIN); +#if SPIRAMS_CHIPS >= 12 + spi_setup(io+12, spi_port, gpio_base(cs[12]), cs[12] & 15); spi_brg(io+12, SPIRAMS_MHZ * 1000); spi_set(io+12, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS13_PORT - spi_setup(io+13, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS13_PORT,SPIRAMS_CS13_PIN); +#if SPIRAMS_CHIPS >= 13 + spi_setup(io+13, spi_port, gpio_base(cs[13]), cs[13] & 15); spi_brg(io+13, SPIRAMS_MHZ * 1000); spi_set(io+13, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS14_PORT - spi_setup(io+14, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS14_PORT,SPIRAMS_CS14_PIN); +#if SPIRAMS_CHIPS >= 14 + spi_setup(io+14, spi_port, gpio_base(cs[14]), cs[14] & 15); spi_brg(io+14, SPIRAMS_MHZ * 1000); spi_set(io+14, PIC32_SPICON_CKE); #endif -#ifdef SPIRAMS_CS15_PORT - spi_setup(io+15, SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS15_PORT,SPIRAMS_CS15_PIN); +#if SPIRAMS_CHIPS >= 15 + spi_setup(io+15, spi_port, gpio_base(cs[15]), cs[15] & 15); spi_brg(io+15, SPIRAMS_MHZ * 1000); spi_set(io+15, PIC32_SPICON_CKE); #endif - printf("spirams0: port %d %s, size %dKB, speed %d Mbit/sec\n", - SPIRAMS_PORT, spi_name(io), SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE, - spi_get_brg(io) / 1000); - bp = prepartition_device("spirams0"); - if (bp) { - spirams_write (0, 0, bp->b_addr, 512); - brelse(bp); - } + printf("spirams0: size %dKB, speed %d Mbit/sec\n", + SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE, spi_get_brg(io) / 1000); + return 1; } + +/* + * Open the disk. + */ +int spirams_open(dev_t dev, int flag, int mode) +{ + return 0; +} + +int spirams_close(dev_t dev, int flag, int mode) +{ + return 0; +} + +/* + * Return the size of the device in kbytes. + */ +daddr_t spirams_size(dev_t dev) +{ + return SPIRAMS_TOTAL_KBYTES; +} + +void spirams_strategy(struct buf *bp) +{ + int offset = bp->b_blkno; + long nblk = btod(bp->b_bcount); + int s; + + /* + * Determine the size of the transfer, and make sure it is + * within the boundaries of the partition. + */ + if (bp->b_blkno + nblk > SPIRAMS_TOTAL_KBYTES) { + /* if exactly at end of partition, return an EOF */ + if (bp->b_blkno == SPIRAMS_TOTAL_KBYTES) { + bp->b_resid = bp->b_bcount; + biodone(bp); + return; + } + /* or truncate if part of it fits */ + nblk = SPIRAMS_TOTAL_KBYTES - bp->b_blkno; + if (nblk <= 0) { + bp->b_error = EINVAL; + bp->b_flags |= B_ERROR; + biodone(bp); + return; + } + bp->b_bcount = nblk << DEV_BSHIFT; + } + + led_control(LED_SWAP, 1); + + s = splbio(); +#ifdef UCB_METER + if (spirams_dkindex >= 0) { + dk_busy |= 1 << spirams_dkindex; + dk_xfer[spirams_dkindex]++; + dk_bytes[spirams_dkindex] += bp->b_bcount; + } +#endif + + if (bp->b_flags & B_READ) { + spirams_read(offset, bp->b_addr, bp->b_bcount); + } else { + spirams_write(offset, bp->b_addr, bp->b_bcount); + } + + biodone(bp); + led_control(LED_SWAP, 0); +#ifdef UCB_METER + if (spirams_dkindex >= 0) + dk_busy &= ~(1 << spirams_dkindex); +#endif + splx(s); +} + +int spirams_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) +{ + int error = 0; + + switch (cmd) { + + case DIOCGETMEDIASIZE: + /* Get disk size in kbytes. */ + *(int*) addr = SPIRAMS_TOTAL_KBYTES; + break; + + default: + error = EINVAL; + break; + } + return error; +} + +/* + * Test to see if device is present. + * Return true if found and initialized ok. + */ +static int +spirams_probe(config) + struct conf_device *config; +{ + int i; + + /* Only one device unit is supported. */ + if (config->dev_unit != 0) + return 0; + + printf("sr0: port SPI%d, pins ", config->dev_ctlr); + for (i=0; idev_pins[i]; + if (i > 0) + printf("/"); + if (i == 7) + printf("\n "); + printf("R%c%d", gpio_portname(cs), gpio_pinno(cs)); + } + printf("\n"); + if (spirams_init(config->dev_ctlr, config->dev_pins) != 0) + return 0; + +#ifdef UCB_METER + dk_alloc(&spirams_dkindex, 1, "sr0"); +#endif + return 1; +} + +struct driver srdriver = { + "sr", spirams_probe, +}; diff --git a/sys/pic32/spirams.h b/sys/pic32/spirams.h index 8ab721d..9613cb3 100644 --- a/sys/pic32/spirams.h +++ b/sys/pic32/spirams.h @@ -1,9 +1,12 @@ #ifndef _SPIRAMS_H #define _SPIRAMS_H -extern int spirams_size(int unit); -extern int spirams_read(int unit, unsigned int offset, char *data, unsigned int bcount); -extern int spirams_write (int unit, unsigned offset, char *data, unsigned bcount); -extern void spirams_preinit (int unit); +#ifdef KERNEL +extern int spirams_open(dev_t dev, int flag, int mode); +extern int spirams_close(dev_t dev, int flag, int mode); +extern daddr_t spirams_size(dev_t dev); +extern void spirams_strategy(struct buf *bp); +extern int spirams_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); +#endif #endif From e8e186905a1d853ba1c3be11773190b84d6abe25 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 29 Sep 2015 20:27:24 -0700 Subject: [PATCH 5/7] Remove unused options from generic Config file. --- sys/pic32/Config.generic | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/sys/pic32/Config.generic b/sys/pic32/Config.generic index a04fb70..5374809 100644 --- a/sys/pic32/Config.generic +++ b/sys/pic32/Config.generic @@ -175,23 +175,6 @@ device sr0 at spi1 options "SPIRAMS_CHIPSIZE=128" # chip size in kbytes options "SPIRAMS_CHIPS=16" # number of chips options "SPIRAMS_MHZ=10" # speed 10 MHz -options "SPIRAMS_PORT=SPI1CON" # TODO: delete this option -signal "SPIRAMS_CS0" pin RF0 # TODO: delete -signal "SPIRAMS_CS1" pin RF1 # TODO: delete -signal "SPIRAMS_CS2" pin RF2 # TODO: delete -signal "SPIRAMS_CS3" pin RF3 # TODO: delete -signal "SPIRAMS_CS4" pin RF4 # TODO: delete -signal "SPIRAMS_CS5" pin RF5 # TODO: delete -signal "SPIRAMS_CS6" pin RF6 # TODO: delete -signal "SPIRAMS_CS7" pin RF7 # TODO: delete -signal "SPIRAMS_CS8" pin RF8 # TODO: delete -signal "SPIRAMS_CS9" pin RF9 # TODO: delete -signal "SPIRAMS_CS10" pin RF10 # TODO: delete -signal "SPIRAMS_CS11" pin RF11 # TODO: delete -signal "SPIRAMS_CS12" pin RF12 # TODO: delete -signal "SPIRAMS_CS13" pin RF13 # TODO: delete -signal "SPIRAMS_CS14" pin RF14 # TODO: delete -signal "SPIRAMS_CS15" pin RF15 # TODO: delete signal "SPIRAMS_LED0" pin RG0 # optional LED indicators signal "SPIRAMS_LED1" pin RG1 signal "SPIRAMS_LED2" pin RG2 From 3e439df5a2ac1dfe297ef5826ae9c247d00ecf1b Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Wed, 30 Sep 2015 13:03:12 -0700 Subject: [PATCH 6/7] Simplify spi_setup() function parameters. --- sys/include/spi.h | 2 +- sys/pic32/mrams.c | 16 ++++------------ sys/pic32/sd.c | 6 +----- sys/pic32/spi.c | 2 +- sys/pic32/spi_bus.c | 12 +++++++++++- sys/pic32/spirams.c | 40 ++++++++++++++++------------------------ 6 files changed, 34 insertions(+), 44 deletions(-) diff --git a/sys/include/spi.h b/sys/include/spi.h index 36209c0..88065cc 100644 --- a/sys/include/spi.h +++ b/sys/include/spi.h @@ -49,7 +49,7 @@ struct spiio { unsigned int mode; }; -extern int spi_setup(struct spiio *io, int channel, unsigned int *tris, unsigned int pin); +extern int spi_setup(struct spiio *io, int channel, int cs); extern void spi_set_cspin(struct spiio *io, unsigned int *tris, unsigned int pin); extern void spi_select(struct spiio *io); extern void spi_deselect(struct spiio *io); diff --git a/sys/pic32/mrams.c b/sys/pic32/mrams.c index 5c6e2a0..69f3eed 100644 --- a/sys/pic32/mrams.c +++ b/sys/pic32/mrams.c @@ -243,14 +243,6 @@ int mrams_write(unsigned int offset, char *data, unsigned bcount) return 1; } -static unsigned *gpio_base(int cs) -{ - int port = (cs >> 4) - 1; - struct gpioreg *base = port + (struct gpioreg*) &TRISA; - - return (unsigned int*) base; -} - /* * Initialize hardware. */ @@ -258,7 +250,7 @@ static int mrams_init(int spi_port, int cs0, int cs1, int cs2, int cs3) { struct spiio *io = &mrams_io[0]; - if (spi_setup(io, spi_port, gpio_base(cs0), cs0 & 15) != 0) { + if (spi_setup(io, spi_port, cs0) != 0) { printf("mr0: cannot open SPI%u port\n", spi_port); return 0; } @@ -269,7 +261,7 @@ static int mrams_init(int spi_port, int cs0, int cs1, int cs2, int cs3) spi_deselect(io); #if MRAMS_CHIPS >= 1 - spi_setup(io+1, spi_port, gpio_base(cs1), cs1 & 15); + spi_setup(io+1, spi_port, cs1); spi_brg(io+1, MRAMS_MHZ * 1000); spi_set(io+1, PIC32_SPICON_CKE); @@ -278,7 +270,7 @@ static int mrams_init(int spi_port, int cs0, int cs1, int cs2, int cs3) spi_deselect(io+1); #endif #if MRAMS_CHIPS >= 2 - spi_setup(io+2, spi_port, gpio_base(cs2), cs2 & 15); + spi_setup(io+2, spi_port, cs2); spi_brg(io+2, MRAMS_MHZ * 1000); spi_set(io+2, PIC32_SPICON_CKE); @@ -287,7 +279,7 @@ static int mrams_init(int spi_port, int cs0, int cs1, int cs2, int cs3) spi_deselect(io+2); #endif #if MRAMS_CHIPS >= 3 - spi_setup(io+3, spi_port, gpio_base(cs3), cs3 & 15); + spi_setup(io+3, spi_port, cs3); spi_brg(io+3, MRAMS_MHZ * 1000); spi_set(io+3, PIC32_SPICON_CKE); diff --git a/sys/pic32/sd.c b/sys/pic32/sd.c index ee95443..d63d52a 100644 --- a/sys/pic32/sd.c +++ b/sys/pic32/sd.c @@ -877,11 +877,7 @@ sd_probe(config) printf("sd%u: port SPI%d, pin cs=R%c%d\n", unit, config->dev_ctlr, gpio_portname(cs), gpio_pinno(cs)); - int port = (cs >> 4) - 1; - int pin = cs & 15; - struct gpioreg *base = port + (struct gpioreg*) &TRISA; - - if (spi_setup(io, config->dev_ctlr, (unsigned int*) base, pin) != 0) { + if (spi_setup(io, config->dev_ctlr, cs) != 0) { printf("sd%u: cannot open SPI%u port\n", unit, config->dev_ctlr); return 0; } diff --git a/sys/pic32/spi.c b/sys/pic32/spi.c index a9ecd4a..a40566e 100644 --- a/sys/pic32/spi.c +++ b/sys/pic32/spi.c @@ -317,7 +317,7 @@ spiprobe(config) gpio_portname(sdo), gpio_pinno(sdo), gpio_portname(sck), gpio_pinno(sck)); - if (spi_setup(io, channel+1, 0, 0) != 0) { + if (spi_setup(io, channel+1, 0) != 0) { printf("spi%u: setup failed\n", channel+1); return 0; } diff --git a/sys/pic32/spi_bus.c b/sys/pic32/spi_bus.c index 366a29d..b5f0336 100644 --- a/sys/pic32/spi_bus.c +++ b/sys/pic32/spi_bus.c @@ -28,11 +28,21 @@ static struct spireg *const spi_base[NSPI] = { // Returns an integer for the number of the device (ala fd). // Returns -1 if no devices are available. // -int spi_setup(struct spiio *io, int channel, unsigned int *tris, unsigned int pin) +int spi_setup(struct spiio *io, int channel, int cs) { + unsigned *tris = 0; + int pin = 0; + if (channel <= 0 || channel > NSPI) return ENXIO; + if (cs != 0) { + /* Compute the port address and pin index of the chip select signal. */ + int port = (cs >> 4) - 1; + tris = (unsigned*) (port + (struct gpioreg*) &TRISA); + pin = cs & 15; + } + // Set up the device io->bus = spi_base[channel-1]; io->cs_tris = tris; diff --git a/sys/pic32/spirams.c b/sys/pic32/spirams.c index 90056b4..8b3d7fe 100644 --- a/sys/pic32/spirams.c +++ b/sys/pic32/spirams.c @@ -315,14 +315,6 @@ int spirams_write (unsigned int offset, char *data, unsigned bcount) return 1; } -static unsigned *gpio_base(int cs) -{ - int port = (cs >> 4) - 1; - struct gpioreg *base = port + (struct gpioreg*) &TRISA; - - return (unsigned int*) base; -} - /* * Initialize hardware. */ @@ -330,7 +322,7 @@ static int spirams_init(int spi_port, char cs[]) { struct spiio *io = &spirams_io[0]; - if (spi_setup(io, spi_port, gpio_base(cs[0]), cs[0] & 15) != 0) { + if (spi_setup(io, spi_port, cs[0]) != 0) { printf("sr0: cannot open SPI%u port\n", spi_port); return 0; } @@ -338,91 +330,91 @@ static int spirams_init(int spi_port, char cs[]) spi_set(io, PIC32_SPICON_CKE); #if SPIRAMS_CHIPS >= 1 - spi_setup(io+1, spi_port, gpio_base(cs[1]), cs[1] & 15); + spi_setup(io+1, spi_port, cs[1]); spi_brg(io+1, SPIRAMS_MHZ * 1000); spi_set(io+1, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 2 - spi_setup(io+2, spi_port, gpio_base(cs[2]), cs[2] & 15); + spi_setup(io+2, spi_port, cs[2]); spi_brg(io+2, SPIRAMS_MHZ * 1000); spi_set(io+2, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 3 - spi_setup(io+3, spi_port, gpio_base(cs[3]), cs[3] & 15); + spi_setup(io+3, spi_port, cs[3]); spi_brg(io+3, SPIRAMS_MHZ * 1000); spi_set(io+3, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 4 - spi_setup(io+4, spi_port, gpio_base(cs[4]), cs[4] & 15); + spi_setup(io+4, spi_port, cs[4]); spi_brg(io+4, SPIRAMS_MHZ * 1000); spi_set(io+4, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 5 - spi_setup(io+5, spi_port, gpio_base(cs[5]), cs[5] & 15); + spi_setup(io+5, spi_port, cs[5]); spi_brg(io+5, SPIRAMS_MHZ * 1000); spi_set(io+5, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 6 - spi_setup(io+6, spi_port, gpio_base(cs[6]), cs[6] & 15); + spi_setup(io+6, spi_port, cs[6]); spi_brg(io+6, SPIRAMS_MHZ * 1000); spi_set(io+6, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 7 - spi_setup(io+7, spi_port, gpio_base(cs[7]), cs[7] & 15); + spi_setup(io+7, spi_port, cs[7]); spi_brg(io+7, SPIRAMS_MHZ * 1000); spi_set(io+7, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 8 - spi_setup(io+8, spi_port, gpio_base(cs[8]), cs[8] & 15); + spi_setup(io+8, spi_port, cs[8]); spi_brg(io+8, SPIRAMS_MHZ * 1000); spi_set(io+8, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 9 - spi_setup(io+9, spi_port, gpio_base(cs[9]), cs[9] & 15); + spi_setup(io+9, spi_port, cs[9]); spi_brg(io+9, SPIRAMS_MHZ * 1000); spi_set(io+9, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 10 - spi_setup(io+10, spi_port, gpio_base(cs[10]), cs[10] & 15); + spi_setup(io+10, spi_port, cs[10]); spi_brg(io+10, SPIRAMS_MHZ * 1000); spi_set(io+10, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 11 - spi_setup(io+11, spi_port, gpio_base(cs[11]), cs[11] & 15); + spi_setup(io+11, spi_port, cs[11]); spi_brg(io+11, SPIRAMS_MHZ * 1000); spi_set(io+11, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 12 - spi_setup(io+12, spi_port, gpio_base(cs[12]), cs[12] & 15); + spi_setup(io+12, spi_port, cs[12]); spi_brg(io+12, SPIRAMS_MHZ * 1000); spi_set(io+12, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 13 - spi_setup(io+13, spi_port, gpio_base(cs[13]), cs[13] & 15); + spi_setup(io+13, spi_port, cs[13]); spi_brg(io+13, SPIRAMS_MHZ * 1000); spi_set(io+13, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 14 - spi_setup(io+14, spi_port, gpio_base(cs[14]), cs[14] & 15); + spi_setup(io+14, spi_port, cs[14]); spi_brg(io+14, SPIRAMS_MHZ * 1000); spi_set(io+14, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 15 - spi_setup(io+15, spi_port, gpio_base(cs[15]), cs[15] & 15); + spi_setup(io+15, spi_port, cs[15]); spi_brg(io+15, SPIRAMS_MHZ * 1000); spi_set(io+15, PIC32_SPICON_CKE); From 0f7e688c2e031e1544e29853bcbcf43384aef582 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Fri, 2 Oct 2015 21:02:10 -0700 Subject: [PATCH 7/7] Add kernel configuration for SnadPIC MX795 board. For board documentation, see: http://www.microcontroller-board.com/snadpic-board-32/11-snadpic-pic32mx795f512l-development-board.html --- sys/pic32/Makefile | 3 +- sys/pic32/README | 2 + sys/pic32/snadpic/Config | 65 ++++++ sys/pic32/snadpic/Makefile | 362 ++++++++++++++++++++++++++++++++ tools/build/Makefile | 2 +- tools/build/skeleton/README.txt | 4 +- 6 files changed, 434 insertions(+), 4 deletions(-) create mode 100644 sys/pic32/snadpic/Config create mode 100644 sys/pic32/snadpic/Makefile diff --git a/sys/pic32/Makefile b/sys/pic32/Makefile index 5af89ad..4b24754 100644 --- a/sys/pic32/Makefile +++ b/sys/pic32/Makefile @@ -3,7 +3,8 @@ # SUBDIR = baremetal duinomite duinomite-emega explorer16 \ fubarino max32 maximite maximite-color mmb-mx7 \ - picadillo pinguino-micro sdxl starter-kit ubw32 wf32 + picadillo pinguino-micro sdxl snadpic starter-kit \ + ubw32 wf32 default: diff --git a/sys/pic32/README b/sys/pic32/README index e32461c..b8678e9 100644 --- a/sys/pic32/README +++ b/sys/pic32/README @@ -30,6 +30,8 @@ Build directories: sdxl/ - Majenko SDXL board. + snadpic/ - SnadPIC MX795 board. + starter-kit/ - Microchip PIC32MX USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail. diff --git a/sys/pic32/snadpic/Config b/sys/pic32/snadpic/Config new file mode 100644 index 0000000..026ef56 --- /dev/null +++ b/sys/pic32/snadpic/Config @@ -0,0 +1,65 @@ +# +# SnadPIC MX795 board +# =================== +# Console on USB. +# +# To build the kernel, use: +# cd sys/pic32/snadpic +# kconfig Config +# make clean +# make +# +# Format of this file is described on page: +# http://retrobsd.org/wiki/doku.php/doc/kconfig +# +architecture "pic32" +cpu "PIC32MX7" # Processor variant +board "SNADPIC" # Board type +ldscript "maximite/bootloader.ld" # Linker script + +# Standard system options +options "CPU_KHZ=80000" # Oscillator frequency of CPU core +options "BUS_KHZ=80000" # Frequency of peripheral bus +options "BUS_DIV=1" # Bus clock divisor 1/2/4/8 + +# Root filesystem at /dev/sd0a, swap at /dev/sd0b +config unix root on sd0a + swap on sd0b + +# Console options +options "CONS_MAJOR=UARTUSB_MAJOR" # UARTUSB device + +# Virtual UART on USB +device uartusb +options "USB_MAX_EP_NUMBER=3" +options "USB_NUM_STRING_DESCRIPTORS=3" + +# UART ports +device uart2 # Pins RF4, RF5 + +# SPI ports +controller spi2 # SD card +controller spi3 # Pins RD1, RD2, RD3 + +# microSD card +device sd0 at spi2 pin RG9 # select pin + +# General purpose I/O ports +# Flags define a mask of available pins +# The following pins excluded: +# RG6, RG7, RG8, RG9 - spi2, SD card +# RD1, RD2, RD3 - spi3 +# RF4, RF5 - uart2 +device gpio0 flags 0xc6ff # port A +device gpio1 flags 0xffff # port B +device gpio2 flags 0xf01e # port C +device gpio3 flags 0xfff1 # port D +device gpio4 flags 0x03ff # port E +device gpio5 flags 0x310f # port F +device gpio6 flags 0xf00f # port G + +# ADC driver +device adc + +# PWM driver +device pwm diff --git a/sys/pic32/snadpic/Makefile b/sys/pic32/snadpic/Makefile new file mode 100644 index 0000000..4104a54 --- /dev/null +++ b/sys/pic32/snadpic/Makefile @@ -0,0 +1,362 @@ +PARAM = -DSNADPIC +PARAM += -DPIC32MX7 +PARAM += -DUARTUSB_ENABLED +PARAM += -DUART2_ENABLED +PARAM += -DSPI2_ENABLED +PARAM += -DSPI3_ENABLED +PARAM += -DSD_ENABLED +PARAM += -DGPIO_ENABLED +PARAM += -DGPIO1_ENABLED +PARAM += -DGPIO2_ENABLED +PARAM += -DGPIO3_ENABLED +PARAM += -DGPIO4_ENABLED +PARAM += -DGPIO5_ENABLED +PARAM += -DGPIO6_ENABLED +PARAM += -DADC_ENABLED +PARAM += -DPWM_ENABLED +PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3 +PARAM += -DUSB_MAX_EP_NUMBER=3 +PARAM += -DCONS_MAJOR=UARTUSB_MAJOR +PARAM += -DBUS_DIV=1 +PARAM += -DBUS_KHZ=80000 +PARAM += -DCPU_KHZ=80000 +LDSCRIPT = "maximite/bootloader.ld" +# +# Makefile for RetroBSD, pic32 target +# +# DEBUG is set to -g by kconfig if debugging is requested (kconfig -g). +# +include ../gcc-config.mk + +AS = ${MIPS_GCC_PREFIX}as ${DEBUG} -mips32r2 -EL +CC = ${MIPS_GCC_PREFIX}gcc ${DEBUG} -mips32r2 -EL -nostdinc -fno-builtin -Werror -Wall +CPP = ${MIPS_GCC_PREFIX}cpp +LD = ${MIPS_GCC_PREFIX}gcc -mips32r2 -EL +LDFLAGS = -nostdlib -T ../${LDSCRIPT} -Wl,-Map=$(basename $@).map +SIZE = ${MIPS_GCC_PREFIX}size +OBJCOPY = ${MIPS_GCC_PREFIX}objcopy +OBJDUMP = ${MIPS_GCC_PREFIX}objdump + +ifneq (${MIPS_GCC_FORMAT},) + LDFLAGS += -Wl,--oformat=${MIPS_GCC_FORMAT} +endif + +# sources are located via $S relative to the compilation directory +S = ../.. + +DEPFLAGS = -MT $@ -MP -MD -MF .deps/$*.dep +DEFS = -I. ${PARAM} -DKERNEL $(DEPFLAGS) +CFLAGS = -O ${DEFS} + +# compile rules: rules are named COMPILE_${SUFFIX} +# SUFFIX is the file suffix, capitalized (e.g. C for a .c file). + +COMPILE_C = ${CC} -c ${CFLAGS} $< +COMPILE_S = ${CC} -c ${DEFS} $< + +OBJS = exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o \ + init_main.o init_sysent.o kern_clock.o kern_descrip.o \ + kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o \ + kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o \ + kern_subr.o kern_synch.o kern_sysctl.o kern_time.o subr_prf.o \ + subr_rmap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o \ + syscalls.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o \ + ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o \ + ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o \ + vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o clock.o cons.o devsw.o \ + exception.o machdep.o mem.o signal.o swap.o sysctl.o adc.o \ + gpio.o pwm.o sd.o spi.o spi_bus.o uart.o usb_device.o \ + usb_function_cdc.o usb_uart.o + +CFILES = $S/kernel/exec_aout.c $S/kernel/exec_conf.c $S/kernel/exec_elf.c \ + $S/kernel/exec_script.c $S/kernel/exec_subr.c \ + $S/kernel/init_main.c $S/kernel/init_sysent.c \ + $S/kernel/kern_clock.c $S/kernel/kern_descrip.c \ + $S/kernel/kern_exec.c $S/kernel/kern_exit.c \ + $S/kernel/kern_fork.c $S/kernel/kern_mman.c \ + $S/kernel/kern_proc.c $S/kernel/kern_prot.c \ + $S/kernel/kern_prot2.c $S/kernel/kern_resource.c \ + $S/kernel/kern_sig.c $S/kernel/kern_sig2.c $S/kernel/kern_subr.c \ + $S/kernel/kern_synch.c $S/kernel/kern_sysctl.c \ + $S/kernel/kern_time.c $S/kernel/subr_prf.c $S/kernel/subr_rmap.c \ + $S/kernel/sys_generic.c $S/kernel/sys_inode.c \ + $S/kernel/sys_pipe.c $S/kernel/sys_process.c \ + $S/kernel/syscalls.c $S/kernel/tty.c $S/kernel/tty_subr.c \ + $S/kernel/tty_tty.c $S/kernel/ufs_alloc.c $S/kernel/ufs_bio.c \ + $S/kernel/ufs_bmap.c $S/kernel/ufs_dsort.c $S/kernel/ufs_fio.c \ + $S/kernel/ufs_inode.c $S/kernel/ufs_mount.c \ + $S/kernel/ufs_namei.c $S/kernel/ufs_subr.c \ + $S/kernel/ufs_syscalls.c $S/kernel/ufs_syscalls2.c \ + $S/kernel/vfs_vnops.c $S/kernel/vm_sched.c $S/kernel/vm_swap.c \ + $S/kernel/vm_swp.c $S/pic32/clock.c $S/pic32/cons.c \ + $S/pic32/devsw.c $S/pic32/exception.c $S/pic32/machdep.c \ + $S/pic32/mem.c $S/pic32/signal.c $S/pic32/swap.c \ + $S/pic32/sysctl.c $S/pic32/adc.c $S/pic32/gpio.c $S/pic32/pwm.c \ + $S/pic32/sd.c $S/pic32/spi.c $S/pic32/spi_bus.c $S/pic32/uart.c \ + $S/pic32/usb_device.c $S/pic32/usb_function_cdc.c \ + $S/pic32/usb_uart.c swapunix.c + +# load lines for config "xxx" will be emitted as: +# xxx: ${SYSTEM_DEP} swapxxx.o +# ${SYSTEM_LD_HEAD} +# ${SYSTEM_LD} swapxxx.o +# ${SYSTEM_LD_TAIL} +SYSTEM_OBJ = startup.o ${OBJS} ioconf.o +ifeq (devcfg.c,$(wildcard devcfg.c)) + SYSTEM_OBJ += devcfg.o +endif +SYSTEM_DEP = Makefile ioconf.c machine sys .deps ${SYSTEM_OBJ} +SYSTEM_LD_HEAD = sh ../newvers.sh > vers.c; ${CC} $(CFLAGS) -c vers.c; rm -f $@ +SYSTEM_LD = -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -o $@; \ + ${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -o $@ +SYSTEM_LD_TAIL = ${SIZE} $@; \ + $(OBJCOPY) -O ihex --change-addresses=0x80000000 $@ $(basename $@).hex; \ + $(OBJCOPY) -O binary -R .boot -R .config $@ $(basename $@).bin; \ + $(OBJDUMP) -d -S $@ > $(basename $@).dis + +unix: unix.elf + +unix.elf: ${SYSTEM_DEP} swapunix.o + ${SYSTEM_LD_HEAD} + ${SYSTEM_LD} swapunix.o + ${SYSTEM_LD_TAIL} + +swapunix.o: swapunix.c + ${COMPILE_C} + +all: unix + +clean: + rm -rf .deps *.elf *.o *.map *.dis *.bin machine sys + +clean-all: clean + rm -f *.h *.hex ioconf.c swap*.c vers.c + +reconfig ioconf.c: Config ../../../tools/kconfig/kconfig + ../../../tools/kconfig/kconfig Config + $(MAKE) clean + rm -f *.hex + +load: unix.elf + pic32prog unix.hex + +machine: + ln -s .. $@ + +sys: + ln -s ../../include $@ + +.deps: + mkdir .deps + +startup.o: ../startup.S + ${COMPILE_S} + +ioconf.o: ioconf.c + ${COMPILE_C} + +exec_aout.o: $S/kernel/exec_aout.c + ${COMPILE_C} + +exec_conf.o: $S/kernel/exec_conf.c + ${COMPILE_C} + +exec_elf.o: $S/kernel/exec_elf.c + ${COMPILE_C} + +exec_script.o: $S/kernel/exec_script.c + ${COMPILE_C} + +exec_subr.o: $S/kernel/exec_subr.c + ${COMPILE_C} + +init_main.o: $S/kernel/init_main.c + ${COMPILE_C} + +init_sysent.o: $S/kernel/init_sysent.c + ${COMPILE_C} + +kern_clock.o: $S/kernel/kern_clock.c + ${COMPILE_C} + +kern_descrip.o: $S/kernel/kern_descrip.c + ${COMPILE_C} + +kern_exec.o: $S/kernel/kern_exec.c + ${COMPILE_C} + +kern_exit.o: $S/kernel/kern_exit.c + ${COMPILE_C} + +kern_fork.o: $S/kernel/kern_fork.c + ${COMPILE_C} + +kern_mman.o: $S/kernel/kern_mman.c + ${COMPILE_C} + +kern_proc.o: $S/kernel/kern_proc.c + ${COMPILE_C} + +kern_prot.o: $S/kernel/kern_prot.c + ${COMPILE_C} + +kern_prot2.o: $S/kernel/kern_prot2.c + ${COMPILE_C} + +kern_resource.o: $S/kernel/kern_resource.c + ${COMPILE_C} + +kern_sig.o: $S/kernel/kern_sig.c + ${COMPILE_C} + +kern_sig2.o: $S/kernel/kern_sig2.c + ${COMPILE_C} + +kern_subr.o: $S/kernel/kern_subr.c + ${COMPILE_C} + +kern_synch.o: $S/kernel/kern_synch.c + ${COMPILE_C} + +kern_sysctl.o: $S/kernel/kern_sysctl.c + ${COMPILE_C} + +kern_time.o: $S/kernel/kern_time.c + ${COMPILE_C} + +subr_prf.o: $S/kernel/subr_prf.c + ${COMPILE_C} + +subr_rmap.o: $S/kernel/subr_rmap.c + ${COMPILE_C} + +sys_generic.o: $S/kernel/sys_generic.c + ${COMPILE_C} + +sys_inode.o: $S/kernel/sys_inode.c + ${COMPILE_C} + +sys_pipe.o: $S/kernel/sys_pipe.c + ${COMPILE_C} + +sys_process.o: $S/kernel/sys_process.c + ${COMPILE_C} + +syscalls.o: $S/kernel/syscalls.c + ${COMPILE_C} + +tty.o: $S/kernel/tty.c + ${COMPILE_C} + +tty_subr.o: $S/kernel/tty_subr.c + ${COMPILE_C} + +tty_tty.o: $S/kernel/tty_tty.c + ${COMPILE_C} + +ufs_alloc.o: $S/kernel/ufs_alloc.c + ${COMPILE_C} + +ufs_bio.o: $S/kernel/ufs_bio.c + ${COMPILE_C} + +ufs_bmap.o: $S/kernel/ufs_bmap.c + ${COMPILE_C} + +ufs_dsort.o: $S/kernel/ufs_dsort.c + ${COMPILE_C} + +ufs_fio.o: $S/kernel/ufs_fio.c + ${COMPILE_C} + +ufs_inode.o: $S/kernel/ufs_inode.c + ${COMPILE_C} + +ufs_mount.o: $S/kernel/ufs_mount.c + ${COMPILE_C} + +ufs_namei.o: $S/kernel/ufs_namei.c + ${COMPILE_C} + +ufs_subr.o: $S/kernel/ufs_subr.c + ${COMPILE_C} + +ufs_syscalls.o: $S/kernel/ufs_syscalls.c + ${COMPILE_C} + +ufs_syscalls2.o: $S/kernel/ufs_syscalls2.c + ${COMPILE_C} + +vfs_vnops.o: $S/kernel/vfs_vnops.c + ${COMPILE_C} + +vm_sched.o: $S/kernel/vm_sched.c + ${COMPILE_C} + +vm_swap.o: $S/kernel/vm_swap.c + ${COMPILE_C} + +vm_swp.o: $S/kernel/vm_swp.c + ${COMPILE_C} + +clock.o: $S/pic32/clock.c + ${COMPILE_C} + +cons.o: $S/pic32/cons.c + ${COMPILE_C} + +devsw.o: $S/pic32/devsw.c + ${COMPILE_C} + +exception.o: $S/pic32/exception.c + ${COMPILE_C} + +machdep.o: $S/pic32/machdep.c + ${COMPILE_C} + +mem.o: $S/pic32/mem.c + ${COMPILE_C} + +signal.o: $S/pic32/signal.c + ${COMPILE_C} + +swap.o: $S/pic32/swap.c + ${COMPILE_C} + +sysctl.o: $S/pic32/sysctl.c + ${COMPILE_C} + +adc.o: $S/pic32/adc.c + ${COMPILE_C} + +gpio.o: $S/pic32/gpio.c + ${COMPILE_C} + +pwm.o: $S/pic32/pwm.c + ${COMPILE_C} + +sd.o: $S/pic32/sd.c + ${COMPILE_C} + +spi.o: $S/pic32/spi.c + ${COMPILE_C} + +spi_bus.o: $S/pic32/spi_bus.c + ${COMPILE_C} + +uart.o: $S/pic32/uart.c + ${COMPILE_C} + +usb_device.o: $S/pic32/usb_device.c + ${COMPILE_C} + +usb_function_cdc.o: $S/pic32/usb_function_cdc.c + ${COMPILE_C} + +usb_uart.o: $S/pic32/usb_uart.c + ${COMPILE_C} + + +ifeq (.deps, $(wildcard .deps)) +-include .deps/*.dep +endif diff --git a/tools/build/Makefile b/tools/build/Makefile index 859486d..277689d 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -1,5 +1,5 @@ BOARD_LIST = duinomite fubarino max32 maximite maximite-color \ - picadillo pinguino-micro sdxl + picadillo pinguino-micro sdxl snadpic SKEL_SCRATCH = skeleton/linux32/pic32prog \ skeleton/linux64/pic32prog \ diff --git a/tools/build/skeleton/README.txt b/tools/build/skeleton/README.txt index d0f152e..832f6ce 100644 --- a/tools/build/skeleton/README.txt +++ b/tools/build/skeleton/README.txt @@ -63,8 +63,8 @@ serial port (COM port) on your computer, depending on your board type. Boards which use HID bootloader: Maximite, Color Maximite, -Duinomite, CGMMSTICK1. For these boards you do not need to -specify the -d option and device name. +Duinomite, CGMMSTICK1, SnadPIC. For these boards you do not +need to specify the -d option and device name. Boards which use a virtual serial port for bootloader: Fubarino SD, chipKIT Max32, Picadillo 35T, Majenko SDXL. For these