diff --git a/sys/include/rd_spirams.h b/sys/include/rd_spirams.h new file mode 100644 index 0000000..8ab721d --- /dev/null +++ b/sys/include/rd_spirams.h @@ -0,0 +1,9 @@ +#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); + +#endif diff --git a/sys/kernel/rdisk.c b/sys/kernel/rdisk.c index 5a91f93..6752eaf 100644 --- a/sys/kernel/rdisk.c +++ b/sys/kernel/rdisk.c @@ -43,6 +43,9 @@ extern int sdsize(int unit); #ifdef MRAMS_ENABLED #include #endif +#ifdef SPIRAMS_ENABLED +#include +#endif int no_deinit(int u) { return 0; } void no_preinit(int u) { return; } @@ -85,6 +88,10 @@ const struct diskentry disks[] = { {mrams_preinit, no_init, no_deinit, no_open, mrams_size, mrams_read, mrams_write, 0, RD_DEFAULT}, #endif +#ifdef SPIRAMS_ENABLED + {spirams_preinit, no_init, no_deinit, no_open, spirams_size, spirams_read, spirams_write, 0, RD_DEFAULT}, +#endif + }; #define NRDSK sizeof(disks)/sizeof(struct diskentry) diff --git a/sys/pic32/cfg/picadillo.map b/sys/pic32/cfg/picadillo.map new file mode 100644 index 0000000..e23e884 --- /dev/null +++ b/sys/pic32/cfg/picadillo.map @@ -0,0 +1,76 @@ +# Format is: silk port pin +# silk is the name of the pin, port and pin is what it maps to. +0 F 2 +1 F 8 +2 E 8 +3 A 3 +4 F 3 +5 G 15 +6 D 11 +7 E 9 +8 D 15 +9 D 3 +10 C 4 +11 D 10 +12 D 9 +13 D 0 +A0 B 0 +14 B 0 +A1 B 1 +15 B 1 +A2 B 2 +16 B 2 +A3 B 3 +17 B 3 +A4 B 4 +18 B 4 +A5 B 5 +19 B 5 +A6 B 6 +20 B 6 +A7 B 7 +21 B 7 +A8 B 8 +22 B 8 +A9 B 9 +23 B 9 +A10 B 10 +24 B 10 +A11 B 11 +25 B 11 +26 A 0 +27 A 1 +28 A 4 +29 A 5 +30 A 2 +31 D 1 +32 D 2 +A14 B 14 +33 B 14 +34 D 14 +35 D 8 +36 A 6 +37 A 7 +38 G 14 +39 G 12 +40 G 13 +41 A 9 +42 A 10 +43 B 12 +44 B 13 +45 C 2 +46 C 13 +47 C 1 +48 G 9 +49 F 4 +50 F 13 +51 F 5 +52 F 5 +53 A 15 +54 A 14 +55 G 7 +56 G 8 +57 G 6 + + + diff --git a/sys/pic32/cfg/spirams.dev b/sys/pic32/cfg/spirams.dev new file mode 100644 index 0000000..bf896ff --- /dev/null +++ b/sys/pic32/cfg/spirams.dev @@ -0,0 +1,184 @@ +always + define SPIRAMS_ENABLED + file rd_spirams.o + require rdisk + require spibus + define SPIRAMS_CHIPSIZE 128 +end always + +option chips + define SPIRAMS_CHIPS %1 +end option + +option port + define SPIRAMS_PORT %1 +end option + +option chipsize + define SPIRAMS_CHIPSIZE %1 +end option + +option mhz + define SPIRAMS_MHZ %1 +end option + +option cs0 + define SPIRAMS_CS0_PORT $TRIS(%1) + define SPIRAMS_CS0_PIN $PIN(%1) +end option + +option cs1 + define SPIRAMS_CS1_PORT $TRIS(%1) + define SPIRAMS_CS1_PIN $PIN(%1) +end option + +option cs2 + define SPIRAMS_CS2_PORT $TRIS(%1) + define SPIRAMS_CS2_PIN $PIN(%1) +end option + +option cs3 + define SPIRAMS_CS3_PORT $TRIS(%1) + define SPIRAMS_CS3_PIN $PIN(%1) +end option + +option cs4 + define SPIRAMS_CS4_PORT $TRIS(%1) + define SPIRAMS_CS4_PIN $PIN(%1) +end option + +option cs5 + define SPIRAMS_CS5_PORT $TRIS(%1) + define SPIRAMS_CS5_PIN $PIN(%1) +end option + +option cs6 + define SPIRAMS_CS6_PORT $TRIS(%1) + define SPIRAMS_CS6_PIN $PIN(%1) +end option + +option cs7 + define SPIRAMS_CS7_PORT $TRIS(%1) + define SPIRAMS_CS7_PIN $PIN(%1) +end option + +option cs8 + define SPIRAMS_CS8_PORT $TRIS(%1) + define SPIRAMS_CS8_PIN $PIN(%1) +end option + +option cs9 + define SPIRAMS_CS9_PORT $TRIS(%1) + define SPIRAMS_CS9_PIN $PIN(%1) +end option + +option cs10 + define SPIRAMS_CS10_PORT $TRIS(%1) + define SPIRAMS_CS10_PIN $PIN(%1) +end option + +option cs11 + define SPIRAMS_CS11_PORT $TRIS(%1) + define SPIRAMS_CS11_PIN $PIN(%1) +end option + +option cs12 + define SPIRAMS_CS12_PORT $TRIS(%1) + define SPIRAMS_CS12_PIN $PIN(%1) +end option + +option cs13 + define SPIRAMS_CS13_PORT $TRIS(%1) + define SPIRAMS_CS13_PIN $PIN(%1) +end option + +option cs14 + define SPIRAMS_CS14_PORT $TRIS(%1) + define SPIRAMS_CS14_PIN $PIN(%1) +end option + +option cs15 + define SPIRAMS_CS15_PORT $TRIS(%1) + define SPIRAMS_CS15_PIN $PIN(%1) +end option + +option led0 + define SPIRAMS_LED0_PORT $TRIS(%1) + define SPIRAMS_LED0_PIN $PIN(%1) +end option + +option led1 + define SPIRAMS_LED1_PORT $TRIS(%1) + define SPIRAMS_LED1_PIN $PIN(%1) +end option + +option led2 + define SPIRAMS_LED2_PORT $TRIS(%1) + define SPIRAMS_LED2_PIN $PIN(%1) +end option + +option led3 + define SPIRAMS_LED3_PORT $TRIS(%1) + define SPIRAMS_LED3_PIN $PIN(%1) +end option + +option led4 + define SPIRAMS_LED4_PORT $TRIS(%1) + define SPIRAMS_LED4_PIN $PIN(%1) +end option + +option led5 + define SPIRAMS_LED5_PORT $TRIS(%1) + define SPIRAMS_LED5_PIN $PIN(%1) +end option + +option led6 + define SPIRAMS_LED6_PORT $TRIS(%1) + define SPIRAMS_LED6_PIN $PIN(%1) +end option + +option led7 + define SPIRAMS_LED7_PORT $TRIS(%1) + define SPIRAMS_LED7_PIN $PIN(%1) +end option + +option led8 + define SPIRAMS_LED8_PORT $TRIS(%1) + define SPIRAMS_LED8_PIN $PIN(%1) +end option + +option led9 + define SPIRAMS_LED9_PORT $TRIS(%1) + define SPIRAMS_LED9_PIN $PIN(%1) +end option + +option led10 + define SPIRAMS_LED10_PORT $TRIS(%1) + define SPIRAMS_LED10_PIN $PIN(%1) +end option + +option led11 + define SPIRAMS_LED11_PORT $TRIS(%1) + define SPIRAMS_LED11_PIN $PIN(%1) +end option + +option led12 + define SPIRAMS_LED12_PORT $TRIS(%1) + define SPIRAMS_LED12_PIN $PIN(%1) +end option + +option led13 + define SPIRAMS_LED13_PORT $TRIS(%1) + define SPIRAMS_LED13_PIN $PIN(%1) +end option + +option led14 + define SPIRAMS_LED14_PORT $TRIS(%1) + define SPIRAMS_LED14_PIN $PIN(%1) +end option + +option led15 + define SPIRAMS_LED15_PORT $TRIS(%1) + define SPIRAMS_LED15_PIN $PIN(%1) +end option + diff --git a/sys/pic32/gcc-config.mk b/sys/pic32/gcc-config.mk index 47efd99..ac5fdbe 100644 --- a/sys/pic32/gcc-config.mk +++ b/sys/pic32/gcc-config.mk @@ -47,6 +47,13 @@ ifndef GCCPREFIX $(error Unable to locate any GCC MIPS toolchain!) endif +# UECIDE on Linux +ifneq (,$(wildcard $UECIDE/cores/chipKIT)) + AVRDUDE = $UECIDE/cores/chipKIT/tools/linux64/avrdude \ + -C $UECIDE/cores/chipKIT/tools/linux64/avrdude.conf -V \ + -P /dev/ttyUSB* +endif + # chipKIT MPIDE on Mac OS X ifneq (,$(wildcard /Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr)) AVRDUDE = /Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude \ diff --git a/sys/pic32/picadillo/PICADILLO b/sys/pic32/picadillo/PICADILLO index bc50dc9..a23858b 100644 --- a/sys/pic32/picadillo/PICADILLO +++ b/sys/pic32/picadillo/PICADILLO @@ -3,7 +3,7 @@ # =================== core pic32mx7 -mapping generic +mapping picadillo linker bootloader-max32 device kernel cpu_khz=80000 bus_khz=80000 @@ -12,7 +12,7 @@ device console device=tty0 device uart1 baud=115200 device rdisk -device sd0 port=2 cs=G9 +device sd0 port=2 cs=48 device gpio device adc diff --git a/sys/pic32/picadillo_rambo/Makefile b/sys/pic32/picadillo_rambo/Makefile new file mode 100644 index 0000000..e7bddc7 --- /dev/null +++ b/sys/pic32/picadillo_rambo/Makefile @@ -0,0 +1,95 @@ +BUILDPATH = ../../../tools/configsys/../../sys/pic32 +H = ../../../tools/configsys/../../sys/include +M = ../../../tools/configsys/../../sys/pic32 +S = ../../../tools/configsys/../../sys/kernel + +vpath %.c $(M):$(S) +vpath %.S $(M):$(S) + +KERNOBJ += adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.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 machdep.o mem.o rd_sd.o rd_spirams.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.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 vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o +EXTRA_TARGETS = + +DEFS += -DADC_ENABLED=YES +DEFS += -DBUS_DIV=1 +DEFS += -DBUS_KHZ=80000 +DEFS += -DCONSOLE_DEVICE=tty0 +DEFS += -DCPU_IDIV=2 +DEFS += -DCPU_KHZ=80000 +DEFS += -DCPU_MUL=20 +DEFS += -DCPU_ODIV=1 +DEFS += -DCRYSTAL=8 +DEFS += -DDC0_DEBUG=DEVCFG0_DEBUG_DISABLED +DEFS += -DDC0_ICE=0 +DEFS += -DDC1_CKM=0 +DEFS += -DDC1_CKS=0 +DEFS += -DDC1_FNOSC=DEVCFG1_FNOSC_PRIPLL +DEFS += -DDC1_IESO=DEVCFG1_IESO +DEFS += -DDC1_OSCIOFNC=0 +DEFS += -DDC1_PBDIV=DEVCFG1_FPBDIV_1 +DEFS += -DDC1_POSCMOD=DEVCFG1_POSCMOD_HS +DEFS += -DDC1_SOSC=0 +DEFS += -DDC1_WDTEN=0 +DEFS += -DDC1_WDTPS=DEVCFG1_WDTPS_1 +DEFS += -DDC2_PLLIDIV=DEVCFG2_FPLLIDIV_2 +DEFS += -DDC2_PLLMUL=DEVCFG2_FPLLMUL_20 +DEFS += -DDC2_PLLODIV=DEVCFG2_FPLLODIV_1 +DEFS += -DDC2_UPLL=0 +DEFS += -DDC2_UPLLIDIV=DEVCFG2_UPLLIDIV_2 +DEFS += -DDC3_CAN=DEVCFG3_FCANIO +DEFS += -DDC3_ETH=DEVCFG3_FETHIO +DEFS += -DDC3_MII=DEVCFG3_FMIIEN +DEFS += -DDC3_SRS=DEVCFG3_FSRSSEL_7 +DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO +DEFS += -DDC3_USERID=0xffff +DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO +DEFS += -DEXEC_AOUT +DEFS += -DEXEC_ELF +DEFS += -DEXEC_SCRIPT +DEFS += -DGPIO_ENABLED=YES +DEFS += -DKERNEL +DEFS += -DPARTITION="spirams0:sa@1500" +DEFS += -DPIC32MX7 +DEFS += -DSD0_CS_PIN=9 +DEFS += -DSD0_CS_PORT=TRISG +DEFS += -DSD0_PORT=2 +DEFS += -DSPIRAMS_CHIPS=13 +DEFS += -DSPIRAMS_CHIPSIZE=128 +DEFS += -DSPIRAMS_CS0_PIN=0 +DEFS += -DSPIRAMS_CS0_PORT=TRISA +DEFS += -DSPIRAMS_CS10_PIN=6 +DEFS += -DSPIRAMS_CS10_PORT=TRISA +DEFS += -DSPIRAMS_CS11_PIN=7 +DEFS += -DSPIRAMS_CS11_PORT=TRISA +DEFS += -DSPIRAMS_CS12_PIN=14 +DEFS += -DSPIRAMS_CS12_PORT=TRISG +DEFS += -DSPIRAMS_CS1_PIN=1 +DEFS += -DSPIRAMS_CS1_PORT=TRISA +DEFS += -DSPIRAMS_CS2_PIN=4 +DEFS += -DSPIRAMS_CS2_PORT=TRISA +DEFS += -DSPIRAMS_CS3_PIN=5 +DEFS += -DSPIRAMS_CS3_PORT=TRISA +DEFS += -DSPIRAMS_CS4_PIN=2 +DEFS += -DSPIRAMS_CS4_PORT=TRISA +DEFS += -DSPIRAMS_CS5_PIN=1 +DEFS += -DSPIRAMS_CS5_PORT=TRISD +DEFS += -DSPIRAMS_CS6_PIN=2 +DEFS += -DSPIRAMS_CS6_PORT=TRISD +DEFS += -DSPIRAMS_CS7_PIN=14 +DEFS += -DSPIRAMS_CS7_PORT=TRISB +DEFS += -DSPIRAMS_CS8_PIN=14 +DEFS += -DSPIRAMS_CS8_PORT=TRISD +DEFS += -DSPIRAMS_CS9_PIN=8 +DEFS += -DSPIRAMS_CS9_PORT=TRISD +DEFS += -DSPIRAMS_ENABLED +DEFS += -DSPIRAMS_PORT=4 +DEFS += -DUART1_BAUD=115200 +DEFS += -DUART1_ENABLED=YES +DEFS += -DUCB_METER + + +LDSCRIPT = ../../../tools/configsys/../../sys/pic32/cfg/bootloader-max32.ld + +CONFIG = PICADILLO_RAMBO +CONFIGPATH = ../../../tools/configsys + +include ../../../tools/configsys/../../sys/pic32/kernel-post.mk diff --git a/sys/pic32/picadillo_rambo/PICADILLO_RAMBO b/sys/pic32/picadillo_rambo/PICADILLO_RAMBO new file mode 100644 index 0000000..415c6d8 --- /dev/null +++ b/sys/pic32/picadillo_rambo/PICADILLO_RAMBO @@ -0,0 +1,22 @@ +# +# Picadillo 35T board +# =================== + +core pic32mx7 +mapping picadillo +linker bootloader-max32 + +device kernel cpu_khz=80000 bus_khz=80000 + +device console device=tty0 +device uart1 baud=115200 + +device rdisk +device sd0 port=2 cs=48 +device spirams0 port=4 chips=13 cs0=26 cs1=27 cs2=28 cs3=29 cs4=30 cs5=31 cs6=32 cs7=33 cs8=34 cs9=35 cs10=36 cs11=37 cs12=38 + +option PARTITION=spirams0:sa@1500 + +device gpio +device adc +device foreignbootloader diff --git a/sys/pic32/spi_bus.c b/sys/pic32/spi_bus.c index 130478c..b9e0574 100644 --- a/sys/pic32/spi_bus.c +++ b/sys/pic32/spi_bus.c @@ -8,7 +8,7 @@ #define NSPI 4 /* Ports SPI1...SPI4 */ -#define MAXSPIDEV 10 +#define MAXSPIDEV 20 struct spi_dev spi_devices[MAXSPIDEV]; @@ -616,7 +616,7 @@ char *spi_name(int dno) return "SPI?"; if(spi_devices[dno].bus==NULL) - return "SPI?"; + return "NO SPI BUS"; if(spi_devices[dno].bus == (struct spireg *)&SPI1CON) return "SPI1";