[GitHub] [mynewt-core] utzig commented on issue #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on issue #1906: hw/bsp/dialog: Add generation of dialog header 
on images
URL: https://github.com/apache/mynewt-core/pull/1906#issuecomment-508870616
 
 
   Yes, we add them by hand. Your looks correct and I am not sure why RAT did 
not identify it; I'll check later.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on issue #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on issue #1906: hw/bsp/dialog: Add generation of dialog 
header on images
URL: https://github.com/apache/mynewt-core/pull/1906#issuecomment-508853069
 
 
   Do we typically add the license headers by hand or use RAT?  I don't think 
this one needs to be excluded, does it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786949
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786959
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786928
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
 
 Review comment:
   fixed.  I fixed a lot of other pep8 issues as well.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786851
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786869
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
 
 Review comment:
   fixed


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786891
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
 
 Review comment:
   fixed


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300786764
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300738348
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
 
 Review comment:
   yeah i can do that for the Pp and Qq as well.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300733978
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
 
 Review comment:
   yeah i was wondering about windows.  I'll change this to your suggestion. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
agross-korg commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300733787
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] utzig commented on issue #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on issue #1906: hw/bsp/dialog: Add generation of dialog header 
on images
URL: https://github.com/apache/mynewt-core/pull/1906#issuecomment-508801322
 
 
   @agross-korg Also you need to include a commit adding the script to 
`/.rat-excludes`. RAT is so awesome that you can just edit the file and add 
`da1469x_header_tool.py`!


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300730268
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300729745
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
 
 Review comment:
   PEP-8: no space before `:` (`data: xxx`), no space before `,` (`offset, `)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300728822
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300730411
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300729387
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
 
 Review comment:
   could also be `range(length)`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300727947
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300732615
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
 
 Review comment:
   Maybe those `\xaa\x11`, `\xaa\x22`, `\xaa\x33`, `\xaa\x44` literals should 
be constants with descriptive names?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300732310
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
 
 Review comment:
   if this should ever run on Windows or something not Unix-like I guess the 
correct way to add the paths would be `os.path.join(os.getcwd(), "repos", 
"mcuboot", "scripts", "imgtool")`... not sure this will ever be required! :-)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300729320
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
 
 Review comment:
   space missing after `=`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-core] utzig commented on a change in pull request #1906: hw/bsp/dialog: Add generation of dialog header on images

2019-07-05 Thread GitBox
utzig commented on a change in pull request #1906: hw/bsp/dialog: Add 
generation of dialog header on images
URL: https://github.com/apache/mynewt-core/pull/1906#discussion_r300730734
 
 

 ##
 File path: hw/bsp/dialog_da1469x-dk-pro/da1469x_header_tool.py
 ##
 @@ -0,0 +1,282 @@
