Skip to content

Commit

Permalink
Merge pull request #61 from orgua/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
orgua authored Sep 11, 2024
2 parents 6a459ae + 1c4e1de commit 175cdd6
Show file tree
Hide file tree
Showing 55 changed files with 1,916 additions and 1,603 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.1
current_version = 0.8.2
commit = False
tag = False

Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/build_pru_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ jobs:
run: "sudo cp software/firmware/lib/am335xl.pru0 ${{ env.PRU_GCC }}/pru-elf/lib/device-specs/am335xl.pru0"
working-directory: "${{ github.workspace }}"

- name: Build PRU0 🧱
- name: Build PRU0 - SHP EMU 🧱
run: |
make
${{ env.PRU_GCC }}/bin/pru-size gen_gcc/pru0-shepherd-fw.elf
make TYPE=EMU
${{ env.PRU_GCC }}/bin/pru-size gen_gcc/pru0-shepherd-EMU-fw.elf
working-directory: "software/firmware/pru0-shepherd-fw/"

- name: Clean Programmer 🧹
run: make clean
working-directory: "software/firmware/pru0-programmer/"

- name: Build PRU0 - SHP HRV 🧱
run: |
make TYPE=HRV
${{ env.PRU_GCC }}/bin/pru-size gen_gcc/pru0-shepherd-HRV-fw.elf
working-directory: "software/firmware/pru0-shepherd-fw/"

- name: Build PRU1 🧱
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:
- id: text-unicode-replacement-char

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.6.0'
rev: 'v0.6.4'
hooks:
- id: ruff-format
- id: ruff
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

## 0.8.2

- PRU gets now partially zeroed buffer-segments
- PRU now gets partially zeroed buffer-segments
- PRU had a race-condition with a loose mutex resulting in keeping old gpio-samples
- python now warns on full gpio-buffer (as it can only hold ~16k entries in 100 ms)
- python now warns if first or last timestamp of gpio-buffer is out of scope of outer buffer-period
- python warns on full gpio-buffer (as it can only hold ~16k entries in 100 ms)
- python warns if first or last timestamp of gpio-buffer is out of scope of outer buffer-period
- hw cape - add errata-list
- vsrc - add datatype to determine state-variables
- CalibrationPair - add units
- split pru0-shepherd-fw into hrv & emu -> kModule, shepherd-sheep, playbooks, workflows adapted
- pru-vsource - add feedback to harvester
- pru-harvester - add feedback & extrapolation for cv-harvester
- **tested**: pytest sheep, pytest herd, playbook dev_rebuild_sw.yml

## 0.8.1

Expand Down
2,844 changes: 1,477 additions & 1,367 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deploy/dev_acquire_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

vars:
cmd_ssh: "ssh {{ ansible_user }}@{{ inventory_hostname }}"
image_name: "shepherd--console-armhf-{{ ansible_date_time.date }}-4g.img.gz"
image_name: "shepherd--console-armhf-{{ ansible_date_time.date }}-4g.img.xz"

tasks:

Expand Down
31 changes: 29 additions & 2 deletions deploy/roles/sheep/tasks/build_shp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
chdir: "{{ sheep_install_path }}/software/firmware/{{ item }}"
target: all
loop:
- pru0-shepherd-fw
- pru0-shepherd-fw # default: EMU
- pru1-shepherd-fw
- pru0-programmer
- pru0-programmer # default: SWD
environment:
PRU_CGT: '{{ sheep_ti_pru_cgt_path }}'
PRU_CGT_SUPPORT: '{{ sheep_ti_pru_support_path }}'
Expand All @@ -44,6 +44,33 @@
- pru0-programmer
become: true

# build harvester
- name: Clean PRU Firmware Source - PRU0
community.general.make:
chdir: "{{ sheep_install_path }}/software/firmware/pru0-shepherd-fw"
target: clean
become: true
- name: Build PRU firmware - PRU0 - Harvester
community.general.make:
chdir: "{{ sheep_install_path }}/software/firmware/pru0-shepherd-fw"
target: all
params:
TYPE: HRV
environment:
PRU_CGT: '{{ sheep_ti_pru_cgt_path }}'
PRU_CGT_SUPPORT: '{{ sheep_ti_pru_support_path }}'
# PRU_GCC: '{{ sheep_gcc_tools_path }}/{{ sheep_gcc_pru_cc_release }}' # TODO: probably just []/pru-elf now
# PRU_GCC_SUPPORT: '{{ sheep_gcc_pru_support_path }}'
become: false
# NOTE: clean & build & install could be just install, but then a manual rebuild needs sudo
- name: Install PRU firmware - PRU0 - HARVESTER
community.general.make:
chdir: "{{ sheep_install_path }}/software/firmware/pru0-shepherd-fw"
target: install
params:
TYPE: HRV
become: true

