gen_app_partitions.py: make generated/app_smem_*.ld files deterministic
gen_app_partitions.py: make generated/app_smem_*.ld files deterministic

Dictionaries are not ordered in Python 3.5 and before, so building twice
in a row could lead to a different partition order, different
build/zephyr/include/generated/app_smem_*.ld files and different
binaries.

Fix with a minor change to the "for" loop in the output function:
make it iterate on sorted(partitions.items()) instead of the raw and
randomly ordered partitions dictionary.

It is easy to reproduce the issue even without downgrading to an
obsolete Python version; pick a test like samples/userspace/shared_mem/
and simply change the code to this:

--- a/scripts/gen_app_partitions.py
+++ b/scripts/gen_app_partitions.py
@@ -159,10 +159,12 @@ def parse_elf_file(partitions):
                     partitions[partition_name][SZ] += size

+import random
 def generate_final_linker(linker_file, partitions):
     string = linker_start_seq
     size_string = ''
-    for partition, item in sorted(partitions.items()):
+    for partition, item in sorted(partitions.items(),
+                                  key=lambda x: random.random()):
         string += data_template.format(partition)
         if LIB in item:
             for lib in item[LIB]:

Signed-off-by: Marc Herbert <77e7c7d746b52c6eb01119b65a031ae1f650246d@intel.com>

galak/zephyr,zephyrproject-rtos/zephyr,Vudentz/zephyr,Vudentz/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,finikorg/zephyr,nashif/zephyr,galak/zephyr,nashif/zephyr,galak/zephyr,nashif/zephyr,Vudentz/zephyr,finikorg/zephyr,Vudentz/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,galak/zephyr,zephyrproject-rtos/zephyr,zephyrproject-rtos/zephyr,finikorg/zephyr,galak/zephyr,nashif/zephyr,nashif/zephyr,Vudentz/zephyr,Vudentz/zephyr