+#! /usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import re
+import click
+import io
+import os.path
+import struct
+import binascii
+import time
+from typing import NamedTuple
+import base64
+
+from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives import serialization
+
+from cryptography.hazmat.primitives import hashes
+
+# Add in patch to mcuboot.  This is required to pull in keys module from 
imgtool
+import sys
+sys.path.append(os.getcwd() + "/repos/mcuboot/scripts/imgtool")
+import keys as keys
+
+class product_header(NamedTuple):
+ident: bytes
+active_addr: int
+update_addr: int
+cmda_reg: int
+cmdb_reg: int
+flash_ident: bytes
+flash_length: int
+cmd_seq: bytes
+
+class key_revocation_entry(NamedTuple):
+key_type: int
+key_index: int
+
+class revocation_section(NamedTuple):
+ident: bytes
+length: int
+
+class device_administration_section(NamedTuple):
+ident: bytes
+length: int
+
+class signature_section(NamedTuple):
+sig_idx: int
+enc_idx: int
+nonce: bytes
+ident: bytes
+length: int
+signature: bytes
+
+class security_section(NamedTuple):
+ident: bytes
+length: int
+
+class fw_header(NamedTuple):
+ident: bytes
+length: int
+crc: int
+version: bytes
+timestamp: int
+ivt_offset: int
+
+def crc16(data : bytearray, offset , length):
+if data is None or offset < 0 or offset > len(data)- 1 and offset+length > 
len(data):
+return 0
+crc = 0x
+for i in range(0, length):
+crc ^= data[offset + i] << 8
+for j in range(0,8):
+if (crc & 0x8000) > 0:
+crc =(crc << 1) ^ 0x1021
+else:
+crc = crc << 1
+return crc & 0x
+
+class da1469x_fw_image(object):
+
+def __init__(self, path, encrypt_file, sig_file, sig_slot, decrypt_slot,
+ revoke, version):
+header = product_header(b'Pp', 0x2000, 0x2000, 0xa8a500eb, 0x66,
+b'\xaa\x11', 3, b'\x01\x40\07')
+self.img = struct.pack('<2s2sH3s', *header)
+self.img += struct.pack('

[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #508: npl/riot: strip down the default configuration

2019-07-05 Thread GitBox
andrzej-kaczmarek commented on a change in pull request #508: npl/riot: strip 
down the default configuration
URL: https://github.com/apache/mynewt-nimble/pull/508#discussion_r300707183
 
 

 ##
 File path: porting/npl/riot/include/syscfg/syscfg.h
 ##
 @@ -830,7 +830,8 @@
 #endif
 
 #ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS
-#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS)
+#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS ((2 + MYNEWT_VAL_BLE_SM_SC) * \
 
 Review comment:
   And yes, SM is not compiled in when LE SC and LE legacy pairing are both 
disabled. There's just a simple handler for L2CAP channel to reply with an 
error on any received signalling.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #508: npl/riot: strip down the default configuration

2019-07-05 Thread GitBox
andrzej-kaczmarek commented on a change in pull request #508: npl/riot: strip 
down the default configuration
URL: https://github.com/apache/mynewt-nimble/pull/508#discussion_r300705983
 
 

 ##
 File path: porting/npl/riot/include/syscfg/syscfg.h
 ##
 @@ -830,7 +830,8 @@
 #endif
 
 #ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS
-#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS)
+#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS ((2 + MYNEWT_VAL_BLE_SM_SC) * \
 
 Review comment:
   We simply create all 3 channels in `ble_hs_conn_alloc` and failure to create 
at least one means connection is not allocated in the host. Even if both LE SC 
and LE legacy pairing are disabled, SM channel has to be allocated in order to 
be compliant with spec [1] that is so we can reply on signalling with an error 
as otherwise remote has no way to know that we do not support pairing.
   
   [1] Core 5.1, Vol 3, Part A,  section 2.1
   > At a minimum, the L2CAP Signaling channel (fixed channel 0x0001) or the
   > L2CAP LE Signaling channel (fixed channel 0x0005) shall be supported. **If
   > fixed channel 0x0005 is supported, then fixed channels 0x0004 and 0x0006
   > shall be supported** (see Table 2.2).


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[mynewt-core] branch master updated: close the correct device in battery_adc_close

2019-07-05 Thread mlaz
This is an automated email from the ASF dual-hosted git repository.

mlaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new c2579ed  close the correct device in battery_adc_close
 new f70171e  Merge pull request #1907 from gonccalo/fix_battery_adc_close
c2579ed is described below

commit c2579ed5d89b4e7ce1133e643c381ec9c9591d47
Author: Gonçalo Grilo 
AuthorDate: Thu Jul 4 19:29:21 2019 +0100

close the correct device in battery_adc_close
---
 hw/battery/src/battery_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/battery/src/battery_adc.c b/hw/battery/src/battery_adc.c
index 80093b7..dfe6f0a 100644
--- a/hw/battery/src/battery_adc.c
+++ b/hw/battery/src/battery_adc.c
@@ -137,7 +137,7 @@ battery_adc_close(struct os_dev *dev)
 {
 struct battery_adc *bat_adc = (struct battery_adc *)dev;
 if (bat_adc->adc_dev) {
-os_dev_close((struct os_dev *)_adc->dev);
+os_dev_close((struct os_dev *)_adc->adc_dev);
 bat_adc->adc_dev = NULL;
 }
 return 0;



[GitHub] [mynewt-core] mlaz merged pull request #1907: Changing the device closed by battery_adc_close

2019-07-05 Thread GitBox
mlaz merged pull request #1907: Changing the device closed by battery_adc_close
URL: https://github.com/apache/mynewt-core/pull/1907
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] haukepetersen commented on a change in pull request #508: npl/riot: strip down the default configuration

2019-07-05 Thread GitBox
haukepetersen commented on a change in pull request #508: npl/riot: strip down 
the default configuration
URL: https://github.com/apache/mynewt-nimble/pull/508#discussion_r300701575
 
 

 ##
 File path: porting/npl/riot/include/syscfg/syscfg.h
 ##
 @@ -830,7 +830,8 @@
 #endif
 
 #ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS
-#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS)
+#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS ((2 + MYNEWT_VAL_BLE_SM_SC) * \
 
 Review comment:
   But in the current configuration, SM is not compiled in, right? So I figured 
there is no need to allocate the corresponding L2CAP channel - despite from not 
being standards compliant. Or is there  anything in the code I missed that 
depends on all 3 channels being allocated even if the SM is missing?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on a change in pull request #508: npl/riot: strip down the default configuration

2019-07-05 Thread GitBox
andrzej-kaczmarek commented on a change in pull request #508: npl/riot: strip 
down the default configuration
URL: https://github.com/apache/mynewt-nimble/pull/508#discussion_r300697476
 
 

 ##
 File path: porting/npl/riot/include/syscfg/syscfg.h
 ##
 @@ -830,7 +830,8 @@
 #endif
 
 #ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS
-#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS)
+#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS ((2 + MYNEWT_VAL_BLE_SM_SC) * \
 
 Review comment:
   we always need 3 channels per connection (ATT, signalling and SM) - this is 
mandatory in spec


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] andrzej-kaczmarek commented on issue #477: npl/riot: reduce default MSYS_1_BLOCK_SIZE to minimum

2019-07-05 Thread GitBox
andrzej-kaczmarek commented on issue #477: npl/riot: reduce default 
MSYS_1_BLOCK_SIZE to minimum
URL: https://github.com/apache/mynewt-nimble/pull/477#issuecomment-508759910
 
 
   Note: to the best of my knowledge things work in NimBLE as I describe below, 
but there is very slight chance that some of numbers here are incorrect so 
please correct me with a concrete proof in such case.
   
   @haukepetersen 
   We definitely should improve sanity checks to make sure configuration makes 
sense, especially if there are settings like `MSYS_1_BLOCK_SIZE` where we know 
that certain size is simply required so we do not try to read past allocated 
buffers. You can create an issue for this so we can continue discussion and 
perhaps someone can pick this up in spare time (perhaps some volunteer would 
like to gain a bit of knowledge on LL internals?).
   
   As for random failures and better error handling, I do not think there is 
any major issue in NimBLE in this regard. I mean, if we run out of buffers we 
don't just crash (if we do, this is an issue and not deliberate action) but try 
to do best we can that is allowed by spec, e.g. reply with an error or drop a 
packet (to be more precise: on RX we do not simply drop a packet, but we NAK it 
properly so it will be retransmitted). While it may seem like "random 
failures", this is not because of inherent randomness in NimBLE but due to 
Bluetooth traffic that is pretty much different every time you connect. Also, 
failures are usually logged to stats which can give a better understanding of 
what happens, but this is iirc not available in ports - feel free to port it :-)
   
   And now `MSYS_1_BLOCK_COUNT`:
   - 1 block is absolutely required for LL to start since it's allocated by 
