diff --git a/adcs/README.org b/adcs/README.org new file mode 100644 index 00000000..aa9f07c7 --- /dev/null +++ b/adcs/README.org @@ -0,0 +1,239 @@ +#+title: SC-Sat1 ADCS board Flight Softrare + + This is for SC-Sat1 ADCS board Flight Softrare + +* Software + Flight Software for SC-Sat1 ADCS board is based on [[https://zephyrproject.org/][Zephyr + RTOS]]. This repository can be use as a Zephyr application + repository -- aka. T2 star topology. + +** Requirements + - Zephyr 3.4 + +** Setting up a Build Environment + #+begin_example + mkdir workspace + cd workspace + git clone https://github.com/spacecubics/scsat1-fsw.git + pip install west + west init -l scsat1-fsw + west update + pip install -r zephyr/scripts/requirements-base.txt + #+end_example + +** How to build + + Here is an instraction to build the flight software. This instruction + uses "scsat1_adcs" as the target board. + + #+begin_example + cd workspace/scsat1-fsw/adcs/ + rm -rf build && west build -b scsat1_adcs + #+end_example + +** How to program + + Currently This code is enough size to running on ITCM on 128 KB ITCM. But if + your code will larger than 128 KB, you need to switch to HREM with below. + And first flash will always fail for a known limitation, need a retry. + + #+begin_example + west flash --cmd-pre-load 'mww 0x4f000000 0x5a5a0000' + west flash --cmd-pre-load 'mww 0x4f000000 0x5a5a0000' + #+end_example + +** How to run the ztest + + This software support the CAN driver, and ztest already prepare the CAN + driver test code. + If you want to run the test code, please build the ztest program with below. + + #+begin_example + cd workspace/ + rm -rf build && west build -b scsat1_adcs zephyr/tests/drivers/can/api/ -- -DBOARD_ROOT=${PWD}/scsat1-fsw/ + #+end_example + + And then you can run the ztest for CAN driver. + + #+begin_example + west flash --cmd-pre-load 'mww 0x4f000000 0x5a5a0000' + west flash --cmd-pre-load 'mww 0x4f000000 0x5a5a0000' + *** Booting Zephyr OS build zephyr-v3.4.0-1430-g0bfe3cc2d051 *** + Running TESTSUITE can_classic + =================================================================== + START - test_add_filter + PASS - test_add_filter in 0.006 seconds + =================================================================== + START - test_filters_added_while_stopped + PASS - test_filters_added_while_stopped in 0.002 seconds + =================================================================== + START - test_filters_preserved_through_bitrate_change + PASS - test_filters_preserved_through_bitrate_change in 0.004 seconds + =================================================================== + START - test_filters_preserved_through_mode_change + PASS - test_filters_preserved_through_mode_change in 0.004 seconds + =================================================================== + START - test_get_capabilities + PASS - test_get_capabilities in 0.001 seconds + =================================================================== + START - test_get_core_clock + PASS - test_get_core_clock in 0.001 seconds + =================================================================== + START - test_get_state + PASS - test_get_state in 0.001 seconds + =================================================================== + START - test_max_ext_filters + E: No free filter left + PASS - test_max_ext_filters in 0.005 seconds + =================================================================== + START - test_max_std_filters + E: No free filter left + PASS - test_max_std_filters in 0.005 seconds + =================================================================== + START - test_receive_timeout + PASS - test_receive_timeout in 0.102 seconds + =================================================================== + START - test_recover + PASS - test_recover in 0.001 seconds + =================================================================== + START - test_recover_while_stopped + PASS - test_recover_while_stopped in 0.001 seconds + =================================================================== + START - test_send_and_forget + PASS - test_send_and_forget in 0.002 seconds + =================================================================== + START - test_send_callback + PASS - test_send_callback in 0.002 seconds + =================================================================== + START - test_send_fd_format + E: unsupported CAN frame flags 0x04 + PASS - test_send_fd_format in 0.004 seconds + =================================================================== + START - test_send_invalid_dlc + E: DLC of 9 exceeds maximum (8) + PASS - test_send_invalid_dlc in 0.004 seconds + =================================================================== + START - test_send_receive_ext_id + PASS - test_send_receive_ext_id in 0.007 seconds + =================================================================== + START - test_send_receive_ext_id_masked + PASS - test_send_receive_ext_id_masked in 0.007 seconds + =================================================================== + START - test_send_receive_ext_id_rtr + PASS - test_send_receive_ext_id_rtr in 0.207 seconds + =================================================================== + START - test_send_receive_msgq + PASS - test_send_receive_msgq in 0.014 seconds + =================================================================== + START - test_send_receive_std_id + PASS - test_send_receive_std_id in 0.006 seconds + =================================================================== + START - test_send_receive_std_id_masked + PASS - test_send_receive_std_id_masked in 0.006 seconds + =================================================================== + START - test_send_receive_std_id_rtr + PASS - test_send_receive_std_id_rtr in 0.206 seconds + =================================================================== + START - test_send_receive_wrong_id + PASS - test_send_receive_wrong_id in 0.103 seconds + =================================================================== + START - test_send_while_stopped + PASS - test_send_while_stopped in 0.001 seconds + =================================================================== + START - test_set_bitrate + PASS - test_set_bitrate in 0.001 seconds + =================================================================== + START - test_set_bitrate_too_high + PASS - test_set_bitrate_too_high in 0.001 seconds + =================================================================== + START - test_set_bitrate_while_started + E: Failed to set timing because enabled CAN + PASS - test_set_bitrate_while_started in 0.005 seconds + =================================================================== + START - test_set_mode_while_started + PASS - test_set_mode_while_started in 0.001 seconds + =================================================================== + START - test_set_state_change_callback + PASS - test_set_state_change_callback in 0.001 seconds + =================================================================== + START - test_set_timing_while_started + E: Failed to set timing because enabled CAN + PASS - test_set_timing_while_started in 0.005 seconds + =================================================================== + START - test_start_while_started + PASS - test_start_while_started in 0.001 seconds + =================================================================== + START - test_stop_while_stopped + PASS - test_stop_while_stopped in 0.001 seconds + =================================================================== + TESTSUITE can_classic succeeded + Running TESTSUITE can_utilities + =================================================================== + START - test_can_bytes_to_dlc + PASS - test_can_bytes_to_dlc in 0.001 seconds + =================================================================== + START - test_can_dlc_to_bytes + PASS - test_can_dlc_to_bytes in 0.001 seconds + =================================================================== + START - test_can_frame_matches_filter + PASS - test_can_frame_matches_filter in 0.001 seconds + =================================================================== + TESTSUITE can_utilities succeeded + + ------ TESTSUITE SUMMARY START ------ + + SUITE PASS - 100.00% [can_classic]: pass = 33, fail = 0, skip = 0, total = 33 duration = 0.718 seconds + - PASS - [can_classic.test_add_filter] duration = 0.006 seconds + - PASS - [can_classic.test_filters_added_while_stopped] duration = 0.002 seconds + - PASS - [can_classic.test_filters_preserved_through_bitrate_change] duration = 0.004 seconds + - PASS - [can_classic.test_filters_preserved_through_mode_change] duration = 0.004 seconds + - PASS - [can_classic.test_get_capabilities] duration = 0.001 seconds + - PASS - [can_classic.test_get_core_clock] duration = 0.001 seconds + - PASS - [can_classic.test_get_state] duration = 0.001 seconds + - PASS - [can_classic.test_max_ext_filters] duration = 0.005 seconds + - PASS - [can_classic.test_max_std_filters] duration = 0.005 seconds + - PASS - [can_classic.test_receive_timeout] duration = 0.102 seconds + - PASS - [can_classic.test_recover] duration = 0.001 seconds + - PASS - [can_classic.test_recover_while_stopped] duration = 0.001 seconds + - PASS - [can_classic.test_send_and_forget] duration = 0.002 seconds + - PASS - [can_classic.test_send_callback] duration = 0.002 seconds + - PASS - [can_classic.test_send_fd_format] duration = 0.004 seconds + - PASS - [can_classic.test_send_invalid_dlc] duration = 0.004 seconds + - PASS - [can_classic.test_send_receive_ext_id] duration = 0.007 seconds + - PASS - [can_classic.test_send_receive_ext_id_masked] duration = 0.007 seconds + - PASS - [can_classic.test_send_receive_ext_id_rtr] duration = 0.207 seconds + - PASS - [can_classic.test_send_receive_msgq] duration = 0.014 seconds + - PASS - [can_classic.test_send_receive_std_id] duration = 0.006 seconds + - PASS - [can_classic.test_send_receive_std_id_masked] duration = 0.006 seconds + - PASS - [can_classic.test_send_receive_std_id_rtr] duration = 0.206 seconds + - PASS - [can_classic.test_send_receive_wrong_id] duration = 0.103 seconds + - PASS - [can_classic.test_send_while_stopped] duration = 0.001 seconds + - PASS - [can_classic.test_set_bitrate] duration = 0.001 seconds + - PASS - [can_classic.test_set_bitrate_too_high] duration = 0.001 seconds + - PASS - [can_classic.test_set_bitrate_while_started] duration = 0.005 seconds + - PASS - [can_classic.test_set_mode_while_started] duration = 0.001 seconds + - PASS - [can_classic.test_set_state_change_callback] duration = 0.001 seconds + - PASS - [can_classic.test_set_timing_while_started] duration = 0.005 seconds + - PASS - [can_classic.test_start_while_started] duration = 0.001 seconds + - PASS - [can_classic.test_stop_while_stopped] duration = 0.001 seconds + + SUITE PASS - 100.00% [can_utilities]: pass = 3, fail = 0, skip = 0, total = 3 duration = 0.003 seconds + - PASS - [can_utilities.test_can_bytes_to_dlc] duration = 0.001 seconds + - PASS - [can_utilities.test_can_dlc_to_bytes] duration = 0.001 seconds + - PASS - [can_utilities.test_can_frame_matches_filter] duration = 0.001 seconds + + SUITE SKIP - 0.00% [canfd]: pass = 0, fail = 0, skip = 8, total = 8 duration = 0.000 seconds + - SKIP - [canfd.test_filters_preserved_through_classic_to_fd_mode_change] duration = 0.000 seconds + - SKIP - [canfd.test_filters_preserved_through_fd_to_classic_mode_change] duration = 0.000 seconds + - SKIP - [canfd.test_get_capabilities] duration = 0.000 seconds + - SKIP - [canfd.test_send_receive_classic] duration = 0.000 seconds + - SKIP - [canfd.test_send_receive_fd] duration = 0.000 seconds + - SKIP - [canfd.test_send_receive_mixed] duration = 0.000 seconds + - SKIP - [canfd.test_set_bitrate_data_while_started] duration = 0.000 seconds + - SKIP - [canfd.test_set_timing_data_while_started] duration = 0.000 seconds + + ------ TESTSUITE SUMMARY END ------ + + =================================================================== + PROJECT EXECUTION SUCCESSFUL + #+end_example diff --git a/adcs/app.overlay b/adcs/app.overlay deleted file mode 100644 index 33ab5b6b..00000000 --- a/adcs/app.overlay +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -/delete-node/ &uartlite0; - -/ { - soc { - uartlite0: uartlite@4f010000 { - compatible = "xlnx,xps-uartlite-1.00.a"; - interrupts = <0 0>; - reg = <0x4f010000 0x10000>; - }; - }; -}; diff --git a/adcs/prj.conf b/adcs/prj.conf index aff4dcdb..a3fbd878 100644 --- a/adcs/prj.conf +++ b/adcs/prj.conf @@ -1,2 +1,4 @@ CONFIG_LIBCSP=y CONFIG_PICOLIBC=y +CONFIG_CAN=y +CONFIG_LOG=y diff --git a/boards/arm/scsat1_adcs/Kconfig.board b/boards/arm/scsat1_adcs/Kconfig.board new file mode 100644 index 00000000..92f0ecdd --- /dev/null +++ b/boards/arm/scsat1_adcs/Kconfig.board @@ -0,0 +1,8 @@ +# SC-Sat1 ADCS Board configuration + +# Copyright (c) 2023 Space Cubics, LLC. +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_SCSAT1_ADCS + bool "SC-Sat1 ADCS Board" + depends on SOC_SERIES_ARM_DESIGNSTART diff --git a/boards/arm/scsat1_adcs/Kconfig.defconfig b/boards/arm/scsat1_adcs/Kconfig.defconfig new file mode 100644 index 00000000..0e127782 --- /dev/null +++ b/boards/arm/scsat1_adcs/Kconfig.defconfig @@ -0,0 +1,20 @@ +# SC-Sat1 ADCS Board + +# Copyright (c) 2023 Space Cubics,LLC +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_SCSAT1_ADCS + +config BOARD + default "scsat1_adcs" + +config CPU_CORTEX_M_HAS_SYSTICK + default y + +config CPU_HAS_ARM_MPU + default y + +config NUM_IRQS + default 32 + +endif # BOARD_SCSAT1_ADCS diff --git a/boards/arm/scsat1_adcs/board.cmake b/boards/arm/scsat1_adcs/board.cmake new file mode 100644 index 00000000..02694994 --- /dev/null +++ b/boards/arm/scsat1_adcs/board.cmake @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_BOARD_SCSAT1_ADCS) + board_runner_args(openocd "--use-elf" "--config=${BOARD_DIR}/support/openocd-ftdi.cfg") + + include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +endif() diff --git a/boards/arm/scsat1_adcs/dts/bindings/sc,hrmem.yaml b/boards/arm/scsat1_adcs/dts/bindings/sc,hrmem.yaml new file mode 100644 index 00000000..59cf87ff --- /dev/null +++ b/boards/arm/scsat1_adcs/dts/bindings/sc,hrmem.yaml @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: Apache-2.0 + +description: Space Cubics HRMEM (High-reliability Memory) + +compatible: "sc,hrmem" + +include: base.yaml + +properties: + reg: + required: true diff --git a/boards/arm/scsat1_adcs/scsat1_adcs.dts b/boards/arm/scsat1_adcs/scsat1_adcs.dts new file mode 100644 index 00000000..2f6b9d27 --- /dev/null +++ b/boards/arm/scsat1_adcs/scsat1_adcs.dts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Space Cubics, LLC. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include + +/ { + model = "Space Cubics Satellite 1 ADCS Board"; + + chosen { + zephyr,console = &uartlite0; + zephyr,shell-uart = &uartlite0; + zephyr,sram = &hrmem; + zephyr,canbus = &can0; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-m3"; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + + mpu: mpu@e000ed90 { + compatible = "arm,armv7m-mpu"; + reg = <0xe000ed90 0x40>; + arm,num-mpu-regions = <8>; + }; + }; + }; + + soc { + hrmem: memory@0 { + compatible = "sc,hrmem"; + reg = <0x00000000 DT_SIZE_M(4)>; + }; + + uartlite0: uartlite@4f010000 { + compatible = "xlnx,xps-uartlite-1.00.a"; + interrupts = <0 0>; + reg = <0x4f010000 0x10000>; + }; + + can0: can@40400000 { + compatible = "sc,can"; + clock-frequency = <24000000>; + interrupts = <5 0>; + reg = <0x40400000 0x10000>; + bus-speed = <1000000>; + sjw = <4>; + sample-point = <750>; + tx-fifo-depth = <64>; + max-filter = <4>; + + can-transceiver { + max-bitrate = <1000000>; + }; + }; + }; +}; + +&nvic { + arm,num-irq-priority-bits = <3>; +}; diff --git a/boards/arm/scsat1_adcs/scsat1_adcs.yaml b/boards/arm/scsat1_adcs/scsat1_adcs.yaml new file mode 100644 index 00000000..66c5b299 --- /dev/null +++ b/boards/arm/scsat1_adcs/scsat1_adcs.yaml @@ -0,0 +1,9 @@ +identifier: scsat1_adcs +name: SC-Sat1 ADCS Board +type: mcu +arch: arm +toolchain: + - zephyr +supported: + - uart + - can diff --git a/boards/arm/scsat1_adcs/scsat1_adcs_defconfig b/boards/arm/scsat1_adcs/scsat1_adcs_defconfig new file mode 100644 index 00000000..fcbe374b --- /dev/null +++ b/boards/arm/scsat1_adcs/scsat1_adcs_defconfig @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_ARM_DESIGNSTART=y +CONFIG_SOC_ARM_DESIGNSTART_FPGA_CORTEX_M3=y +CONFIG_BOARD_SCSAT1_ADCS=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000 +CONFIG_ARM_MPU=n + +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_XIP=n +CONFIG_FLASH_SIZE=0 +CONFIG_FLASH_BASE_ADDRESS=0x0 +CONFIG_BOOTLOADER_SRAM_SIZE=0 diff --git a/boards/arm/scsat1_adcs/support/akizuki-m-02990.cfg b/boards/arm/scsat1_adcs/support/akizuki-m-02990.cfg new file mode 100644 index 00000000..cadf916d --- /dev/null +++ b/boards/arm/scsat1_adcs/support/akizuki-m-02990.cfg @@ -0,0 +1,12 @@ +# +# Akizuki Denshi FT2232D Module (M-02990) +# +# https://akizukidenshi.com/catalog/g/gM-02990/ +# + +adapter driver ftdi +ftdi device_desc "Dual RS232" +ftdi vid_pid 0x0403 0x6010 + +# Every pin set as high impedance except TCK, TDI, TDO and TMS +ftdi layout_init 0x0008 0x000b diff --git a/boards/arm/scsat1_adcs/support/openocd-ft232r.cfg b/boards/arm/scsat1_adcs/support/openocd-ft232r.cfg new file mode 100644 index 00000000..ccdcd2b6 --- /dev/null +++ b/boards/arm/scsat1_adcs/support/openocd-ft232r.cfg @@ -0,0 +1,2 @@ +source [find interface/ft232r.cfg] +source [find scobc-module1.cfg] diff --git a/boards/arm/scsat1_adcs/support/openocd-ftdi.cfg b/boards/arm/scsat1_adcs/support/openocd-ftdi.cfg new file mode 100644 index 00000000..14d6ef55 --- /dev/null +++ b/boards/arm/scsat1_adcs/support/openocd-ftdi.cfg @@ -0,0 +1,3 @@ +source [find akizuki-m-02990.cfg] +adapter speed 2000 +source [find scobc-module1.cfg] diff --git a/boards/arm/scsat1_adcs/support/openocd.cfg b/boards/arm/scsat1_adcs/support/openocd.cfg new file mode 100644 index 00000000..bfd27c5b --- /dev/null +++ b/boards/arm/scsat1_adcs/support/openocd.cfg @@ -0,0 +1,21 @@ +source [find interface/cmsis-dap.cfg] +transport select swd +source [find target/swj-dp.tcl] + +adapter speed 5000 + +set _CHIPNAME cortex_m3 +set _ENDIAN little +set _WORKAREASIZE 0x4000 +set _CPUTAPID 0x412FC231 + +swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID +dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap +$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0 + +if {![using_hla]} { + cortex_m reset_config sysresetreq +} diff --git a/boards/arm/scsat1_adcs/support/scobc-module1.cfg b/boards/arm/scsat1_adcs/support/scobc-module1.cfg new file mode 100644 index 00000000..aad20e5e --- /dev/null +++ b/boards/arm/scsat1_adcs/support/scobc-module1.cfg @@ -0,0 +1,31 @@ +# Copyright (C) 2021 Space Cubics, LLC. +# Yasushi SHOJI + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME cortex_m3 +} + +if { [info exists CPUTAPID ] } { + set _CPUTAPID $CPUTAPID +} else { + set _CPUTAPID 0x4ba00477 +} + +if { [info exists WORKAREASIZE] } { + set _WORKAREASIZE $WORKAREASIZE +} else { + set _WORKAREASIZE 0x4000 +} + +jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID +dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap +$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0 + +if {![using_hla]} { + cortex_m reset_config sysresetreq +}