Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Firmware/radio/at.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern __pdata uint8_t at_testmode; ///< AT_TEST_* bits
#define AT_TEST_TDM 2

// max size of an AT command
#ifdef CPU_SI1030
#ifdef INCLUDE_AES
#define AT_CMD_MAXLEN 69
#else
#define AT_CMD_MAXLEN 16
Expand Down
22 changes: 18 additions & 4 deletions Firmware/radio/printfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,26 @@ vprintfl(const char * fmt, va_list ap) __reentrant
static char __idata buffer[12]; /* 37777777777(oct) */
char __idata * stri;

if (unsigned_flag) {
__ultoa(val, buffer, radix);
unsigned long uval;
uint8_t negative = 0;

if (!unsigned_flag && val < 0) {
negative = 1;
// not -val: that overflows for LONG_MIN
uval = 0UL - (unsigned long)val;
} else {
__ltoa(val, buffer, radix);
uval = (unsigned long)val;
}
stri = buffer + (sizeof(buffer) - 1);
*stri = 0;
do {
uint8_t d = (uint8_t)(uval % radix);
uval /= radix;
*--stri = (d < 10) ? ('0' + d) : ('A' + (d - 10));
} while (uval != 0);
if (negative) {
*--stri = '-';
}
stri = buffer;
while (*stri) {
output_char(*stri);
stri++;
Expand Down
10 changes: 6 additions & 4 deletions Firmware/radio/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@
#ifdef CPU_SI1030
#define RX_BUFF_MAX 1024 //2048
#define TX_BUFF_MAX 1024
#ifdef INCLUDE_AES
#define ENCRYPT_BUFF_MAX 17*60 // 16 bit encrypted packets plus one for size
static __pdata uint16_t encrypt_buff_start = 400; // Start decrypting more to clear buffer
static __pdata uint16_t encrypt_buff_end = 500; // End our quick buffer clear
#endif // INCLUDE_AES
#else
#define RX_BUFF_MAX 1850
#define TX_BUFF_MAX 645
#endif // CPU_SI1030

__xdata uint8_t rx_buf[RX_BUFF_MAX] = {0};
__xdata uint8_t tx_buf[TX_BUFF_MAX] = {0};
__xdata uint8_t rx_buf[RX_BUFF_MAX];
__xdata uint8_t tx_buf[TX_BUFF_MAX];
#ifdef INCLUDE_AES
__xdata uint8_t encrypt_buf[ENCRYPT_BUFF_MAX] = {0};
#endif // INCLUDE_AES
// FIFO insert/remove pointers
static volatile __pdata uint16_t rx_insert, rx_remove;
static volatile __pdata uint16_t tx_insert, tx_remove;
#ifdef CPU_SI1030
#ifdef INCLUDE_AES
static volatile __pdata uint16_t encrypt_insert, encrypt_remove;
#endif

Expand Down Expand Up @@ -208,7 +210,7 @@ serial_init(register uint8_t speed)
rx_remove = 0;
tx_insert = 0;
tx_remove = 0;
#ifdef CPU_SI1030
#ifdef INCLUDE_AES
encrypt_insert = 0;
encrypt_remove = 0;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Firmware/radio/tdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ __pdata struct tdm_trailer trailer;

/// buffer to hold a remote AT command before sending
static bool send_at_command;
static __pdata char remote_at_cmd[AT_CMD_MAXLEN + 1];
static __xdata char remote_at_cmd[AT_CMD_MAXLEN + 1];

#define PACKET_OVERHEAD (sizeof(trailer)+16)

Expand Down
28 changes: 19 additions & 9 deletions Firmware/tools/check_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,31 @@ def extract_C_functions(c, d):
error_count = 0

def check_xiseg():
'''check that XISEG has not overflowed'''
'''check that external RAM has not overflowed'''
global error_count
xmatch = re.compile(r'^XISEG\s*(\w+)\s*(\w+)');
# XSEG holds the uninitialised xdata and XISEG the initialised part, and a
# firmware can end up with either of them empty, so look at both and take
# whichever ends higher
xmatch = re.compile(r'^(XISEG|XSEG)\s*(\w+)\s*(\w+)');
for map in glob.glob("%s.map"%board):
f = open(map)
end = 0
name = None
for line in f:
m = xmatch.match(line)
if m:
ofs1 = int(m.group(1),16)
ofs2 = int(m.group(2),16)
print(os.popen("tail -n5 %s.mem"%board).read())
print('XISEG %s - %u bytes available' % (map, xram_size-(ofs1+ofs2)))
if ofs1 + ofs2 >= xram_size:
print('ERROR: XISEG overflow %u in %s' % (ofs1+ofs2, map))
error_count += 1
ofs1 = int(m.group(2),16)
ofs2 = int(m.group(3),16)
if ofs1 + ofs2 > end:
end = ofs1 + ofs2
name = m.group(1)
if name is None:
continue
print(os.popen("tail -n5 %s.mem"%board).read())
print('%s %s - %u bytes available' % (name, map, xram_size-end))
if end >= xram_size:
print('ERROR: %s overflow %u in %s' % (name, end, map))
error_count += 1


# go through all the headers looking for extern declarations of functions
Expand Down
Loading