scansm as a placeholder for SCAN_REQ PDU; by quickly looking through code I am 
pretty sure it would be possible to remove this requirement now since it should 
be possible to create SCAN_REQ on the fly (it was not possible when this was 
implemented few years ago)
   - 1 block is required to receive any LL packet and send reply if needed, 
because RX PDU block is reused for TX PDU in such case
   
   This means with only 2 blocks it is possible to create and maintain 
connection, and even receive some data. This is also enough for (G)ATT server 
to reply on requests in general, however reading attribute from ATT database 
requires an extra block for attribute value so some (most?) of those requests 
will fail with only 2 block available. With 3 blocks 80 bytes each you can have 
working connection with usable GATT (it works, I checked using `btshell`).
   
   So why 3 does not work for you? I do not know, could be that phone you try 
to connect with does some procedures which requires an extra block and it's 
just not possible to handle all control and data packets before e.g. timeout 
occurs. Each device behaves differently and that's basically why using an 
"absolute minimum" value is not really a good solution. Perhaps something like 
"recommended value" would be more appropriate here and this would be default 
value since they are adjusted in case we find current value is not good for 
some reason.
   
   One more example to give you better idea on why a single "absolute minimum" 
value won't work with all devices. While checking the above I found an issue in 
code handling `ATT Read By Group Type Request` where we can indeed silently 
drop packet inside ATT server due to oom. To be clear here, we do check this 
pretty consistently in code but there is single execution path where ATT error 
is not set properly which causes us to drop error response. This has an 
interesting consequence because it is actually what makes (G)ATT connection 
work with my Android phone using 3 blocks only. What happens after connection 
is that phone sends control PDU to update connection parameters and data packet 
with mentioned request - both consume remaining 2 blocks. We silently (and 
incorrectly) fail to reply on ATT request and apparently Android for whatever 
reason will retry after few seconds when LL procedure is completed so we have 2 
blocks to handle request and it will work just fine. However, once I fix this 
issue (which is a simple one-liner) (G)ATT won't work because we will reply 
with an error on ATT request and phone will not retry so you basically can't 
discover services. So assuming I will fix the issue, what is an "absolute 
minimum" value here? I do not know, because I do not know how many other PDUs 
an Android phone can send us at once. As ambiguous as it sounds, "sane" is the 
proper value here.
   
   As for data length extensions, small blocks do not mean you can't use this 