# build second programmer
- name: Clean PRU Firmware Source - Programmer 2 - SBW
community.general.make:
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
project = "SHEPHERD"
project_copyright = "2019-2024, Networked Embedded Systems Lab, TU Dresden & TU Darmstadt"
author = "Kai Geissdoerfer, Ingmar Splitt"
release = "0.8.1"
release = "0.8.2"

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/dev/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Use `bump2version` to update the version number across the repository:
```shell
pipenv shell
pre-commit run --all-files
bump2version --allow-dirty --new-version 0.8.1 patch
bump2version --allow-dirty --new-version 0.8.2 patch
# version-format: major.minor.patch
```

Expand Down
7 changes: 7 additions & 0 deletions hardware/cape_v2.5a/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changes and Errors for future Version

- replace target header with 40pin edge-Connector
- keep pin-mapping of target v1.0
- add more dir-changing (reuse 2x Dir of prog-adapter)
- harvester seems a bit too fast - current is overswinging - see SM141K04LV ivcurve
- disable GPIO IO if voltage is cut (due to low_threshold)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions software/firmware/pru0-module-py/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ SOURCES = $(BASE_PATH)/pru0-shepherd-fw/virtual_harvester.c
SOURCES += $(BASE_PATH)/pru0-shepherd-fw/virtual_converter.c
SOURCES += $(BASE_PATH)/pru0-shepherd-fw/calibration.c
SOURCES += $(BASE_PATH)/pru0-shepherd-fw/math64_safe.c
SOURCES += $(BASE_PATH)/pru0-module-py/shp_pru/pru_source.c
SOURCES += $(BASE_PATH)/pru0-module-py/shepherd_pru/pru_source.c

OBJECTS=$(SOURCES:.c=.o)

TARGET=./shp_pru/_shared_pru.so
TARGET=./shepherd_pru/_shared_pru.so

all: $(TARGET)

Expand Down
22 changes: 11 additions & 11 deletions software/firmware/pru0-module-py/examples/emulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"BQ25570",
]

target = ResistiveTarget(resistance_Ohm=1000)
target = ResistiveTarget(R_Ohm=1000)

paths_local_hrv = {hrv_name: Path(__file__).parent / f"hrv_{hrv_name}.h5" for hrv_name in hrv_list}
results: dict = {}
Expand All @@ -34,16 +34,16 @@
path_output = path_input.with_name(
path_input.stem + "_" + src_name + "_cim" + path_input.suffix
)
# if not path_output.exists():
simulate_source(
config=VirtualSourceConfig(
inherit_from=src_name,
C_output_uF=0,
),
target=target,
path_input=path_input,
path_output=path_output,
)
if not path_output.exists():
simulate_source(
config=VirtualSourceConfig(
inherit_from=src_name,
C_output_uF=0,
),
target=target,
path_input=path_input,
path_output=path_output,
)
with Reader(path_output, verbose=False) as _fh:
results[path_output.stem] = _fh.energy()

Expand Down
2 changes: 1 addition & 1 deletion software/firmware/pru0-module-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
]
requires-python = ">= 3.10"
dependencies = [
"shepherd-core[elf,inventory]>=2024.8.2",
"shepherd-core[elf,inventory]>=2024.9.1", # limit due to newest features
"tqdm",
]

Expand Down
2 changes: 1 addition & 1 deletion software/firmware/pru0-module-py/shepherd_pru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .pru_source_model import PruSourceModel
from .pru_source_simulation import simulate_source

__version__ = "0.8.1"
__version__ = "0.8.2"

