diff --git a/deploy/roles/sheep/tasks/build_shp.yml b/deploy/roles/sheep/tasks/build_shp.yml index afc90d7c..a64ff709 100644 --- a/deploy/roles/sheep/tasks/build_shp.yml +++ b/deploy/roles/sheep/tasks/build_shp.yml @@ -16,7 +16,6 @@ - pru0-shepherd-fw - pru1-shepherd-fw - pru0-programmer - - pru1-sync become: true - name: Build PRU firmware @@ -27,7 +26,6 @@ - pru0-shepherd-fw - pru1-shepherd-fw - pru0-programmer - - pru1-sync environment: PRU_CGT: '{{ sheep_ti_pru_cgt_path }}' PRU_CGT_SUPPORT: '{{ sheep_ti_pru_support_path }}' @@ -44,7 +42,6 @@ - pru0-shepherd-fw - pru1-shepherd-fw - pru0-programmer - - pru1-sync become: true # build second programmer diff --git a/software/firmware/Makefile b/software/firmware/Makefile index 8dffe4bf..c7dde5fc 100644 --- a/software/firmware/Makefile +++ b/software/firmware/Makefile @@ -1,4 +1,4 @@ -DIRS = pru0-shepherd-fw pru1-shepherd-fw device-tree pru0-programmer pru1-sync +DIRS = pru0-shepherd-fw pru1-shepherd-fw device-tree pru0-programmer # TODO: this makefile currently can't produce both versions of the programmer BUILDDIRS = $(DIRS:%=build-%) diff --git a/software/firmware/pru1-sync/.gitignore b/software/firmware/pru1-sync/.gitignore deleted file mode 100644 index 7b86b0c3..00000000 --- a/software/firmware/pru1-sync/.gitignore +++ /dev/null @@ -1 +0,0 @@ -gen/* diff --git a/software/firmware/pru1-sync/Makefile b/software/firmware/pru1-sync/Makefile deleted file mode 100644 index 7c244610..00000000 --- a/software/firmware/pru1-sync/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -PRU_NUM = 1 -mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) -current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) -folder_path := $(dir $(mkfile_path)) -PROJ_NAME = $(current_dir) -FW_NAME = sync - -BASE_PATH ?= ./.. - -# include headers with -I or --include_path= (cgt-only) -# small hack to get resource_table without code-duplication -INCLUDE = -I$(BASE_PATH)/pru1-shepherd-fw/include - -# external sources - add manually -SOURCES = $(BASE_PATH)/lib/src/iep.c -SOURCES += $(BASE_PATH)/lib/src/simple_lock.c -# internal sources -SOURCES += $(notdir $(wildcard ./*.c)) - -# internal asm-sources -ASM_SOURCES = $(notdir $(wildcard ./*.asm)) -# external asm-sources - add manually -#ASM_SOURCES += $(BASE_PATH)/lib/src/spi_transfer_pru.asm # adc_readwrite, adc_fastread, dac_write - - -# look for gcc, but use cgt as fallback / default -ifdef PRU_GCC -include $(BASE_PATH)/lib/GCC/Makefile -else -include $(BASE_PATH)/lib/CGT/Makefile -endif diff --git a/software/firmware/pru1-sync/main.c b/software/firmware/pru1-sync/main.c deleted file mode 100644 index 7f569d26..00000000 --- a/software/firmware/pru1-sync/main.c +++ /dev/null @@ -1,173 +0,0 @@ -/* -This FW is for generating an external sync event on both pru1 debug pins -mainly because accessing gpio from kMod is harder -*/ -#include -#include -#include - -#include "iep.h" -#include "intc.h" - -#include "commons.h" -#include "resource_table.h" -#include "shepherd_config.h" -#include "stdint_fast.h" - -/* The Arm to Host interrupt for the timestamp event is mapped to Host interrupt 0 -> Bit 30 (see resource_table.h) */ -#define HOST_INT_TIMESTAMP_MASK (1U << 30U) - -// both pins have a LED -#define DEBUG_PIN0_MASK BIT_SHIFT(P8_28) -#define DEBUG_PIN1_MASK BIT_SHIFT(P8_30) - -#define DEBUG_STATE_0 write_r30(read_r30() & ~(DEBUG_PIN0_MASK | DEBUG_PIN1_MASK)) -#define DEBUG_STATE_1 write_r30(read_r30() | (DEBUG_PIN0_MASK | DEBUG_PIN1_MASK)) - - -enum SyncState -{ - IDLE, - REPLY_PENDING -}; - - -// alternative message channel specially dedicated for errors -static void send_status(volatile struct SharedMem *const shared_mem, enum MsgType type, - const uint32_t value) -{ - // do not care for sent-status -> the newest error wins IF different from previous - if (!((shared_mem->pru1_msg_error.type == type) && - (shared_mem->pru1_msg_error.value[0] == value))) - { - shared_mem->pru1_msg_error.unread = 0u; - shared_mem->pru1_msg_error.type = type; - shared_mem->pru1_msg_error.value[0] = value; - shared_mem->pru1_msg_error.id = MSG_TO_KERNEL; - // NOTE: always make sure that the unread-flag is activated AFTER payload is copied - shared_mem->pru1_msg_error.unread = 1u; - } - if (type >= 0xE0) __delay_cycles(200u / TIMER_TICK_NS); // 200 ns -} - - -static inline bool_ft receive_sync_reply(volatile struct SharedMem *const shared_mem, - struct SyncMsg *const msg) -{ - if (shared_mem->pru1_sync_inbox.unread >= 1) - { - if (shared_mem->pru1_sync_inbox.id != MSG_TO_PRU) - { - /* Error occurs if something writes over boundaries */ - send_status(shared_mem, MSG_ERR_MEMCORRUPTION, 0); - return 0; - } - if (shared_mem->pru1_sync_inbox.type == MSG_TEST) - { - // pipeline-test for msg-system - shared_mem->pru1_sync_inbox.unread = 0; - send_status(shared_mem, MSG_TEST, shared_mem->pru1_sync_inbox.buffer_block_period); - return 0; - } - // NOTE: do not overwrite external msg without thinking twice! sync-routine relies on that content - *msg = shared_mem->pru1_sync_inbox; // TODO: faster to copy only the needed payload - shared_mem->pru1_sync_inbox.unread = 0; - return 1; - } - return 0; -} - - -// emits a 1 on success -// pru1_sync_outbox: (future opt.) needs to have special config set: identifier=MSG_TO_KERNEL and unread=1 -static inline bool_ft send_sync_request(volatile struct SharedMem *const shared_mem, - const struct ProtoMsg *const msg) -{ - if (shared_mem->pru1_sync_outbox.unread == 0) - { - shared_mem->pru1_sync_outbox = *msg; - shared_mem->pru1_sync_outbox.id = MSG_TO_KERNEL; - // NOTE: always make sure that the unread-flag is activated AFTER payload is copied - shared_mem->pru1_sync_outbox.unread = 1u; - return 1; - } - /* Error occurs if PRU was not able to handle previous message in time */ - send_status(shared_mem, MSG_ERR_BACKPRESSURE, 0); - return 0; -} - - -int32_t event_loop(volatile struct SharedMem *const shared_mem) -{ - /* Prepare message that will be received and sent to Linux kernel module */ - struct ProtoMsg sync_rqst = {.id = MSG_TO_KERNEL, .type = MSG_NONE, .unread = 0u}; - struct SyncMsg sync_repl = { - .buffer_block_period = TIMER_BASE_PERIOD, - .analog_sample_period = TIMER_BASE_PERIOD / ADC_SAMPLES_PER_BUFFER, - .compensation_steps = 0u, - }; - - /* Clear raw interrupt status from ARM host */ - INTC_CLEAR_EVENT(HOST_PRU_EVT_TIMESTAMP); - /* Wait for first timer interrupt from Linux host */ - while (!(read_r31() & HOST_INT_TIMESTAMP_MASK)) {} - - if (INTC_CHECK_EVENT(HOST_PRU_EVT_TIMESTAMP)) INTC_CLEAR_EVENT(HOST_PRU_EVT_TIMESTAMP); - - while (1) - { - /* Trigger for interrupt from Linux host to take timestamp */ - while (!(read_r31() & HOST_INT_TIMESTAMP_MASK)); - - if (!INTC_CHECK_EVENT(HOST_PRU_EVT_TIMESTAMP)) continue; - DEBUG_STATE_1; - - /* Take timestamp of IEP */ - sync_rqst.value[0] = iep_get_cnt_val(); - /* Clear interrupt */ - INTC_CLEAR_EVENT(HOST_PRU_EVT_TIMESTAMP); - - send_sync_request(shared_mem, &sync_rqst); - - /* waiting for a reply from Linux kernel module */ - while (receive_sync_reply(shared_mem, &sync_repl) < 1) - { - __delay_cycles(2000); // = 10 us - } - shared_mem->next_buffer_timestamp_ns = sync_repl.next_timestamp_ns; - DEBUG_STATE_0; - } -} - - -int main(void) -{ - volatile struct SharedMem *const shared_memory = - (volatile struct SharedMem *) PRU_SHARED_MEM_STRUCT_OFFSET; - - /* Allow OCP primary port access by the PRU so the PRU can read external memories */ - CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; - DEBUG_STATE_0; - - /* Enable 'timestamp' interrupt from ARM host */ - CT_INTC.EISR_bit.EN_SET_IDX = HOST_PRU_EVT_TIMESTAMP; - - /* wait until pru0 is ready */ - while (shared_memory->cmp0_trigger_for_pru1 == 0u) __delay_cycles(10); - shared_memory->cmp0_trigger_for_pru1 = 0u; - -reset: - send_status(shared_memory, MSG_STATUS_RESTARTING_ROUTINE, 101); - /* Make sure the mutex is clear */ - simple_mutex_exit(&shared_memory->gpio_edges_mutex); - - shared_memory->analog_value_current = 0u; - shared_memory->analog_value_voltage = 0u; - shared_memory->analog_value_index = 0u; - - iep_init(); - iep_reset(); - - event_loop(shared_memory); - goto reset; -} diff --git a/software/kernel-module/src/commons.h b/software/kernel-module/src/commons.h index 86d05fce..b90804be 100644 --- a/software/kernel-module/src/commons.h +++ b/software/kernel-module/src/commons.h @@ -10,7 +10,6 @@ #define PRU0_FW_PRG_SWD ("am335x-pru0-programmer-SWD-fw") #define PRU0_FW_PRG_SBW ("am335x-pru0-programmer-SBW-fw") #define PRU1_FW_DEFAULT ("am335x-pru1-shepherd-fw") -#define PRU1_FW_SYNC ("am335x-pru1-sync-fw") // NOTE: a (almost)Copy of this definition-file exists for the pru-firmware (copy changes by hand) diff --git a/software/kernel-module/src/sysfs_interface.c b/software/kernel-module/src/sysfs_interface.c index b543f48c..c50d4943 100644 --- a/software/kernel-module/src/sysfs_interface.c +++ b/software/kernel-module/src/sysfs_interface.c @@ -833,10 +833,10 @@ static ssize_t sysfs_pru1_firmware_store(struct kobject *kobj, struct kobj_attri /* FAIL with no file-name or not matching start-string */ if (strlen(buffer) == 0) return -EINVAL; - if ((strncmp(buffer, "sync", 4) == 0) || (strncmp(buffer, PRU1_FW_SYNC, 19) == 0)) + if (strncmp(buffer, "sync", 4) == 0) { - swap_pru_firmware("", PRU1_FW_SYNC); - /* only for debug */ + printk(KERN_ERR "shprd.k: sync-fw was removed"); + // NOTE: this could be removed, but that makes the whole FN useless } else { swap_pru_firmware("", PRU1_FW_DEFAULT); } diff --git a/software/python-package/shepherd_sheep/sysfs_interface.py b/software/python-package/shepherd_sheep/sysfs_interface.py index 702d885e..ba43b368 100644 --- a/software/python-package/shepherd_sheep/sysfs_interface.py +++ b/software/python-package/shepherd_sheep/sysfs_interface.py @@ -583,7 +583,6 @@ def check_programmer() -> str: "am335x-pru0-programmer-SWD-fw", "am335x-pru0-programmer-SBW-fw", "am335x-pru1-shepherd-fw", - "am335x-pru1-sync-fw", # just for debug ]