Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
augustofg committed Mar 9, 2020
2 parents c4bb4e9 + 7587af2 commit 21329d8
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 50 deletions.
6 changes: 5 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion nuttx
1 change: 1 addition & 0 deletions rffe-board/rffe/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions scripts/gdb/gdbinit
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 7 additions & 6 deletions scripts/gdb/pygdbinit
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -34,5 +35,5 @@ LoadSVD()

end

svd_load ./scripts/gdb/LPC176x5x_v0.2.svd
svd_load ../scripts/gdb/LPC176x5x_v0.2.svd

75 changes: 38 additions & 37 deletions utils/rffe_nuttx_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 21329d8

Please sign in to comment.