Re: Flash configuration in dts file

Laurence Pasteau

Thanks David.

However since I had this issue, I change the board definition to have a board out of zephyr scope, since it is a board created here in the compagny for a specific custom. Before I used pca10040 board and a dts.overlay file with all custom components but it is less clean.

It seems that what I needed to do works when the dts file is out of zephyr scope. I don't really undestand why but my issue is resolved in this way.

I have in dts file :
        zephyr ,code-partition = &slot_partition;
Then :
        slot_partition: partition@0 {
            label = "code-partition";
            reg = <0x00000000 0x40000>;

and CONFIG_FLASH_LOAD_SIZE  is correclty setted to 262kB.


De : David Brown <david.brown@...>
Envoyé : mardi 21 août 2018 19:46
À : Laurence Pasteau
Cc : zephyr-devel@...
Objet : Re: [Zephyr-devel] Flash configuration in dts file

On Fri, Aug 17, 2018 at 02:51:54PM +0000, Laurence Pasteau wrote:

>However in the script that generates the generated_dts_board files from dts, it
>seems that :

I wonder if you are running into the same bug I've found in the
extraction script, which assumes the partition reg values are absolute
rather than relative.  I've included the patch below if you want to
try it, and I'll be pushing it into the Zephyr tree soon.

From 656a2b6a78698c1173d9b5537c25eff8f01e2aba Mon Sep 17 00:00:00 2001
From: David Brown <david.brown@...>
Date: Tue, 21 Aug 2018 11:40:51 -0600
Subject: [PATCH] scripts: dts: Fix flash load offset

The flash load offset is being computed assuming that the reg property
in the partition table is an absolute address.  Since this is a relative
address, this causes the offset to effectively subtract the flash base
twice.  Since most flash devices start at zero, this hasn't been noticed
until now.

Change this so that the load-offset is just the offset of the code

Signed-off-by: David Brown <david.brown@...>
 scripts/dts/extract/ | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/dts/extract/ b/scripts/dts/extract/
index fb5d42981..98fb8422d 100644
--- a/scripts/dts/extract/
+++ b/scripts/dts/extract/
@@ -95,8 +95,7 @@ class DTFlash(DTDirective):
         if node and node is not self._flash_node:
             # only compute the load offset if the code partition
             # is not the same as the flash base address
-            load_offset = str(int(node['props']['reg'][0]) \
-                              - int(self._flash_node['props']['reg'][0]))
+            load_offset = node['props']['reg'][0]
             load_defs['CONFIG_FLASH_LOAD_OFFSET'] = load_offset
             load_size = node['props']['reg'][1]
             load_defs['CONFIG_FLASH_LOAD_SIZE'] = load_size

Join to automatically receive all group messages.