__all__ = [
"PruConverterModel",
Expand Down
5 changes: 5 additions & 0 deletions software/firmware/pru0-module-py/shepherd_pru/pru_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "virtual_harvester.h"
#include <stdint.h>

#define EMU_SUPPORT

/*
ripped out parts from sample_emulator() in sampling.c
*/
Expand All @@ -22,5 +24,8 @@ uint32_t vsrc_iterate_sampling(uint32_t input_voltage_uV, uint32_t input_current

converter_update_states_and_output(&shared_mem);

/* feedback path - important for boost-less circuits */
if (feedback_to_hrv) { voltage_set_uV = V_input_request_uV; }

return get_V_output_uV();
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(

self.cfg_src = VirtualSourceConfig() if vsrc is None else vsrc
cnv_config = ConverterPRUConfig.from_vsrc(
self.cfg_src, log_intermediate_node=log_intermediate
data=self.cfg_src, dtype_in=dtype_in, log_intermediate_node=log_intermediate
)
self.cnv: VirtualConverterModel = VirtualConverterModel(cnv_config, self._cal_pru)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def simulate_source(
cal_out = file_out.get_calibration_data()

src = VirtualSourceModel(
config, cal_emu, log_intermediate=False, window_size=file_inp.get_window_samples()
config,
cal_emu,
dtype_in=file_inp.get_datatype(),
log_intermediate=False,
window_size=file_inp.get_window_samples(),
)
i_out_nA = 0
e_out_Ws = 0.0
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/pru0-programmer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ folder_path := $(dir $(mkfile_path))
PROTO ?= SWD
PROJ_NAME = $(current_dir)-$(PROTO)
FW_NAME = programmer-$(PROTO)
# choose variant with "make PROTO=SWD|SBW"
# choose variant with "make PROTO=SWD|SBW", with SWD being default

BASE_PATH ?= ./..

Expand Down
4 changes: 2 additions & 2 deletions software/firmware/pru0-programmer/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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)))
if (!((shared_mem->pru0_msg_error.type == type) &&
(shared_mem->pru0_msg_error.value[0] == value)))
{
shared_mem->pru0_msg_error.unread = 0u;
shared_mem->pru0_msg_error.type = type;
Expand Down
10 changes: 8 additions & 2 deletions software/firmware/pru0-shepherd-fw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ PRU_NUM = 0
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
folder_path := $(dir $(mkfile_path))
PROJ_NAME = $(current_dir)
FW_NAME = shepherd
TYPE ?= EMU
PROJ_NAME = $(current_dir)-$(TYPE)
FW_NAME = shepherd-$(TYPE)
# choose variant with "make TYPE=EMU|HRV", with EMU being default

BASE_PATH ?= ./..

Expand All @@ -22,6 +24,10 @@ ASM_SOURCES = $(notdir $(wildcard ./*.asm))
# external asm-sources - add manually
ASM_SOURCES += $(BASE_PATH)/lib/src/register_magic.asm # get_size_in_bits, log2safe, max_value, min_value

ifeq ($(TYPE), HRV) # switch to HRV with "make TYPE=HRV"
CFLAGS += -D HRV_SUPPORT
endif

# look for gcc, but use cgt as fallback / default
ifdef PRU_GCC
ASM_SOURCES += $(BASE_PATH)/lib/src/spi_transfer_pru_gcc.asm # small hack: constants are defined differently
Expand Down
11 changes: 11 additions & 0 deletions software/firmware/pru0-shepherd-fw/include/fw_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef PRU0_FW_CONFIG_H_
#define PRU0_FW_CONFIG_H_

/* split of fw due to PRU-limitations
-> select a primary mode when none is chosen
*/
#if !(defined(EMU_SUPPORT) || defined(HRV_SUPPORT))
#define EMU_SUPPORT
#endif

#endif // PRU0_FW_CONFIG_H_
43 changes: 23 additions & 20 deletions software/firmware/pru0-shepherd-fw/include/virtual_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
#include "commons.h"
#include <stdint.h>

void converter_initialize(const volatile struct ConverterConfig *config);

void converter_calc_inp_power(uint32_t input_voltage_uV, uint32_t input_current_nA);
void converter_calc_out_power(uint32_t current_adc_raw);
void converter_update_cap_storage(void);
uint32_t converter_update_states_and_output(volatile struct SharedMem *shared_mem);

void set_P_input_fW(uint32_t P_fW);
void set_P_output_fW(uint32_t P_fW);
void set_V_intermediate_uV(uint32_t C_uV);
uint64_t get_P_input_fW(void);
uint64_t get_P_output_fW(void);
uint32_t get_V_intermediate_uV(void);
uint32_t get_V_intermediate_raw(void);
uint32_t get_I_mid_out_nA(void);
uint32_t get_V_output_uV(void);
bool_ft get_state_log_intermediate(void);

void set_batok_pin(volatile struct SharedMem *shared_mem, bool_ft value);

void converter_initialize(const volatile struct ConverterConfig *config);

void converter_calc_inp_power(uint32_t input_voltage_uV, uint32_t input_current_nA);
void converter_calc_out_power(uint32_t current_adc_raw);
void converter_update_cap_storage(void);
uint32_t converter_update_states_and_output(volatile struct SharedMem *shared_mem);

void set_P_input_fW(uint32_t P_fW);
void set_P_output_fW(uint32_t P_fW);
void set_V_intermediate_uV(uint32_t C_uV);
uint64_t get_P_input_fW(void);
uint64_t get_P_output_fW(void);
uint32_t get_V_intermediate_uV(void);
uint32_t get_V_intermediate_raw(void);
uint32_t get_I_mid_out_nA(void);
uint32_t get_V_output_uV(void);
bool_ft get_state_log_intermediate(void);

void set_batok_pin(volatile struct SharedMem *shared_mem, bool_ft value);

/* feedback to harvester - global vars */
extern bool_ft feedback_to_hrv;
extern uint32_t V_input_request_uV;

/* Direct Connection
* - Voltage-value in buffer is written to DAC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#include "commons.h"
#include "stdint.h"

void harvester_initialize(const volatile struct HarvesterConfig *);
void harvester_initialize(const volatile struct HarvesterConfig *);

void sample_adc_harvester(struct SampleBuffer *buffer, uint32_t sample_idx);
void sample_adc_harvester(struct SampleBuffer *buffer, uint32_t sample_idx);

void sample_ivcurve_harvester(uint32_t *p_voltage_uV, uint32_t *p_current_nA);
void sample_ivcurve_harvester(uint32_t *p_voltage_uV, uint32_t *p_current_nA);

/* global vars to allow feedback from vsource */
extern uint32_t voltage_set_uV;

#endif //PRU_FIRMWARE_PRU0_SHEPHERD_FW_HARVESTER_H
Loading

0 comments on commit 175cdd6

Please sign in to comment.