From 67d814c7c20db196964736e3f86aca0df568d9c0 Mon Sep 17 00:00:00 2001 From: Polprzewodnikowy Date: Sat, 20 Aug 2022 23:00:41 +0200 Subject: [PATCH] General cleanup And multiline commit message test --- build.sh | 8 +++++--- docker_build.sh | 2 ++ fw/rtl/mcu/mcu_top.sv | 11 +++-------- sw/bootloader/src/exception.c | 3 ++- sw/bootloader/src/version.c | 5 +++++ sw/bootloader/src/version.h | 1 + sw/controller/build.sh | 1 - sw/controller/src/button.c | 10 +++++----- sw/controller/src/button.h | 2 +- sw/controller/src/fpga.h | 14 +++++--------- sw/update/update.py | 8 +++++--- 11 files changed, 34 insertions(+), 31 deletions(-) diff --git a/build.sh b/build.sh index 05ce52b..4187689 100755 --- a/build.sh +++ b/build.sh @@ -32,6 +32,7 @@ build_bootloader () { if [ ! -z "${GIT_BRANCH+x}" ]; then FLAGS+=" -DGIT_BRANCH='\"$GIT_BRANCH\"'"; fi if [ ! -z "${GIT_TAG+x}" ]; then FLAGS+=" -DGIT_TAG='\"$GIT_TAG\"'"; fi if [ ! -z "${GIT_SHA+x}" ]; then FLAGS+=" -DGIT_SHA='\"$GIT_SHA\"'"; fi + if [ ! -z "${GIT_MESSAGE+x}" ]; then FLAGS+=" -DGIT_MESSAGE='\"$GIT_MESSAGE\"'"; fi make all -j USER_FLAGS="$FLAGS" popd > /dev/null @@ -76,9 +77,10 @@ build_update () { rm -f ./sc64.upd fi GIT_INFO="" - if [ ! -z "${GIT_BRANCH+x}" ]; then GIT_INFO+="branch: $GIT_BRANCH "; fi - if [ ! -z "${GIT_TAG+x}" ]; then GIT_INFO+="tag: $GIT_TAG "; fi - if [ ! -z "${GIT_SHA+x}" ]; then GIT_INFO+="sha: $GIT_SHA "; fi + if [ ! -z "${GIT_BRANCH}" ]; then GIT_INFO+="branch: [$GIT_BRANCH] "; fi + if [ ! -z "${GIT_TAG}" ]; then GIT_INFO+="tag: [$GIT_TAG] "; fi + if [ ! -z "${GIT_SHA}" ]; then GIT_INFO+="sha: [$GIT_SHA] "; fi + if [ ! -z "${GIT_MESSAGE}" ]; then GIT_INFO+="message: [$GIT_MESSAGE] "; fi GIT_INFO=$(echo "$GIT_INFO" | xargs) python3 update.py \ --git "$GIT_INFO" \ diff --git a/docker_build.sh b/docker_build.sh index bdcb5cf..0129053 100755 --- a/docker_build.sh +++ b/docker_build.sh @@ -7,6 +7,7 @@ pushd $(dirname $0) > /dev/null GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) GIT_TAG=$(git describe --tags 2> /dev/null) GIT_SHA=$(git rev-parse HEAD) +GIT_MESSAGE=$(git log --oneline --format=%B -n 1 HEAD | head -n 1) if [ -t 1 ]; then DOCKER_OPTIONS="-it" @@ -23,6 +24,7 @@ docker run \ -e GIT_BRANCH="$GIT_BRANCH" \ -e GIT_TAG="$GIT_TAG" \ -e GIT_SHA="$GIT_SHA" \ + -e GIT_MESSAGE="$GIT_MESSAGE" \ $BUILDER_IMAGE \ ./build.sh $@ diff --git a/fw/rtl/mcu/mcu_top.sv b/fw/rtl/mcu/mcu_top.sv index c3ef7a0..e4fa0df 100644 --- a/fw/rtl/mcu/mcu_top.sv +++ b/fw/rtl/mcu/mcu_top.sv @@ -375,15 +375,10 @@ module mcu_top ( case (address) REG_STATUS: begin reg_rdata <= { - 24'd0, - sd_det_ff[2], - ~fifo_bus.tx_full, - ~fifo_bus.rx_empty, - n64_scb.flashram_pending, + 29'd0, n64_scb.cfg_pending, - usb_dma_scb.busy, - usb_scb.reset_pending, - button_ff[2] + ~sd_det_ff[2], + ~button_ff[2] }; end diff --git a/sw/bootloader/src/exception.c b/sw/bootloader/src/exception.c index 4c7101a..c53ac92 100644 --- a/sw/bootloader/src/exception.c +++ b/sw/bootloader/src/exception.c @@ -189,7 +189,8 @@ void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, exception_print("branch: %s\n", version->git_branch); exception_print("tag: %s\n", version->git_tag); - exception_print("sha: %s\n\n", version->git_sha); + exception_print("sha: %s\n", version->git_sha); + exception_print("message: %s\n\n", version->git_message); exception_print("%s\n\n", exception_get_description(exception_code)); exception_print("pc: 0x%08lX sr: 0x%08lX cr: 0x%08lX hw: 0x%08lX [%.4s]\n", e->epc.u32, e->sr, e->cr, sc64_version, (char *) (&sc64_version)); exception_print("zr: 0x%08lX at: 0x%08lX v0: 0x%08lX v1: 0x%08lX\n", e->zr.u32, e->at.u32, e->v0.u32, e->v1.u32); diff --git a/sw/bootloader/src/version.c b/sw/bootloader/src/version.c index 47401e4..645dfc8 100644 --- a/sw/bootloader/src/version.c +++ b/sw/bootloader/src/version.c @@ -17,6 +17,11 @@ static version_t version = { #else #warning "No GIT_SHA provided" #endif +#ifdef GIT_MESSAGE + .git_message = GIT_MESSAGE, +#else +#warning "No GIT_MESSAGE provided" +#endif }; diff --git a/sw/bootloader/src/version.h b/sw/bootloader/src/version.h index 439e320..8b875ed 100644 --- a/sw/bootloader/src/version.h +++ b/sw/bootloader/src/version.h @@ -6,6 +6,7 @@ typedef const struct { const char *git_branch; const char *git_tag; const char *git_sha; + const char *git_message; } version_t; diff --git a/sw/controller/build.sh b/sw/controller/build.sh index 18a31a8..a969cec 100755 --- a/sw/controller/build.sh +++ b/sw/controller/build.sh @@ -1,6 +1,5 @@ #!/bin/bash - set -e case "$1" in diff --git a/sw/controller/src/button.c b/sw/controller/src/button.c index 319eed2..f92e5c6 100644 --- a/sw/controller/src/button.c +++ b/sw/controller/src/button.c @@ -19,10 +19,6 @@ bool button_get_state (void) { return p.state; } -button_mode_t button_get_mode (void) { - return p.mode; -} - void button_set_mode (button_mode_t mode) { p.mode = mode; if (p.mode == BUTTON_MODE_NONE) { @@ -30,6 +26,10 @@ void button_set_mode (button_mode_t mode) { } } +button_mode_t button_get_mode (void) { + return p.mode; +} + void button_init (void) { p.shift = 0x00000000UL; p.state = false; @@ -41,7 +41,7 @@ void button_process (void) { usb_tx_info_t packet_info; uint32_t status = fpga_reg_get(REG_STATUS); p.shift <<= 1; - if (!(status & STATUS_BUTTON)) { + if (status & STATUS_BUTTON) { p.shift |= (1 << 0); } if (!p.state && p.shift == 0xFFFFFFFFUL) { diff --git a/sw/controller/src/button.h b/sw/controller/src/button.h index 5f14e4a..cf48999 100644 --- a/sw/controller/src/button.h +++ b/sw/controller/src/button.h @@ -14,8 +14,8 @@ typedef enum { bool button_get_state (void); -button_mode_t button_get_mode (void); void button_set_mode (button_mode_t mode); +button_mode_t button_get_mode (void); void button_init (void); void button_process (void); diff --git a/sw/controller/src/fpga.h b/sw/controller/src/fpga.h index a2c8fad..79b3d64 100644 --- a/sw/controller/src/fpga.h +++ b/sw/controller/src/fpga.h @@ -60,22 +60,18 @@ typedef enum { #define FPGA_MAX_MEM_TRANSFER (1024) +#define USB_STATUS_RXNE (1 << 0) +#define USB_STATUS_TXE (1 << 1) + #define MEM_SCR_START (1 << 0) #define MEM_SCR_STOP (1 << 1) #define MEM_SCR_DIRECTION (1 << 2) #define MEM_SCR_BUSY (1 << 3) #define MEM_SCR_LENGTH_BIT (4) -#define USB_STATUS_RXNE (1 << 0) -#define USB_STATUS_TXE (1 << 1) - #define STATUS_BUTTON (1 << 0) -#define STATUS_USB_RESET_PENDING (1 << 1) -#define STATUS_DMA_BUSY (1 << 2) -#define STATUS_CFG_PENDING (1 << 3) -#define STATUS_FLASHRAM_PENDING (1 << 4) -#define STATUS_USB_RXNE (1 << 5) -#define STATUS_USB_TXE (1 << 6) +#define STATUS_SD_INSERTED (1 << 1) +#define STATUS_CFG_PENDING (1 << 2) #define USB_SCR_FIFO_FLUSH (1 << 0) #define USB_SCR_RXNE (1 << 1) diff --git a/sw/update/update.py b/sw/update/update.py index 393d9bc..9ffcc78 100644 --- a/sw/update/update.py +++ b/sw/update/update.py @@ -14,6 +14,7 @@ from io import BufferedRandom class JedecError(Exception): pass + class JedecFile: __fuse_length: int = 0 __fuse_offset: int = 0 @@ -175,6 +176,7 @@ class SC64UpdateData: return self.__data + if __name__ == "__main__": parser = argparse.ArgumentParser(description='SC64 update file generator') parser.add_argument('--git', metavar='git', required=False, help='git text to embed in update info') @@ -200,9 +202,9 @@ if __name__ == "__main__": f'creation time: [{creation_time}]', ] if (args.git): - info.append(f'git: [{args.git}]') - update_info = '\n'.join(info) - print(f'Update info:\n{update_info}') + info.append(args.git) + update_info = ' '.join(info) + print(update_info) update.add_update_info(update_info.encode()) if (args.mcu):