diff --git a/bootloader/build/Makefile b/bootloader/build/Makefile index 372093e0731bb648dd43a82b51c1c2773d599fc8..6457c125d8e1fdaed27835a45c2a9e8356a09849 100644 --- a/bootloader/build/Makefile +++ b/bootloader/build/Makefile @@ -60,6 +60,8 @@ hal/src/hal_atomic.o \ OBJS_AS_ARGS += $(OBJS:%="%") +GIT_VER = $(shell git describe --always --dirty) + # List the dependency files DEPS := $(OBJS:%.o=%.d) @@ -133,9 +135,9 @@ flash: all @echo Building file: $< @echo ARM/GNU C Compiler $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \ --D__SAMD21G18A__ -mcpu=cortex-m0plus \ -$(GCC_INCS) \ --MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + -D__SAMD21G18A__ -mcpu=cortex-m0plus -D__GIT_VER__="\"$(GIT_VER)\"" \ + $(GCC_INCS) \ + -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" @echo Finished building: $< diff --git a/bootloader/src/i2c_impl.c b/bootloader/src/i2c_impl.c index b5037de8e9ffc216125ecf5a8db362d7f3960418..0651c09bfd7a3b671e25b0745aeae908846882c7 100644 --- a/bootloader/src/i2c_impl.c +++ b/bootloader/src/i2c_impl.c @@ -13,6 +13,7 @@ const char MFR_REV[] = "0.1.0"; const char MFR_LOC[] = "Geneva"; const char MFR_DAT[] = "190801"; const char MFR_SER[] = "123456789"; +const char IC_DEVICE_REV[] = __GIT_VER__; void query_prp(); uint8_t query_r; @@ -36,7 +37,9 @@ static const int8_t cmd_data_lengths[] = { -(int8_t)sizeof(MFR_REV), // 0x9B -(int8_t)sizeof(MFR_LOC), // 0x9C -(int8_t)sizeof(MFR_DAT), // 0x9D - -(int8_t)sizeof(MFR_SER)}; // 0x9E + -(int8_t)sizeof(MFR_SER), // 0x9E + -(int8_t)sizeof(IC_DEVICE_REV) //0xAE +}; // for block write-block read process calls, which modify the length static int8_t cmd_data_length_query = -1; @@ -57,6 +60,7 @@ static cmd_t cmds_cmds[] = (cmd_t[]){ {0x009C, (int8_t *)&cmd_data_lengths[4], (uint8_t *)&MFR_LOC, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_NAN, 0}, {0x009D, (int8_t *)&cmd_data_lengths[5], (uint8_t *)&MFR_DAT, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_NAN, 0}, {0x009E, (int8_t *)&cmd_data_lengths[6], (uint8_t *)&MFR_SER, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_NAN, 0}, + {0x00AE, (int8_t *)&cmd_data_lengths[7], (uint8_t *)&IC_DEVICE_REV, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_NAN, 0}, {0xFF01, (int8_t *)&ext_cmd_data_lengths[0], (uint8_t *)&fw_len, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, 0, 0}, {0xFF02, (int8_t *)&ext_cmd_data_lengths[1], (uint8_t *)fw_block, (fp_t)NULL, (fp_t)&written_fw_block, (fp_t)NULL, 0, 1}, {0xFF03, (int8_t *)&ext_cmd_data_lengths[2], (uint8_t *)&fw_checksum, (fp_t)NULL, (fp_t)&written_fw_checksum, (fp_t)NULL, 0, 0}, diff --git a/doc/source/firmware.rst b/doc/source/firmware.rst index eae634a11b2cc383d88fbbbf519a3539735a9d19..d88252d2e1db5761104c351d8e84754b5557a3c3 100644 --- a/doc/source/firmware.rst +++ b/doc/source/firmware.rst @@ -142,6 +142,8 @@ returned by READ_VOUT_. +--------------+---------------------+------------------------+-------------+----------------------+ | 9E | MFR_SERIAL_ | Block read | var | serial number | +--------------+---------------------+------------------------+-------------+----------------------+ + | AE | IC_DEVICE_REV_ | Block read | var | git commit id | + +--------------+---------------------+------------------------+-------------+----------------------+ | FF | PMBUS_COMMAND_EXT_ | Extended command | var | access extended cmds | +--------------+---------------------+------------------------+-------------+----------------------+ @@ -420,6 +422,17 @@ MFR_SERIAL This returns a manufacturer serial string (currently unused, returns "123456789"). +.. _IC_DEVICE_REV: + +IC_DEVICE_REV +~~~~~~~~~~~~~ + +| Command code: **AE** +| Transaction type: **Block read** +| Data length: **var** + +This returns a git commit id of the used firmware. + .. _PMBUS_COMMAND_EXT: PMBUS_COMMAND_EXT diff --git a/main_fw/build/Makefile b/main_fw/build/Makefile index 399cde98b5866b62383641d88d3f5b212029cb17..e7eb4d86f1ea158a023c6bf1e44cbbb6edd723b7 100644 --- a/main_fw/build/Makefile +++ b/main_fw/build/Makefile @@ -31,7 +31,9 @@ else $(error need to provide a legal value for VER) endif -CFLAGS=-mcpu=cortex-m0plus -DDEBUG -D__SAMD21G18A__ $(MMVER) -Wall -c -std=gnu99 -ffunction-sections -mlong-calls -fomit-frame-pointer --sysroot=/usr/arm-none-eabi +CFLAGS=-mcpu=cortex-m0plus -DDEBUG -D__SAMD21G18A__ $(MMVER) -Wall -c \ + -std=gnu99 -ffunction-sections -mlong-calls -fomit-frame-pointer \ + --sysroot=/usr/arm-none-eabi -D__GIT_VER__="\"$(GIT_VER)\"" GCC_CFLAGS=-march=armv6-m -mcpu=cortex-m0plus -mthumb -Os -g3 CLANG_CFLAGS=-DUSE_CLANG -I$(CLANG_NEWLIB_PATH)/include/ -flto -Os -fshort-enums -ffreestanding --target=arm-none-eabi -march=thumbv6m -g EXTRA_OPT_ARGS= @@ -57,6 +59,8 @@ ifdef BE_COMPLIANT_USE_LINEAR16 CLANG_CFLAGS += -DUSE_LINEAR16 endif +GIT_VER = $(shell git describe --always --dirty) + IRQ_handlers := Reset_Handler \ Dummy_Handler \ RTC_Handler \ diff --git a/main_fw/src/i2c_impl.c b/main_fw/src/i2c_impl.c index 69786c88559acbb627ab380ab7f3fcc2bf880701..c79b61eb3784643a348ba7799ac99e6ce85a7c91 100644 --- a/main_fw/src/i2c_impl.c +++ b/main_fw/src/i2c_impl.c @@ -24,6 +24,7 @@ const char MFR_REV[] = "0.2p-ERRO"; const char MFR_LOC[] = "Geneva"; const char MFR_DAT[] = "211020"; const char MFR_SER[] = "123456789"; +const char IC_DEVICE_REV[] = __GIT_VER__; #ifdef USE_LINEAR16 const uint8_t vout_mode = 0x16; // linear mode, fixed 2^10 exponent @@ -125,8 +126,9 @@ static const int8_t cmd_data_lengths[] = { 2, // 0x3B 2, // 0x3C 1, // 0x3D - 2}; // 0x3E - + 2, // 0x3E + -(int8_t)sizeof(IC_DEVICE_REV)// 0xAE +}; // only block write-block read process calls modify the length static int8_t cmd_data_length_query = -1; @@ -166,6 +168,7 @@ static const cmd_t cmds_cmds[] = (cmd_t[]){ {0x003C, (int8_t *)&cmd_data_lengths[22], (uint8_t *)&setfrpms_lin[1], (fp_t)NULL, &set_frpms, (fp_t)NULL, QUERY_WR | QUERY_FMT_LIN, 0}, {0x003D, (int8_t *)&cmd_data_lengths[23], (uint8_t *)&fan_config_3_4, &get_fan_configs, &fan_config, (fp_t)NULL, QUERY_WR | QUERY_FMT_NAN, 0}, {0x003E, (int8_t *)&cmd_data_lengths[24], (uint8_t *)&setfrpms_lin[2], (fp_t)NULL, &set_frpms, (fp_t)NULL, QUERY_WR | QUERY_FMT_LIN, 0}, + {0x00AE, (int8_t *)&cmd_data_lengths[25], (uint8_t *)&IC_DEVICE_REV, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, QUERY_RD | QUERY_FMT_NAN, 0}, {0xFF05, (int8_t *)&ext_cmd_data_lengths[0], (uint8_t *)&dummy_byte, (fp_t)NULL, &boot_new_fw, (fp_t)NULL, 0, 0}, {0xFF06, (int8_t *)&ext_cmd_data_lengths[1], (uint8_t *)&dummy_byte, (fp_t)NULL, &uc_reset, (fp_t)NULL, 0, 0}, {0xFF10, (int8_t *)&ext_cmd_data_lengths[2], (uint8_t *)&seconds_up, (fp_t)NULL, (fp_t)NULL, (fp_t)NULL, 0, 0},