diff --git a/make.sh b/make.sh index d9ac462..5e2f26c 100755 --- a/make.sh +++ b/make.sh @@ -9,7 +9,11 @@ git_hash_tag() { NUTTX_GIT_HASH=$(git describe --no-match --always --dirty --abbrev=40) cd .. RFFE_GIT_HASH=$(git describe --no-match --always --dirty --abbrev=40) - RFFE_GIT_TAG=$(git describe --exact-match --tags) + RFFE_GIT_TAG=$(git describe --exact-match --tags 2>/dev/null) + if [ -z "$RFFE_GIT_TAG" ]; then + RFFE_GIT_TAG="devel" + echo "Development build" + fi printf "/* Auto-generated file */\n\n#define APPS_GIT_HASH \"${APPS_GIT_HASH}\"\n#define NUTTX_GIT_HASH \"${NUTTX_GIT_HASH}\"\n#define RFFE_GIT_HASH \"${RFFE_GIT_HASH}\"\n#define RFFE_GIT_TAG \"${RFFE_GIT_TAG}\"\n" > rffe-app/git_version.h } diff --git a/nuttx b/nuttx index 4f632e2..c4ea466 160000 --- a/nuttx +++ b/nuttx @@ -1 +1 @@ -Subproject commit 4f632e2eba06991b1e286503170d483f037b3d1b +Subproject commit c4ea466caaa22def6d71c76b4c77ce01be8a97e4 diff --git a/rffe-board/rffe/defconfig b/rffe-board/rffe/defconfig index 5feb4fb..3897931 100644 --- a/rffe-board/rffe/defconfig +++ b/rffe-board/rffe/defconfig @@ -20,6 +20,7 @@ CONFIG_ARCH_CHIP_LPC1769=y CONFIG_ARCH_CHIP_LPC17XX_40XX=y CONFIG_ARCH_STACKDUMP=y CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_RESET_ON_ASSERT=1 CONFIG_BOARD_ASSERT_RESET_VALUE=1 CONFIG_BOARD_LOOPSPERMSEC=7982 CONFIG_BUILTIN=y diff --git a/scripts/gdb/gdbinit b/scripts/gdb/gdbinit index 167a64d..49c83dd 100644 --- a/scripts/gdb/gdbinit +++ b/scripts/gdb/gdbinit @@ -1,23 +1,24 @@ -def rst +define rst + set *((uint32_t*) 0x40000000) = 1 << 2 monitor reset halt end -def start_timer +define start_timer set *(unsigned int*)0xE000EDFC |= 0x01000000 set *(unsigned int*)0xE0001004 = 0 set *(unsigned int*)0xE0001000 = 1 end -def read_timer +define read_timer p *(unsigned int*)0xE0001004 end -def ldr +define ldr load rst end -def ldrc +define ldrc load rst c diff --git a/scripts/gdb/pygdbinit b/scripts/gdb/pygdbinit index 8e4a72f..a4a7c3c 100644 --- a/scripts/gdb/pygdbinit +++ b/scripts/gdb/pygdbinit @@ -1,23 +1,24 @@ -def rst +define rst + set *((uint32_t*) 0x40000000) = 1 << 2 monitor reset halt end -def start_timer +define start_timer set *(unsigned int*)0xE000EDFC |= 0x01000000 set *(unsigned int*)0xE0001004 = 0 set *(unsigned int*)0xE0001000 = 1 end -def read_timer +define read_timer p *(unsigned int*)0xE0001004 end -def ldr +define ldr load rst end -def ldrc +define ldrc load rst c @@ -34,5 +35,5 @@ LoadSVD() end -svd_load ./scripts/gdb/LPC176x5x_v0.2.svd +svd_load ../scripts/gdb/LPC176x5x_v0.2.svd diff --git a/utils/rffe_nuttx_lib.py b/utils/rffe_nuttx_lib.py index b46bcd7..cd5c368 100644 --- a/utils/rffe_nuttx_lib.py +++ b/utils/rffe_nuttx_lib.py @@ -30,6 +30,43 @@ def write_sector(self, data, start_addr): self.s.send(data) ans = self.s.recv(1) + def reprogram(self, file_path, version, bootloader=False): + major, minor, patch = map(int,re.split('[., _]',version)) + + start_addr = 0x48000 + + with open(file_path, "rb") as f: + + self.erase_all() + + buf = f.read(256) + while buf != b"": + + pad = bytearray() + pad.extend(buf) + + if len(buf) < 256: + pad.extend(b'\377' * (256 - len(pad))) + + self.write_sector(pad, start_addr) + start_addr += 256 + buf = f.read(256) + + boot_sec = bytearray() + boot_sec.extend(b'\377' * 256) + + boot_sec[248] = major + boot_sec[249] = minor + boot_sec[250] = patch + boot_sec[251] = 2 if bootloader else 1 + boot_sec[252] = 0xAA + boot_sec[253] = 0xAA + boot_sec[254] = 0xAA + boot_sec[255] = 0xAA + self.write_sector(boot_sec, 0x0007FF00) + self.reset() + self.close() + def reset(self): self.s.send(b"r") self.s.close() @@ -155,44 +192,8 @@ def reprogram(self, file_path, version, bootloader=False): first argument, a string, is the path to the binary file which corresponds to the program will be loaded in the device. The second argument is the new firmware version formated as: x.y.z or x_y_z""" - pass - major, minor, patch = map(int,re.split('[., _]',version)) - - start_addr = 0x48000 - rffe_fw = RFFEFWUpdate(self.ip) - - with open(file_path, "rb") as f: - - rffe_fw.erase_all() - - buf = f.read(256) - while buf != b"": - - pad = bytearray() - pad.extend(buf) - - if len(buf) < 256: - pad.extend(b'\377' * (256 - len(pad))) - - rffe_fw.write_sector(pad, start_addr) - start_addr += 256 - buf = f.read(256) - - boot_sec = bytearray() - boot_sec.extend(b'\377' * 256) - - boot_sec[248] = major - boot_sec[249] = minor - boot_sec[250] = patch - boot_sec[251] = 2 if bootloader else 1 - boot_sec[252] = 0xAA - boot_sec[253] = 0xAA - boot_sec[254] = 0xAA - boot_sec[255] = 0xAA - rffe_fw.write_sector(boot_sec, 0x0007FF00) - rffe_fw.reset() - self.close() + rffe_fw.reprogram(file_path, version, bootloader); def set_pid_ac_kc(self, value): """Sets the PID Kc parameter in the A/C front-end. The value is passed as a floating-point numpber."""