summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGlenn Ruben Bakke <glennbakke@gmail.com>2017-10-04 21:45:04 +0200
committerGlenn Ruben Bakke <glennbakke@gmail.com>2017-10-04 21:45:04 +0200
commitbcab2ba0a80297100919366add6bada140c6ed75 (patch)
tree5133218f4fc010d5688f006dbdd1e2f346a843f7 /tools
parent4468731e3d039a3f72ac25aa43e936cf5ebb3f78 (diff)
parentf869d6b2e339c04469c6c9ea3fb2fabd7bbb2d8c (diff)
ports/nrf: Upmerging port with upstream master
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check_code_size.sh2
-rwxr-xr-xtools/codestats.sh44
-rwxr-xr-xtools/mpy-tool.py51
-rw-r--r--tools/upip.py2
-rw-r--r--tools/upip_utarfile.py6
5 files changed, 55 insertions, 50 deletions
diff --git a/tools/check_code_size.sh b/tools/check_code_size.sh
index c5f0c6ffd..2925ff168 100755
--- a/tools/check_code_size.sh
+++ b/tools/check_code_size.sh
@@ -10,7 +10,7 @@ REFERENCE=$HOME/persist/firmware.bin
if [ -f $REFERENCE ]; then
size_old=$(stat -c%s $REFERENCE)
- size_new=$(stat -c%s minimal/build/firmware.bin)
+ size_new=$(stat -c%s ports/minimal/build/firmware.bin)
echo "Old size: $size_old new size: $size_new"
if [ $size_new -gt $size_old ]; then
echo "Validation failure: Core code size increased"
diff --git a/tools/codestats.sh b/tools/codestats.sh
index 5272f3e9c..09284a30d 100755
--- a/tools/codestats.sh
+++ b/tools/codestats.sh
@@ -9,7 +9,7 @@
# executing because it does not exist in old revisions of the repository.
# check that we are in the root directory of the repository
-if [ ! -d py -o ! -d unix -o ! -d stmhal ]; then
+if [ ! -d py -o ! -d ports/unix -o ! -d ports/stm32 ]; then
echo "script must be run from root of the repository"
exit 1
fi
@@ -23,18 +23,18 @@ AWK=awk
MAKE="make -j2"
# these are the binaries that are built; some have 2 or 3 depending on version
-bin_unix=unix/micropython
-bin_stmhal=stmhal/build-PYBV10/firmware.elf
-bin_barearm_1=bare-arm/build/flash.elf
-bin_barearm_2=bare-arm/build/firmware.elf
-bin_minimal=minimal/build/firmware.elf
-bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf
-bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf
-bin_cc3200_3=cc3200/build/WIPY/release/application.axf
+bin_unix=ports/unix/micropython
+bin_stm32=ports/stm32/build-PYBV10/firmware.elf
+bin_barearm_1=ports/bare-arm/build/flash.elf
+bin_barearm_2=ports/bare-arm/build/firmware.elf
+bin_minimal=ports/minimal/build/firmware.elf
+bin_cc3200_1=ports/cc3200/build/LAUNCHXL/application.axf
+bin_cc3200_2=ports/cc3200/build/LAUNCHXL/release/application.axf
+bin_cc3200_3=ports/cc3200/build/WIPY/release/application.axf
# start at zero size; if build fails reuse previous valid size
size_unix="0"
-size_stmhal="0"
+size_stm32="0"
size_barearm="0"
size_minimal="0"
size_cc3200="0"
@@ -86,7 +86,7 @@ function get_size3() {
if [ -r $output ]; then
last_rev=$(tail -n1 $output | $AWK '{print $1}')
else
- echo "# hash size_unix size_stmhal size_barearm size_minimal size_cc3200 pystones" > $output
+ echo "# hash size_unix size_stm32 size_barearm size_minimal size_cc3200 pystones" > $output
last_rev="v1.0"
fi
@@ -132,37 +132,37 @@ EOF
#### unix ####
$RM $bin_unix
- $MAKE -C unix CFLAGS_EXTRA=-DNDEBUG
+ $MAKE -C ports/unix CFLAGS_EXTRA=-DNDEBUG
size_unix=$(get_size $size_unix $bin_unix)
# undo patch if it was applied
git checkout unix/modtime.c
- #### stmhal ####
+ #### stm32 ####
- $RM $bin_stmhal
- $MAKE -C stmhal board=PYBV10
- size_stmhal=$(get_size $size_stmhal $bin_stmhal)
+ $RM $bin_stm32
+ $MAKE -C ports/stm32 board=PYBV10
+ size_stm32=$(get_size $size_stm32 $bin_stm32)
#### bare-arm ####
$RM $bin_barearm_1 $bin_barearm_2
- $MAKE -C bare-arm
+ $MAKE -C ports/bare-arm
size_barearm=$(get_size2 $size_barearm $bin_barearm_1 $bin_barearm_2)
#### minimal ####
- if [ -r minimal/Makefile ]; then
+ if [ -r ports/minimal/Makefile ]; then
$RM $bin_minimal
- $MAKE -C minimal CROSS=1
+ $MAKE -C ports/minimal CROSS=1
size_minimal=$(get_size $size_minimal $bin_minimal)
fi
#### cc3200 ####
- if [ -r cc3200/Makefile ]; then
+ if [ -r ports/cc3200/Makefile ]; then
$RM $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3
- $MAKE -C cc3200 BTARGET=application
+ $MAKE -C ports/cc3200 BTARGET=application
size_cc3200=$(get_size3 $size_cc3200 $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3)
fi
@@ -178,7 +178,7 @@ EOF
#### output data for this commit ####
- echo "$hash $size_unix $size_stmhal $size_barearm $size_minimal $size_cc3200 $pystones" >> $output
+ echo "$hash $size_unix $size_stm32 $size_barearm $size_minimal $size_cc3200 $pystones" >> $output
done
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py
index 544f90cc8..ded962487 100755
--- a/tools/mpy-tool.py
+++ b/tools/mpy-tool.py
@@ -239,7 +239,7 @@ class RawCode:
def dump(self):
# dump children first
for rc in self.raw_codes:
- rc.freeze()
+ rc.freeze('')
# TODO
def freeze(self, parent_name):
@@ -331,27 +331,29 @@ class RawCode:
# TODO
raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,))
- # generate constant table
- print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {'
- % (self.escaped_name, len(self.qstrs) + len(self.objs) + len(self.raw_codes)))
- for qst in self.qstrs:
- print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id)
- for i in range(len(self.objs)):
- if type(self.objs[i]) is float:
- print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B')
- print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i))
- print('#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C')
- n = struct.unpack('<I', struct.pack('<f', self.objs[i]))[0]
- n = ((n & ~0x3) | 2) + 0x80800000
- print(' (mp_rom_obj_t)(0x%08x),' % (n,))
- print('#else')
- print('#error "MICROPY_OBJ_REPR_D not supported with floats in frozen mpy files"')
- print('#endif')
- else:
- print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i))
- for rc in self.raw_codes:
- print(' MP_ROM_PTR(&raw_code_%s),' % rc.escaped_name)
- print('};')
+ # generate constant table, if it has any entries
+ const_table_len = len(self.qstrs) + len(self.objs) + len(self.raw_codes)
+ if const_table_len:
+ print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {'
+ % (self.escaped_name, const_table_len))
+ for qst in self.qstrs:
+ print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id)
+ for i in range(len(self.objs)):
+ if type(self.objs[i]) is float:
+ print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B')
+ print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i))
+ print('#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C')
+ n = struct.unpack('<I', struct.pack('<f', self.objs[i]))[0]
+ n = ((n & ~0x3) | 2) + 0x80800000
+ print(' (mp_rom_obj_t)(0x%08x),' % (n,))
+ print('#else')
+ print('#error "MICROPY_OBJ_REPR_D not supported with floats in frozen mpy files"')
+ print('#endif')
+ else:
+ print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i))
+ for rc in self.raw_codes:
+ print(' MP_ROM_PTR(&raw_code_%s),' % rc.escaped_name)
+ print('};')
# generate module
if self.simple_name.str != '<module>':
@@ -362,7 +364,10 @@ class RawCode:
print(' .n_pos_args = %u,' % self.prelude[3])
print(' .data.u_byte = {')
print(' .bytecode = bytecode_data_%s,' % self.escaped_name)
- print(' .const_table = (mp_uint_t*)const_table_data_%s,' % self.escaped_name)
+ if const_table_len:
+ print(' .const_table = (mp_uint_t*)const_table_data_%s,' % self.escaped_name)
+ else:
+ print(' .const_table = NULL,')
print(' #if MICROPY_PERSISTENT_CODE_SAVE')
print(' .bc_len = %u,' % len(self.bytecode))
print(' .n_obj = %u,' % len(self.objs))
diff --git a/tools/upip.py b/tools/upip.py
index 7b85c718f..411da49e8 100644
--- a/tools/upip.py
+++ b/tools/upip.py
@@ -122,7 +122,7 @@ def url_open(url):
s.connect(addr)
if proto == "https:":
- s = ussl.wrap_socket(s)
+ s = ussl.wrap_socket(s, server_hostname=host)
if warn_ussl:
print("Warning: %s SSL certificate is not validated" % host)
warn_ussl = False
diff --git a/tools/upip_utarfile.py b/tools/upip_utarfile.py
index 65ce0bdca..460ca2cd4 100644
--- a/tools/upip_utarfile.py
+++ b/tools/upip_utarfile.py
@@ -3,7 +3,7 @@ import uctypes
# http://www.gnu.org/software/tar/manual/html_node/Standard.html
TAR_HEADER = {
"name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100),
- "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 12),
+ "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 11),
}
DIRTYPE = "dir"
@@ -75,8 +75,8 @@ class TarFile:
return None
d = TarInfo()
- d.name = str(h.name, "utf-8").rstrip()
- d.size = int(bytes(h.size).rstrip(), 8)
+ d.name = str(h.name, "utf-8").rstrip("\0")
+ d.size = int(bytes(h.size), 8)
d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
return d