feature. You can assuming there are enough small blocks to hold long data PDU - 
we do not need a single block to hold complete data PDU and we'll do just fine 
with chained mbufs. In fact, having a lot of smaller blocks instead of few 
large blocks may be better on nRF51 since it allows to use 

[GitHub] [mynewt-nimble] haukepetersen opened a new pull request #508: npl/riot: strip down the default configuration

2019-07-05 Thread GitBox
haukepetersen opened a new pull request #508: npl/riot: strip down the default 
configuration
URL: https://github.com/apache/mynewt-nimble/pull/508
 
 
   The intention for the NimBLE RIOT port is to provide a rather simplistic 
default configuration, which can be extended from inside the RIOT build system. 
For example, the IP-over-BLE implementation 
(https://github.com/RIOT-OS/RIOT/pull/11578) re-configures the buffer sizes and 
count to more suitable values for that specific use-case.
   
   This PR disables the link layers security and privacy features, and 
optimizes the internal buffer space needed by the l2cap layer.
   
   Building RIOTs default `examples/nimble_gatt` application for the `nrf52dk`, 
this saves ~6.5k of ROM and ~1k of RAM.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] haukepetersen commented on issue #477: npl/riot: reduce default MSYS_1_BLOCK_SIZE to minimum

2019-07-05 Thread GitBox
haukepetersen commented on issue #477: npl/riot: reduce default 
MSYS_1_BLOCK_SIZE to minimum
URL: https://github.com/apache/mynewt-nimble/pull/477#issuecomment-508702215
 
 
   so from what I learned, I further disabled the controller's data length 
extension by default for the RIOT port. As the `msys` buffer sizes are in the 
default config now fairly minimal, it seems to contradicting to allow for large 
link layer packtes at the same time. 
   
   Also it fits better into the overall integration strategy for RIOT: per 
default, NimBLE provides a minimal configuration, and the RIOT build system 
takes care of (re)enabling all the features on demand.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] haukepetersen commented on issue #477: npl/riot: reduce default MSYS_1_BLOCK_SIZE to minimum

2019-07-05 Thread GitBox
haukepetersen commented on issue #477: npl/riot: reduce default 
MSYS_1_BLOCK_SIZE to minimum
URL: https://github.com/apache/mynewt-nimble/pull/477#issuecomment-508676739
 
 
   Oh, I am too tired this morning, everything I needed is actually in the 
email archive posted above...
   
   To summarize (one again), for the current master, the numbers seem to be 
(just tested on a `nrf51` cortex-m0):
   - `sizeof(struct ble_mbuf_hdr)` -> 16 bytes / 20 bytes (w and w/o extended 
adv)
   - `sizeof(struct os_mbuf)` -> 16 bytes
   - `sizeof(struct os_mbuf_pkthdr)` -> 8 bytes
   - HCI ACL data header: 4 bytes
   - PDU: 39 bytes
   
   -> sums up to 83 bytes / 87 bytes -> 88 bytes still seem valid with the 
current code base.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] haukepetersen commented on issue #477: npl/riot: reduce default MSYS_1_BLOCK_SIZE to minimum

2019-07-05 Thread GitBox
haukepetersen commented on issue #477: npl/riot: reduce default 
MSYS_1_BLOCK_SIZE to minimum
URL: https://github.com/apache/mynewt-nimble/pull/477#issuecomment-508668178
 
 
   This discussion is quite fruitful for me, and I hope I don't start to annoy 
anyone :-)
   
   To go forward, I'd like to suggest the following:
   - get this PR merged with the current values (80 bytes msys bufsize, 4 msys 
buffers) -> so is it ok if I squash?
   - move/continue this discussion in a separate issue -> I will gladly open 
one an summarize what we discussed so far.
   
   Only I am offline on holiday for the next 3 weeks, so you won't hear back 
from me until August...


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services