├── doxybuild ├── deploy │ └── .nojekyll └── .gitignore ├── apps ├── pt_demo │ ├── .gitignore │ ├── pt_demo.ybug │ ├── Makefile.spinn │ ├── Makefile │ ├── README │ ├── Makefile.host │ └── pt_trig ├── gdb-test │ ├── gdb-test.ybug │ ├── Makefile │ └── gdb-test.c ├── life │ ├── life.ybug │ └── Makefile ├── hello │ ├── hello.ybug │ ├── Makefile │ └── hello.c ├── heat_demo │ ├── visualiser.linux │ ├── heat_demo.ybug │ └── Makefile ├── interrupt │ ├── interrupt.ybug │ ├── Makefile │ └── interrupt.c ├── data_abort │ ├── data_abort.ybug │ ├── Makefile │ └── data_abort.c ├── random │ ├── random.ybug │ ├── Makefile │ └── random.c ├── hello_cpp │ ├── hello_cpp.ybug │ ├── Makefile │ └── hello_cpp.cpp ├── simple │ ├── simple.ybug │ └── Makefile ├── ring │ ├── ring.ybug │ ├── Makefile │ └── ring.c └── sdping │ ├── sdping.ybug │ ├── Makefile │ ├── sdp_recv.pl │ ├── sdp_ping.pl │ └── sdping.c ├── tools ├── boot │ ├── spin4.conf │ ├── spin5.conf │ ├── spin1.conf │ ├── spin2.conf │ └── spin3.conf ├── board.info ├── mkbuild ├── sark.sct ├── mkbin ├── Makefile ├── sark.lnk ├── h2asm ├── SpiNN │ └── Boot.pm └── arm2gas ├── bmp ├── bmp_date ├── bin │ └── .gitignore ├── bmp_boot.sct ├── bmp_main.sct ├── mainpage.dox ├── change.log ├── sum.pl ├── Makefile ├── bmp_flash.c ├── lpc_types.h └── bmp_crc.c ├── MANIFEST.in ├── .ratexcludes ├── .gitignore ├── scamp ├── scamp-3.sct ├── mksv ├── sark.c ├── spinn_regs.h ├── mkpad ├── boot.lnk ├── scamp-del.c ├── scamp-3.lnk ├── spinn_phy.h ├── spinn_phy.c ├── boot_aplx.s ├── spinn_srom.c └── Makefile ├── docs ├── ybug │ └── Makefile ├── gdb-spin │ └── Makefile ├── spin1_api │ └── Makefile ├── sark │ ├── Makefile │ ├── sysram.fig │ ├── sdram.fig │ └── tcm.fig ├── scp │ ├── Makefile │ ├── cmd-write.fig │ ├── sdp-scp.fig │ ├── cmd-read.fig │ └── cmd-ver.fig └── appnote.tex ├── include ├── sark_cpp.h ├── spin1_api_cpp.h ├── scamp_spin1_sync.h └── version.h ├── .github ├── dependabot.yml ├── workflows │ ├── add_prs_to_project.yml │ ├── publish.yml │ ├── self_hosted.yml │ └── c_actions.yml └── actions │ └── clone_matching │ └── action.yml ├── .readthedocs.yml ├── LICENSE_POLICY.md ├── Makefile ├── make ├── app.make └── spinnaker_tools.mk ├── sark ├── sark_div0.c ├── Makefile └── sark_pkt.c ├── mainpage.dox ├── spin1_api └── Makefile ├── setup ├── release.sh └── CITATION.cff /doxybuild/deploy/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/pt_demo/.gitignore: -------------------------------------------------------------------------------- 1 | drawer* 2 | -------------------------------------------------------------------------------- /tools/boot/spin4.conf: -------------------------------------------------------------------------------- 1 | hw_ver 4 2 | -------------------------------------------------------------------------------- /tools/boot/spin5.conf: -------------------------------------------------------------------------------- 1 | hw_ver 5 2 | -------------------------------------------------------------------------------- /bmp/bmp_date: -------------------------------------------------------------------------------- 1 | const unsigned int build_date = 999; 2 | -------------------------------------------------------------------------------- /doxybuild/.gitignore: -------------------------------------------------------------------------------- 1 | /tools/ 2 | /bmp/ 3 | /deploy/ 4 | -------------------------------------------------------------------------------- /tools/boot/spin1.conf: -------------------------------------------------------------------------------- 1 | hw_ver 2 2 | led0 0x00076104 3 | -------------------------------------------------------------------------------- /tools/boot/spin2.conf: -------------------------------------------------------------------------------- 1 | hw_ver 2 2 | led0 0x00006103 3 | -------------------------------------------------------------------------------- /tools/boot/spin3.conf: -------------------------------------------------------------------------------- 1 | hw_ver 3 2 | led0 0x00000502 3 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CITATION.cff LICENSE.md requirements.txt pypi_to_import -------------------------------------------------------------------------------- /bmp/bin/.gitignore: -------------------------------------------------------------------------------- 1 | /BOOT-* 2 | /PROGH-* 3 | /PROGL-* 4 | /bmp_boot 5 | /bmp_main 6 | -------------------------------------------------------------------------------- /apps/gdb-test/gdb-test.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubotron & 3 | 4 | app_load gdb-test.aplx . 1 16 5 | -------------------------------------------------------------------------------- /apps/life/life.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubogrid & 3 | 4 | app_load life.aplx all 1-16 16 5 | sleep 30 6 | app_stop 16 7 | -------------------------------------------------------------------------------- /apps/hello/hello.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubotron & 3 | 4 | app_load hello.aplx . 1 16 5 | sleep 6 | iobuf 1 7 | app_stop 16 8 | -------------------------------------------------------------------------------- /apps/heat_demo/visualiser.linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpiNNakerManchester/spinnaker_tools/HEAD/apps/heat_demo/visualiser.linux -------------------------------------------------------------------------------- /tools/board.info: -------------------------------------------------------------------------------- 1 | # Sample board info file 2 | 3 | chip 1 2 core 6 4 | chip 6 7 core 12 5 | chip 2 5 link 1 6 | chip 3 3 dead 7 | -------------------------------------------------------------------------------- /apps/interrupt/interrupt.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubotron & 3 | 4 | app_load interrupt.aplx . 7 16 5 | sleep 10 6 | iobuf 7 7 | app_stop 16 8 | -------------------------------------------------------------------------------- /apps/data_abort/data_abort.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubotron & 3 | 4 | app_load data_abort.aplx . 1 16 5 | sleep 0.1 6 | ps 7 | ps 1 8 | app_stop 16 9 | -------------------------------------------------------------------------------- /apps/random/random.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubogrid & 3 | 4 | app_load random.aplx all 1-16 16 5 | sleep 5 6 | iobuf 1 7 | sleep 15 8 | app_stop 16 9 | -------------------------------------------------------------------------------- /apps/hello_cpp/hello_cpp.ybug: -------------------------------------------------------------------------------- 1 | 2 | # make APP=hello_cpp 3 | # tubotron & 4 | 5 | app_load hello_cpp.aplx . 1 16 6 | sleep 7 | iobuf 1 8 | app_stop 16 9 | -------------------------------------------------------------------------------- /apps/simple/simple.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubotron & 3 | 4 | app_load simple.aplx all 1 16 5 | sleep 6 | ps 7 | app_sig all 16 sync0 8 | ps 9 | sleep 20 10 | ps 11 | app_stop 16 12 | -------------------------------------------------------------------------------- /apps/ring/ring.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubogrid & 3 | 4 | app_load ring.aplx @0,0 1-16 16 5 | sleep 0.1 6 | app_sig all 16 sync0 7 | sleep 0.1 8 | iobuf 2 9 | sleep 30 10 | app_stop 16 11 | -------------------------------------------------------------------------------- /apps/heat_demo/heat_demo.ybug: -------------------------------------------------------------------------------- 1 | # make 2 | # tubotron & 3 | # visualiser & 4 | 5 | iptag 1 set . 17894 6 | app_load heat_demo.aplx all 1-16 16 7 | sleep 1 8 | app_sig all 16 sync0 9 | 10 | -------------------------------------------------------------------------------- /.ratexcludes: -------------------------------------------------------------------------------- 1 | **/*.ybug 2 | **/*.sct 3 | **/*.log 4 | **/*.conf 5 | **/*.fig 6 | **/*.eps 7 | **/*.tag 8 | 9 | **/build/** 10 | 11 | **/release.txt 12 | **/bmp/bmp_date 13 | **/bmp/core_* 14 | **/bmp/lpc* 15 | **/tools/board.info 16 | 17 | **/.nojekyll 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.github 3 | !.gitignore 4 | *~ 5 | *.swp 6 | *.a 7 | *.o 8 | *.gas 9 | *.s 10 | *.bin 11 | *.elf 12 | *.aplx 13 | *.boot 14 | *.txt 15 | *.dvi 16 | *.aux 17 | *.log 18 | *.pdf 19 | *.tab 20 | *.sv 21 | **/build 22 | html 23 | /doxybuild 24 | /sllt.tag 25 | /Debug/ 26 | -------------------------------------------------------------------------------- /bmp/bmp_boot.sct: -------------------------------------------------------------------------------- 1 | ; 2 | ; Scatter load file for BMP Bootstrap on LPC1768 3 | ; 4 | 5 | BOOT 0 6 | { 7 | BOOT 0 4096 8 | { 9 | bmp_boot.o (.boot_vec, +FIRST) 10 | bmp_boot.o (.flash_copy) 11 | *.o (+RO) 12 | bmp_boot.o (.padding, +LAST) 13 | } 14 | 15 | STACK 0x10007800 EMPTY 0x7e0 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /apps/pt_demo/pt_demo.ybug: -------------------------------------------------------------------------------- 1 | # Boot the board 2 | 3 | boot 4 | 5 | # Go to root chip and set up IPTag on port 17894 6 | 7 | sp root 8 | iptag 1 set . 17894 9 | 10 | # Load the "tracer" to all chips on cores 1-16 11 | 12 | app_load tracer.aplx all 1-16 16 13 | 14 | # Wait a while then load the "aggregator" to core 1 on (0, 0) 15 | 16 | sleep 0.1 17 | app_load aggregator.aplx . 1 17 18 | -------------------------------------------------------------------------------- /scamp/scamp-3.sct: -------------------------------------------------------------------------------- 1 | # 2 | # Scatter load file for SC&MP in RAM 3 | # 4 | 5 | IMAGE 0 6 | { 7 | ITCM 0 0x7f00 8 | { 9 | * (_alib_reset, +FIRST) 10 | * (+RO) 11 | * (_alib_align, +LAST) 12 | } 13 | 14 | DTCM 0x00400000 15 | { 16 | * (+RW) 17 | * (+ZI) 18 | } 19 | 20 | STACK 0x00408000 EMPTY -0x800 21 | { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /bmp/bmp_main.sct: -------------------------------------------------------------------------------- 1 | #! armcc -E 2 | 3 | // 4 | // Scatter load file for BMP on LPC1768 5 | // 6 | 7 | // "BASE" is passed in from the linker command line 8 | 9 | IMAGE BASE 10 | { 11 | PROGRAM BASE 32768 12 | { 13 | bmp_init.o (.vectors, +FIRST) 14 | * (+RO) 15 | bmp_init.o (.padding, +LAST) 16 | } 17 | 18 | // Allow 4K bytes for Flash buffer and 96 bytes for uninitialised data 19 | 20 | SRAM 0x10001060 0x000067a0 21 | { 22 | * (+RW) 23 | * (+ZI) 24 | } 25 | 26 | STACK 0x10007800 EMPTY 0x7e0 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /docs/ybug/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ybug.pdf: ybug.tex ../appnote.tex 16 | pdflatex $< 17 | 18 | clean: 19 | /bin/rm -f *.aux *.log *.pdf 20 | -------------------------------------------------------------------------------- /docs/gdb-spin/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | gdb-spin.pdf: gdb-spin.tex ../appnote.tex 16 | pdflatex $< 17 | 18 | clean: 19 | /bin/rm -f *.aux *.log *.pdf 20 | -------------------------------------------------------------------------------- /apps/sdping/sdping.ybug: -------------------------------------------------------------------------------- 1 | # 2 | # tubotron & 3 | # 4 | # Load code in "ybug" as below and then 5 | # 6 | # ./sdp_ping 192.168.240.xxx 1 1 6 1 7 | # 8 | # This sends SDP packets into SpiNNaker on port 1 and the "sdping" 9 | # program running there sends them back to the sender which receives 10 | # and prints them. 11 | # 12 | # Stop that (CTRL/C) and then 13 | # 14 | # ./sdp_ping 192.168.240.xxx 1 1 6 2 15 | # 16 | # and in another shell 17 | # 18 | # ./sdp_recv 17894 1.5 19 | # 20 | # Now the sender is using port 2 which instructs the "sdping" program 21 | # on SpiNNaker to send the packets back to the host using IPTag 1 22 | # which is set up to use UDP port 17894. The "sdp_recv" program will 23 | # receive these packets and print them. 24 | 25 | sp root 26 | iptag 1 set . 17894 27 | app_load sdping.aplx @1,1 6 16 28 | -------------------------------------------------------------------------------- /docs/spin1_api/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | spin1_api.pdf: spin1_api.tex threads.eps 16 | pdflatex spin1_api.tex 17 | pdflatex spin1_api.tex 18 | 19 | clean: 20 | /bin/rm -f *.dvi *.pdf *.log *.aux 21 | -------------------------------------------------------------------------------- /docs/sark/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | sark.pdf: sark.tex ../appnote.tex sdram.pdf sysram.pdf tcm.pdf 16 | pdflatex sark.tex 17 | 18 | %.pdf: %.fig 19 | fig2dev -Lpdf $< $@ 20 | 21 | clean: 22 | /bin/rm -f *.aux *.log *.pdf *.bak 23 | -------------------------------------------------------------------------------- /include/sark_cpp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //! \file 18 | //! \brief Wrapper for using sark.h from C++ 19 | #pragma GCC diagnostic ignored "-Wwrite-strings" 20 | 21 | extern "C" 22 | { 23 | #include 24 | } 25 | -------------------------------------------------------------------------------- /docs/scp/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | scp.pdf: scp.tex ../appnote.tex sdp-scp.pdf cmd-ver.pdf cmd-read.pdf cmd-write.pdf 16 | pdflatex scp.tex 17 | 18 | %.pdf: %.fig 19 | fig2dev -Lpdf $< $@ 20 | 21 | clean: 22 | /bin/rm -f *.aux *.log *.pdf *.bak 23 | -------------------------------------------------------------------------------- /include/spin1_api_cpp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //! \file 18 | //! \brief Wrapper for using spin1_api.h from C++ 19 | #pragma GCC diagnostic ignored "-Wwrite-strings" 20 | 21 | extern "C" 22 | { 23 | #include 24 | } 25 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: 2 16 | updates: 17 | - package-ecosystem: "github-actions" 18 | directory: "/" 19 | schedule: 20 | interval: "weekly" 21 | assignees: 22 | - "dkfellows" 23 | reviewers: 24 | - "rowleya" 25 | -------------------------------------------------------------------------------- /scamp/mksv: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Copyright (c) 2015 The University of Manchester 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | use strict; 18 | use warnings; 19 | 20 | use SpiNN::Struct; 21 | 22 | my $sv = SpiNN::Struct->new; 23 | 24 | die "mksv: failed\n" unless defined $sv; 25 | 26 | binmode(STDOUT); 27 | print substr $sv->pack ("sv"), 0, 128; 28 | -------------------------------------------------------------------------------- /apps/hello/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 15 | 16 | APP := hello 17 | include $(SPINN_INSTALL_DIR)/make/app.make -------------------------------------------------------------------------------- /apps/life/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 15 | 16 | APP := life 17 | include $(SPINN_INSTALL_DIR)/make/app.make 18 | -------------------------------------------------------------------------------- /apps/pt_demo/Makefile.spinn: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | include $(SPINN_INSTALL_DIR)/make/app.make 18 | -------------------------------------------------------------------------------- /apps/ring/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP := ring 18 | include $(SPINN_INSTALL_DIR)/make/app.make 19 | -------------------------------------------------------------------------------- /apps/sdping/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP := sdping 18 | include $(SPINN_INSTALL_DIR)/make/app.make -------------------------------------------------------------------------------- /apps/gdb-test/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 15 | 16 | APP := gdb-test 17 | include $(SPINN_INSTALL_DIR)/make/app.make 18 | -------------------------------------------------------------------------------- /apps/heat_demo/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP:=heat_demo 18 | include $(SPINN_INSTALL_DIR)/make/app.make -------------------------------------------------------------------------------- /apps/hello_cpp/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 15 | 16 | APP := hello_cpp 17 | include $(SPINN_INSTALL_DIR)/make/app.make 18 | -------------------------------------------------------------------------------- /apps/random/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP := random 18 | include $(SPINN_INSTALL_DIR)/make/app.make 19 | -------------------------------------------------------------------------------- /apps/simple/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP := simple 18 | include $(SPINN_INSTALL_DIR)/make/app.make 19 | -------------------------------------------------------------------------------- /apps/data_abort/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 15 | 16 | APP := data_abort 17 | include $(SPINN_INSTALL_DIR)/make/app.make 18 | -------------------------------------------------------------------------------- /apps/interrupt/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP := interrupt 18 | THUMB := 0 19 | include $(SPINN_INSTALL_DIR)/make/app.make 20 | -------------------------------------------------------------------------------- /apps/pt_demo/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APPS = aggregator tracer 16 | GNU := 1 17 | 18 | all: 19 | for app in $(APPS); do ("$(MAKE)" -f Makefile.spinn GNU=$(GNU) APP=$$app) || exit $$?; done 20 | "$(MAKE)" -f Makefile.host 21 | 22 | clean: 23 | for app in $(APPS); do ("$(MAKE)" -f Makefile.spinn GNU=$(GNU) APP=$$app clean) || exit $$?; done 24 | "$(MAKE)" -f Makefile.host clean 25 | -------------------------------------------------------------------------------- /scamp/sark.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //! \file 18 | //! \brief Main entry point for SARK 19 | #include "sark.h" 20 | 21 | //! \brief Main entry point. 22 | //! 23 | //! \note user application code will supply their own version of this; 24 | //! this version is just for raw SARK. 25 | void c_main(void) 26 | { 27 | sark_cpu_state(CPU_STATE_IDLE); 28 | cpu_sleep(); 29 | } 30 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: 2 16 | build: 17 | os: ubuntu-22.04 18 | tools: 19 | python: "3.10" 20 | jobs: 21 | build: 22 | html: 23 | - doxygen ./Doxyfile 24 | - cd bmp; doxygen ./Doxyfile 25 | - mkdir -p ${READTHEDOCS_OUTPUT}html/bmp 26 | - cp -a doxybuild/tools/html/* ${READTHEDOCS_OUTPUT}html/ 27 | - cp -a doxybuild/bmp/html/* ${READTHEDOCS_OUTPUT}html/bmp 28 | -------------------------------------------------------------------------------- /LICENSE_POLICY.md: -------------------------------------------------------------------------------- 1 | # License Agreement 2 | 3 | Up to date information for the whole [SpiNNakerManchester Projects](https://github.com/SpiNNakerManchester) can be found [here](https://spinnakermanchester.github.io/latest/LicenseAgreement.html) 4 | 5 | As shown there the software is currently being released under the Apache License 2.0 listed [here](https://www.apache.org/licenses/LICENSE-2.0) 6 | 7 | 8 | # Paper Authorship 9 | 10 | See: [here](https://spinnakermanchester.github.io/latest/LicenseAgreement.html#paper-authorship) 11 | 12 | # Modifications 13 | 14 | See: [here](https://spinnakermanchester.github.io/latest/LicenseAgreement.html#modifications) 15 | 16 | # Contributors 17 | 18 | For up to date information on Contributors see the graphs/contributors pages on each project. 19 | 20 | For example [https://github.com/SpiNNakerManchester/spinnaker_tools/graphs/contributors](https://github.com/SpiNNakerManchester/spinnaker_tools/graphs/contributors) 21 | 22 | [Combined list](https://spinnakermanchester.github.io/latest/LicenseAgreement.html#contributors) 23 | 24 | -------------------------------------------------------------------------------- /tools/mkbuild: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Copyright (c) 2015 The University of Manchester 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Utility to create a small C file (on stdout) which contains 18 | # 19 | # - an integer constant which is the Unix time. 20 | # - a string constant containing the first 15 characters of the argument 21 | 22 | die "bad args" unless $#ARGV == 0; 23 | 24 | my $name = substr $ARGV[0], 0, 15; 25 | 26 | printf "const int build_date = %d;\n", time (); 27 | printf "const char build_name\[\] = \"%s\";\n", $name; 28 | -------------------------------------------------------------------------------- /apps/data_abort/data_abort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | void c_main(void) 20 | { 21 | uint *rom = (uint *) ROM_BASE; 22 | uint data = 0x55aa55aa; 23 | 24 | io_printf(IO_STD, "Reading ROM at %08x = %08x\n", (uint) rom, rom[0]); 25 | io_printf(IO_STD, "Writing ROM at %08x > %08x\n", (uint) rom, data); 26 | 27 | rom[0] = data; 28 | 29 | io_printf(IO_STD, "Reading ROM at %08x = %08x\n", (uint) rom, rom[0]); 30 | } 31 | -------------------------------------------------------------------------------- /bmp/mainpage.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | * @cond copright_declaration 3 | * Copyright (c) 2020 The University of Manchester 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * @endcond 17 | * 18 | * @mainpage spinnaker_tools: SpiNNaker Board Management Processor 19 | * 20 | * The SpiNNaker board management processor firmware (BMP) manages power, heat, 21 | * and inter-board links. It is usually only accessed via spalloc. Note that the 22 | * BMP does not run on SpiNNaker chips; it has a significantly different 23 | * hardware configuration. 24 | * 25 | * See bmp.h for a way into the BMP implementation. 26 | */ 27 | -------------------------------------------------------------------------------- /apps/pt_demo/README: -------------------------------------------------------------------------------- 1 | 2 | This directory contains a "Path Tracer" demo for SpiNNaker. It was 3 | originally written by Andrew Webb and has been kept up to date by 4 | Steve Temple. 5 | 6 | Two applications run on SpiNNaker. The "aggregator" application runs 7 | on core 1 of chip (0,0) and it collects results from the "tracer" 8 | application which runs on cores 2-16 of chip (0, 0) and cores 1-16 of 9 | all of the other chips. 10 | 11 | On the host, an OpenGL application "drawer" runs which gets data sent 12 | from the "aggregator" and displays it in a window. The tracing is 13 | started by sending an SCP command to the "aggregator" from a trigger 14 | program "pt_trig" run on the host. 15 | 16 | Building and running the demo... 17 | 18 | 1) Compile the host and SpiNNaker code 19 | (you'll need "pthread" and "freeglut" libraries installed...) 20 | 21 | > make 22 | 23 | 2) Start the "drawer" 24 | 25 | > ./drawer 600 & 26 | 27 | 3) Load the application(s) onto SpiNNaker (substitute your IP address) 28 | 29 | > ybug 192.168.240.253 < pt_demo.ybug 30 | 31 | 4) Trigger the application (substitute IP address). 32 | 33 | > ./pt_trig 192.168.240.253 600 10 16 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | DIRS = sark spin1_api 16 | 17 | GNU = 1 18 | 19 | all: $(DIRS) 20 | @for d in $(DIRS); do $(MAKE) -C $$d GNU=$(GNU) || exit $$?; done 21 | 22 | clean: $(DIRS) 23 | @for d in $(DIRS); do $(MAKE) -C $$d GNU=$(GNU) clean || exit $$?; done 24 | 25 | install: $(DIRS) tools 26 | @for d in $(DIRS) tools; do $(MAKE) -C $$d GNU=$(GNU) install || exit $$?; done 27 | 28 | doxygen: 29 | doxygen 30 | (cd bmp; exec doxygen) 31 | -@rm -rf doxybuild/deploy/bmp 32 | cp -a doxybuild/tools/html/* doxybuild/deploy 33 | cp -a doxybuild/bmp/html doxybuild/deploy/bmp 34 | -------------------------------------------------------------------------------- /scamp/spinn_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //! \file 18 | //! \brief Miscellaneous test registers 19 | //! \deprecated This file seems to be be unused. 20 | 21 | #ifndef SPINN_REGS_H 22 | #define SPINN_REGS_H 23 | 24 | uint reg_test(const uint *vec); 25 | 26 | extern uint timer_test[]; 27 | extern uint cc_test[]; 28 | extern uint dma_test[]; 29 | extern uint vic_test[]; 30 | 31 | extern uint sdram_test[]; 32 | 33 | extern uint router_test[]; 34 | extern uint ether_test[]; 35 | extern uint wdog_test[]; 36 | extern uint sysctl_test[]; 37 | extern uint pl340_test[]; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /.github/workflows/add_prs_to_project.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions 16 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 17 | 18 | name: Add PRs to Project 19 | on: 20 | pull_request: 21 | types: 22 | - review_requested 23 | jobs: 24 | call-add-prs-to-project: 25 | uses: SpiNNakerManchester/SupportScripts/.github/workflows/add_prs_to_project.yml@main 26 | secrets: 27 | personal_access_token: ${{ secrets.SPINNAKER_PAT }} 28 | -------------------------------------------------------------------------------- /make/app.make: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ifndef SPINN_INSTALL_DIR 16 | $(error SPINN_INSTALL_DIR is not set. Please define SPINN_INSTALL_DIR to the location where the tools are installed) 17 | endif 18 | 19 | ifndef APP 20 | $(error APP is not defined. Please rerun with APP=) 21 | endif 22 | 23 | ifndef OBJECTS 24 | OBJECTS = $(BUILD_DIR)$(APP).o 25 | endif 26 | 27 | include $(SPINN_INSTALL_DIR)/make/spinnaker_tools.mk 28 | 29 | all: $(APP_OUTPUT_DIR)$(APP).aplx 30 | 31 | clean: 32 | $(RM) $(OBJECTS) $(BUILD_DIR)$(APP).txt $(APP_OUTPUT_DIR)$(APP).aplx $(BUILD_DIR)$(APP).elf 33 | 34 | .PHONY: all clean 35 | -------------------------------------------------------------------------------- /scamp/mkpad: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Copyright (c) 2015 The University of Manchester 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | use strict; 18 | use warnings; 19 | 20 | die "bad args\n" unless $#ARGV == 1 && -r $ARGV[0] && $ARGV[1] =~ /^\d+$/; 21 | 22 | my ($file, $size) = @ARGV; 23 | 24 | my $file_size = -s $file; 25 | my $buf; 26 | 27 | die "file too big\n" if $file_size > $size; 28 | 29 | open my $fh, "<", $file or die "Can't open $file\n"; 30 | binmode($fh); 31 | my $r = sysread $fh, $buf, $file_size; 32 | close $fh; 33 | 34 | die "failed to read file\n" if $r != $file_size; 35 | 36 | my $pad = chr (0) x ($size - $file_size); 37 | 38 | binmode(STDOUT); 39 | print $buf, $pad; 40 | -------------------------------------------------------------------------------- /tools/sark.sct: -------------------------------------------------------------------------------- 1 | # 2 | # sark.sct armlink scatter file for SARK/SpiNNaker applications 3 | # 4 | # Copyright (C) The University of Manchester - 2011 5 | # 6 | # Author Steve Temple, APT Group, School of Computer Science 7 | # 8 | # Email temples@cs.man.ac.uk 9 | # 10 | 11 | # Copyright (c) 2011 The University of Manchester 12 | # 13 | # Licensed under the Apache License, Version 2.0 (the "License"); 14 | # you may not use this file except in compliance with the License. 15 | # You may obtain a copy of the License at 16 | # 17 | # https://www.apache.org/licenses/LICENSE-2.0 18 | # 19 | # Unless required by applicable law or agreed to in writing, software 20 | # distributed under the License is distributed on an "AS IS" BASIS, 21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | # See the License for the specific language governing permissions and 23 | # limitations under the License. 24 | 25 | 26 | IMAGE 0 27 | { 28 | ITCM 0 0x7f00 29 | { 30 | * (_alib_reset, +FIRST) 31 | * (+RO) 32 | * (_alib_align, +LAST) 33 | } 34 | 35 | DTCM 0x400000 0xf800 36 | { 37 | * (+RW) 38 | * (+ZI) 39 | } 40 | 41 | STACK 0x40f800 EMPTY 0x800 42 | { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bmp/change.log: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # 3 | # SpiNNaker board management processor code - version notes 4 | # 5 | #------------------------------------------------------------------------------- 6 | 7 | version 2.1.2 - 30/08/2018 - bug fixing 8 | 9 | bug fix: 10 | 11 | * fixes non-atomic accesses to the event queues 12 | which caused BMP crashes 13 | 14 | #------------------------------------------------------------------------------- 15 | 16 | version 2.1.1 - 18/01/2018 - code style reformatting 17 | 18 | new features: 19 | 20 | * version split from spinnaker_tools version 21 | * extensive code style reformatting (no functional changes) 22 | 23 | #------------------------------------------------------------------------------- 24 | 25 | version 2.1.0 - 22/04/2016 - tracking spinnaker_tools version 26 | 27 | #------------------------------------------------------------------------------- 28 | 29 | version 2.0.0 - 22/12/2015 - introduction of semantic versioning 30 | 31 | New Features: 32 | 33 | * version numbers use the semantic version style (major.minor.patch) 34 | * version tied to spiNnnaker_tools version 35 | 36 | #------------------------------------------------------------------------------- 37 | -------------------------------------------------------------------------------- /scamp/boot.lnk: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | // boot.lnk GNU linker script for scamp/boot_aplx.s build 4 | // 5 | // Copyright (C) The University of Manchester - 2011-2013 6 | // 7 | // Author Steve Temple, APT Group, School of Computer Science 8 | // 9 | // Email temples@cs.man.ac.uk 10 | // 11 | 12 | // Copyright (c) 2011 The University of Manchester 13 | // 14 | // Licensed under the Apache License, Version 2.0 (the "License"); 15 | // you may not use this file except in compliance with the License. 16 | // You may obtain a copy of the License at 17 | // 18 | // https://www.apache.org/licenses/LICENSE-2.0 19 | // 20 | // Unless required by applicable law or agreed to in writing, software 21 | // distributed under the License is distributed on an "AS IS" BASIS, 22 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | // See the License for the specific language governing permissions and 24 | // limitations under the License. 25 | */ 26 | 27 | 28 | MEMORY 29 | { 30 | ITCM : ORIGIN = 0, LENGTH = 0x7f00 31 | } 32 | 33 | 34 | SECTIONS 35 | { 36 | ITCM_BASE = 0x00000000; 37 | 38 | . = ITCM_BASE; 39 | 40 | RO_DATA : 41 | { 42 | * (boot_aplx); 43 | } > ITCM 44 | 45 | . = ALIGN (4); 46 | 47 | RO_BASE = ITCM_BASE; 48 | } 49 | -------------------------------------------------------------------------------- /sark/sark_div0.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //------------------------------------------------------------------------------ 18 | //! \file 19 | //! \brief Functions to handle division by 0 20 | //! 21 | //! \copyright © The University of Manchester - 2017-2019 22 | //! 23 | //------------------------------------------------------------------------------ 24 | 25 | #include 26 | 27 | // Functions to handle division by 0 (simply RTE) 28 | 29 | //! Handles divide by zero by doing an RTE 30 | void __aeabi_idiv0(void) { 31 | rt_error(RTE_DIV0); 32 | } 33 | 34 | //! Handles divide by zero by doing an RTE 35 | void __aeabi_ldiv0(void) { 36 | rt_error(RTE_DIV0); 37 | } 38 | -------------------------------------------------------------------------------- /apps/hello/hello.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | Simple Hello World program which writes output to two different 19 | places. One is IO_STD, which should appear on a "tubotron" viewer. 20 | The other is IO_BUF which goes to a memory buffer on the SpiNNaker 21 | chip and can be viewed with the "iobuf" command in "ybug" 22 | */ 23 | 24 | 25 | #include 26 | 27 | 28 | void c_main(void) 29 | { 30 | char buf[64]; 31 | 32 | io_printf(IO_STD, "Hello world! (via SDP)\n"); 33 | 34 | io_printf(IO_BUF, "Hello world! (via SDRAM)\n"); 35 | 36 | // io_printf can also do sprintf! 37 | 38 | io_printf(buf, "Hello world! (via printf...)\n"); 39 | io_printf(IO_BUF, buf); 40 | } 41 | -------------------------------------------------------------------------------- /include/scamp_spin1_sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //! Clock drift fixed-point number definition in terms of the number of 18 | //! fractional bits and the mask to get the fractional bits 19 | #define DRIFT_FP_BITS 17U 20 | #define DRIFT_INT_MASK (((1U << (32 - DRIFT_FP_BITS)) - 1) << DRIFT_FP_BITS) 21 | #define DRIFT_FRAC_MASK ((1U << DRIFT_FP_BITS) - 1) 22 | #define DRIFT_ONE (1U << DRIFT_FP_BITS) 23 | #define TIME_BETWEEN_SYNC_US 2000000U // !< The time between sync signals in us 24 | //! For some calculations a signed int is better 25 | static const int DRIFT_FP_FACTOR = 1 << DRIFT_FP_BITS; 26 | static const int TIME_BETWEEN_SYNC_INT = TIME_BETWEEN_SYNC_US; 27 | static const int DRIFT_HALF = 1 << (DRIFT_FP_BITS - 1); 28 | -------------------------------------------------------------------------------- /apps/hello_cpp/hello_cpp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | Simple Hello World program which writes output to two different 19 | places. One is IO_STD, which should appear on a "tubotron" viewer. 20 | The other is IO_BUF which goes to a memory buffer on the SpiNNaker 21 | chip and can be viewed with the "iobuf" command in "ybug" 22 | */ 23 | #include 24 | 25 | extern "C" void c_main() 26 | { 27 | char buf[64]; 28 | 29 | io_printf(IO_STD, "Hello world from C++! (via SDP)\n"); 30 | 31 | io_printf(IO_BUF, "Hello world from C++! (via SDRAM)\n"); 32 | 33 | // io_printf can also do sprintf! 34 | 35 | io_printf(buf, "Hello world from C++! (via printf...)\n"); 36 | io_printf(IO_BUF, buf); 37 | } 38 | -------------------------------------------------------------------------------- /include/version.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | //! \file version.h 3 | //! \brief Header file describing SpiNNaker low-level tool version 4 | //! 5 | //! \copyright © The University of Manchester - 2016 6 | //! 7 | //! \author Steve Temple, APT Group, School of Computer Science 8 | //! Email: steven.temple@manchester.ac.uk 9 | //! 10 | //------------------------------------------------------------------------------ 11 | 12 | /* 13 | * Copyright (c) 2016 The University of Manchester 14 | * 15 | * Licensed under the Apache License, Version 2.0 (the "License"); 16 | * you may not use this file except in compliance with the License. 17 | * You may obtain a copy of the License at 18 | * 19 | * https://www.apache.org/licenses/LICENSE-2.0 20 | * 21 | * Unless required by applicable law or agreed to in writing, software 22 | * distributed under the License is distributed on an "AS IS" BASIS, 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | * See the License for the specific language governing permissions and 25 | * limitations under the License. 26 | */ 27 | 28 | #ifndef __VERSION_H__ 29 | #define __VERSION_H__ 30 | 31 | //! SpiNNaker Low Level Tools Version: string 32 | #define SLLT_VER_STR "4.0.0" 33 | //! SpiNNaker Low Level Tools Version: BCD 34 | #define SLLT_VER_NUM 0x040000 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tools/mkbin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Copyright (c) 2015 The University of Manchester 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Utility to read two files, pad them both to a multiple of 4 bytes 18 | # and write to stdout. The files are assumed to be less than 64KB. 19 | 20 | use strict; 21 | use warnings; 22 | 23 | die "bad args\n" unless $#ARGV == 1 && -r $ARGV[0] && -r $ARGV[1]; 24 | 25 | open my ($fh), "<", $ARGV[0] or die; 26 | binmode($fh); 27 | my $len_ro = sysread $fh, my ($buf_ro), 65536; 28 | close $fh; 29 | 30 | open $fh, "<", $ARGV[1] or die; 31 | binmode($fh); 32 | my $len_rw = sysread $fh, my ($buf_rw), 65536; 33 | close $fh; 34 | 35 | my $pad_ro = (($len_ro & 3) != 0) ? 4 - ($len_ro & 3) : 0; 36 | my $pad_rw = (($len_rw & 3) != 0) ? 4 - ($len_rw & 3) : 0; 37 | 38 | binmode(STDOUT); 39 | print $buf_ro, chr(0) x $pad_ro, $buf_rw, chr(0) x $pad_rw; 40 | -------------------------------------------------------------------------------- /apps/pt_demo/Makefile.host: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | OBJECTS = drawer.o listener.o 16 | 17 | APP = drawer 18 | 19 | OBJS=$(OBJECTS:%=build/%) 20 | 21 | MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 22 | CURRENT_DIR := $(dir $(MAKEFILE_PATH)) 23 | UNAME_S := $(shell uname -s) 24 | 25 | ifeq ($(findstring MINGW, $(UNAME_S)), MINGW) 26 | CFLAGS += -D FREEGLUT_STATIC -D WINVER=0x501 -D WIN32_LEAN_AND_MEAN 27 | LIBS += -lfreeglut_static -lopengl32 -lwinmm -lgdi32 -lglu32 -lpthread -lws2_32 -lsqlite3 28 | PRE_LDFLAGS += -static-libgcc 29 | endif 30 | ifeq ($(UNAME_S), Darwin) 31 | LIBS += -framework OpenGL -framework GLUT -lpthread 32 | endif 33 | ifeq ($(UNAME_S), Linux) 34 | LIBS += -lGL -lGLU -lglut -lpthread -lm 35 | endif 36 | 37 | 38 | all: $(APP) 39 | 40 | build/%.o: %.c 41 | -mkdir -p $(dir $@) 42 | gcc -I$(CURRENT_DIR) $(CFLAGS) -o $@ -c $< 43 | 44 | $(APP): $(OBJS) 45 | gcc $(PRE_LDFLAGS) -L$(CURRENT_DIR) -o $@ $^ $(LIBS) 46 | 47 | clean: 48 | rm -rf build 49 | 50 | -------------------------------------------------------------------------------- /mainpage.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | * @cond copright_declaration 3 | * Copyright (c) 2020 The University of Manchester 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * @endcond 17 | * 18 | * @mainpage spinnaker_tools: SpiNNaker API, SARK, SC&MP, and Spin1 API 19 | * 20 | * The SpiNNaker low-level software tools consist of: 21 | * 22 | * * [spinnaker.h](spinnaker_8h.html) — The low-level definition of how to access the SpiNNaker 23 | * hardware 24 | * * SARK — The SpiNNaker Application Runtime Kernel (see [sark.h](sark_8h.html)). 25 | * This can be considered to be the C library of SpiNNaker. 26 | * * SC&MP — The SpiNNaker Control and Monitor Processor (see [scamp.h](scamp_8h.html)). 27 | * This can be considered to be the operating system of SpiNNaker. 28 | * * Spin1 API — The SpiNNaker API runtime environment for simulation 29 | * applications (see [spin1_api.h](spin1__api_8h.html)). 30 | * 31 | * There is also the [Board Management Processor (BMP)][bmp], but this is 32 | * normally transparent to user code (and not usually addressable). 33 | * 34 | * [bmp]: bmp/index.html 35 | */ 36 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Publish 16 | on: 17 | push: 18 | branches: [ master ] 19 | jobs: 20 | build: 21 | permissions: 22 | contents: write 23 | runs-on: ubuntu-latest 24 | timeout-minutes: 10 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v4 28 | - name: Doxygen 29 | uses: mattnotmitt/doxygen-action@v1.9.8 30 | with: 31 | working-directory: . 32 | - name: Doxygen BMP 33 | uses: mattnotmitt/doxygen-action@v1.9.8 34 | with: 35 | working-directory: bmp 36 | - name: Combine documentation trees 37 | run: | 38 | rm -rf deploy/bmp || true 39 | cp -a tools/html/* deploy 40 | cp -a bmp/html deploy/bmp 41 | working-directory: doxybuild 42 | - name: Deploy to GitHub Pages 43 | uses: JamesIves/github-pages-deploy-action@v4.6.3 44 | with: 45 | branch: gh-pages 46 | folder: doxybuild/deploy 47 | -------------------------------------------------------------------------------- /bmp/sum.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Copyright (c) 2012 The University of Manchester 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | use strict; 18 | use warnings; 19 | 20 | use String::CRC32; 21 | 22 | use SpiNN::Util qw/bmp_version/; 23 | 24 | 25 | die "bad args\n" unless $#ARGV == 1; 26 | 27 | my ($SIZE, $in, $out) = (65536, @ARGV); 28 | 29 | 30 | # Read program binary into buffer 31 | 32 | open my $fh, "<", $in or die "Can't open $in\n"; 33 | my $len = sysread $fh, my ($buffer), $SIZE; 34 | close $fh; 35 | 36 | die "Program read error\n" unless defined $len; 37 | die "Program not 4-byte aligned\n" unless $len % 4 == 0; 38 | die "Program too big\n" if $len == $SIZE; 39 | 40 | 41 | # Fudge to compute reset vector checksum for LPC1768 42 | 43 | if ($in =~ /BOOT/i) 44 | { 45 | use integer; 46 | 47 | my @w = unpack "V8", $buffer; 48 | my $sum = 0; 49 | $sum += $w[$_] for (0..6); 50 | $w[7] = -$sum; 51 | substr $buffer, 0, 32, pack ("V8", @w); 52 | } 53 | 54 | # Compute checksum, append to buffer and write out 55 | 56 | $out .= "-" . bmp_version (); 57 | 58 | $buffer .= pack "V", ~crc32 ($buffer); 59 | 60 | open $fh, ">", $out or die "Can't open $out\n"; 61 | syswrite $fh, $buffer or die "Write failed"; 62 | close $fh; 63 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 16 | 17 | MAKEFILES = spinnaker_tools.mk app.make 18 | COMMON_MAKE = $(MAKEFILES:%=$(abspath $(CURRENT_DIR)/../make/%)) 19 | 20 | MKDIR := mkdir -p 21 | INSTALL := install 22 | 23 | BOOT = boot/sark.struct boot/spin1.conf boot/spin2.conf boot/spin3.conf boot/spin4.conf boot/spin5.conf 24 | PERL = SpiNN/Boot.pm SpiNN/CLI.pm SpiNN/Cmd.pm SpiNN/SCP.pm SpiNN/Struct.pm SpiNN/Util.pm 25 | TOOLS = arm2gas bmpc bmpstat gdb-spin h2asm mkaplx mkbin mkbuild sark.lnk sark.sct tubogrid tubotron ybug 26 | 27 | BOOT_SRC = $(BOOT:%=$(CURRENT_DIR)/%) 28 | PERL_SRC = $(PERL:%=$(CURRENT_DIR)/%) 29 | TOOLS_SRC = $(TOOLS:%=$(CURRENT_DIR)/%) 30 | 31 | install: 32 | $(eval SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS))))) 33 | $(MKDIR) $(SPINN_INSTALL_DIR)/tools 34 | $(MKDIR) $(SPINN_INSTALL_DIR)/tools/SpiNN 35 | $(MKDIR) $(SPINN_INSTALL_DIR)/tools/boot 36 | $(MKDIR) $(SPINN_INSTALL_DIR)/make 37 | $(INSTALL) -c -m755 $(TOOLS_SRC) $(SPINN_INSTALL_DIR)/tools 38 | $(INSTALL) -c -m755 $(PERL_SRC) $(SPINN_INSTALL_DIR)/tools/SpiNN 39 | $(INSTALL) -c -m644 $(BOOT_SRC) $(SPINN_INSTALL_DIR)/tools/boot 40 | $(INSTALL) -c -m644 $(COMMON_MAKE) $(SPINN_INSTALL_DIR)/make 41 | -------------------------------------------------------------------------------- /docs/sark/sysram.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5b 2 | Landscape 3 | Center 4 | Metric 5 | A4 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 11 | 900 3150 3600 3150 12 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 13 | 900 900 3600 900 3600 7650 900 7650 900 900 14 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 15 | 900 7200 3600 7200 16 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 17 | 900 5850 3600 5850 18 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 19 | 900 2250 3600 2250 20 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 21 | 1 1 2.00 60.00 60.00 22 | 3015 5940 3015 5670 23 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 24 | 1 1 2.00 60.00 60.00 25 | 3015 5760 3015 6030 26 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 27 | 900 1350 3600 1350 28 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 900 0xe5008000\001 29 | 4 0 0 50 -1 18 12 0.0000 4 210 1800 1035 7515 Reset block (256)\001 30 | 4 0 0 50 -1 18 12 0.0000 4 210 1470 1035 5715 SysRAM heap\001 31 | 4 0 0 50 -1 18 12 0.0000 4 210 2415 990 3060 VCPU Blocks (18 * 128)\001 32 | 4 1 0 50 -1 18 15 0.0000 4 240 2925 2250 675 System RAM - 32 Kbytes\001 33 | 4 0 0 50 -1 18 12 0.0000 4 210 1875 990 1260 System Vars (256)\001 34 | 4 0 0 50 -1 18 12 0.0000 4 210 2145 1035 7065 User SysRAM (4096)\001 35 | 4 0 0 50 -1 18 12 0.0000 4 210 1305 990 2160 System Data\001 36 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 1350 0xe5007f00\001 37 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 2250 0xe5007900\001 38 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 3105 0xe5007000\001 39 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 7200 0xe5000100\001 40 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 7650 0xe5000000\001 41 | 4 0 0 50 -1 14 12 0.0000 4 195 2025 -1125 7200 sv->sysram_base\001 42 | 4 0 0 50 -1 14 12 0.0000 4 195 2025 -1125 5850 sv->sysram_heap\001 43 | 4 0 0 50 -1 14 12 0.0000 4 195 1755 -1125 3150 sv->vcpu_base\001 44 | 4 0 0 50 -1 14 12 0.0000 4 120 540 -1125 1350 sv->\001 45 | 4 0 0 50 -1 18 12 0.0000 4 210 1455 3780 6075 (configurable)\001 46 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 5850 0xe5001100\001 47 | -------------------------------------------------------------------------------- /apps/gdb-test/gdb-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Simple SpiNNaker application to demonstrate use of GDB 18 | 19 | #include 20 | 21 | // Declare a struct type to contain data for this program 22 | 23 | typedef struct my_data { 24 | uint count; 25 | uchar list[16]; 26 | struct my_data *self; 27 | } my_data_t; 28 | 29 | // Declare an instance of the data struct. This is what we want to inspect 30 | // with GDB. Placing many or all of the module's variables in a single 31 | // struct is useful for debugging as we can display them all with a single 32 | // command in GDB. The compiler is just as efficient at addressing these 33 | // variables whether or not they are located in a struct. 34 | 35 | my_data_t app_data; 36 | 37 | // A timer function, called every 10ms. This copies the tick count into 38 | // the data struct and updates one of the array elements with a new 39 | // random number each time. It also sets the 'self' pointer to itself 40 | // so that we can see this in GDB. 41 | 42 | void timer_proc(uint ticks, uint arg2) 43 | { 44 | app_data.count = ticks; 45 | app_data.list[ticks % 16] = spin1_rand(); 46 | app_data.self = &app_data; 47 | } 48 | 49 | // Main function which sets up and runs the timer 50 | 51 | void c_main(void) 52 | { 53 | io_printf(IO_STD, ">> %s on %d \n", sark_app_name(), sark_core_id()); 54 | 55 | spin1_callback_on(TIMER_TICK, timer_proc, 1); 56 | spin1_set_timer_tick(10 * 1000); 57 | spin1_start(SYNC_NOWAIT); 58 | } 59 | -------------------------------------------------------------------------------- /docs/sark/sdram.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5b 2 | Landscape 3 | Center 4 | Metric 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 11 | 900 3150 3600 3150 12 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 13 | 900 900 3600 900 3600 7650 900 7650 900 900 14 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 15 | 900 2700 3600 2700 16 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 17 | 900 6075 3600 6075 18 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 19 | 1 1 2.00 60.00 60.00 20 | 3150 6075 3150 5805 21 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 22 | 1 1 2.00 60.00 60.00 23 | 3150 6075 3150 6345 24 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 25 | 900 7020 3600 7020 26 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 27 | 1 1 2.00 60.00 60.00 28 | 3150 7020 3150 7290 29 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 30 | 1 1 2.00 60.00 60.00 31 | 3150 7020 3150 6750 32 | 4 1 0 50 -1 18 15 0.0000 4 240 2460 2250 675 SDRAM - 128 Mbytes\001 33 | 4 0 0 50 -1 18 12 0.0000 4 210 2790 990 7560 SDRAM Buffers (18 * 128K)\001 34 | 4 0 0 50 -1 18 12 0.0000 4 210 2160 990 3060 System Buffer (256K)\001 35 | 4 0 0 50 -1 18 12 0.0000 4 210 2160 990 2610 System Heap (~8MB)\001 36 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 900 0x68000000\001 37 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 2700 0x67840000\001 38 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 3150 0x67800000\001 39 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 7650 0x60000000\001 40 | 4 0 0 50 -1 14 12 0.0000 4 180 1890 -1125 7650 sv->sdram_bufs\001 41 | 4 0 0 50 -1 14 12 0.0000 4 195 1755 -1125 3150 sv->sdram_sys\001 42 | 4 0 0 50 -1 14 12 0.0000 4 195 1620 -1125 2700 sv->sys_heap\001 43 | 4 0 0 50 -1 18 12 0.0000 4 210 2310 990 5985 SDRAM Heap (~114M)\001 44 | 4 0 0 50 -1 18 12 0.0000 4 210 1905 990 6930 User SDRAM (4M)\001 45 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 6075 0x60640000\001 46 | 4 0 0 50 -1 14 12 0.0000 4 150 1350 3690 7020 0x60240000\001 47 | 4 0 0 50 -1 18 12 0.0000 4 210 1455 3825 7245 (configurable)\001 48 | 4 0 0 50 -1 14 12 0.0000 4 195 1890 -1125 6075 sv->sdram_heap\001 49 | 4 0 0 50 -1 14 12 0.0000 4 180 1890 -1125 7020 sv->sdram_base\001 50 | 4 0 0 50 -1 18 12 0.0000 4 210 1455 3825 6300 (configurable)\001 51 | -------------------------------------------------------------------------------- /apps/sdping/sdp_recv.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ##------------------------------------------------------------------------------ 4 | ## 5 | ## sdp_recv SDP receiver program 6 | ## 7 | ## Copyright (C) The University of Manchester - 2014 8 | ## 9 | ## Author Steve Temple, APT Group, School of Computer Science 10 | ## Email temples@cs.man.ac.uk 11 | ## 12 | ##------------------------------------------------------------------------------ 13 | 14 | # Copyright (c) 2014 The University of Manchester 15 | # 16 | # Licensed under the Apache License, Version 2.0 (the "License"); 17 | # you may not use this file except in compliance with the License. 18 | # You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | 28 | 29 | use strict; 30 | use warnings; 31 | 32 | use SpiNN::SCP; 33 | 34 | 35 | my $spin; # SpiNNaker handle 36 | my $timeout; # Receive timeout 37 | 38 | 39 | # Process the two arguments and open connection to SpiNNaker 40 | # The first argument is the UDP port to listen on and the 41 | # second is the timeout (in seconds) for the receive operation. 42 | 43 | sub process_args 44 | { 45 | die "usage: sdp_recv \n" unless 46 | $#ARGV == 1 && 47 | $ARGV[0] =~ /^\d+$/ && 48 | $ARGV[1] =~ /^\d+(\.\d+)?$/; 49 | 50 | $spin = SpiNN::SCP->new (port => $ARGV[0]); 51 | 52 | die "Failed to start receiver\n" unless $spin; 53 | 54 | $timeout = $ARGV[1]; 55 | } 56 | 57 | 58 | # Main loop which waits for incoming SDP messages and prints them 59 | # using the SpiNN::SCP debug facility 60 | 61 | sub main 62 | { 63 | process_args (); 64 | 65 | while (1) 66 | { 67 | my $rc = $spin->recv_sdp (timeout => $timeout, debug => 4); 68 | 69 | print "# No reply\n" unless $rc; 70 | print "\n"; 71 | } 72 | } 73 | 74 | 75 | main (); 76 | 77 | #------------------------------------------------------------------------------ 78 | -------------------------------------------------------------------------------- /docs/scp/cmd-write.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5b 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 11 | 9450 4050 10350 4050 10350 4725 9450 4725 12 | 2 1 1 2 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 13 | 8550 4050 9450 4050 14 | 2 1 1 2 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 15 | 8550 4725 9450 4725 16 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 17 | 8550 4050 7650 4050 7650 4725 8550 4725 18 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 19 | 1350 4050 1350 4725 20 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 21 | 2250 4050 2250 4725 22 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 23 | 4050 4050 4050 4725 24 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 25 | 5850 4050 5850 4725 26 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 27 | 1350 5850 1350 6525 28 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 29 | 450 4050 7650 4050 7650 4725 450 4725 450 4050 30 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 31 | 450 5850 2250 5850 2250 6525 450 6525 450 5850 32 | 4 1 0 50 -1 18 8 0.0000 4 105 795 900 4365 CMD_WRITE\001 33 | 4 1 0 50 -1 18 10 0.0000 4 150 210 900 4590 (3)\001 34 | 4 1 0 50 -1 18 10 0.0000 4 150 525 900 4005 cmd_rc\001 35 | 4 1 0 50 -1 18 10 0.0000 4 120 270 1800 4005 seq\001 36 | 4 1 0 50 -1 18 10 0.0000 4 150 330 3150 4005 arg1\001 37 | 4 1 0 50 -1 18 10 0.0000 4 150 330 4950 4005 arg2\001 38 | 4 1 0 50 -1 18 10 0.0000 4 150 330 6750 4005 arg3\001 39 | 4 1 0 50 -1 18 10 0.0000 4 120 630 3150 4455 Address\001 40 | 4 1 0 50 -1 18 10 0.0000 4 150 495 1800 6255 SeqNo\001 41 | 4 1 0 50 -1 18 10 0.0000 4 150 540 900 6165 RC_OK\001 42 | 4 1 0 50 -1 18 10 0.0000 4 150 390 900 6390 (128)\001 43 | 4 1 0 50 -1 18 10 0.0000 4 120 330 9000 4005 data\001 44 | 4 1 0 50 -1 18 10 0.0000 4 150 495 1800 4455 SeqNo\001 45 | 4 1 0 50 -1 18 10 0.0000 4 150 375 6750 4365 Type\001 46 | 4 1 0 50 -1 18 10 0.0000 4 150 1095 4950 4365 Length (bytes)\001 47 | 4 1 0 50 -1 18 8 0.0000 4 120 1110 4905 4590 0 <= Length <= 256\001 48 | 4 1 0 50 -1 18 8 0.0000 4 120 1515 6750 4590 0=Byte, 1=Short, 2=Word\001 49 | 4 1 0 50 -1 18 10 0.0000 4 150 525 855 5760 cmd_rc\001 50 | 4 1 0 50 -1 18 10 0.0000 4 120 270 1800 5760 seq\001 51 | 4 0 0 50 -1 18 12 0.0000 4 210 1815 0 5535 Response Packet\001 52 | 4 0 0 50 -1 18 12 0.0000 4 165 1815 0 3735 Command Packet\001 53 | 4 1 0 50 -1 18 10 0.0000 4 150 1905 9000 4455 Write data (<= 256 bytes)\001 54 | -------------------------------------------------------------------------------- /docs/scp/sdp-scp.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5b 2 | Landscape 3 | Center 4 | Metric 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 -45 4905 3645 5895 11 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 12 | 0 4950 450 4950 450 5850 0 5850 0 4950 13 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 14 | 450 4950 900 4950 900 5850 450 5850 450 4950 15 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 16 | 900 4950 1800 4950 1800 5850 900 5850 900 4950 17 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 18 | 1800 4950 2700 4950 2700 5850 1800 5850 1800 4950 19 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 20 | 2700 4950 3600 4950 3600 5850 2700 5850 2700 4950 21 | -6 22 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 23 | 0 3150 900 3150 900 4050 0 4050 0 3150 24 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 25 | 900 4050 0 4950 26 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 27 | 2700 4050 3600 4950 28 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 29 | 3600 4950 7650 4950 7650 5850 3600 5850 3600 4950 30 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 31 | 6750 4050 7650 4950 32 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 33 | 900 3150 6750 3150 6750 4050 900 4050 900 3150 34 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 35 | 2700 4050 2700 3150 36 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 37 | 1 1 2.00 90.00 120.00 38 | 1 1 2.00 90.00 120.00 39 | 0 2925 6750 2925 40 | 4 0 0 50 -1 18 12 0.0000 4 165 465 270 3555 SDP\001 41 | 4 0 0 50 -1 18 12 0.0000 4 165 375 270 3780 Hdr\001 42 | 4 0 0 50 -1 18 12 0.0000 4 165 240 1755 4320 16\001 43 | 4 0 0 50 -1 18 12 0.0000 4 165 120 180 6075 2\001 44 | 4 0 0 50 -1 18 12 0.0000 4 165 120 630 6075 2\001 45 | 4 0 0 50 -1 18 12 0.0000 4 165 120 1305 6075 4\001 46 | 4 0 0 50 -1 18 12 0.0000 4 165 120 2205 6075 4\001 47 | 4 0 0 50 -1 18 12 0.0000 4 165 120 3105 6075 4\001 48 | 4 0 0 50 -1 18 12 0.0000 4 165 435 45 5355 cmd\001 49 | 4 0 0 50 -1 18 12 0.0000 4 165 330 45 5580 _rc\001 50 | 4 0 0 50 -1 18 12 0.0000 4 210 465 2070 5490 arg2\001 51 | 4 0 0 50 -1 18 12 0.0000 4 210 465 2970 5490 arg3\001 52 | 4 0 0 50 -1 18 12 0.0000 4 210 465 1170 5490 arg1\001 53 | 4 0 0 50 -1 18 12 0.0000 4 165 375 495 5445 seq\001 54 | 4 0 0 50 -1 18 12 0.0000 4 210 750 135 4275 8 bytes\001 55 | 4 0 0 50 -1 18 12 0.0000 4 165 450 5400 5445 data\001 56 | 4 0 0 50 -1 18 12 0.0000 4 165 1230 2520 2835 SDP Packet\001 57 | 4 0 0 50 -1 18 12 0.0000 4 165 1005 3420 3645 SDP Data\001 58 | 4 1 0 50 -1 18 12 0.0000 4 165 675 5580 6075 <= 256\001 59 | -------------------------------------------------------------------------------- /docs/scp/cmd-read.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5b 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 2 7 7 50 -1 -1 0.000 0 0 7 0 0 4 11 | 9450 4050 10350 4050 10350 4725 9450 4725 12 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 13 | 1350 4050 1350 4725 14 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 15 | 2250 4050 2250 4725 16 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 17 | 4050 4050 4050 4725 18 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 19 | 5850 4050 5850 4725 20 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 21 | 1350 5850 1350 6525 22 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 23 | 450 4050 7650 4050 7650 4725 450 4725 450 4050 24 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 25 | 450 5850 2250 5850 2250 6525 450 6525 450 5850 26 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 27 | 3150 5850 2250 5850 2250 6525 3150 6525 28 | 2 1 1 2 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 29 | 3150 5850 4050 5850 30 | 2 1 1 2 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 31 | 3150 6525 4050 6525 32 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 33 | 4050 5850 4950 5850 4950 6525 4050 6525 34 | 4 1 0 50 -1 18 10 0.0000 4 150 885 900 4365 CMD_READ\001 35 | 4 1 0 50 -1 18 10 0.0000 4 150 210 900 4590 (2)\001 36 | 4 1 0 50 -1 18 10 0.0000 4 150 525 900 4005 cmd_rc\001 37 | 4 1 0 50 -1 18 10 0.0000 4 120 270 1800 4005 seq\001 38 | 4 1 0 50 -1 18 10 0.0000 4 150 330 3150 4005 arg1\001 39 | 4 1 0 50 -1 18 10 0.0000 4 150 330 4950 4005 arg2\001 40 | 4 1 0 50 -1 18 10 0.0000 4 150 330 6750 4005 arg3\001 41 | 4 1 0 50 -1 18 10 0.0000 4 120 630 3150 4455 Address\001 42 | 4 1 0 50 -1 18 10 0.0000 4 150 495 1800 6255 SeqNo\001 43 | 4 1 0 50 -1 18 10 0.0000 4 150 540 900 6165 RC_OK\001 44 | 4 1 0 50 -1 18 10 0.0000 4 150 390 900 6390 (128)\001 45 | 4 1 0 50 -1 18 10 0.0000 4 150 495 1800 4455 SeqNo\001 46 | 4 1 0 50 -1 18 10 0.0000 4 150 375 6750 4365 Type\001 47 | 4 1 0 50 -1 18 10 0.0000 4 150 1095 4950 4365 Length (bytes)\001 48 | 4 1 0 50 -1 18 8 0.0000 4 120 1110 4905 4590 0 <= Length <= 256\001 49 | 4 1 0 50 -1 18 8 0.0000 4 120 1515 6750 4590 0=Byte, 1=Short, 2=Word\001 50 | 4 1 0 50 -1 18 10 0.0000 4 150 1860 3600 6210 Read data (<= 256 bytes)\001 51 | 4 1 0 50 -1 18 10 0.0000 4 120 330 3600 5805 data\001 52 | 4 1 0 50 -1 18 10 0.0000 4 150 525 855 5760 cmd_rc\001 53 | 4 1 0 50 -1 18 10 0.0000 4 120 270 1800 5760 seq\001 54 | 4 0 0 50 -1 18 12 0.0000 4 210 1815 0 5535 Response Packet\001 55 | 4 0 0 50 -1 18 12 0.0000 4 165 1815 0 3735 Command Packet\001 56 | -------------------------------------------------------------------------------- /apps/pt_demo/pt_trig: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Simple program to send an SCP trigger message to the Path Tracer 4 | # 5 | # Steve Temple - 3 Apr 2014 6 | # 7 | # Adapted from a python script originally written by Andrew Webb. 8 | 9 | # Copyright (c) 2014 The University of Manchester 10 | # 11 | # Licensed under the Apache License, Version 2.0 (the "License"); 12 | # you may not use this file except in compliance with the License. 13 | # You may obtain a copy of the License at 14 | # 15 | # https://www.apache.org/licenses/LICENSE-2.0 16 | # 17 | # Unless required by applicable law or agreed to in writing, software 18 | # distributed under the License is distributed on an "AS IS" BASIS, 19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | # See the License for the specific language governing permissions and 21 | # limitations under the License. 22 | 23 | use strict; 24 | use warnings; 25 | 26 | use SpiNN::SCP; 27 | 28 | # Process args 29 | 30 | die "usage: pt_trig " . 31 | "\n" unless $#ARGV == 3; 32 | 33 | 34 | my ($host, $frameHeight, $antialiasing, $cores) = @ARGV; 35 | 36 | 37 | # Open connection to SpiNNaker 38 | 39 | my $spin = SpiNN::SCP->new (target => $host, debug => 0); 40 | die unless $spin; 41 | 42 | 43 | # Set up viewing position parameters, etc. 44 | 45 | my @position = (-220.0, 50.0, 0.0); 46 | my @look = (1.0, 0.0, 0.0); 47 | my @up = (0.0, 1.0, 0.0); 48 | 49 | my $horizontalFieldOfView = 60.0; 50 | my $verticalFieldOfView = 50.0; 51 | 52 | my ($camx, $camy, $camz) = (int ($position[0] * 512), 53 | int ($position[1] * 512), 54 | int ($position[2] * 512)); 55 | 56 | my ($lookx, $looky, $lookz) = (int ($look[0] * 65536), 57 | int ($look[1] * 65536), 58 | int ($look[2] * 65536)); 59 | 60 | my ($upx, $upy, $upz) = (int ($up[0] * 65536), 61 | int ($up[1] * 65536), 62 | int ($up[2] * 65536)); 63 | 64 | my $frameWidth = int ($frameHeight * $horizontalFieldOfView / $verticalFieldOfView); 65 | 66 | 67 | # Pack them up... 68 | 69 | my $data = pack "V*", 70 | $camx, $camy, $camz, 71 | $lookx, $looky, $lookz, 72 | $upx, $upy, $upz, 73 | $frameWidth, $frameHeight, 74 | int ($horizontalFieldOfView * 65536), int ($verticalFieldOfView * 65536), 75 | $antialiasing, 0, 0, $cores; 76 | 77 | # Send to Port 1 on Core 1 of Chip (0, 0) 78 | 79 | $spin->send_scp (4, 0, 0, 0, $data, addr => [0, 0, 1], port => 1); 80 | -------------------------------------------------------------------------------- /scamp/scamp-del.c: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | //! \file 3 | //! \brief SC&MP monitor delegation routines 4 | //! 5 | //! \copyright © The University of Manchester - 2017-2019 6 | //! 7 | //! \author Luis Plana, APT Group, School of Computer Science 8 | //! Email: luis.plana@manchester.ac.uk 9 | //! 10 | //------------------------------------------------------------------------------ 11 | 12 | /* 13 | * Copyright (c) 2017 The University of Manchester 14 | * 15 | * Licensed under the Apache License, Version 2.0 (the "License"); 16 | * you may not use this file except in compliance with the License. 17 | * You may obtain a copy of the License at 18 | * 19 | * https://www.apache.org/licenses/LICENSE-2.0 20 | * 21 | * Unless required by applicable law or agreed to in writing, software 22 | * distributed under the License is distributed on an "AS IS" BASIS, 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | * See the License for the specific language governing permissions and 25 | * limitations under the License. 26 | */ 27 | 28 | #include "spinnaker.h" 29 | #include "sark.h" 30 | #include "scamp.h" 31 | 32 | 33 | //------------------------------------------------------------------------------ 34 | 35 | //! Copy executable image from SDRAM to ITCM and boot it 36 | void img_cp_exe (void) { 37 | typedef void (*boot_img_t)(void); 38 | boot_img_t boot_img = (boot_img_t) ITCM_BASE; 39 | 40 | // start boot image DMA to top-half of DTCM, 41 | dma[DMA_ADRS] = (uint) SDRAM_BASE; 42 | dma[DMA_ADRT] = (uint) DTCM_BASE + 0x00008000; 43 | dma[DMA_DESC] = 1 << 24 | 4 << 21 | 0 << 19 | BOOT_IMAGE_SIZE; 44 | 45 | // start boot image DMA to ITCM, 46 | dma[DMA_ADRT] = (uint) ITCM_BASE; 47 | dma[DMA_DESC] = 1 << 24 | 4 << 21 | 0 << 19 | BOOT_IMAGE_SIZE; 48 | 49 | // wait for DTCM DMA to complete, 50 | while (!(dma[DMA_STAT] & (1 << 10))) { 51 | continue; 52 | } 53 | 54 | // clear DMA transfer complete, 55 | dma[DMA_CTRL] = 1 << 3; 56 | 57 | // wait for ITCM DMA to complete, 58 | while (!(dma[DMA_STAT] & (1 << 10))) { 59 | continue; 60 | } 61 | 62 | // clear DMA transfer complete, 63 | dma[DMA_CTRL] = 1 << 3; 64 | 65 | // and jump to boot image 66 | boot_img(); 67 | } 68 | 69 | 70 | //------------------------------------------------------------------------------ 71 | -------------------------------------------------------------------------------- /apps/interrupt/interrupt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | This program demonstrates a very simple bare-metal interrupt 19 | handler for SpiNNaker. 20 | */ 21 | 22 | 23 | #include 24 | 25 | uint ticks; 26 | 27 | 28 | // This is the interrupt handler. It needs to acknowledge the 29 | // interrupt, do any interrupt processing (flip a LED and write a 30 | // message) and finally tell the VIC that the routine is finished. 31 | 32 | // Note that it's not normally a good idea to do "io_printf" inside 33 | // an interrupt handler as it can be quite slow. This instance is 34 | // OK because the interrupt is only occurring a couple of times 35 | // per second. 36 | 37 | INT_HANDLER timer_int_han(void) 38 | { 39 | tc[T1_INT_CLR] = (uint) tc; // Clear interrupt in timer 40 | 41 | sark_led_set(LED_FLIP(1)); // Flip a LED 42 | 43 | io_printf(IO_BUF, "Tick %d\n", ++ticks); // Write message to buffer 44 | 45 | vic[VIC_VADDR] = (uint) vic; // Tell VIC we're done 46 | } 47 | 48 | 49 | // This routine sets up the core's Timer1 hardware. It loads control 50 | // registers to configure the timer and then sets up the VIC (vectored 51 | // interrupt controller) to direct Timer1 interrupts to the handler 52 | // above 53 | 54 | void timer_setup(uint period) 55 | { 56 | tc[T1_CONTROL] = 0xe2; // Set up count-down mode 57 | tc[T1_LOAD] = sark.cpu_clk * period; // Load time in microsecs 58 | 59 | sark_vic_set(SLOT_0, TIMER1_INT, 1, timer_int_han); // Set VIC slot 0 60 | } 61 | 62 | 63 | // "c_main" calls the routine to set up the interrupt handler and 64 | // then goes to sleep permanently, but still waking for the interrupt. 65 | 66 | void c_main(void) 67 | { 68 | io_printf(IO_STD, "Timer interrupt example\n"); // Say hello 69 | 70 | timer_setup(500000); // This is 500,000 us (0.5 secs) 71 | 72 | cpu_sleep(); // Send core to sleep 73 | } 74 | -------------------------------------------------------------------------------- /scamp/scamp-3.lnk: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | // scamp-3.lnk GNU linker script for SCAMP build 4 | // 5 | // Copyright (C) The University of Manchester - 2011-2020 6 | // 7 | // Author Steve Temple, APT Group, School of Computer Science 8 | // 9 | // Email temples@cs.man.ac.uk 10 | // 11 | 12 | // Copyright (c) 2011 The University of Manchester 13 | // 14 | // Licensed under the Apache License, Version 2.0 (the "License"); 15 | // you may not use this file except in compliance with the License. 16 | // You may obtain a copy of the License at 17 | // 18 | // https://www.apache.org/licenses/LICENSE-2.0 19 | // 20 | // Unless required by applicable law or agreed to in writing, software 21 | // distributed under the License is distributed on an "AS IS" BASIS, 22 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | // See the License for the specific language governing permissions and 24 | // limitations under the License. 25 | 26 | */ 27 | 28 | 29 | MEMORY 30 | { 31 | ITCM : ORIGIN = 0, LENGTH = 0x7f00 32 | DTCM : ORIGIN = 0x400000, LENGTH = 0xf800 33 | } 34 | 35 | 36 | SECTIONS 37 | { 38 | ITCM_BASE = 0x00000000; 39 | DTCM_BASE = 0x00400000; 40 | 41 | STACK_TOP = 0x00408000; 42 | STACK_SIZE = 0x800; 43 | 44 | APLX_SIZE = 64; 45 | APLX_ENTRY = 16; 46 | 47 | . = ITCM_BASE; 48 | 49 | RO_DATA : 50 | { 51 | * (_alib_reset); 52 | * (alib_*); 53 | * (.text*); 54 | __init_array_start = .; 55 | KEEP (*(.init_array*)) 56 | __init_array_end = .; 57 | * (.rodata*); 58 | * (.fini*); 59 | * (.init*); 60 | } > ITCM 61 | 62 | . = ALIGN (4); 63 | 64 | /* 65 | Attempt to deal with .ARM.exdix* sections. Ideally we probably 66 | want to throw these away but for now they go into the RO binary 67 | See also "objcopy" lines in make file... 68 | */ 69 | 70 | EX_DATA : 71 | { 72 | * (.ARM.exidx*); 73 | } > ITCM 74 | 75 | RO_LENGTH = . - ITCM_BASE; 76 | 77 | . = DTCM_BASE; 78 | 79 | RW_DATA : 80 | { 81 | * (.data*); 82 | } > DTCM 83 | 84 | . = ALIGN (4); 85 | 86 | RW_LENGTH = . - DTCM_BASE; 87 | 88 | ZI_DATA : 89 | { 90 | * (.bss*); 91 | * (COMMON); 92 | } > DTCM 93 | 94 | . = ALIGN (4); 95 | 96 | HEAP_BASE = .; 97 | 98 | RO_BASE = ITCM_BASE; 99 | RO_FROM = APLX_SIZE; 100 | 101 | RW_BASE = DTCM_BASE; 102 | RW_FROM = APLX_SIZE + RO_LENGTH - APLX_ENTRY; 103 | 104 | ZI_BASE = RW_BASE + RW_LENGTH; 105 | ZI_LENGTH = HEAP_BASE - ZI_BASE; 106 | } 107 | -------------------------------------------------------------------------------- /tools/sark.lnk: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | // sark.lnk GNU linker script for SARK/SpiNNaker applications 4 | // 5 | // Copyright (C) The University of Manchester - 2011-2013 6 | // 7 | // Author Steve Temple, APT Group, School of Computer Science 8 | // 9 | // Email temples@cs.man.ac.uk 10 | // 11 | 12 | // Copyright (c) 2011 The University of Manchester 13 | // 14 | // Licensed under the Apache License, Version 2.0 (the "License"); 15 | // you may not use this file except in compliance with the License. 16 | // You may obtain a copy of the License at 17 | // 18 | // https://www.apache.org/licenses/LICENSE-2.0 19 | // 20 | // Unless required by applicable law or agreed to in writing, software 21 | // distributed under the License is distributed on an "AS IS" BASIS, 22 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | // See the License for the specific language governing permissions and 24 | // limitations under the License. 25 | 26 | */ 27 | 28 | 29 | MEMORY 30 | { 31 | ITCM : ORIGIN = 0, LENGTH = 0x7f00 32 | DTCM : ORIGIN = 0x400000, LENGTH = 0xf800 33 | } 34 | 35 | 36 | SECTIONS 37 | { 38 | ITCM_BASE = 0x00000000; 39 | DTCM_BASE = 0x00400000; 40 | 41 | STACK_TOP = 0x00410000; 42 | STACK_SIZE = 0x800; 43 | 44 | APLX_SIZE = 64; 45 | APLX_ENTRY = 16; 46 | 47 | . = ITCM_BASE; 48 | 49 | RO_DATA : 50 | { 51 | * (_alib_reset); 52 | * (alib_*); 53 | * (.text*); 54 | __init_array_start = .; 55 | KEEP (*(.init_array*)) 56 | __init_array_end = .; 57 | * (.rodata*); 58 | * (.fini*); 59 | * (.init*); 60 | } > ITCM 61 | 62 | . = ALIGN (4); 63 | 64 | /* 65 | Attempt to deal with .ARM.exdix* sections. Ideally we probably 66 | want to throw these away but for now they go into the RO binary 67 | See also "objcopy" lines in make file... 68 | */ 69 | 70 | EX_DATA : 71 | { 72 | * (.ARM.exidx*); 73 | } > ITCM 74 | 75 | RO_LENGTH = . - ITCM_BASE; 76 | 77 | . = DTCM_BASE; 78 | 79 | RW_DATA : 80 | { 81 | * (.data*); 82 | } > DTCM 83 | 84 | . = ALIGN (4); 85 | 86 | RW_LENGTH = . - DTCM_BASE; 87 | 88 | ZI_DATA : 89 | { 90 | * (.bss*); 91 | * (COMMON); 92 | } > DTCM 93 | 94 | . = ALIGN (4); 95 | 96 | HEAP_BASE = .; 97 | 98 | RO_BASE = ITCM_BASE; 99 | RO_FROM = APLX_SIZE; 100 | 101 | RW_BASE = DTCM_BASE; 102 | RW_FROM = APLX_SIZE + RO_LENGTH - APLX_ENTRY; 103 | 104 | ZI_BASE = RW_BASE + RW_LENGTH; 105 | ZI_LENGTH = HEAP_BASE - ZI_BASE; 106 | } 107 | -------------------------------------------------------------------------------- /spin1_api/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 16 | 17 | # Makefile for spin1_api 18 | ifeq ($(GNU),1) 19 | BUILD_DIR := $(abspath $(CURRENT_DIR)/../build/gnu) 20 | else 21 | BUILD_DIR := $(abspath $(CURRENT_DIR)/../build/arm) 22 | endif 23 | override LIB := 1 24 | 25 | include $(CURRENT_DIR)/../make/spinnaker_tools.mk 26 | 27 | #------------------------------------------------------------------------------- 28 | 29 | APIOBJS := spin1_api.o spin1_isr.o 30 | APIOBJ := $(APIOBJS:%.o=$(BUILD_DIR)/%.o) 31 | HEADERS := spin1_api.h spin1_api_params.h scamp_spin1_sync.h spin1_api_cpp.h 32 | HEADER := $(HEADERS:%.h=$(SPINN_INC_DIR)/%.h) 33 | 34 | ifeq ($(GNU),1) 35 | LIBNAME := libspin1_api 36 | else 37 | LIBNAME := spin1_api 38 | endif 39 | 40 | APILIB := $(BUILD_DIR)/$(LIBNAME).a 41 | 42 | APIOPT := $(OSPACE) 43 | CFLAGS += $(APIOPT) 44 | 45 | #------------------------------------------------------------------------------- 46 | 47 | # APILIB (default target) 48 | 49 | $(APILIB): $(BUILD_DIR)/sark.o $(APIOBJ) 50 | $(RM) $@ 51 | $(AR) $@ $^ 52 | 53 | $(BUILD_DIR)/sark.o: 54 | @$(MAKE) -C ../sark $@ 55 | 56 | #------------------------------------------------------------------------------- 57 | 58 | # API 59 | 60 | $(BUILD_DIR)/spin1_api.o: spin1_api.c $(HEADER) 61 | $(CC_THUMB) $(CFLAGS) -o $@ $< 62 | 63 | $(BUILD_DIR)/spin1_isr.o: spin1_isr.c $(HEADER) 64 | $(CC) $(CFLAGS) -o $@ $< 65 | 66 | #------------------------------------------------------------------------------- 67 | install: $(APILIB) 68 | $(eval SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS))))) 69 | $(MKDIR) $(SPINN_INSTALL_DIR)/lib 70 | $(MKDIR) $(SPINN_INSTALL_DIR)/include 71 | $(INSTALL) -c -m644 $< $(SPINN_INSTALL_DIR)/lib 72 | $(INSTALL) -c -m644 $(HEADERS:%.h=$(SPINN_INC_DIR)/%.h) $(SPINN_INSTALL_DIR)/include 73 | 74 | clean: 75 | $(RM) $(APILIB) $(APIOBJ) $(BUILD_DIR)/sark.o 76 | 77 | .PHONY: clean 78 | -------------------------------------------------------------------------------- /scamp/spinn_phy.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | //! \file 3 | //! \brief Spinnaker support routines for SMC PHY (physical layer ethernet) chip 4 | //! 5 | //! \copyright © The University of Manchester - 2009-2019 6 | //! 7 | //! \author Steve Temple, APT Group, School of Computer Science 8 | //! 9 | //------------------------------------------------------------------------------ 10 | 11 | /* 12 | * Copyright (c) 2009 The University of Manchester 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); 15 | * you may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * https://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | #ifndef SPINN_PHY_H 28 | #define SPINN_PHY_H 29 | 30 | //! \brief PHY registers 31 | //! \details Documentation guessed based on 32 | //! https://github.com/goertzenator/smsc7500/blob/master/smsclan7500.h 33 | enum spinn_phy_registers { 34 | PHY_CONTROL = 0, //!< Control register 35 | PHY_STATUS = 1, //!< Status register 36 | PHY_ID1 = 2, //!< PHY identifier 1 register 37 | PHY_ID2 = 3, //!< PHY identifier 2 register 38 | PHY_AUTO_ADV = 4, //!< Auto Negotiation Advertisement register 39 | PHY_AUTO_LPA = 5, //!< Auto Negotiation Link Partner register 40 | PHY_AUTO_EXP = 6, //!< Auto Negotiation Expansion register 41 | PHY_SI_REV = 16, // !< WTF is this? 42 | PHY_MODE_CSR = 17, //!< 10/100 Mode Control/Status register 43 | PHY_SP_MODE = 18, //!< 10/100 Special Modes register 44 | PHY_ERR_COUNT = 26, //!< Error count register 45 | PHY_SP_CSIR = 27, //!< Special Control/Status Indication register 46 | PHY_INT_SRC = 29, //!< Interrupt source register 47 | PHY_INT_MASK = 30, //!< Interrupt mask register 48 | PHY_SP_CSR = 31, //!< Special Control/Status register 49 | }; 50 | 51 | //! Reset the PHY chip 52 | void phy_reset(void); 53 | //! \brief Write to the PHY chip 54 | //! \param[in] addr: The register to write to 55 | //! \param[in] data: The value to write (really a ushort) 56 | void phy_write(uint addr, uint data); 57 | //! \brief Read from the PHY chip 58 | //! \param[in] addr: The register to read from 59 | //! \return The read value (really a ushort) 60 | uint phy_read(uint addr); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /docs/sark/tcm.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5b 2 | Landscape 3 | Center 4 | Metric 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 11 | 900 1350 3600 1350 12 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 13 | 900 3150 3600 3150 14 | 2 1 1 2 0 7 50 -1 -1 6.000 0 0 -1 0 0 2 15 | 900 5850 3600 5850 16 | 2 1 1 2 0 7 50 -1 -1 6.000 0 0 -1 0 0 2 17 | 900 7200 3600 7200 18 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 19 | 900 900 3600 900 3600 7650 900 7650 900 900 20 | 2 2 0 0 0 30 52 -1 20 0.000 0 0 -1 0 0 5 21 | 900 3150 3600 3150 3600 7650 900 7650 900 3150 22 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 23 | 900 900 3600 900 3600 7650 900 7650 900 900 24 | 2 2 0 0 0 30 52 -1 20 0.000 0 0 -1 0 0 5 25 | 900 900 3600 900 3600 1350 900 1350 900 900 26 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 27 | 5400 5850 8100 5850 28 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 29 | 5400 7200 8100 7200 30 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 31 | 5400 900 8100 900 8100 7650 5400 7650 5400 900 32 | 2 1 1 2 0 7 50 -1 -1 6.000 0 0 -1 0 0 2 33 | 5400 2250 8100 2250 34 | 2 1 1 2 0 7 50 -1 -1 6.000 0 0 -1 0 0 2 35 | 5400 1350 8100 1350 36 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 37 | 5400 2700 8100 2700 38 | 2 1 1 2 0 7 50 -1 -1 6.000 0 0 -1 0 0 2 39 | 5400 1800 8100 1800 40 | 2 2 0 0 0 30 52 -1 20 0.000 0 0 -1 0 0 5 41 | 5400 5850 8100 5850 8100 7650 5400 7650 5400 5850 42 | 2 2 0 0 0 30 52 -1 20 0.000 0 0 -1 0 0 5 43 | 5400 900 8100 900 8100 2700 5400 2700 5400 900 44 | 4 0 0 50 -1 18 12 0.0000 4 180 1875 1035 7515 Reset vectors, etc\001 45 | 4 0 0 50 -1 18 12 0.0000 4 210 1305 1035 7065 Library code\001 46 | 4 0 0 50 -1 18 12 0.0000 4 210 2130 1035 5715 Application program\001 47 | 4 0 0 50 -1 18 12 0.0000 4 165 810 1035 3015 Unused\001 48 | 4 0 0 50 -1 18 12 0.0000 4 210 1560 990 1260 Reserved (256)\001 49 | 4 1 0 50 -1 18 15 0.0000 4 240 1995 2250 765 ITCM - 32 Kbytes\001 50 | 4 0 0 50 -1 14 12 0.0000 4 150 810 3690 900 0x8000\001 51 | 4 1 0 50 -1 18 15 0.0000 4 240 2115 6750 765 DTCM - 64 Kbytes\001 52 | 4 0 0 50 -1 18 12 0.0000 4 165 1380 5535 7515 RW variables\001 53 | 4 0 0 50 -1 18 12 0.0000 4 165 1200 5535 7065 ZI variables\001 54 | 4 0 0 50 -1 18 12 0.0000 4 210 525 5535 5715 Heap\001 55 | 4 0 0 50 -1 18 12 0.0000 4 210 2220 5535 1665 IRQ mode stack (256)\001 56 | 4 0 0 50 -1 18 12 0.0000 4 210 2385 5535 2610 SYS mode stack (1152)\001 57 | 4 0 0 50 -1 18 12 0.0000 4 210 2190 5535 2115 FIQ mode stack (256)\001 58 | 4 0 0 50 -1 18 12 0.0000 4 210 2280 5535 1260 SVC mode stack (384)\001 59 | 4 0 0 50 -1 14 12 0.0000 4 150 810 3690 1350 0x7f00\001 60 | 4 0 0 50 -1 14 12 0.0000 4 150 810 3690 7650 0x0000\001 61 | 4 0 0 50 -1 14 12 0.0000 4 150 1080 8190 900 0x410000\001 62 | 4 0 0 50 -1 14 12 0.0000 4 150 1080 8190 2700 0x40f800\001 63 | 4 0 0 50 -1 14 12 0.0000 4 150 1080 8190 7650 0x400000\001 64 | -------------------------------------------------------------------------------- /apps/sdping/sdp_ping.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ##------------------------------------------------------------------------------ 4 | ## 5 | ## sdp_ping SDP ping program 6 | ## 7 | ## Copyright (C) The University of Manchester - 2014 8 | ## 9 | ## Author Steve Temple, APT Group, School of Computer Science 10 | ## Email temples@cs.man.ac.uk 11 | ## 12 | ##------------------------------------------------------------------------------ 13 | 14 | # Copyright (c) 2014 The University of Manchester 15 | # 16 | # Licensed under the Apache License, Version 2.0 (the "License"); 17 | # you may not use this file except in compliance with the License. 18 | # You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | 28 | 29 | use strict; 30 | use warnings; 31 | 32 | use SpiNN::SCP; 33 | 34 | 35 | my $sleep = 1.0; # Repeat (secs) 36 | my $debug = 4; # Debug level (3 or 4) 37 | 38 | my $spin; # SpiNNaker handle 39 | my $port; # SpiNNaker app. port 40 | 41 | 42 | # Process the five arguments and open the connection to SpiNNaker 43 | # The arguments are 44 | # hostname (or IP address) of the SpiNNaker system 45 | # X coordinate of the SpiNNaker chip 46 | # Y coordinate of the SpiNNaker chip 47 | # core number on the SpiNNaker chip 48 | # SDP port to which the messages should be sent 49 | 50 | sub process_args 51 | { 52 | die "usage: sdp_ping \n" unless 53 | $#ARGV == 4 && 54 | $ARGV[1] =~ /^\d+$/ && 55 | $ARGV[2] =~ /^\d+$/ && 56 | $ARGV[3] =~ /^\d+$/ && 57 | $ARGV[4] =~ /^\d+$/; 58 | 59 | $spin = SpiNN::SCP->new (target => $ARGV[0]); 60 | die "Failed to connect to $ARGV[0]\n" unless $spin; 61 | 62 | $spin->addr ($ARGV[1], $ARGV[2], $ARGV[3]); 63 | 64 | $port = $ARGV[4]; 65 | } 66 | 67 | 68 | # Main loop which sends a ping SDP packet every "$sleep" seconds and looks 69 | # for incoming reply packets. Both sent and received packets are printed 70 | # using the SpiNN::SCP debug facility. We expect a reply only if we send 71 | # to port 1 72 | 73 | sub main 74 | { 75 | process_args (); 76 | 77 | my $data = "0123456789abcdef" . chr(0); 78 | my $pad = pack "V4", 0, 0, 0, 0; 79 | 80 | while (1) 81 | { 82 | $spin->send_sdp ($pad . $data, port => $port, reply => ($port == 1), 83 | debug => $debug); 84 | 85 | print "\n"; 86 | 87 | my $rc = $spin->recv_sdp (timeout => 0.1, debug => $debug); 88 | 89 | print "# No reply\n" unless $rc; 90 | print "\n"; 91 | 92 | select (undef, undef, undef, $sleep); 93 | } 94 | } 95 | 96 | 97 | main (); 98 | 99 | #------------------------------------------------------------------------------ 100 | -------------------------------------------------------------------------------- /apps/random/random.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | This example program demonstrates the use of Tubogrid to get simple 19 | per-core animation. It also shows scheduled timer events and the use 20 | of SARK's event queueing. 21 | */ 22 | 23 | 24 | #include 25 | 26 | 27 | // It's not safe to do output to IO_STD inside an interrupt routine 28 | // so this application queues an io_printf call on the event queue 29 | // which is processed as a foreground activity. "queue_proc" is the 30 | // "event_proc" which is queued. 31 | 32 | 33 | void queue_proc(uint colour, uint time) 34 | { 35 | char *s = (colour) ? "white" : "black"; // Make a colour string 36 | 37 | io_printf(IO_STD, "#%s;#fill;#red;%d\n", s, time); // And print it 38 | } 39 | 40 | 41 | // This "event_proc" is called each time the timer elapses. It is 42 | // effectively an interrupt handler. It flips colour (black/white) 43 | // each time it is called and schedules a queued event to print the 44 | // new colour to the Tubogrid. It also writes a message to an IO 45 | // buffer and reschedules itself to occur again at some random time 46 | // in the future. 47 | 48 | 49 | void timer_proc(uint colour, uint b) 50 | { 51 | uint rand = sark_rand() & 255; // Get next random period 52 | 53 | colour = !colour; // Flip the colour 54 | 55 | event_queue_proc(queue_proc, colour, rand, PRIO_0); // Queue printing 56 | 57 | io_printf(IO_BUF, "Timer next %d\n", rand); // Do buffered printing 58 | 59 | // Reschedule ourselves again 60 | 61 | timer_schedule_proc(timer_proc, colour, 0, 10000 * (rand + 1)); 62 | } 63 | 64 | 65 | // The main program finds out which core it is running on and prints 66 | // a welcome message showing the core. Then it seeds the random 67 | // number generator with a combination of chip ID, core ID and the 68 | // time in milliseconds. 69 | 70 | // Then it registers a timer event and places the first activation 71 | // of the timer event on the event queue 72 | 73 | // It then starts the event handling loop and, if that ever terminates, 74 | // prints a closing message before exiting. 75 | 76 | 77 | void c_main(void) 78 | { 79 | uint core = sark_core_id(); // Get core ID 80 | io_printf(IO_BUF, "Started core %d\n", core); // and print it 81 | 82 | sark_srand((sark_chip_id() << 8) + core * sv->time_ms); // Init randgen 83 | 84 | event_register_timer(SLOT_0); // Set up the timer event mechanism 85 | 86 | event_queue_proc(timer_proc, 0, 0, PRIO_0); // Queue the first timer call 87 | 88 | uint rc = event_start(0, 0, SYNC_NOWAIT); // Start event handling 89 | 90 | io_printf(IO_BUF, "Terminated rc %d\n", rc);// Printed if event_stop used... 91 | } 92 | -------------------------------------------------------------------------------- /scamp/spinn_phy.c: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | //! \file 3 | //! \brief Spinnaker support routines for SMC PHY chip 4 | //! 5 | //! \copyright © The University of Manchester - 2009, 2010 6 | //! 7 | //! \author Steve Temple, APT Group, School of Computer Science 8 | //! 9 | //------------------------------------------------------------------------------ 10 | 11 | /* 12 | * Copyright (c) 2009 The University of Manchester 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); 15 | * you may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * https://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | #include "spinnaker.h" 28 | #include "sark.h" 29 | 30 | void phy_reset(void) 31 | { 32 | er[ETH_PHY_CTRL] = 0; 33 | sark_delay_us(10); 34 | er[ETH_PHY_CTRL] = PHY_CTRL_NRST; 35 | } 36 | 37 | //! \brief Sends bits to the PHY chip via the SMC 38 | //! \param[in] data: the data to move, in the _upper_ bits 39 | //! (critical when fewer than 32 bits being moved) 40 | //! \param[in] len: the number of bits to move (up to 32) 41 | static void phy_shift_out(uint data, uint len) 42 | { 43 | uint c = er[ETH_PHY_CTRL]; 44 | 45 | while (len--) { 46 | if (data & 0x80000000) { 47 | c |= PHY_CTRL_DOUT; 48 | } else { 49 | c &= ~PHY_CTRL_DOUT; 50 | } 51 | 52 | er[ETH_PHY_CTRL] = c; 53 | sark_delay_us(1); 54 | er[ETH_PHY_CTRL] = c | PHY_CTRL_CLK; 55 | sark_delay_us(1); 56 | er[ETH_PHY_CTRL] = c; 57 | 58 | data = data << 1; 59 | } 60 | } 61 | 62 | //! \brief Receive some bits from the PHY chip via the SMC 63 | //! \param[in] len: the number of bits to receive (up to 32) 64 | //! \return The received data, in the _low_ bits 65 | static uint phy_shift_in(uint len) 66 | { 67 | uint c = er[ETH_PHY_CTRL]; 68 | uint r = 0; 69 | 70 | while (len--) { 71 | sark_delay_us(1); 72 | r = r << 1; 73 | if (er[ETH_PHY_CTRL] & PHY_CTRL_DIN) { 74 | r |= 1; 75 | } 76 | er[ETH_PHY_CTRL] = c | PHY_CTRL_CLK; 77 | sark_delay_us(1); 78 | er[ETH_PHY_CTRL] = c; 79 | } 80 | 81 | return r; 82 | } 83 | 84 | 85 | void phy_write(uint addr, uint data) 86 | { 87 | uint c = er[ETH_PHY_CTRL]; 88 | 89 | data = 0x50020000 | (addr << 18) | data; 90 | er[ETH_PHY_CTRL] = c | PHY_CTRL_OE; 91 | 92 | phy_shift_out(0xffffffff, 32); 93 | phy_shift_out(data, 32); 94 | 95 | er[ETH_PHY_CTRL] = c; 96 | } 97 | 98 | 99 | uint phy_read(uint addr) 100 | { 101 | uint c = er[ETH_PHY_CTRL]; 102 | 103 | er[ETH_PHY_CTRL] = c | PHY_CTRL_OE; 104 | 105 | phy_shift_out(0xffffffff, 32); 106 | phy_shift_out(0x60000000 | (addr << 18), 14); 107 | 108 | er[ETH_PHY_CTRL] = c; 109 | 110 | phy_shift_out(0, 2); 111 | 112 | return phy_shift_in(16); 113 | } 114 | -------------------------------------------------------------------------------- /setup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #------------------------------------------------------------------------------- 3 | # 4 | # Setup script for low-level Spinnaker work 5 | # 6 | #------------------------------------------------------------------------------- 7 | 8 | # Copyright (c) 2015 The University of Manchester 9 | # 10 | # Licensed under the Apache License, Version 2.0 (the "License"); 11 | # you may not use this file except in compliance with the License. 12 | # You may obtain a copy of the License at 13 | # 14 | # https://www.apache.org/licenses/LICENSE-2.0 15 | # 16 | # Unless required by applicable law or agreed to in writing, software 17 | # distributed under the License is distributed on an "AS IS" BASIS, 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | # See the License for the specific language governing permissions and 20 | # limitations under the License. 21 | 22 | set -a 23 | 24 | #------------------------------------------------------------------------------- 25 | 26 | # This file should be sourced, not executed! 27 | if [ "$0" == "${BASH_SOURCE[0]}" ]; then 28 | echo "WARNING: $0 should be sourced, not executed. Try: source $0" 29 | fi 30 | 31 | #------------------------------------------------------------------------------- 32 | 33 | # SPINN_DIRS should point to the directory containing subdirs "tools", 34 | # "lib", "include", etc. It's used by many tools to locate resources. 35 | # used during the building of SpiNNaker applications. The subdirectory 36 | # "tools" contains locally developed tools for building applications. 37 | 38 | SPINN_DIRS=`cd "$(dirname "${BASH_SOURCE[0]}")";pwd -P` 39 | 40 | #------------------------------------------------------------------------------- 41 | 42 | # SPINN_PATH is a path variable (elements separated by ":"). It's used 43 | # to find resources used while building and running applications. It 44 | # should always contain at least the "tools/boot" directory of $SPINN_DIRS 45 | 46 | SPINN_PATH=$SPINN_DIRS/tools/boot 47 | 48 | #------------------------------------------------------------------------------- 49 | 50 | # Add the "tools" directory to the Unix PATH and to the Perl library 51 | # search path. 52 | 53 | PATH=$SPINN_DIRS/tools:$PATH 54 | 55 | PERL5LIB=$SPINN_DIRS/tools:$PERL5LIB 56 | 57 | #------------------------------------------------------------------------------- 58 | 59 | # Set up variables pointing to the ARM software development tools 60 | # These tools need a licence file so set that up as well. You may need 61 | # to edit this section for your local environment 62 | 63 | # *** EDIT HERE *** 64 | 65 | ARMTOOLS=/home/amulinks/spinnaker/tools/RVDS40 66 | 67 | ARMBIN=$ARMTOOLS/RVCT/Programs/4.0/400/linux-pentium 68 | ARMLIB=$ARMTOOLS/RVCT/Data/4.0/400/lib 69 | ARMINC=$ARMTOOLS/RVCT/Data/4.0/400/include/unix 70 | 71 | LM_LICENSE_FILE=PORT@SERVER.cs.man.ac.uk:$LM_LICENSE_FILE 72 | 73 | #------------------------------------------------------------------------------- 74 | 75 | # Set up variables pointing to the GNU software development tools. 76 | # You may need to edit this section for your local environment 77 | 78 | # *** EDIT HERE *** 79 | 80 | GNUTOOLS=/local/temples/gcc-arm-none-eabi-4_9-2015q3 81 | 82 | GNUBIN=$GNUTOOLS/bin 83 | 84 | #------------------------------------------------------------------------------- 85 | 86 | # Finally, add ARM and GNU software development tools to the PATH 87 | 88 | PATH=$GNUBIN:$ARMBIN:$PATH 89 | 90 | #------------------------------------------------------------------------------- 91 | 92 | 93 | chmod u+x $SPINN_DIRS/tools/* 94 | 95 | -------------------------------------------------------------------------------- /docs/appnote.tex: -------------------------------------------------------------------------------- 1 | % 2 | % Simple LaTeX header to generate SpiNNaker documentation 3 | % 4 | % Generates AppNotes if variable NoteNum is defined otherwise 5 | % just generates a simple note. The variables TitleA and TitleB 6 | % may be overridden (second and third lines of title heading) 7 | % TitleC is optional and only used if defined. 8 | % 9 | 10 | % Copyright (c) 2009 The University of Manchester 11 | % 12 | % Licensed under the Apache License, Version 2.0 (the "License"); 13 | % you may not use this file except in compliance with the License. 14 | % You may obtain a copy of the License at 15 | % 16 | % https://www.apache.org/licenses/LICENSE-2.0 17 | % 18 | % Unless required by applicable law or agreed to in writing, software 19 | % distributed under the License is distributed on an "AS IS" BASIS, 20 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | % See the License for the specific language governing permissions and 22 | % limitations under the License. 23 | 24 | \documentclass[11pt,a4paper]{article} 25 | 26 | \usepackage{fancyhdr} 27 | \usepackage{color} 28 | \usepackage{ifthen} 29 | \usepackage{xspace} 30 | \usepackage{listings} 31 | \usepackage{enumitem} 32 | \usepackage{alltt} 33 | \renewcommand{\ttdefault}{txtt} 34 | %\usepackage[compact]{titlesec} 35 | 36 | \usepackage[pdftex,a4paper]{geometry} 37 | \usepackage[pdftex]{graphicx} 38 | 39 | \geometry{left=25mm,right=25mm,top=25mm,bottom=20mm} 40 | 41 | \ifdefined\TitleA 42 | \else 43 | \def\TitleA{SpiNNaker Group, School of Computer Science, 44 | University of Manchester} 45 | \fi 46 | 47 | \ifdefined\TitleB 48 | \else 49 | \def\TitleB{\Author\ - \Date\ - Version \Version} 50 | \fi 51 | 52 | \ifdefined\NoteNum 53 | \def\HeadLeft{SpiNNaker AppNote \NoteNum} 54 | \def\HeadCentre{\ShortTitle} 55 | \def\HeadRight{Page \thepage} 56 | \def\Title{AppNote \NoteNum\ - \FullTitle} 57 | \else 58 | \def\HeadLeft{\ShortTitle} 59 | \def\HeadCentre{} 60 | \def\HeadRight{Page \thepage} 61 | \def\Title{\FullTitle} 62 | \fi 63 | 64 | \addtolength{\headheight}{2pt} 65 | 66 | \pagestyle{fancy} 67 | 68 | \renewcommand{\headrulewidth}{0.6pt} 69 | 70 | \lhead{\itshape\HeadLeft} 71 | \chead{\itshape\HeadCentre} 72 | \rhead{\itshape\HeadRight} 73 | 74 | \fancyfoot{} 75 | 76 | \newcommand{\image}[5][] 77 | { 78 | \begin{figure}[#2] 79 | \begin{center} 80 | \includegraphics[#1]{#3} 81 | \ifthenelse{\equal{#5}{}}{}{\caption{#5}} 82 | \label{fig:#4} 83 | \end{center} 84 | \end{figure} 85 | } 86 | 87 | % A substitute for changepage/chngpage's adjustwidth: provides a changemargin 88 | % environment. 89 | \def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]} 90 | \let\endchangemargin=\endlist 91 | 92 | \newenvironment{shell} 93 | { 94 | \begin{changemargin}{2em}{0em} 95 | \begin{alltt} 96 | \small 97 | } 98 | { 99 | \end{alltt} 100 | \end{changemargin} 101 | } 102 | 103 | \setcounter{secnumdepth}{-1} 104 | \setlength{\parindent}{0pt} 105 | \setlength{\parskip}{6pt} 106 | 107 | \setitemize{itemsep=0pt} 108 | \setitemize{parsep=0pt} 109 | \setitemize{leftmargin=12pt} 110 | 111 | \lstset{xleftmargin=2em,columns=flexible,basicstyle=\ttfamily\small} 112 | 113 | \begin{document} 114 | 115 | \begin{center} 116 | \setlength{\parskip}{0em} 117 | {\Large\bfseries\Title} 118 | \par 119 | \vspace{5mm} 120 | {\large\itshape\TitleA} 121 | \par 122 | \vspace{2mm} 123 | {\large\itshape\TitleB} 124 | \ifdefined\TitleC 125 | \par 126 | \vspace{2mm} 127 | {\large\itshape\TitleC} 128 | \fi 129 | \end{center} 130 | -------------------------------------------------------------------------------- /apps/sdping/sdping.c: -------------------------------------------------------------------------------- 1 | /****a* sdping.c/sdping_summary 2 | * 3 | * SUMMARY 4 | * sample SpiNNaker SDP application 5 | * 6 | * AUTHOR 7 | * Steve Temple - temples@cs.man.ac.uk 8 | * 9 | * DETAILS 10 | * Created on : 03 May 2011 11 | * Version : $Revision: 1196 $ 12 | * Last modified on : $Date: 2011-06-27 14:32:29 +0100 (Mon, 27 Jun 2011) $ 13 | * Last modified by : $Author: plana $ 14 | * $Id: simple.c 1196 2011-06-27 13:32:29Z plana $ 15 | * $HeadURL: file:///home/amulinks/spinnaker/svn/spinn_api/trunk/examples/simple.c $ 16 | * 17 | * COPYRIGHT 18 | * Copyright (c) The University of Manchester, 2011. All rights reserved. 19 | * SpiNNaker Project 20 | * Advanced Processor Technologies Group 21 | * School of Computer Science 22 | * 23 | *******/ 24 | 25 | /* 26 | * Copyright (c) 2011 The University of Manchester 27 | * 28 | * Licensed under the Apache License, Version 2.0 (the "License"); 29 | * you may not use this file except in compliance with the License. 30 | * You may obtain a copy of the License at 31 | * 32 | * https://www.apache.org/licenses/LICENSE-2.0 33 | * 34 | * Unless required by applicable law or agreed to in writing, software 35 | * distributed under the License is distributed on an "AS IS" BASIS, 36 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 37 | * See the License for the specific language governing permissions and 38 | * limitations under the License. 39 | */ 40 | 41 | 42 | #include 43 | 44 | 45 | // Swap source and dest fields of an SDP packet to return to sender 46 | 47 | void swap_sdp_hdr(sdp_msg_t *msg) 48 | { 49 | uint dest_port = msg->dest_port; 50 | uint dest_addr = msg->dest_addr; 51 | 52 | msg->dest_port = msg->srce_port; 53 | msg->srce_port = dest_port; 54 | 55 | msg->dest_addr = msg->srce_addr; 56 | msg->srce_addr = dest_addr; 57 | } 58 | 59 | 60 | // Callback for SDP message received - 61 | // Print the message via Tubotron then... 62 | // Port 1 - return to sender 63 | // Port 2 - return to IPTag 1 64 | // Port 7 - exit API 65 | // Note that the message buffer must be freed here. 66 | 67 | void process_sdp(uint m, uint port) 68 | { 69 | sdp_msg_t *msg = (sdp_msg_t *) m; 70 | 71 | io_printf(IO_STD, "SDP len %d, port %d - %s\n", msg->length, port, msg->data); 72 | 73 | if (port == 1) { // Port 1 - echo to sender 74 | swap_sdp_hdr(msg); 75 | (void) spin1_send_sdp_msg(msg, 10); 76 | } else if (port == 2) { // Port 2 - send via IPTAG 1 77 | msg->tag = 1; // IPTag 1 78 | msg->dest_port = PORT_ETH; // Ethernet 79 | msg->dest_addr = sv->dbg_addr; // Root chip 80 | msg->flags = 0x07; // Flags = 7 81 | msg->srce_port = spin1_get_core_id(); // Source port 82 | msg->srce_addr = spin1_get_chip_id(); // Source addr 83 | 84 | (void) spin1_send_sdp_msg(msg, 10); 85 | } 86 | 87 | spin1_msg_free(msg); 88 | 89 | if (port == 7) { 90 | spin1_exit(0); 91 | } 92 | } 93 | 94 | 95 | // "flip_led" is the timer callback. 96 | 97 | void flip_led(uint ticks, uint null) 98 | { 99 | spin1_led_control(LED_INV(1)); 100 | } 101 | 102 | 103 | // Main program just sets up callbacks and then starts the API 104 | 105 | void c_main(void) 106 | { 107 | io_printf(IO_STD, ">> sdping\n"); 108 | 109 | spin1_set_timer_tick(1000000); 110 | 111 | spin1_callback_on(TIMER_TICK, flip_led, 3); 112 | spin1_callback_on(SDP_PACKET_RX, process_sdp, 2); 113 | 114 | spin1_start(SYNC_NOWAIT); 115 | 116 | io_printf(IO_STD, ">> sdping done\n"); 117 | } 118 | -------------------------------------------------------------------------------- /scamp/boot_aplx.s: -------------------------------------------------------------------------------- 1 | 2 | ;;------------------------------------------------------------------------------ 3 | ;; 4 | ;; boot_aplx.s Self-loading preamble for SC&MP APLX files 5 | ;; 6 | ;; Copyright (C) The University of Manchester - 2009-2013 7 | ;; 8 | ;; Author Steve Temple, APT Group, School of Computer Science 9 | ;; Email temples@cs.man.ac.uk 10 | ;; 11 | ;;------------------------------------------------------------------------------ 12 | ;; 13 | ;; Copyright (c) 2015 The University of Manchester 14 | ;; 15 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 16 | ;; you may not use this file except in compliance with the License. 17 | ;; You may obtain a copy of the License at 18 | ;; 19 | ;; https://www.apache.org/licenses/LICENSE-2.0 20 | ;; 21 | ;; Unless required by applicable law or agreed to in writing, software 22 | ;; distributed under the License is distributed on an "AS IS" BASIS, 23 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | ;; See the License for the specific language governing permissions and 25 | ;; limitations under the License. 26 | ;; 27 | ;;------------------------------------------------------------------------------ 28 | 29 | get spinnaker.s 30 | get sark.s 31 | 32 | preserve8 33 | 34 | area boot_aplx, readonly, code, align=7 35 | 36 | entry 37 | 38 | aplx_start mov sp, #DTCM_TOP ; Set up stack 39 | adr r0, aplx_args ; APLX block in DTCM 40 | ldm r0, {r0-r1, r4-r5} ; Get address & args 41 | blx proc_aplx ; Go to loader 42 | 43 | ; When booting via bootROM, APLX table ends up in DTCM 128 bytes above 44 | ; start of image 45 | 46 | aplx_args dcd DTCM_BASE + 0x8080 ; Address of APLX table 47 | dcd 0 ; Arg passed in r0 (app_id) 48 | 49 | aplx_svc msr cpsr_c, #IMASK_ALL+MODE_SVC 50 | bx lr 51 | 52 | ;------------------------------------------------------------------------------- 53 | 54 | ; proc_aplx (uint table, uint arg) 55 | 56 | code16 57 | 58 | proc_aplx push {r1, r4-r7, lr} ; Save link and r1, r4-r7 59 | ldr r1, aplx_buffer ; Get buffer to r1 60 | adr r6, aplx_loader ; r6 -> loader code 61 | mov r7, #APLX_BUF_SIZE ; Move 64 bytes... 62 | 63 | aplx_l0 ldm r6!, {r2-r5} ; ... 16 at a time 64 | stm r1!, {r2-r5} 65 | sub r7, #16 66 | bne aplx_l0 67 | 68 | mov r4, r0 ; Table pointer to r4 69 | sub r1, #APLX_BUF_SIZE-1 ; r1 -> load point + 1 70 | bx r1 71 | 72 | align 4 73 | 74 | aplx_buffer dcd APLX_BUFFER 75 | 76 | ; Come here with table address in r4 77 | 78 | aplx_loader ldm r4!, {r0-r3} ; Get opcode & operands 79 | 80 | cmp r0, #APLX_ACOPY ; Copy absolute 81 | beq aplx_copy 82 | cmp r0, #APLX_RCOPY ; Copy relative 83 | beq aplx_rcopy 84 | cmp r0, #APLX_FILL ; Fill 85 | beq aplx_fill 86 | cmp r0, #APLX_EXEC ; Execute 87 | beq aplx_exec 88 | 89 | pop {r1, r4-r7, pc} ; Restore & return 90 | 91 | aplx_rcopy add r2, r4 ; Copy relative 92 | sub r2, #APLX_ENTRY_SIZE ; Reduce by table entry size 93 | 94 | aplx_copy ldm r2!, {r0, r5-r7} ; Copy absolute 95 | stm r1!, {r0, r5-r7} ; r1 -> to 96 | ldm r2!, {r0, r5-r7} ; r2 -> from 97 | stm r1!, {r0, r5-r7} ; r3 = length 98 | sub r3, #32 99 | bhi aplx_copy 100 | b aplx_loader 101 | 102 | aplx_fill movs r5, r3 ; Fill 103 | movs r6, r3 ; r1 -> to 104 | movs r7, r3 ; r2 = length 105 | aplx_l1 stm r1!, {r3, r5-r7} ; r3 = data 106 | stm r1!, {r3, r5-r7} 107 | sub r2, #32 108 | bhi aplx_l1 109 | b aplx_loader 110 | 111 | aplx_exec ldr r0, [sp, #0] ; Get arg to r0 112 | blx r1 ; Exec absolute 113 | b aplx_loader ; r1 = address 114 | 115 | align 128 116 | code32 117 | aplx_end 118 | 119 | ;------------------------------------------------------------------------------ 120 | end 121 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2016 The University of Manchester 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Build and package up a release of the SpiNNaker low-level tools. Builds SC&MP 18 | # and all documentation in a clean check-out of the repository and packages 19 | # a subset of build artefacts (e.g. PDFs and SC&MP binary). 20 | 21 | if [ -z "$SPINN_DIRS" ]; then 22 | echo "ERROR: \$SPINN_DIRS not defined. Did you source setup?" 23 | exit 1 24 | fi 25 | cd "$SPINN_DIRS" 26 | 27 | # Version low-level tools version number 28 | VER=`grep SLLT_VER_STR include/version.h | awk '{ print $3 }' | sed s/\"//g` 29 | 30 | # Release name 31 | NAME=spinnaker_tools_$VER 32 | 33 | # Location of released file 34 | RELEASE_DIR=/tmp 35 | RELEASE_FILE="$RELEASE_DIR/$NAME.tar.gz" 36 | 37 | 38 | # Warn if there are uncommitted changes 39 | if [ -n "$(git status --porcelain | grep -vx " M setup")" ]; then 40 | echo "WARNING: There are some uncommitted changes." 41 | git status --short 42 | echo "Press to build anyway or Ctrl+C to stop." 43 | read REPLY 44 | fi 45 | 46 | # Warn if we're not in the master branch 47 | if [ -z "$(git branch | grep -x "* master")" ]; then 48 | echo "WARNING: Not in master branch." 49 | git branch 50 | echo "Press to build anyway or Ctrl+C to stop." 51 | read REPLY 52 | fi 53 | 54 | # Use a temporary working directory to produce the build 55 | WORKING_DIR="$(mktemp -d)" 56 | echo "Building in temporary dir: $WORKING_DIR" 57 | cd "$WORKING_DIR" 58 | git clone --quiet --depth 1 "file://$SPINN_DIRS" . 59 | 60 | # Build SARK 61 | echo "Building SARK" 62 | (cd "$WORKING_DIR/sark" && make GNU=0 SPINN_DIRS=$WORKING_DIR) || exit 2 63 | 64 | # Build SC&MP 65 | echo "Building SC&MP" 66 | (cd "$WORKING_DIR/scamp" && make GNU=0 install SPINN_DIRS=$WORKING_DIR) || exit 3 67 | 68 | # Build documentation 69 | for document_makefile in $(find docs/ -name Makefile); do 70 | document_dir="$(dirname "$document_makefile")" 71 | echo "Building $document_dir" 72 | (cd "$document_dir" && make < /dev/null) || exit 4 73 | done 74 | 75 | # Package just the git-tracked files for the release 76 | echo "Building release" 77 | git archive --output "$NAME.tar" --prefix "$NAME/" HEAD \ 78 | README.md release.txt setup Makefile \ 79 | build include sark spin1_api lib make tools apps \ 80 | || exit 5 81 | 82 | # Add selected build artefacts 83 | echo "Adding build artefacts" 84 | ( 85 | # Directories for documentation 86 | find docs -type d 87 | 88 | # Documentation (excluding PDFs of figures) 89 | for document_makefile in $(find docs/ -name Makefile); do 90 | document_dir="$(dirname "$document_makefile")" 91 | echo "$document_dir/$(basename "$document_dir").pdf" 92 | done 93 | 94 | # SC&MP binary 95 | echo "tools/boot/scamp.boot" 96 | ) | xargs tar fr "$NAME.tar" --transform='s:.*:'"$NAME"'/\0:' --no-recursion \ 97 | || exit 6 98 | 99 | 100 | # Gzip the tar file and place this in the output directory 101 | echo "Compressing archive" 102 | mkdir -p "$RELEASE_DIR" 103 | gzip -c "$NAME.tar" > "$RELEASE_FILE" || exit 7 104 | 105 | echo "Removing temporary files" 106 | rm -rf "$WORKING_DIR" || exit 8 107 | 108 | echo "Release created: $RELEASE_FILE" 109 | -------------------------------------------------------------------------------- /.github/actions/clone_matching/action.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions 16 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 17 | 18 | name: "Clone matching" 19 | description: "Clone the branch with a name matching that of the tests being done, or master if that doesn't exist" 20 | inputs: 21 | repository: 22 | description: The repository (or repositories on multiple lines) to clone 23 | required: true 24 | runs: 25 | using: "composite" 26 | steps: 27 | - id: git_clone_matching 28 | run: | 29 | SAVEIFS=$IFS # Save current IFS 30 | IFS=$'\n' # Change IFS to new line 31 | REPOS=(${{ inputs.repository }}) # split to array 32 | IFS=$SAVEIFS # Restore IFS 33 | # For each repositoty in the list 34 | for (( i=0; i<${#REPOS[@]}; i++)) 35 | do 36 | REPO=${REPOS[$i]} 37 | echo "Testing branch of $REPO" 38 | # for each pair $1 commit id and $2 full branch name 39 | BRANCH=$(git ls-remote $REPO | awk ' 40 | BEGIN { 41 | id = "x" 42 | # The next line is a default signalling not found 43 | branch = "REMOTE_PARSE_FAILED" 44 | # In this repository it could be a branch or a tag 45 | # Full branch names of branches are in the format refs/heads/foobar 46 | target_branch = "refs/heads/" ENVIRON["GITHUB_REF_NAME"] 47 | # Full branch names of tags are in the format refs/tags/foobar 48 | target_tag = "refs/tags/" ENVIRON["GITHUB_REF_NAME"] 49 | } 50 | $2=="HEAD" { 51 | # Found the HEAD commit save its id to match below 52 | # Note that the remote HEAD ref comes first 53 | id = $1 54 | } 55 | $1==id { 56 | # Find the full branch or tag name for the HEAD 57 | # Strip out the start to leave the short branch name 58 | sub(/refs\/(heads|tags)\//, "", $2) 59 | branch = $2 60 | # May be overwritten by the rule below; this is OK 61 | } 62 | $2==target_branch || $2==target_tag { 63 | # Found a commit with a matching full branch or tag name 64 | # save just the short name 65 | branch = ENVIRON["GITHUB_REF_NAME"] 66 | # Reset the ID to a non-hash so the rule to match it will not fire 67 | id = "x" 68 | } 69 | END { 70 | # return branch 71 | # AKA set $BRANCH to branch 72 | print branch 73 | }') 74 | git clone --branch $BRANCH --single-branch --depth 1 $REPO 75 | echo "Checked out branch $BRANCH of $REPO" 76 | done 77 | shell: bash 78 | 79 | # Notes: 80 | # Variable naming is different inside the awk equation and outside of it 81 | # Outside it is $GITHUB_REF_NAME Inside ENVIRON["GITHUB_REF_NAME"] 82 | 83 | # GITHUB_REF is the full name. example /ref/heads/foobar 84 | # GITHUB_REF_NAME is just branch nam. example foobar 85 | 86 | # Integration many be a branch while repositories may be tags or vice versa 87 | # The HEAD could be refs/heads/master or refs/heads/main ect -------------------------------------------------------------------------------- /apps/ring/ring.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 The University of Manchester 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | ring.c - this program demonstrates core-to-core communication using 19 | multicast packets on a single chip. 16 application cores are 20 | arranged in a ring and a packet is sent from one to the next. 21 | 22 | A timed delay of 0.25 secs is used to slow the packet transmission 23 | so that it is visble and the reception of a packet causes a square 24 | to be updated on the "tubogrid" display. 25 | 26 | The User variables are used to track the execution of events. 27 | */ 28 | 29 | 30 | #include 31 | 32 | 33 | uint core; // Core ID of this core 34 | 35 | 36 | // This "proc" is called when a scheduled timer delay elapses. It 37 | // puts a message in the print buffer for the core and sends a packet 38 | // to the next core in the ring. It stops event processing when the 39 | // count exceeds 128. 40 | 41 | void timer_proc(uint count, uint none) 42 | { 43 | sark.vcpu->user0++; 44 | 45 | io_printf(IO_BUF, "# timer_proc %d\n", count); 46 | 47 | if (count > 128) { 48 | event_stop(0); 49 | } else { 50 | pkt_tx_kd(core, count + 1); 51 | } 52 | } 53 | 54 | 55 | // This "proc" is called when a multicast packet is received. It sends 56 | // a message to the "tubogrid" containing the count that came in the 57 | // packet's payload. The background changes colour every 16 iterations. 58 | 59 | void pkt_proc(uint key, uint data) 60 | { 61 | sark.vcpu->user1++; 62 | 63 | char *colour = (data & 16) ? "blue" : "red"; 64 | io_printf(IO_STD, "#%s;#fill;#white;%d\n", colour, data); 65 | 66 | timer_schedule_proc(timer_proc, data, 0, 250000); 67 | } 68 | 69 | 70 | // The main program prints a message to the core's IO buffer and then 71 | // sets up a routing table entry so that packets which contain this 72 | // core's ID in the key field are routed to the next core in the ring. 73 | // Then it sets up callbacks for the elapsed timer and packet received 74 | // events. Core 1 (only) places an initial call to the timer proc on 75 | // the event queue. Finally, it starts event processing but requires a 76 | // SYNC0 signal before operation commences. 77 | 78 | void c_main(void) 79 | { 80 | core = sark_core_id(); 81 | uint app_id = sark_app_id(); 82 | char *app_name = (char *) &sark.vcpu->app_name; 83 | 84 | // Say hello... 85 | io_printf(IO_BUF, "# App \"%s\" on core %d (AppID %d)\n", 86 | app_name, core, app_id); 87 | 88 | // Initialise User variables 89 | sark.vcpu->user0 = sark.vcpu->user1 = 0; 90 | 91 | // Set up a single MC router entry to send packets to the next core 92 | // in the ring 93 | 94 | uint e = rtr_alloc(1); 95 | if (e == 0) { 96 | rt_error(RTE_ABORT); 97 | } 98 | 99 | uint next = (core == 16) ? 1 : core + 1; 100 | 101 | rtr_mc_set(e, core, 0xffffffff, MC_CORE_ROUTE(next)); 102 | 103 | // Register the two events we're using and set up packet transmission queue 104 | event_register_queue(pkt_proc, EVENT_RXPKT, SLOT_0, PRIO_0); 105 | event_register_pkt(16, SLOT_1); 106 | event_register_timer(SLOT_2); 107 | 108 | // If we are core 1 then set things going by placing an event on the queue 109 | if (core == 1) { 110 | event_queue_proc(timer_proc, 0, 0, PRIO_0); 111 | } 112 | 113 | // Start event processing but wait for SYNC0 114 | uint rc = event_start(0, 0, SYNC_WAIT); 115 | 116 | // Print RC if we stop... 117 | io_printf(IO_BUF, "Terminated - RC %d\n", rc); 118 | } 119 | -------------------------------------------------------------------------------- /tools/h2asm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ##------------------------------------------------------------------------------ 4 | ## 5 | ## mkhdr Simplistic script to convert C header files to ARM assembly 6 | ## 7 | ## Copyright (C) The University of Manchester - 2009, 2010, 2011, 2020 8 | ## 9 | ## Author Steve Temple, APT Group, School of Computer Science 10 | ## Email temples@cs.man.ac.uk 11 | ## 12 | ##------------------------------------------------------------------------------ 13 | 14 | # Copyright (c) 2009 The University of Manchester 15 | # 16 | # Licensed under the Apache License, Version 2.0 (the "License"); 17 | # you may not use this file except in compliance with the License. 18 | # You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | 28 | 29 | # This program reads a C language .h file and converts it to an ARM 30 | # assember format file. Only a limited range of conversions is 31 | # performed - its main purpose is to convert "#define NAME VALUE" to 32 | # "NAME equ VALUE". 33 | # 34 | # Single line comments "//" are converted to ";". Multi-line comments 35 | # "/* .. */" are not supported. 36 | # 37 | # Conditional compilation by means of "#if(n)def NAME" is supported but 38 | # there must be no trailing characters on the matching "#else" and 39 | # "#endif" lines. 40 | # 41 | # Lines of the form 42 | # 43 | # #define NAME INT_AT(VALUE) 44 | # #define NAME BYTE_AT(VALUE) 45 | # 46 | # are converted to 47 | # 48 | # NAME equ VALUE 49 | # 50 | # Unrecognised lines are omitted from the output and multiple blank 51 | # lines are compressed. 52 | # 53 | # Values in enum declarations are also supported, but only in a limited 54 | # fashion; if default enumeration is used, it must only be used for the 55 | # leading prefix of values in the enumeration. The enumeration must start 56 | # at the beginning of the line. Any typedef of the enumeration must be 57 | # separate (it will be ignored). Enums must finish with '};' on a line on 58 | # its own. 59 | 60 | use strict; 61 | use warnings; 62 | 63 | 64 | my $blank = 0; 65 | my $in_enum = 0; 66 | my $enum_count; 67 | my $time = localtime(time()); 68 | 69 | printf ";\n; Auto-generated from \"%s\" - $time\n;\n", $ARGV[0] || ""; 70 | 71 | 72 | while (<>) { 73 | chomp; 74 | s/^\s+|\s+$//g; 75 | s/\/\//;/; 76 | s/! $@ 71 | 72 | $(BUILD_DIR)/%.gas: %.s 73 | $(MKDIR) $(BUILD_DIR) 74 | $(SPINN_TOOLS_DIR)/arm2gas $< > $@ 75 | 76 | $(BUILD_DIR)/sark_alib.o: $(BUILD_DIR)/sark_alib.gas $(BUILD_DIR)/spinnaker.gas $(BUILD_DIR)/sark.gas 77 | $(MKDIR) $(BUILD_DIR) 78 | $(AS) -I $(BUILD_DIR) -o $@ $< 79 | 80 | else 81 | 82 | $(BUILD_DIR)/%.s: $(SPINN_INC_DIR)/%.h 83 | $(MKDIR) $(BUILD_DIR) 84 | $(SPINN_TOOLS_DIR)/h2asm $< > $@ 85 | 86 | $(BUILD_DIR)/%.s: %.s 87 | $(MKDIR) $(BUILD_DIR) 88 | $(CP) $< $@ 89 | 90 | $(BUILD_DIR)/sark_alib.o: $(BUILD_DIR)/sark_alib.s $(BUILD_DIR)/spinnaker.s $(BUILD_DIR)/sark.s 91 | $(MKDIR) $(BUILD_DIR) 92 | $(AS) -o $@ $< 93 | 94 | endif 95 | 96 | #------------------------------------------------------------------------------- 97 | 98 | # SARK C sources 99 | 100 | $(BUILD_DIR)/%.o: %.c $(SPINN_INC_DIR)/spinnaker.h $(SPINN_INC_DIR)/sark.h 101 | $(CC_THUMB) $(CFLAGS) -o $@ $< 102 | 103 | $(BUILD_DIR)/sark_isr.o: sark_isr.c $(SPINN_INC_DIR)/spinnaker.h $(SPINN_INC_DIR)/sark.h 104 | $(CC) $(CFLAGS) -o $@ $< 105 | 106 | $(BUILD_DIR)/sark_div0.o: sark_div0.c $(SPINN_INC_DIR)/spinnaker.h $(SPINN_INC_DIR)/sark.h 107 | $(CC) $(CFLAGS) -o $@ $< 108 | 109 | #------------------------------------------------------------------------------- 110 | install: $(SARKLIB) 111 | $(eval SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS))))) 112 | $(MKDIR) $(SPINN_INSTALL_DIR)/lib 113 | $(MKDIR) $(SPINN_INSTALL_DIR)/include 114 | $(INSTALL) -c -m644 $< $(SPINN_INSTALL_DIR)/lib 115 | $(INSTALL) -c -m644 $(SPINN_INC_DIR)/version.h $(SPINN_INC_DIR)/spinnaker.h $(SPINN_INC_DIR)/sark.h $(SPINN_INC_DIR)/sark_cpp.h $(SPINN_INSTALL_DIR)/include 116 | clean: 117 | $(RM) $(SARKLIB) $(SARKOBJ) $(SARK_ASM_OBJ) 118 | 119 | .PHONY: clean 120 | -------------------------------------------------------------------------------- /bmp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for BMP firmware 3 | # 4 | 5 | # Copyright (c) 2012 The University of Manchester 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 20 | SPINN_TOOLS_DIR = $(abspath $(CURRENT_DIR)/../tools) 21 | 22 | BOOT_OBJ = bmp_clock.o bmp_flash.o bmp_crc.o 23 | 24 | MAIN_OBJ = bmp_can.o bmp_net.o bmp_cmd.o bmp_event.o bmp_hw.o \ 25 | bmp_io.o bmp_flash.o bmp_ssp.o bmp_crc.o bmp_eth.o bmp_i2c.o \ 26 | bmp_main.o 27 | 28 | SOURCES = bmp_init.c bmp_can.c bmp_net.c bmp_cmd.c bmp_event.c \ 29 | bmp_io.c bmp_flash.c bmp_ssp.c bmp_crc.c bmp_eth.c bmp_i2c.c \ 30 | bmp_main.c bmp_date bmp_hw.c bmp_boot.c bmp_clock.c bmp.h 31 | 32 | BOOT_SCT = bmp_boot.sct 33 | MAIN_SCT = bmp_main.sct 34 | 35 | CFLAGS = -c --c99 --cpu=Cortex-M3 -I ../include 36 | 37 | BOOT_LFLAGS = --entry=boot_proc --scatter=$(BOOT_SCT) 38 | MAIN_LFLAGS_L = --entry=c_main --scatter=$(MAIN_SCT) --predefine="-DBASE=0x10000" 39 | MAIN_LFLAGS_H = --entry=c_main --scatter=$(MAIN_SCT) --predefine="-DBASE=0x20000" 40 | 41 | CC = armcc 42 | LD = armlink 43 | OBJCOPY = fromelf 44 | OBJDUMP = fromelf -cds 45 | RM = /bin/rm -f 46 | MV = /bin/mv 47 | 48 | 49 | all: bmp_main.elf bmp_boot.elf 50 | 51 | bmp_boot.elf: $(BOOT_OBJ) $(BOOT_SCT) bmp_boot.c 52 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB perl -pe "s/BUILD_DATE/time/e" bmp_boot.c > bmp_tmp.c 53 | $(CC) $(CFLAGS) -o bmp_boot.o bmp_tmp.c 54 | $(RM) bmp_tmp.c 55 | 56 | $(LD) $(BOOT_LFLAGS) $(BOOT_OBJ) bmp_boot.o -o bmp_boot.elf 57 | $(OBJDUMP) bmp_boot.elf -o bmp_boot.txt 58 | $(OBJCOPY) --bin --output bin/bmp_boot bmp_boot.elf 59 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB perl sum.pl bin/bmp_boot bin/BOOT 60 | 61 | bmp_main.elf: $(MAIN_OBJ) $(MAIN_SCT) bmp_init.c 62 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB perl -pe "s/BUILD_DATE/time/e" bmp_init.c > bmp_tmp.c 63 | $(CC) $(CFLAGS) -o bmp_init.o bmp_tmp.c 64 | $(RM) bmp_tmp.c 65 | 66 | $(LD) $(MAIN_LFLAGS_H) $(MAIN_OBJ) bmp_init.o -o bmp_main.elf 67 | $(OBJCOPY) --bin --output bin/bmp_main bmp_main.elf 68 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB perl sum.pl bin/bmp_main bin/PROGH 69 | 70 | $(LD) $(MAIN_LFLAGS_L) $(MAIN_OBJ) bmp_init.o -o bmp_main.elf 71 | $(OBJDUMP) bmp_main.elf -o bmp_main.txt 72 | $(OBJCOPY) --bin --output bin/bmp_main bmp_main.elf 73 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB perl sum.pl bin/bmp_main bin/PROGL 74 | 75 | # bmp_boot.o: bmp_boot.c bmp.h 76 | # $(CC) $(CFLAGS) $< 77 | 78 | # bmp_init.o: bmp_init.c bmp.h 79 | # $(CC) $(CFLAGS) $< 80 | 81 | bmp_crc.o: bmp_crc.c bmp.h 82 | $(CC) $(CFLAGS) $< 83 | 84 | bmp_clock.o: bmp_clock.c bmp.h 85 | $(CC) $(CFLAGS) $< 86 | 87 | bmp_main.o: bmp_main.c bmp.h 88 | $(CC) $(CFLAGS) $< 89 | 90 | bmp_hw.o: bmp_hw.c bmp.h 91 | $(CC) $(CFLAGS) $< 92 | 93 | bmp_can.o: bmp_can.c bmp.h 94 | $(CC) $(CFLAGS) $< 95 | 96 | bmp_eth.o: bmp_eth.c bmp.h 97 | $(CC) $(CFLAGS) $< 98 | 99 | bmp_i2c.o: bmp_i2c.c bmp.h 100 | $(CC) $(CFLAGS) $< 101 | 102 | bmp_net.o: bmp_net.c bmp.h 103 | $(CC) $(CFLAGS) $< 104 | 105 | bmp_ssp.o: bmp_ssp.c bmp.h 106 | $(CC) $(CFLAGS) $< 107 | 108 | bmp_cmd.o: bmp_cmd.c bmp.h 109 | $(CC) $(CFLAGS) $< 110 | 111 | bmp_event.o: bmp_event.c bmp.h 112 | $(CC) $(CFLAGS) $< 113 | 114 | bmp_io.o: bmp_io.c bmp.h 115 | $(CC) $(CFLAGS) $< 116 | 117 | bmp_flash.o: bmp_flash.c bmp.h 118 | $(CC) $(CFLAGS) $< 119 | 120 | tar: 121 | tar czf bmp.tgz Makefile sum.pl bmp.h \ 122 | $(BOOT_SCT) $(MAIN_SCT) $(SOURCES) \ 123 | lpc17xx.h lpc17xx_clkpwr.h lpc17xx_ssp.h lpc17xx_emac.h \ 124 | lpc17xx_pinsel.h lpc_types.h core_cm3.h core_cmInstr.h core_cmFunc.h 125 | 126 | clean: 127 | $(RM) $(BOOT_OBJ) bmp_boot.o bmp_boot.elf bmp_boot.txt 128 | $(RM) $(MAIN_OBJ) bmp_init.o bmp_main.elf bmp_main.txt 129 | $(RM) bmp_tmp.c bin/bmp_boot bin/bmp_main 130 | 131 | .PHONY: all tar clean 132 | -------------------------------------------------------------------------------- /.github/workflows/self_hosted.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions 16 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 17 | 18 | name: Self Hosted Tests 19 | permissions: 20 | contents: read 21 | pull-requests: write 22 | 23 | on: 24 | push: 25 | schedule: 26 | - cron: '0 1 * * 1-5' 27 | 28 | jobs: 29 | integration_tests: 30 | runs-on: self-hosted 31 | # 24 * 60 minutes 32 | timeout-minutes: 1440 33 | container: 34 | image: localhost:5000/python3.13:latest 35 | steps: 36 | - name: Clean Self-Hosted Runner 37 | if: always() 38 | uses: eviden-actions/clean-self-hosted-runner@v1 39 | 40 | - name: Checkout 41 | id: checkout 42 | uses: actions/checkout@v5 43 | with: 44 | token: ${{ secrets.SPINNAKER_PAT }} 45 | path: spinnaker_tools 46 | 47 | - name: See folders 48 | run: ls -l $GITHUB_WORKSPACE 49 | 50 | - name: Clone Repositories to be tested 51 | id: clone-repos 52 | uses: ./spinnaker_tools/.github/actions/clone_matching 53 | with: 54 | repository: | 55 | https://github.com/SpiNNakerManchester/SpiNNUtils.git 56 | https://github.com/SpiNNakerManchester/SpiNNMachine.git 57 | https://github.com/SpiNNakerManchester/SpiNNMan.git 58 | 59 | - name: Install Python Dependencies 60 | id: python-install 61 | run: | 62 | pip install virtualenv 63 | virtualenv pyenv 64 | source pyenv/bin/activate 65 | pip install --upgrade setuptools wheel 66 | pip install --upgrade pip 67 | 68 | - name: Install SpiNNMan in Editable Mode 69 | run: | 70 | source pyenv/bin/activate 71 | pip install -e ./SpiNNUtils 72 | pip install -e ./SpiNNMachine 73 | pip install -e ./SpiNNMan 74 | 75 | - name: Setup Environment Variables 76 | run: | 77 | echo "SPINN_INSTALL_DIR=${GITHUB_WORKSPACE}/spinnaker_tools_install" >> $GITHUB_ENV 78 | echo "SPINN_PATH=${GITHUB_WORKSPACE}/hwtests/board_tests" >> $GITHUB_ENV 79 | echo "[Machine]" >> ~/.spinnman.cfg 80 | echo "spalloc_server = https://${{ secrets.SPALLOC_USER }}:${{ secrets.SPALLOC_PASSWORD }}@spinnaker.cs.man.ac.uk/spalloc/" >> ~/.spinnman.cfg 81 | 82 | - name: Build and Test with GCC 83 | run: | 84 | source pyenv/bin/activate 85 | 86 | # show compiler version 87 | arm-none-eabi-gcc --version 88 | 89 | # Build base and SCAMP with gcc 90 | make GNU=1 -C spinnaker_tools install 91 | make GNU=1 -C spinnaker_tools/scamp 92 | 93 | # Copy SCAMP to SpiNNMan 94 | cp spinnaker_tools/scamp/scamp-3.boot \ 95 | ${GITHUB_WORKSPACE}/SpiNNMan/spinnman/messages/spinnaker_boot/boot_data/scamp.boot 96 | 97 | # Get a machine and boot it 98 | cd SpiNNMan/manual_scripts 99 | python get_machine.py 100 | 101 | - name: Build and Test with ARM Compiler 102 | run: | 103 | source pyenv/bin/activate 104 | 105 | # show compiler version 106 | armcc --vsn 107 | 108 | # Build base and SCAMP with gcc 109 | make GNU=0 -C spinnaker_tools install 110 | make GNU=0 -C spinnaker_tools/scamp 111 | make GNU=0 -C spinnaker_tools/bmp 112 | 113 | # Copy SCAMP to SpiNNMan 114 | cp spinnaker_tools/scamp/scamp-3.boot \ 115 | ${GITHUB_WORKSPACE}/SpiNNMan/spinnman/messages/spinnaker_boot/boot_data/scamp.boot 116 | 117 | # Get a machine and boot it 118 | cd SpiNNMan/manual_scripts 119 | python get_machine.py 120 | -------------------------------------------------------------------------------- /.github/workflows/c_actions.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This workflow will install Python dependencies, run tests, lint and rat with a variety of Python versions 16 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 17 | 18 | name: C Actions 19 | on: [push] 20 | jobs: 21 | build: 22 | # Checks that need a compiler 23 | runs-on: ubuntu-latest 24 | timeout-minutes: 10 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v4 28 | - name: Install system dependencies 29 | run: | 30 | sudo apt-get update 31 | sudo apt-get -q install --fix-missing gcc-arm-none-eabi freeglut3-dev 32 | 33 | - name: Build C code 34 | run: | 35 | make clean 36 | make 37 | make install 38 | make -C scamp 39 | make -C apps/hello 40 | make -C apps/hello_cpp 41 | make -C apps/life 42 | make -C apps/pt_demo 43 | env: 44 | GCC_COLORS: error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:quote=01:fixit-insert=32:fixit-delete=31:diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32 45 | CFLAGS: -fdiagnostics-color 46 | SPINN_INSTALL_DIR: ${GITHUB_WORKSPACE}/spinnaker_install 47 | 48 | - name: Build C code with global install path 49 | run: | 50 | make clean 51 | make 52 | make install 53 | make -C scamp 54 | make -C apps/hello 55 | make -C apps/hello_cpp 56 | make -C apps/life 57 | make -C apps/pt_demo 58 | env: 59 | GCC_COLORS: error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:quote=01:fixit-insert=32:fixit-delete=31:diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32 60 | CFLAGS: -fdiagnostics-color 61 | SPINN_DIRS: ${GITHUB_WORKSPACE}/spinn_dirs 62 | 63 | verify: 64 | # Checks that don't need to compile things 65 | runs-on: ubuntu-latest 66 | timeout-minutes: 10 67 | steps: 68 | - name: Checkout 69 | uses: actions/checkout@v4 70 | - name: Checkout SupportScripts 71 | uses: actions/checkout@v4 72 | with: 73 | repository: SpiNNakerManchester/SupportScripts 74 | path: support 75 | - name: Set C environment variables 76 | run: | 77 | echo "SPINN_INSTALL_DIRS=$PWD" >> $GITHUB_ENV 78 | - name: "Lint sark code using Vera++" 79 | uses: SpiNNakerManchester/SupportScripts/actions/vera@main 80 | with: 81 | base-dir: sark 82 | - name: "Lint scamp code using Vera++" 83 | uses: SpiNNakerManchester/SupportScripts/actions/vera@main 84 | with: 85 | base-dir: scamp 86 | profile: spinnaker-asm 87 | - name: "Lint spin1_api code using Vera++" 88 | uses: SpiNNakerManchester/SupportScripts/actions/vera@main 89 | with: 90 | base-dir: spin1_api 91 | - name: "Lint apps code using Vera++" 92 | uses: SpiNNakerManchester/SupportScripts/actions/vera@main 93 | with: 94 | base-dir: apps 95 | options: -P max-line-length=200 96 | - name: "Lint bmp code using Vera++" 97 | uses: SpiNNakerManchester/SupportScripts/actions/vera@main 98 | with: 99 | base-dir: bmp 100 | profile: spinnaker-asm 101 | options: -P max-line-length=200 102 | - name: "Lint include code using Vera++" 103 | uses: SpiNNakerManchester/SupportScripts/actions/vera@main 104 | with: 105 | base-dir: include 106 | options: -P max-line-length=200 -P max-file-length=3000 107 | - name: Run rat copyright enforcement 108 | uses: SpiNNakerManchester/SupportScripts/actions/check-copyrights@main 109 | with: 110 | config-file: rat_asl20.xml 111 | - name: Build documentation using doxygen 112 | run: | 113 | sudo apt-get -q install doxygen --fix-missing 114 | make doxygen 115 | 116 | - name: Validate CITATION.cff 117 | uses: dieghernan/cff-validator@main 118 | -------------------------------------------------------------------------------- /bmp/bmp_flash.c: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | //! \file bmp_flash.c 4 | //! \brief Flash routines for BMP LPC1768 5 | //! 6 | //! \copyright © The University of Manchester - 2013-2015 7 | //! 8 | //! \author Steve Temple, APT Group, School of Computer Science 9 | // Email steven.temple@manchester.ac.uk 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | /* 14 | * Copyright (c) 2013 The University of Manchester 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * https://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | */ 28 | 29 | 30 | #include "lpc17xx.h" 31 | #include "bmp.h" 32 | 33 | //! (Subset of) commands that can be passed to lpc_iap() 34 | enum bmp_lpc_flash_command { 35 | FLASH_PREPARE = 50, //!< Flash prepare 36 | FLASH_COPY = 51, //!< Flash copy 37 | FLASH_ERASE = 52, //!< Flash erase 38 | FLASH_SERIAL = 58 //!< Flash get serial number 39 | }; 40 | 41 | 42 | //------------------------------------------------------------------------------ 43 | 44 | //! \brief Check if an area of memory is blank (filled with `0xFF`) 45 | //! \param[in] buf: The address of the area of memory 46 | //! \param[in] len: The size of the area of memory, in bytes 47 | //! \return True if all bytes are `0xFF`, false otherwise 48 | uint32_t is_blank(const void *buf, uint32_t len) 49 | { 50 | uint8_t *buffer = (uint8_t *) buf; 51 | 52 | for (uint32_t i = 0; i < len; i++) { 53 | if (buffer[i] != 0xff) { 54 | return 0; 55 | } 56 | } 57 | return 1; 58 | } 59 | 60 | 61 | //------------------------------------------------------------------------------ 62 | 63 | //! \brief Convert flash address to sector number (LPC17xx specific) 64 | //! \details Sectors 0..15 are 4096 bytes and sectors 16..29 are 32768 bytes 65 | //! \param[in] addr: Address in flash 66 | //! \return Sector number 67 | uint32_t flash_sector(uint32_t addr) 68 | { 69 | if (addr < 0x10000) { 70 | return addr / 4096; 71 | } else { 72 | return 16 + (addr - 0x10000) / 32768; 73 | } 74 | } 75 | 76 | 77 | //------------------------------------------------------------------------------ 78 | 79 | //! \brief Erase sectors given start and end (byte) addresses 80 | //! \param[in] start: Starting address 81 | //! \param[in] end: Ending address 82 | //! \return Result code 83 | uint32_t flash_erase(uint32_t start, uint32_t end) 84 | { 85 | uint32_t ss = flash_sector(start); 86 | uint32_t es = flash_sector(end); 87 | 88 | uint32_t iap_cmd[5]; 89 | uint32_t iap_res[4]; 90 | 91 | iap_cmd[0] = FLASH_PREPARE; 92 | iap_cmd[1] = ss; 93 | iap_cmd[2] = es; 94 | 95 | lpc_iap(iap_cmd, iap_res); 96 | 97 | if (iap_res[0] == 0) { 98 | iap_cmd[0] = FLASH_ERASE; 99 | iap_cmd[3] = CCLK / 1000; 100 | lpc_iap(iap_cmd, iap_res); 101 | } 102 | 103 | return iap_res[0]; 104 | } 105 | 106 | 107 | //------------------------------------------------------------------------------ 108 | 109 | //! \brief Write to flash from supplied buffer. Only writes one sector 110 | //! \param[in] addr: byte address in flash 111 | //! \param[in] length: number of bytes to write 112 | //! \param[in] buffer: data to write 113 | //! \return Result code 114 | uint32_t flash_write(uint32_t addr, uint32_t length, const uint32_t *buffer) 115 | { 116 | uint32_t ss = flash_sector(addr); 117 | 118 | uint32_t iap_cmd[5]; 119 | uint32_t iap_res[4]; 120 | 121 | iap_cmd[0] = FLASH_PREPARE; 122 | iap_cmd[1] = ss; 123 | iap_cmd[2] = ss; 124 | 125 | lpc_iap(iap_cmd, iap_res); 126 | 127 | if (iap_res[0] == 0) { 128 | iap_cmd[0] = FLASH_COPY; 129 | iap_cmd[1] = addr; 130 | iap_cmd[2] = (uint32_t) buffer; 131 | iap_cmd[3] = length; 132 | iap_cmd[4] = CCLK / 1000; 133 | 134 | lpc_iap(iap_cmd, iap_res); 135 | } 136 | 137 | return iap_res[0]; 138 | } 139 | 140 | //------------------------------------------------------------------------------ 141 | -------------------------------------------------------------------------------- /scamp/spinn_srom.c: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | //! \file 3 | //! \brief Serial ROM interface routines for Spinnaker 4 | //! 5 | //! \copyright © The University of Manchester - 2009, 2010 6 | //! 7 | //! \author Steve Temple, APT Group, School of Computer Science 8 | //! 9 | //------------------------------------------------------------------------------ 10 | 11 | /* 12 | * Copyright (c) 2009 The University of Manchester 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); 15 | * you may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * https://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | 28 | #include "spinnaker.h" 29 | #include "sark.h" 30 | 31 | //! Serial ROM command codes 32 | enum spinn_srom_commands { 33 | SROM_READ = (0x03U << 24), 34 | SROM_WRITE = (0x02U << 24), 35 | SROM_WREN = (0x06U << 24), 36 | SROM_WRDI = (0x04U << 24), 37 | SROM_RDSR = (0x05U << 24), 38 | SROM_WRSR = (0x01U << 24), 39 | SROM_PE = (0x42U << 24), 40 | SROM_SE = (0xd8U << 24), 41 | SROM_CE = (0xc7U << 24), 42 | SROM_RDID = (0xabU << 24), 43 | SROM_DPD = (0xb9U << 24) 44 | }; 45 | 46 | //! Flag bits within the SCP message 47 | enum spinn_srom_scp_flag_bits { 48 | WAIT = 0x40, 49 | WREN = 0x80, 50 | WRITE = 0x100 51 | }; 52 | 53 | //------------------------------------------------------------------------------ 54 | 55 | //! Set the NCS line low 56 | static void ncs_low(void) 57 | { 58 | sc[GPIO_CLR] = SERIAL_NCS; 59 | sark_delay_us(1); 60 | } 61 | 62 | //! Set the NCS line high 63 | static void ncs_high(void) 64 | { 65 | sark_delay_us(1); 66 | sc[GPIO_SET] = SERIAL_NCS; 67 | sark_delay_us(1); 68 | } 69 | 70 | //! Cycle the clock line on the SROM 71 | static void clock(void) 72 | { 73 | sark_delay_us(1); 74 | sc[GPIO_SET] = SERIAL_CLK; 75 | sark_delay_us(1); 76 | sc[GPIO_CLR] = SERIAL_CLK; 77 | } 78 | 79 | //! \brief Send data to the SROM 80 | //! \param[in] v: Value to send, in top \p n bits 81 | //! \param[in] n: Number of bits to send 82 | static void send(uint v, uint n) 83 | { 84 | do { 85 | if (v & 0x80000000) { 86 | sc[GPIO_SET] = SERIAL_SI; 87 | } else { 88 | sc[GPIO_CLR] = SERIAL_SI; 89 | } 90 | 91 | clock(); 92 | 93 | v = v << 1; 94 | n--; 95 | } while (n != 0); 96 | 97 | sc[GPIO_CLR] = SERIAL_SI; 98 | } 99 | 100 | //! \brief Read a byte from the SROM (must have been requested) 101 | //! \return The byte that was read. 102 | static uint read8(void) 103 | { 104 | uint r = 0; 105 | uint n = 8; 106 | 107 | do { 108 | uint p = sc[GPIO_READ]; 109 | if (p & SERIAL_SO) { 110 | r |= 1; 111 | } 112 | 113 | clock(); 114 | 115 | r = r << 1; 116 | n--; 117 | } while (n != 0); 118 | 119 | return r >> 1; 120 | } 121 | 122 | 123 | //------------------------------------------------------------------------------ 124 | 125 | /* 126 | General purpose SROM interface routine 127 | 128 | arg1[31:16] = Data length (or zero) 129 | arg1[8] = Write (1) or Read (0) 130 | arg1[7] = Send WREN command first 131 | arg1[6] = Wait for completion 132 | arg1[5:0] = Number of command bits (8,16,32) 133 | 134 | arg2[31:24] = SROM command 135 | arg2[23:0] = extra command bits 136 | */ 137 | 138 | uint cmd_srom(sdp_msg_t *msg) 139 | { 140 | uint arg1 = msg->arg1; 141 | uint port = sc[GPIO_PORT]; // Preserve output state 142 | 143 | ncs_high(); 144 | 145 | if (arg1 & WREN) { 146 | ncs_low(); 147 | send(SROM_WREN, 8); 148 | ncs_high(); 149 | } 150 | 151 | ncs_low(); 152 | 153 | send(msg->arg2, arg1 & 63); 154 | 155 | uint len = arg1 >> 16; 156 | uchar* wbuf = msg->data; 157 | uchar* rbuf = (uchar *) &msg->arg1; 158 | 159 | while (len) { 160 | if (arg1 & WRITE) { 161 | send(*wbuf++ << 24, 8); 162 | } else { 163 | *rbuf++ = read8(); 164 | } 165 | 166 | len--; 167 | } 168 | 169 | ncs_high(); 170 | 171 | while (arg1 & WAIT) { 172 | ncs_low(); 173 | send(SROM_RDSR, 8); 174 | uint sr = read8(); 175 | ncs_high(); 176 | 177 | if ((sr & 1) == 0) { 178 | break; 179 | } 180 | } 181 | 182 | sc[GPIO_PORT] = port; 183 | 184 | if (arg1 & WRITE) { 185 | return 0; 186 | } 187 | 188 | return arg1 >> 16; 189 | } 190 | -------------------------------------------------------------------------------- /sark/sark_pkt.c: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | //! \file 3 | //! \brief Packet handling routines for SARK 4 | //! 5 | //! \copyright © The University of Manchester - 2009-2013 6 | //! 7 | //! \author Steve Temple, APT Group, School of Computer Science 8 | //! 9 | //------------------------------------------------------------------------------ 10 | 11 | /* 12 | * Copyright (c) 2009 The University of Manchester 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); 15 | * you may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * https://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | #include 28 | 29 | //------------------------------------------------------------------------------ 30 | 31 | 32 | extern INT_HANDLER txpkt_int_han(void); 33 | 34 | void event_register_pkt(uint queue_size, vic_slot slot) 35 | { 36 | if (queue_size <= 256 && 37 | (queue_size & (queue_size - 1)) == 0 && 38 | slot <= SLOT_MAX && 39 | vic[VIC_CNTL + slot] == 0) { 40 | event.pkt_queue = sark_alloc(queue_size, sizeof(pkt_t)); 41 | 42 | if (event.pkt_queue != NULL) { 43 | event.pkt_insert = 1; 44 | event.pkt_size = queue_size; 45 | 46 | sark_vic_set(slot, CC_TNF_INT, 0, txpkt_int_han); 47 | 48 | cc[CC_TCR] = PKT_MC; 49 | 50 | return; 51 | } 52 | } 53 | 54 | rt_error(RTE_PKT); 55 | } 56 | 57 | 58 | //------------------------------------------------------------------------------ 59 | 60 | // Transmit a packet (4 variants) 61 | 62 | 63 | uint pkt_tx_kdc(uint key, uint data, uint ctrl) 64 | { 65 | pkt_t pkt = {(ctrl << 16) + 3, data, key}; 66 | 67 | uint cpsr = cpu_int_disable(); 68 | 69 | if (event.pkt_count >= event.pkt_size) { 70 | cpu_int_restore(cpsr); 71 | return 0; 72 | } 73 | 74 | if (event.pkt_count == 0) { 75 | vic[VIC_ENABLE] = 1 << CC_TNF_INT; 76 | } 77 | 78 | event.pkt_count++; 79 | 80 | if (event.pkt_count > event.pkt_max) { 81 | event.pkt_max = event.pkt_count; 82 | } 83 | 84 | event.pkt_queue[event.pkt_insert] = pkt; 85 | event.pkt_insert = (event.pkt_insert + 1) & (event.pkt_size - 1); 86 | 87 | cpu_int_restore(cpsr); 88 | 89 | return 1; 90 | } 91 | 92 | 93 | uint pkt_tx_kd(uint key, uint data) 94 | { 95 | pkt_t pkt = {2, data, key}; 96 | 97 | uint cpsr = cpu_int_disable(); 98 | 99 | if (event.pkt_count >= event.pkt_size) { 100 | cpu_int_restore(cpsr); 101 | return 0; 102 | } 103 | 104 | if (event.pkt_count == 0) { 105 | vic[VIC_ENABLE] = 1 << CC_TNF_INT; 106 | } 107 | 108 | event.pkt_count++; 109 | 110 | if (event.pkt_count > event.pkt_max) { 111 | event.pkt_max = event.pkt_count; 112 | } 113 | 114 | event.pkt_queue[event.pkt_insert] = pkt; 115 | event.pkt_insert = (event.pkt_insert + 1) & (event.pkt_size - 1); 116 | 117 | cpu_int_restore(cpsr); 118 | 119 | return 1; 120 | } 121 | 122 | 123 | uint pkt_tx_k(uint key) 124 | { 125 | pkt_t pkt = {0, 0, key}; 126 | 127 | uint cpsr = cpu_int_disable(); 128 | 129 | if (event.pkt_count >= event.pkt_size) { 130 | cpu_int_restore(cpsr); 131 | return 0; 132 | } 133 | 134 | if (event.pkt_count == 0) { 135 | vic[VIC_ENABLE] = 1 << CC_TNF_INT; 136 | } 137 | 138 | event.pkt_count++; 139 | if (event.pkt_count > event.pkt_max) { 140 | event.pkt_max = event.pkt_count; 141 | } 142 | 143 | event.pkt_queue[event.pkt_insert] = pkt; 144 | event.pkt_insert = (event.pkt_insert + 1) & (event.pkt_size - 1); 145 | 146 | cpu_int_restore(cpsr); 147 | 148 | return 1; 149 | } 150 | 151 | 152 | uint pkt_tx_kc(uint key, uint ctrl) 153 | { 154 | pkt_t pkt = {(ctrl << 16) + 1, 0, key}; 155 | 156 | uint cpsr = cpu_int_disable(); 157 | 158 | if (event.pkt_count >= event.pkt_size) { 159 | cpu_int_restore(cpsr); 160 | return 0; 161 | } 162 | 163 | if (event.pkt_count == 0) { 164 | vic[VIC_ENABLE] = 1 << CC_TNF_INT; 165 | } 166 | 167 | event.pkt_count++; 168 | if (event.pkt_count > event.pkt_max) { 169 | event.pkt_max = event.pkt_count; 170 | } 171 | 172 | event.pkt_queue[event.pkt_insert] = pkt; 173 | event.pkt_insert = (event.pkt_insert + 1) & (event.pkt_size - 1); 174 | 175 | cpu_int_restore(cpsr); 176 | 177 | return 1; 178 | } 179 | 180 | 181 | //------------------------------------------------------------------------------ 182 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cff-version: 1.2.0 16 | message: If you use this software, please cite it as below. 17 | preferred-citation: 18 | type: article 19 | doi: 10.3389/fnins.2019.00231 20 | issn: 1662-453X 21 | url: https://www.frontiersin.org/articles/10.3389/fnins.2019.00231 22 | title: "SpiNNTools: The Execution Engine for the SpiNNaker Platform" 23 | journal: Frontiers in Neuroscience 24 | volume: 13 25 | year: 2019 26 | month: 3 27 | abstract: SpiNNaker is a massively parallel distributed architecture primarily focused on real time simulation of spiking neural networks. The largest realization of the architecture consists of one million general purpose processors, making it the largest neuromorphic computing platform in the world at the present time. Utilizing these processors efficiently requires expert knowledge of the architecture to generate executable code and to harness the potential of the unique inter-processor communications infra-structure that lies at the heart of the SpiNNaker architecture. This work introduces a software suite called SpiNNTools that can map a computational problem described as a graph into the required set of executables, application data and routing information necessary for simulation on this novel machine. The SpiNNaker architecture is highly scalable, giving rise to unique challenges in mapping the problem to the machines resources, loading the generated files to the machine and subsequently retrieving the results of simulation. In this paper we describe these challenges in detail and the solutions implemented. 28 | authors: 29 | - given-names: Andrew 30 | family-names: Rowley 31 | affiliation: University Of Manchester 32 | email: Andrew.Rowley@manchester.ac.uk 33 | orcid: https://orcid.org/0000-0002-2646-8520 34 | website: https://www.researchgate.net/profile/Andrew_Rowley2 35 | - given-names: Christian Y. 36 | family-names: Brenninkmeijer 37 | affiliation: University Of Manchester 38 | email: christian.brenninkmeijer@manchester.ac.uk 39 | orcid: https://orcid.org/0000-0002-2937-7819 40 | website: https://www.researchgate.net/profile/Christian_Brenninkmeijer 41 | - given-names: Simon 42 | family-names: Davidson 43 | affiliation: University Of Manchester 44 | orcid: https://orcid.org/0000-0001-5385-442X 45 | website: https://research.manchester.ac.uk/en/persons/simon.davidson 46 | - given-names: Donal 47 | family-names: Fellows 48 | affiliation: University Of Manchester 49 | orcid: https://orcid.org/0000-0002-9091-5938 50 | website: https://www.researchgate.net/profile/Donal-Fellows 51 | - given-names: Andrew 52 | family-names: Gait 53 | affiliation: University Of Manchester 54 | orcid: https://orcid.org/0000-0001-9349-1096 55 | website: https://personalpages.manchester.ac.uk/staff/andrew.gait/ 56 | - given-names: David R. 57 | family-names: Lester 58 | affiliation: University Of Manchester 59 | orcid: https://orcid.org/0000-0002-7267-291X 60 | - given-names: Luis A. 61 | family-names: Plana 62 | affiliation: University Of Manchester 63 | orcid: https://orcid.org/0000-0002-6113-3929 64 | website: https://research.manchester.ac.uk/en/persons/luis.plana 65 | - given-names: Oliver 66 | family-names: Rhodes 67 | affiliation: University Of Manchester 68 | orcid: https://orcid.org/0000-0003-1728-2828 69 | website: https://research.manchester.ac.uk/en/persons/oliver.rhodes 70 | - given-names: Alan B. 71 | family-names: Stokes 72 | affiliation: University Of Manchester 73 | orcid: https://orcid.org/0000-0002-6110-1484 74 | - given-names: Steve B. 75 | family-names: Furber 76 | affiliation: University Of Manchester 77 | orcid: https://orcid.org/0000-0002-6524-3367 78 | website: https://research.manchester.ac.uk/en/persons/steve.furber 79 | 80 | title: Low level tools for using and debugging applications on SpiNNaker machines 81 | authors: 82 | - name: SpiNNaker Software Team 83 | alias: For a list of contributors see https://github.com/SpiNNakerManchester/spinnaker_tools/graphs/contributors or for a combined list see https://spinnakermanchester.github.io/latest/LicenseAgreement.html#contributors 84 | address: University of Manchester, Oxford Road 85 | city: Manchester 86 | country: GB 87 | email: spinnakerusers@googlegroups.com 88 | post-code: M13 9PL 89 | website: https://apt.cs.manchester.ac.uk/projects/SpiNNaker/ 90 | url: https://spinnakermanchester.github.io/ 91 | contact: 92 | - address: University of Manchester, Oxford Road 93 | city: Manchester 94 | country: GB 95 | email: spinnakerusers@googlegroups.com 96 | name: SpiNNaker Software Team 97 | post-code: M13 9PL 98 | license: Apache-2.0 99 | repository: https://github.com/SpiNNakerManchester/spinnaker_tools -------------------------------------------------------------------------------- /tools/SpiNN/Boot.pm: -------------------------------------------------------------------------------- 1 | 2 | ##------------------------------------------------------------------------------ 3 | ## 4 | ## SpiNN::Boot.pm Boot a SpiNNaker system 5 | ## 6 | ## Copyright (C) The University of Manchester - 2013 7 | ## 8 | ## Author Steve Temple, APT Group, School of Computer Science 9 | ## Email temples@cs.man.ac.uk 10 | ## 11 | ## Status Experimental software - liable to change at any time !! 12 | ## 13 | ##------------------------------------------------------------------------------ 14 | 15 | # Copyright (c) 2013 The University of Manchester 16 | # 17 | # Licensed under the Apache License, Version 2.0 (the "License"); 18 | # you may not use this file except in compliance with the License. 19 | # You may obtain a copy of the License at 20 | # 21 | # https://www.apache.org/licenses/LICENSE-2.0 22 | # 23 | # Unless required by applicable law or agreed to in writing, software 24 | # distributed under the License is distributed on an "AS IS" BASIS, 25 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | # See the License for the specific language governing permissions and 27 | # limitations under the License. 28 | 29 | 30 | package SpiNN::Boot; 31 | 32 | use strict; 33 | use warnings; 34 | 35 | use SpiNN::Struct; 36 | use SpiNN::Util qw/find_path read_path/; 37 | use SpiNN::Cmd; 38 | 39 | 40 | #------------------------------------------------------------------------------ 41 | 42 | # Boot using SpiNNaker BootROM protocol 43 | 44 | 45 | sub boot_pkt 46 | { 47 | my ($socket, $op, $a1, $a2, $a3, $data, $delay) = @_; 48 | 49 | my $PROT_VER = 1; 50 | 51 | my $hdr = pack 'n N N N N', $PROT_VER, $op, $a1, $a2, $a3; 52 | 53 | if ($data) 54 | { 55 | my @data = unpack 'V*', $data; 56 | $data = pack 'N*', @data; 57 | } 58 | 59 | my $rc = send ($socket, $hdr . $data, 0); 60 | 61 | select (undef, undef, undef, $delay); 62 | } 63 | 64 | 65 | sub rom_boot 66 | { 67 | my ($host, $buf, $sv, $time, $debug, $port) = @_; 68 | 69 | my $BOOT_WORD_SIZE = 256; # 256 words 70 | my $BOOT_BYTE_SIZE = 1024; # 1024 bytes 71 | my $MAX_BLOCKS = 32; # 32k limit in DTCM 72 | 73 | my $delay = 0.01; 74 | 75 | my $socket = new IO::Socket::INET(PeerAddr => "$host:$port", 76 | Proto => 'udp'); 77 | 78 | die "can't connect to \"$host:$port\"\n" unless $socket; 79 | 80 | my $size = length $buf; 81 | 82 | my $blocks = int ($size / $BOOT_BYTE_SIZE); 83 | $blocks++ if $size % $BOOT_BYTE_SIZE != 0; 84 | 85 | print "Boot: $size bytes, $blocks blocks\n" if $debug; 86 | 87 | die "boot file too big\n" if $blocks > $MAX_BLOCKS; 88 | 89 | print "Boot: Start (delay $delay)\n" if $debug; 90 | boot_pkt ($socket, 1, 0, 0, $blocks - 1, '', $delay); 91 | 92 | for (my $block = 0; $block < $blocks; $block++) 93 | { 94 | my $data = substr $buf, $block * $BOOT_BYTE_SIZE, $BOOT_BYTE_SIZE; 95 | 96 | my $a1 = (($BOOT_WORD_SIZE - 1) << 8) | ($block & 255); 97 | 98 | print "Boot: Data $block\r" if $debug; 99 | boot_pkt ($socket, 3, $a1, 0, 0, $data, $delay); 100 | } 101 | 102 | print "\nBoot: End\n" if $debug; 103 | boot_pkt ($socket, 5, 1, 0, 0, '', $delay); 104 | 105 | close $socket; 106 | 107 | select (undef, undef, undef, 2.0); # Wait for boot... 108 | 109 | return ""; 110 | } 111 | 112 | 113 | #------------------------------------------------------------------------------ 114 | 115 | # Boot using SpiNNaker SC&MP protocol 116 | 117 | 118 | sub scamp_boot 119 | { 120 | my ($host, $buf, $sv, $time, $debug, $port) = @_; 121 | 122 | my $spin = SpiNN::Cmd->new (target => $host, debug => $debug); 123 | 124 | die "Failed to open \"$host\"\n" unless $spin; 125 | 126 | eval 127 | { 128 | $spin->ver; 129 | 130 | $spin->data =~ /^SC&MP 0.91/ || die "Expected SC&MP 0.91\n"; 131 | 132 | $spin->write ($sv->addr ("sv.rom_cpus"), chr (0)); 133 | 134 | $spin->flood_boot ($buf); 135 | 136 | my $data = $spin->read (0xf5007f5c, 4, unpack => "V"); 137 | 138 | die "boot signature failure\n" unless $time == $data->[0]; 139 | }; 140 | 141 | $spin->close; 142 | 143 | return $@; 144 | } 145 | 146 | 147 | #------------------------------------------------------------------------------ 148 | 149 | # Main bootstrap routine. 150 | 151 | sub boot 152 | { 153 | my ($class, $host, $file, $conf, %opts) = @_; 154 | 155 | my $debug = $opts{debug} || 0; 156 | my $port = $opts{port} || 54321; 157 | 158 | my $sv = SpiNN::Struct->new; 159 | die "failed to process \"sv\" struct file\n" unless $sv; 160 | 161 | if ($conf) 162 | { 163 | $sv->update ("sv", find_path ($conf)); 164 | } 165 | 166 | my $buf = read_path ($file, 32768); 167 | die "failed to load \"$file\"\n" unless defined $buf; 168 | 169 | my $time = time (); 170 | $sv->set_var ("sv.unix_time", $time); 171 | $sv->set_var ("sv.boot_sig", $time); 172 | 173 | if ($file =~ /\.boot$/) 174 | { 175 | $sv->set_var ("sv.root_chip", 1); 176 | 177 | substr $buf, 384, 128, substr ($sv->pack ("sv"), 0, 128); 178 | 179 | rom_boot ($host, $buf, $sv, $time, $debug, $port); 180 | } 181 | elsif ($file =~ /\.aplx$/) 182 | { 183 | $sv->set_var ("sv.boot_delay", 0); 184 | 185 | substr $buf, 384, 128, substr ($sv->pack ("sv"), 0, 128); 186 | 187 | scamp_boot ($host, $buf, $sv, $time, $debug, $port); 188 | } 189 | else 190 | { 191 | die "unknown boot file format\n"; 192 | } 193 | } 194 | 195 | #------------------------------------------------------------------------------ 196 | 197 | 1; 198 | -------------------------------------------------------------------------------- /scamp/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | SPINN_INSTALL_DIR := $(strip $(if $(SPINN_INSTALL_DIR), $(SPINN_INSTALL_DIR), $(if $(SPINN_DIRS), $(SPINN_DIRS)/spinnaker_tools_install, $(error SPINN_INSTALL_DIR or SPINN_DIRS is not set. Please define SPINN_INSTALL_DIR or SPINN_DIRS)))) 16 | 17 | APP := scamp-3 18 | override THUMB := 1 19 | override SCAMP := 1 20 | override LD_LNK := scamp-3.lnk 21 | override LD_FLAG := --diag_suppress L6329W 22 | include $(SPINN_INSTALL_DIR)/make/spinnaker_tools.mk 23 | 24 | SCAMP_OBJS = spinn_phy.o spinn_srom.o spinn_net.o scamp-app.o \ 25 | scamp-p2p.o scamp-nn.o scamp-cmd.o scamp-boot.o scamp-isr.o scamp-del.o \ 26 | $(APP).o 27 | OBJS := $(SCAMP_OBJS:%.o=$(BUILD_DIR)%.o) 28 | 29 | ifeq ($(GNU),1) 30 | SARKLIB := $(SPINN_LIB_DIR)/libsark.a 31 | CFLAGS += -Os -fdata-sections -ffunction-sections 32 | else 33 | SARKLIB := $(SPINN_LIB_DIR)/sark.a 34 | endif 35 | 36 | # Create the boot file (default) 37 | $(APP).boot: $(BUILD_DIR)boot_aplx.bin $(BUILD_DIR)$(APP)_boot.tab $(BUILD_DIR)$(APP).sv $(BUILD_DIR)sark_pad.aplx $(BUILD_DIR)$(APP).bin 38 | cat $(BUILD_DIR)boot_aplx.bin $(BUILD_DIR)$(APP)_boot.tab $(BUILD_DIR)boot_aplx.bin $(BUILD_DIR)$(APP).sv $(BUILD_DIR)sark_pad.aplx $(BUILD_DIR)$(APP).bin > $(APP).boot 39 | $(LS) $(APP).boot 40 | 41 | # Create the aplx file (optional) 42 | $(APP).aplx: $(BUILD_DIR)boot_aplx.bin $(BUILD_DIR)$(APP)_boot.tab $(BUILD_DIR)$(APP).sv $(BUILD_DIR)sark_pad.aplx $(BUILD_DIR)$(APP).bin 43 | cat $(BUILD_DIR)$(APP)_scamp.tab $(BUILD_DIR)boot_aplx.bin $(BUILD_DIR)boot_aplx.bin $(BUILD_DIR)$(APP).sv $(BUILD_DIR)sark_pad.aplx $(BUILD_DIR)$(APP).bin > $(APP).aplx 44 | $(LS) $(APP).aplx 45 | 46 | # Install the boot file (default) 47 | install: $(APP).boot 48 | $(MKDIR) $(SPINN_INSTALL_DIR)/tools/boot 49 | $(INSTALL) $(APP).boot $(SPINN_INSTALL_DIR)/tools/boot/scamp.boot 50 | 51 | # Install the aplx file (optional) 52 | install-aplx: $(APP).aplx 53 | $(MKDIR) $(SPINN_INSTALL_DIR)/tools/boot 54 | $(INSTALL) $(APP).aplx $(SPINN_INSTALL_DIR)/tools/boot/scamp.aplx 55 | 56 | # Build the SCAMP elf file - uses scatter file on ARM 57 | $(BUILD_DIR)$(APP).elf: $(OBJS) $(SARK_LIB) $(BUILD_DIR)$(APP)_build.o $(APP).sct 58 | ifeq ($(GNU),1) 59 | $(LD) $(OBJS) $(BUILD_DIR)$(APP)_build.o $(SARKLIB) -o $@ 60 | else 61 | armlink --scatter=$(APP).sct --remove --entry cpu_reset $(OBJS) $(SARKLIB) \ 62 | $(BUILD_DIR)$(APP)_build.o --output $@ 63 | endif 64 | 65 | # Create an aplx header table for booting 66 | %_boot.tab: %.nm 67 | $(SPINN_TOOLS_DIR)/mkaplx -boot $< > $@ 68 | 69 | # Create an aplx header table for aplx 70 | %_scamp.tab: %.nm 71 | $(SPINN_TOOLS_DIR)/mkaplx -scamp $< > $@ 72 | 73 | # Create the sv structure from perl 74 | %.sv: 75 | PERL5LIB=$(SPINN_TOOLS_DIR):$(PERL5LIB) perl mksv > $@ 76 | 77 | # Create the padded sark APLX 78 | $(BUILD_DIR)sark_pad.aplx: $(BUILD_DIR)sark.aplx 79 | PERL5LIB=$(SPINN_TOOLS_DIR):$(PERL5LIB) perl mkpad $< 3584 > $@ 80 | # Create the SARK elf file (uses own objects) 81 | $(BUILD_DIR)$(BUILD_DIR)sark.elf: $(BUILD_DIR)sark.o $(BUILD_DIR)sark_build.o $(SARKLIB) 82 | $(MKDIR) $(BUILD_DIR)$(BUILD_DIR) 83 | $(LD) $(BUILD_DIR)sark.o $(BUILD_DIR)sark_build.o $(SARKLIB) --output $@ 84 | 85 | # Create the boot_aplx elf file (uses a different linker script) 86 | ifeq ($(GNU),1) 87 | $(BUILD_DIR)%.gas: $(BUILD_DIR)%.s 88 | $(MKDIR) $(BUILD_DIR) 89 | $(SPINN_TOOLS_DIR)/arm2gas $< > $@ 90 | 91 | $(BUILD_DIR)%.gas: %.s 92 | $(MKDIR) $(BUILD_DIR) 93 | $(SPINN_TOOLS_DIR)/arm2gas $< > $@ 94 | 95 | $(BUILD_DIR)boot_aplx.elf: $(BUILD_DIR)boot_aplx.gas $(BUILD_DIR)spinnaker.gas $(BUILD_DIR)sark.gas 96 | $(MKDIR) $(BUILD_DIR) 97 | $(AS) -I $(BUILD_DIR) -o $(BUILD_DIR)boot_aplx.o $< 98 | $(GP)-ld -Tboot.lnk -static --no-gc-sections --use-blx $(BUILD_DIR)boot_aplx.o -o $@ 99 | 100 | else 101 | $(BUILD_DIR)boot_aplx.elf: boot_aplx.s $(BUILD_DIR)spinnaker.s $(BUILD_DIR)sark.s 102 | $(MKDIR) $(BUILD_DIR) 103 | $(AS) -I $(BUILD_DIR) boot_aplx.s -o $(BUILD_DIR)boot_aplx.o 104 | armlink --ro_base 0 -o $@ $(BUILD_DIR)boot_aplx.o 105 | endif 106 | 107 | # Convert h file to s 108 | $(BUILD_DIR)%.s: $(SPINN_INC_DIR)/%.h 109 | $(MKDIR) $(BUILD_DIR) 110 | $(MKDIR) $(BUILD_DIR) 111 | $(SPINN_TOOLS_DIR)/h2asm $< > $@ 112 | 113 | # Compile the interrupt service routines without THUMB 114 | $(BUILD_DIR)scamp-isr.o: scamp-isr.c $(SPINN_INC_DIR)/spinnaker.h $(SPINN_INC_DIR)/sark.h scamp.h 115 | $(CC_NO_THUMB) $(CFLAGS) scamp-isr.c -o $@ 116 | 117 | # Compile the delegation boot-image copy and execute routine without THUMB 118 | $(BUILD_DIR)scamp-del.o: scamp-del.c $(SPINN_INC_DIR)/spinnaker.h $(SPINN_INC_DIR)/sark.h scamp.h 119 | $(CC_NO_THUMB) $(CFLAGS) scamp-del.c -o $@ 120 | 121 | tar: 122 | tar -C .. -czf /tmp/scamp.tgz scamp/spinn_phy.c \ 123 | scamp/spinn_srom.c scamp/spinn_net.c scamp/scamp-app.c \ 124 | scamp/scamp-p2p.c scamp/scamp-nn.c scamp/scamp-cmd.c \ 125 | scamp/scamp-boot.c scamp/scamp-isr.c scamp/scamp-del.c scamp/spinn_phy.h \ 126 | scamp/scamp.h scamp/spinn_net.h scamp/spinn_regs.h \ 127 | scamp/boot_aplx.s scamp/$(APP).c scamp/$(APP).sct scamp/sark.c \ 128 | scamp/Makefile scamp/mkpad scamp/mksv scamp/$(APP).lnk scamp/boot.lnk 129 | 130 | clean: 131 | $(RM) -r $(BUILD_DIR)* $(APP).boot 132 | 133 | .PHONY: tar clean install install-aplx 134 | -------------------------------------------------------------------------------- /tools/arm2gas: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ##------------------------------------------------------------------------------ 4 | ## 5 | ## arm2gas Simplistic script to convert "armasm" source to GNU "as" 6 | ## 7 | ## Copyright (C) The University of Manchester - 2009-2013 8 | ## 9 | ## Author Steve Temple, APT Group, School of Computer Science 10 | ## Email temples@cs.man.ac.uk 11 | ## 12 | ##------------------------------------------------------------------------------ 13 | 14 | # Copyright (c) 2009 The University of Manchester 15 | # 16 | # Licensed under the Apache License, Version 2.0 (the "License"); 17 | # you may not use this file except in compliance with the License. 18 | # You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | 28 | # This program converts ARM assembly language source files into GNU "as" format. 29 | # Processor opcodes are not converted as both assemblers support the same 30 | # syntax. Assembler directives are converted but only a subset is currently 31 | # supported and new ones will have to be added as the need arises. Labels 32 | # and comments are converted as appropriate. 33 | # 34 | # The following conversions are currently done 35 | # 36 | # NAME equ VALUE .equ NAME, VALUE 37 | # area NAME, etc .section NAME, "ax" 38 | # export NAME .global NAME 39 | # import NAME .global NAME 40 | # dcd VALUES .word VALUES 41 | # dcw VALUES .short VALUES 42 | # dcb VALUES .byte VALUES 43 | # NAME1 rn NAME2 NAME1 .req NAME2 44 | # align VALUE .align VALUE 45 | # if :def: NAME .ifdef NAME 46 | # if :lnot: :def: NAME .ifndef NAME 47 | # else .else 48 | # endif .endif 49 | # macro .macro 50 | # mend .endm 51 | # code16 .thumb 52 | # code32 .arm 53 | # ltorg .ltorg 54 | # % VALUE .space VALUE 55 | # space VALUE .space VALUE 56 | # get FILE.s .include FILE.gas 57 | # NAME proc .type NAME STT_FUNC NAME: 58 | # end [ignored] 59 | # endp [ignored] 60 | # preserve8 [ignored] 61 | # entry [ignored] 62 | 63 | 64 | use strict; 65 | use warnings; 66 | 67 | my $space = " " x 16; 68 | my $macro = 0; 69 | 70 | while (<>) 71 | { 72 | my $comment = ""; 73 | my $label = ""; 74 | my $op = ""; 75 | my $rest = ""; 76 | 77 | chomp; 78 | 79 | if (s/\s*(;.*)$//) 80 | { 81 | $comment = $1; 82 | $comment =~ s/\s+$//; 83 | $comment =~ s/^;/@/; 84 | } 85 | 86 | if (s/^(\S+)\s*//) 87 | { 88 | $label = "$1:"; 89 | } 90 | 91 | if (s/^\s*(\S+)\s*//) 92 | { 93 | $op = lc $1; 94 | } 95 | 96 | if (s/(.+)//) 97 | { 98 | $rest = "$1 "; 99 | $rest =~ s/\s+$//; 100 | } 101 | 102 | $label = sprintf "%-15s ", $label; 103 | $op = sprintf "%-7s ", $op if $op ne ""; 104 | $rest = sprintf "%-23s ", $rest if $op ne "" && $comment ne ""; 105 | 106 | # print "/$label/$op/$rest/$comment\n"; 107 | 108 | if ($macro) 109 | { 110 | print "$space.macro $op$rest$comment\n"; 111 | $macro = 0; 112 | } 113 | elsif ($op eq 'area ') 114 | { 115 | $rest =~ s/\s*,.*//; # Lose all but first field 116 | $rest =~ s/\|//g; # Strip out "|" 117 | print "$space.section $rest, \"ax\"$comment\n"; 118 | } 119 | elsif ($op eq 'export ' || $op eq 'import ') 120 | { 121 | if ($rest =~ s/\s*\[weak\]//i) 122 | { 123 | print "$space.global $rest$comment\n"; 124 | print "$space.weak $rest\n"; 125 | } 126 | else 127 | { 128 | print "$space.global $rest$comment\n"; 129 | } 130 | } 131 | elsif ($op eq 'equ ') 132 | { 133 | $label =~ s/:\s*$//; 134 | print "$space.equ $label, $rest$comment\n"; 135 | } 136 | elsif ($op eq 'dcd ') 137 | { 138 | print "$label.word $rest$comment\n"; 139 | } 140 | elsif ($op eq 'dcw ') 141 | { 142 | print "$label.short $rest$comment\n"; 143 | } 144 | elsif ($op eq 'dcb ') 145 | { 146 | print "$label.byte $rest$comment\n"; 147 | } 148 | elsif ($op eq 'rn ') 149 | { 150 | $label =~ s/:/ /; 151 | print "$label.req $rest$comment\n"; 152 | } 153 | elsif ($op eq 'align ') 154 | { 155 | print "$label.balign $rest, 0 $comment\n"; 156 | } 157 | elsif ($op eq 'else ' || $op eq 'endif ') 158 | { 159 | print "$label.$op $rest$comment\n"; 160 | } 161 | elsif ($op eq 'mend ') 162 | { 163 | print "$label.endm $rest$comment\n"; 164 | } 165 | elsif ($op eq 'code16 ') 166 | { 167 | print "$label.thumb $rest$comment\n"; 168 | } 169 | elsif ($op eq 'code32 ') 170 | { 171 | print "$label.arm $rest$comment\n"; 172 | } 173 | elsif ($op eq 'ltorg ') 174 | { 175 | print "$label.ltorg $rest$comment\n"; 176 | } 177 | elsif ($op eq 'proc ') 178 | { 179 | my $l = $label; 180 | $l =~ s/:\s*//; 181 | print "$space.type $l, STT_FUNC $comment\n"; 182 | $label =~ s/\s*$//; 183 | print "$label\n"; 184 | } 185 | elsif ($op eq 'if ' && $rest =~ s/:lnot:\s*:def:\s*//i) 186 | { 187 | print "$label.ifndef $rest$comment\n"; 188 | } 189 | elsif ($op eq 'if ' && $rest =~ s/:def:\s*//i) 190 | { 191 | print "$label.ifdef $rest$comment\n"; 192 | } 193 | elsif ($op eq 'macro ') 194 | { 195 | $macro = 1; 196 | } 197 | elsif ($op eq '% ' || $op eq 'space ') 198 | { 199 | print "$label.space $rest$comment\n"; 200 | } 201 | elsif ($op eq 'get ') 202 | { 203 | $rest =~ s/\.s$//; 204 | print "$label.include \"$rest.gas\"$comment\n"; 205 | } 206 | elsif ($op eq 'end ' || $op eq 'endp ' || $op eq 'preserve8 ' || 207 | $op eq 'entry ') 208 | { 209 | #!! print "\@ $label$op$rest$comment\n"; 210 | } 211 | else 212 | { 213 | $label = "" if $label eq $space && $op eq ""; 214 | print "$label$op$rest$comment\n"; 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /docs/scp/cmd-ver.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5c 2 | Portrait 3 | Center 4 | Metric 5 | A4 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 11 | 9450 450 10350 450 10350 1125 9450 1125 12 | 2 1 1 2 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 13 | 8550 1125 9450 1125 14 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 15 | 8550 450 7650 450 7650 1125 8550 1125 16 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 17 | 1350 450 1350 1125 18 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 19 | 2250 450 2250 1125 20 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 21 | 4050 450 4050 1125 22 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 23 | 5850 450 5850 1125 24 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 25 | 450 450 7650 450 7650 1125 450 1125 450 450 26 | 2 1 1 2 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 27 | 8550 450 9450 450 28 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 29 | 2250 3780 2250 4455 30 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 31 | 1350 3780 1350 4455 32 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 33 | 4050 3780 4050 4455 34 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 35 | 9450 3780 10845 3780 10845 4455 9450 4455 36 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 37 | 9495 3780 7650 3780 7650 4455 9495 4455 38 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 39 | 450 3780 7650 3780 7650 4455 450 4455 450 3780 40 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 41 | 5850 3780 5850 4455 42 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 43 | 3150 4455 3150 3780 44 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 45 | 4950 4455 4950 3780 46 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 47 | 3600 4455 3600 3780 48 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 49 | 2250 2250 2250 2925 50 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 51 | 1350 2250 1350 2925 52 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 53 | 4050 2250 4050 2925 54 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 55 | 9450 2250 10350 2250 10350 2925 9450 2925 56 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 4 57 | 9540 2250 7650 2250 7650 2925 9495 2925 58 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5 59 | 450 2250 7650 2250 7650 2925 450 2925 450 2250 60 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 61 | 5850 2250 5850 2925 62 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 63 | 3150 2925 3150 2250 64 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 65 | 4950 2925 4950 2250 66 | 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 67 | 3600 2925 3600 2250 68 | 2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2 69 | 9360 3780 9360 4455 70 | 4 1 0 50 -1 18 10 0.0000 4 150 795 900 765 CMD_VER\001 71 | 4 1 0 50 -1 18 10 0.0000 4 150 210 900 990 (0)\001 72 | 4 1 0 50 -1 18 10 0.0000 4 120 1020 6750 855 \001 73 | 4 1 0 50 -1 18 10 0.0000 4 120 1020 4950 855 \001 74 | 4 1 0 50 -1 18 10 0.0000 4 120 1020 3150 855 \001 75 | 4 1 0 50 -1 18 10 0.0000 4 120 1020 9000 855 \001 76 | 4 1 0 50 -1 18 10 0.0000 4 150 525 1800 855 SeqNo\001 77 | 4 1 0 50 -1 18 10 0.0000 4 150 585 900 405 cmd_rc\001 78 | 4 1 0 50 -1 18 10 0.0000 4 120 285 1800 405 seq\001 79 | 4 1 0 50 -1 18 10 0.0000 4 150 345 3150 405 arg1\001 80 | 4 1 0 50 -1 18 10 0.0000 4 150 345 4950 405 arg2\001 81 | 4 1 0 50 -1 18 10 0.0000 4 150 345 6750 405 arg3\001 82 | 4 1 0 50 -1 18 10 0.0000 4 120 345 9000 405 data\001 83 | 4 1 0 50 -1 18 10 0.0000 4 150 570 900 1350 2 bytes\001 84 | 4 1 0 50 -1 18 10 0.0000 4 120 90 1800 1350 2\001 85 | 4 1 0 50 -1 18 10 0.0000 4 120 90 3150 1350 4\001 86 | 4 1 0 50 -1 18 10 0.0000 4 120 90 4950 1350 4\001 87 | 4 1 0 50 -1 18 10 0.0000 4 120 90 6750 1350 4\001 88 | 4 0 0 50 -1 18 12 0.0000 4 150 1635 0 135 Command Packet\001 89 | 4 1 0 50 -1 18 10 0.0000 4 120 810 6750 4185 Build date\001 90 | 4 1 0 50 -1 18 10 0.0000 4 150 525 1800 4185 SeqNo\001 91 | 4 1 0 50 -1 18 10 0.0000 4 150 585 900 4095 RC_OK\001 92 | 4 1 0 50 -1 18 10 0.0000 4 150 390 900 4320 (128)\001 93 | 4 1 0 50 -1 18 10 0.0000 4 120 300 2700 4095 P2P\001 94 | 4 1 0 50 -1 18 10 0.0000 4 150 390 3375 4095 Phys\001 95 | 4 1 0 50 -1 18 10 0.0000 4 120 270 3825 4095 Virt\001 96 | 4 1 0 50 -1 18 10 0.0000 4 120 495 5400 4095 Buffer\001 97 | 4 1 0 50 -1 18 10 0.0000 4 120 600 4545 4095 Version\001 98 | 4 1 0 50 -1 18 10 0.0000 4 120 330 5400 4320 Size\001 99 | 4 1 0 50 -1 18 10 0.0000 4 120 630 4545 4320 Number\001 100 | 4 1 0 50 -1 18 10 0.0000 4 120 345 3825 4320 CPU\001 101 | 4 1 0 50 -1 18 10 0.0000 4 120 345 3375 4320 CPU\001 102 | 4 1 0 50 -1 18 10 0.0000 4 120 390 2700 4320 Addr\001 103 | 4 1 0 50 -1 18 10 0.0000 4 150 585 900 3735 cmd_rc\001 104 | 4 1 0 50 -1 18 10 0.0000 4 120 285 1800 3735 seq\001 105 | 4 1 0 50 -1 18 10 0.0000 4 150 345 3150 3735 arg1\001 106 | 4 1 0 50 -1 18 10 0.0000 4 150 345 4950 3735 arg2\001 107 | 4 1 0 50 -1 18 10 0.0000 4 150 345 6750 3735 arg3\001 108 | 4 1 0 50 -1 18 10 0.0000 4 120 345 9000 3735 data\001 109 | 4 0 0 50 -1 18 12 0.0000 4 195 3060 0 3465 Response Packet (2.0.0 onwards)\001 110 | 4 1 0 50 -1 18 10 0.0000 4 120 810 6750 2655 Build date\001 111 | 4 1 0 50 -1 18 10 0.0000 4 150 525 1800 2655 SeqNo\001 112 | 4 1 0 50 -1 18 10 0.0000 4 150 585 900 2565 RC_OK\001 113 | 4 1 0 50 -1 18 10 0.0000 4 150 390 900 2790 (128)\001 114 | 4 1 0 50 -1 18 10 0.0000 4 150 1470 9000 2790 (NULL terminated)\001 115 | 4 1 0 50 -1 18 10 0.0000 4 120 300 2700 2565 P2P\001 116 | 4 1 0 50 -1 18 10 0.0000 4 150 390 3375 2565 Phys\001 117 | 4 1 0 50 -1 18 10 0.0000 4 120 270 3825 2565 Virt\001 118 | 4 1 0 50 -1 18 10 0.0000 4 120 495 5400 2565 Buffer\001 119 | 4 1 0 50 -1 18 10 0.0000 4 120 600 4545 2565 Version\001 120 | 4 1 0 50 -1 18 10 0.0000 4 120 330 5400 2790 Size\001 121 | 4 1 0 50 -1 18 10 0.0000 4 120 630 4545 2790 Number\001 122 | 4 1 0 50 -1 18 10 0.0000 4 120 345 3825 2790 CPU\001 123 | 4 1 0 50 -1 18 10 0.0000 4 120 345 3375 2790 CPU\001 124 | 4 1 0 50 -1 18 10 0.0000 4 120 390 2700 2790 Addr\001 125 | 4 1 0 50 -1 18 10 0.0000 4 150 585 900 2205 cmd_rc\001 126 | 4 1 0 50 -1 18 10 0.0000 4 120 285 1800 2205 seq\001 127 | 4 1 0 50 -1 18 10 0.0000 4 150 345 3150 2205 arg1\001 128 | 4 1 0 50 -1 18 10 0.0000 4 150 345 4950 2205 arg2\001 129 | 4 1 0 50 -1 18 10 0.0000 4 150 345 6750 2205 arg3\001 130 | 4 1 0 50 -1 18 10 0.0000 4 120 345 9000 2205 data\001 131 | 4 0 0 50 -1 18 12 0.0000 4 195 2565 0 1935 Response Packet (pre 2.0.0)\001 132 | 4 1 0 50 -1 18 10 0.0000 4 150 690 9000 2565 ID String\001 133 | 4 1 0 50 -1 18 10 0.0000 4 150 1125 10125 4185 Version String\001 134 | 4 1 0 50 -1 18 10 0.0000 4 150 690 8505 4185 ID String\001 135 | -------------------------------------------------------------------------------- /make/spinnaker_tools.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 The University of Manchester 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Common includes for making SpiNNaker binaries 16 | 17 | # Find where we are now so we can keep track of where things are now 18 | # Note this will move when this is "installed" (but that happens elsewhere) 19 | CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 20 | SPINNAKER_TOOLS_DIRS = $(abspath $(CURRENT_DIR)/..) 21 | 22 | # Set to 1 for GNU tools, 0 for ARM 23 | GNU := 1 24 | 25 | # Set to 1 if using SARK/API (0 for SARK) 26 | API := 1 27 | 28 | # Set to 1 to make Thumb code (0 for ARM) 29 | THUMB := 0 30 | 31 | # Set to 1 to include debug info in ELF file 32 | DEBUG := 1 33 | 34 | # Set to 1 if making a library (advanced!) 35 | LIB := 0 36 | 37 | # Prefix for GNU tool binaries 38 | GP := arm-none-eabi 39 | 40 | ifndef APP_OUTPUT_DIR 41 | APP_OUTPUT_DIR := ./ 42 | endif 43 | 44 | ifndef BUILD_DIR 45 | ifeq ($(GNU),1) 46 | BUILD_DIR := build/gnu/ 47 | else 48 | BUILD_DIR := build/arm/ 49 | endif 50 | endif 51 | 52 | ifeq ($(DEBUG),1) 53 | .SECONDARY: $(BUILD_DIR)$(APP).elf 54 | endif 55 | 56 | SPINN_LIB_DIR = $(SPINNAKER_TOOLS_DIRS)/lib 57 | SPINN_INC_DIR = $(SPINNAKER_TOOLS_DIRS)/include 58 | SPINN_TOOLS_DIR = $(SPINNAKER_TOOLS_DIRS)/tools 59 | 60 | # ------------------------------------------------------------------------------ 61 | # Tools 62 | 63 | ifeq ($(GNU),1) 64 | 65 | # GNU Compiler (gcc) settings 66 | AS := $(GP)-as --defsym GNU=1 -mthumb-interwork -march=armv5te 67 | CC_NO_THUMB := $(GP)-gcc -c -mthumb-interwork -march=armv5te -std=gnu99 -ffreestanding -I $(SPINN_INC_DIR) 68 | CXX_NO_THUMB := $(GP)-gcc -c -mthumb-interwork -march=armv5te -std=c++11 -ffreestanding -I $(SPINN_INC_DIR) -fno-rtti -fno-exceptions 69 | CC_THUMB := $(CC_NO_THUMB) -mthumb -DTHUMB 70 | CXX_THUMB := $(CXX_NO_THUMB) -mthumb -DTHUMB 71 | 72 | OSPACE := -Os 73 | OTIME := -Ofast 74 | ALL_WARNINGS := -Wall -Wextra 75 | 76 | LD_LNK := $(SPINN_TOOLS_DIR)/sark.lnk 77 | LD_FLAG := 78 | 79 | ifeq ($(LIB), 1) 80 | CFLAGS += -fdata-sections -ffunction-sections 81 | LD := $(GP)-ld -i 82 | else 83 | LD := $(GP)-gcc -T$(LD_LNK) -Wl,-e,cpu_reset -Wl,-static -ffreestanding -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--use-blx -nostartfiles -static 84 | LFLAGS += -L $(SPINN_LIB_DIR) 85 | endif 86 | 87 | AR := $(GP)-ar -rcs 88 | OC := $(GP)-objcopy 89 | OD := $(GP)-objdump -dxt > 90 | NM := $(GP)-nm 91 | SPINN_LIBS += $(SPINN_LIB_DIR)/libspin1_api.a 92 | 93 | else 94 | # ARM Compiler settings 95 | AS := armasm --keep --cpu=5te --apcs interwork 96 | CC_NO_THUMB := armcc -c --c99 --cpu=5te --apcs interwork --min_array_alignment=4 -I $(SPINN_INC_DIR) 97 | CXX_NO_THUMB := armcc -c --cpp11 --cpu=5te --apcs interwork --min_array_alignment=4 -I $(SPINN_INC_DIR) --no_rtti --no_exceptions 98 | CC_THUMB := $(CC_NO_THUMB) --thumb -DTHUMB 99 | CXX_THUMB := $(CXX_NO_THUMB) --thumb -DTHUMB 100 | 101 | OSPACE := -Ospace 102 | OTIME := -Otime 103 | ALL_WARNINGS := 104 | 105 | ifeq ($(LIB), 1) 106 | CFLAGS += --split_sections 107 | LD := armlink --partial 108 | else 109 | LD = armlink --scatter=$(SPINN_TOOLS_DIR)/sark.sct $(LD_FLAG) --remove --entry cpu_reset 110 | endif 111 | 112 | AR := armar -rsc 113 | OC := fromelf 114 | OD := fromelf -cds --output 115 | NM := nm 116 | SPINN_LIBS += $(SPINN_LIB_DIR)/spin1_api.a 117 | endif 118 | 119 | RM := rm -f 120 | RMDIR := rmdir 121 | CAT := cat 122 | LS := ls -l 123 | MKDIR := mkdir -p 124 | CP := cp 125 | MV := mv 126 | INSTALL := install 127 | 128 | ifeq ($(THUMB),1) 129 | CC := $(CC_THUMB) 130 | CXX := $(CXX_THUMB) 131 | else 132 | CC := $(CC_NO_THUMB) 133 | CXX := $(CXX_NO_THUMB) 134 | endif 135 | 136 | ifeq ($(DEBUG),1) 137 | CFLAGS += -g 138 | AFLAGS += -g 139 | endif 140 | 141 | 142 | # Primary target is an APLX file - built from the ELF 143 | # 1) Make an APLX header from the ELF file with "mkaplx" and concatenate 144 | # that with the binary to make the APLX file 145 | # 2) "ls" the APLX file 146 | $(APP_OUTPUT_DIR)%.aplx: $(BUILD_DIR)%.bin $(BUILD_DIR)%.nm 147 | $(MKDIR) $(APP_OUTPUT_DIR) 148 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB $(SPINN_TOOLS_DIR)/mkaplx $(BUILD_DIR)$*.nm | $(CAT) - $(BUILD_DIR)$*.bin > $@ 149 | 150 | # Create a list of the objects in the file using nm 151 | $(BUILD_DIR)%.nm: $(BUILD_DIR)%.elf 152 | $(NM) $< > $@ 153 | 154 | # Create a binary file which is the concatenation of RO and RW sections 155 | $(BUILD_DIR)%.bin: $(BUILD_DIR)%.elf 156 | ifeq ($(GNU),1) 157 | $(OC) -O binary -j RO_DATA -j EX_DATA $< $(BUILD_DIR)RO_DATA.bin 158 | $(OC) -O binary -j RW_DATA $< $(BUILD_DIR)RW_DATA.bin 159 | ls -l $(BUILD_DIR)RO_DATA.bin 160 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB $(SPINN_TOOLS_DIR)/mkbin $(BUILD_DIR)RO_DATA.bin $(BUILD_DIR)RW_DATA.bin > $@ 161 | $(RM) $(BUILD_DIR)RO_DATA.bin $(BUILD_DIR)RW_DATA.bin 162 | else 163 | $(OC) --bin --output $@ $< 164 | endif 165 | 166 | # Build the ELF file 167 | # 1) Link application object(s), build file and library to make the ELF 168 | # 2) Create a list file 169 | $(BUILD_DIR)%.elf: $(OBJECTS) $(BUILD_DIR)%_build.o 170 | # spinnaker_tools.mk elf 171 | $(LD) $(LFLAGS) $(OBJECTS) $(BUILD_DIR)$*_build.o $(LIBS) $(SPINN_LIBS) -o $@ 172 | $(OD) $(BUILD_DIR)$*.txt $@ 173 | 174 | # Build sark_build.o 175 | $(BUILD_DIR)%_build.c: 176 | $(MKDIR) $(BUILD_DIR) 177 | PERL5LIB=$(SPINN_TOOLS_DIR):$$PERL5LIB $(SPINN_TOOLS_DIR)/mkbuild $* > $@ 178 | 179 | $(BUILD_DIR)%.o: %.c 180 | # spinnaker_tools.mk c 181 | $(MKDIR) $(BUILD_DIR) 182 | $(CC) $(CFLAGS) -o $@ $< 183 | 184 | $(BUILD_DIR)%.o: %.cpp 185 | # spinnaker_tools.mk cpp 186 | $(MKDIR) $(BUILD_DIR) 187 | $(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ $< 188 | -------------------------------------------------------------------------------- /bmp/lpc_types.h: -------------------------------------------------------------------------------- 1 | /***********************************************************************//** 2 | * @file lpc_types.h 3 | * @brief Contains the NXP ABL typedefs for C standard types. 4 | * It is intended to be used in ISO C conforming development 5 | * environments and checks for this insofar as it is possible 6 | * to do so. 7 | * @version 1.0 8 | * @date 27 Jul. 2008 9 | * @author wellsk 10 | ************************************************************************** 11 | * Software that is described herein is for illustrative purposes only 12 | * which provides customers with programming information regarding the 13 | * products. This software is supplied "AS IS" without any warranties. 14 | * NXP Semiconductors assumes no responsibility or liability for the 15 | * use of the software, conveys no license or title under any patent, 16 | * copyright, or mask work right to the product. NXP Semiconductors 17 | * reserves the right to make changes in the software without 18 | * notification. NXP Semiconductors also make no representation or 19 | * warranty that such application will be suitable for the specified 20 | * use without further testing or modification. 21 | **************************************************************************/ 22 | 23 | /* Type group ----------------------------------------------------------- */ 24 | /** @defgroup LPC_Types LPC_Types 25 | * @ingroup LPC1700CMSIS_FwLib_Drivers 26 | * @{ 27 | */ 28 | 29 | #ifndef LPC_TYPES_H 30 | #define LPC_TYPES_H 31 | 32 | /* Includes ------------------------------------------------------------------- */ 33 | #include 34 | 35 | 36 | /* Public Types --------------------------------------------------------------- */ 37 | /** @defgroup LPC_Types_Public_Types LPC_Types Public Types 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief Boolean Type definition 43 | */ 44 | typedef enum { 45 | FALSE = 0, 46 | TRUE = !FALSE 47 | } Bool; 48 | 49 | /** 50 | * @brief Flag Status and Interrupt Flag Status type definition 51 | */ 52 | typedef enum { 53 | RESET = 0, SET = !RESET 54 | } FlagStatus, IntStatus, SetState; 55 | #define PARAM_SETSTATE(State) ((State==RESET) || (State==SET)) 56 | 57 | /** 58 | * @brief Functional State Definition 59 | */ 60 | typedef enum { 61 | DISABLE = 0, 62 | ENABLE = !DISABLE 63 | } FunctionalState; 64 | #define PARAM_FUNCTIONALSTATE(State) ((State==DISABLE) || (State==ENABLE)) 65 | 66 | /** 67 | * @ Status type definition 68 | */ 69 | typedef enum { 70 | ERROR = 0, 71 | SUCCESS = !ERROR 72 | } Status; 73 | 74 | 75 | /** 76 | * Read/Write transfer type mode (Block or non-block) 77 | */ 78 | typedef enum { 79 | NONE_BLOCKING = 0, /**< None Blocking type */ 80 | BLOCKING, /**< Blocking type */ 81 | } TRANSFER_BLOCK_Type; 82 | 83 | 84 | /** Pointer to Function returning Void (any number of parameters) */ 85 | typedef void (*PFV)(); 86 | 87 | /** Pointer to Function returning int32_t (any number of parameters) */ 88 | typedef int32_t(*PFI)(); 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | 95 | /* Public Macros -------------------------------------------------------------- */ 96 | /** @defgroup LPC_Types_Public_Macros LPC_Types Public Macros 97 | * @{ 98 | */ 99 | 100 | /* _BIT(n) sets the bit at position "n" 101 | * _BIT(n) is intended to be used in "OR" and "AND" expressions: 102 | * e.g., "(_BIT(3) | _BIT(7))". 103 | */ 104 | #undef _BIT 105 | /* Set bit macro */ 106 | #define _BIT(n) (1< = (any_expression) & _BITMASK(x), where 0 < x <= 32. 122 | * If "any_expression" results in a value that is larger than can be 123 | * contained in 'x' bits, the bits above 'x - 1' are masked off. When 124 | * used with the _SBF example above, the example would be written: 125 | * a_reg = ((_SBF(5,7) | _SBF(12,0xF)) & _BITMASK(16)) 126 | * This ensures that the value written to a_reg is no wider than 127 | * 16 bits, and makes the code easier to read and understand. 128 | */ 129 | #undef _BITMASK 130 | /* Bitmask creation macro */ 131 | #define _BITMASK(field_width) (_BIT(field_width) - 1) 132 | 133 | /* NULL pointer */ 134 | #ifndef NULL 135 | #define NULL ((void*) 0) 136 | #endif 137 | 138 | /* Number of elements in an array */ 139 | #define NELEMENTS(array) (sizeof(array) / sizeof(array[0])) 140 | 141 | #define STATIC static /* Static data/function define */ 142 | #define EXTERN extern /* External data/function define */ 143 | 144 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 145 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 146 | 147 | /** 148 | * @} 149 | */ 150 | 151 | 152 | /* Old Type Definition compatibility ------------------------------------------ */ 153 | /** @addtogroup LPC_Types_Public_Types LPC_Types Public Types 154 | * @{ 155 | */ 156 | 157 | /** SMA type for character type */ 158 | typedef char CHAR; 159 | 160 | /** SMA type for 8 bit unsigned value */ 161 | typedef uint8_t UNS_8; 162 | 163 | /** SMA type for 8 bit signed value */ 164 | typedef int8_t INT_8; 165 | 166 | /** SMA type for 16 bit unsigned value */ 167 | typedef uint16_t UNS_16; 168 | 169 | /** SMA type for 16 bit signed value */ 170 | typedef int16_t INT_16; 171 | 172 | /** SMA type for 32 bit unsigned value */ 173 | typedef uint32_t UNS_32; 174 | 175 | /** SMA type for 32 bit signed value */ 176 | typedef int32_t INT_32; 177 | 178 | /** SMA type for 64 bit signed value */ 179 | typedef int64_t INT_64; 180 | 181 | /** SMA type for 64 bit unsigned value */ 182 | typedef uint64_t UNS_64; 183 | 184 | /** 32 bit boolean type */ 185 | typedef Bool BOOL_32; 186 | 187 | /** 16 bit boolean type */ 188 | typedef Bool BOOL_16; 189 | 190 | /** 8 bit boolean type */ 191 | typedef Bool BOOL_8; 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | 198 | #endif /* LPC_TYPES_H */ 199 | 200 | /** 201 | * @} 202 | */ 203 | 204 | /* --------------------------------- End Of File ------------------------------ */ 205 | -------------------------------------------------------------------------------- /bmp/bmp_crc.c: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | //! \file bmp_crc.c 4 | //! \brief CRC32 routines for BMP LPC1768 5 | //! 6 | //! \author Steve Temple, APT Group, School of Computer Science 7 | // Email steven.temple@manchester.ac.uk 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | /* 12 | * Copyright (c) 2012 The University of Manchester 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); 15 | * you may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * https://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | #include 28 | 29 | #ifdef TEST 30 | #include 31 | #endif 32 | 33 | //! CRC constants, precomputed from CRC polynomial 34 | const uint32_t crc_table[] = { 35 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 36 | 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 37 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 38 | 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 39 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 40 | 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 41 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 42 | 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 43 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 44 | 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 45 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 46 | 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 47 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 48 | 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 49 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 50 | 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 51 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 52 | 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 53 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 54 | 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 55 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 56 | 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 57 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 58 | 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 59 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 60 | 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 61 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 62 | 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 63 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 64 | 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 65 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 66 | 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 67 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 68 | 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 69 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 70 | 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 71 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 72 | 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 73 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 74 | 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 75 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 76 | 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 77 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 78 | }; 79 | 80 | 81 | //! \brief Compute CRC32 for a buffer of given length. 82 | //! \param[in] buf: the data to compute the CRC of 83 | //! \param[in] len: number of bytes in \p buf 84 | //! \param[in] crc: can be 0xffffffff to start checking, or result of a 85 | //! previous call. 86 | //! \return The final result needs to be inverted to produce valid CRC32. 87 | 88 | uint32_t crc32(void *buf, uint32_t len, uint32_t crc) 89 | { 90 | uint8_t *buffer = (uint8_t *) buf; 91 | 92 | for (int32_t i = 0; i < len; i++) { 93 | crc = crc_table[(crc ^ (*buffer++)) & 0xff] ^ (crc >> 8); 94 | } 95 | return crc; 96 | } 97 | 98 | 99 | //! \brief Compute the CRC of a buffer 100 | //! \param[in] buf: the data to compute the CRC of 101 | //! \param[in] len: number of bytes in \p buf 102 | //! \return The CRC of the buffer 103 | uint32_t crc32_chk(void *buf, uint32_t len) 104 | { 105 | uint8_t *buffer = (uint8_t *) buf; 106 | uint32_t crc = 0xffffffff; 107 | 108 | while (len--) { 109 | crc = crc_table[(crc ^ (*buffer++)) & 0xff] ^ (crc >> 8); 110 | } 111 | return crc; 112 | } 113 | 114 | 115 | //! \brief Compute and insert CRC32 of a buffer where the CRC is placed in 116 | //! the last 4 bytes 117 | //! \param[in] buf: the data to compute the CRC of 118 | //! \param[in] len: number of bytes in \p buf 119 | void crc32_buf(void *buf, uint32_t len) 120 | { 121 | uint8_t *buffer = (uint8_t *) buf; 122 | uint32_t crc = 0xffffffff; 123 | 124 | while (len > 4) { 125 | crc = crc_table[(crc ^ (*buffer++)) & 0xff] ^ (crc >> 8); 126 | len--; 127 | } 128 | 129 | while (len--) { 130 | *buffer++ = crc; 131 | crc = crc >> 8; 132 | } 133 | } 134 | 135 | 136 | #ifdef TEST 137 | 138 | uint8_t buf[4096]; 139 | 140 | int main(void) 141 | { 142 | uint32_t crc = 0xffffffff; 143 | uint32_t count = 0; 144 | 145 | for (int i = 0; i < 4096; i++) { 146 | buf[i] = 0xff; 147 | } 148 | crc32_insert(buf, 4096); 149 | fwrite(buf, 1, 4096, stdout); 150 | 151 | while (1) { 152 | uint32_t r = fread(buf, 1, 4096, stdin); 153 | if (r == 0) { 154 | break; 155 | } 156 | count++; 157 | crc = crc32(buf, r, crc); 158 | } 159 | 160 | fprintf(stderr, "CRC32 %08x (%d)\n", crc, count); 161 | } 162 | #endif 163 | --------------------------------------------------------------------------------