Skip to content

toolkit: Support a custom global-cfg.db. #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dpgeorge
Copy link
Member

This change makes it so global-cfg.db is loaded from the user config dir, specified by --config-dir <dir>. That means each board needs to provide a copy of this, tailored to that board. It's a pretty small file so that should be OK.

Fixes #3.

@dpgeorge dpgeorge requested a review from iabdalkader March 13, 2025 07:21
@@ -687,7 +687,7 @@ def main():
parser.add_argument(
"--config-dir",
type=str,
default=Path(os.path.dirname(__file__)) / "build/config",
default=None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the default is unchanged, it's just configured in paths.py now.

@iabdalkader
Copy link
Collaborator

I'm yet to wrap my mind around the maze of paths :) but I don't pass any config dirs when calling the tools because I use the default build/config/app-device-config-ae3.json. Will it be possible to provide similar default global-cfg-ae3.db, in the same directory maybe?

@dpgeorge
Copy link
Member Author

Will it be possible to provide similar default global-cfg-ae3.db, in the same directory maybe?

Yes, but then how will you specify this file?

@dpgeorge
Copy link
Member Author

In the end I will add targets to the Makefile like make maintenance and make updateSystemPackage. They will pass the correct config directory options.

# Use Toolkit directory as the default.
CONFIG_INPUT_DIR = TOOLKIT_DIR / "build/config"
else:
CONFIG_INPUT_DIR = Path(config_dir)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this force us to provide the app-device-config-aex.json file in the same directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't that what you want, all the relevant config files in the one location?

Copy link
Collaborator

@iabdalkader iabdalkader Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but there's no way to specify which global-cfg.db to use, so we'd have to provide our own config dir with duplicated files if we want to use something other than AE7 in global-cfg.db. Alternatively, we could keep the file where it was, /utils/global-cfg.db, and add files for AE3, AE7 and an arg to specify which one to use?

EDIT: I realized the default global-cfg.db is also set for AE7, which we don't use.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also provide these as args via board.mk files with default for Interface and jtag-adater? As they should have been done in the first place. Though, I'm not sure about that long device part name.

    DEVICE_PART_NUMBER = cfg["DEVICE"]["Part#"]
    DEVICE_REVISION = cfg["DEVICE"]["Revision"]
    MRAM_BURN_INTERFACE = cfg["MRAM-BURNER"]["Interface"]
    JTAG_ADAPTER = cfg["MRAM-BURNER"]["Jtag-adapter"]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So each part has a unique number, I don't see any reason for the long part description string. We could just pass the part number, and revision, as args, and find the rest of the features from the DB.

Available options:

1 - E7 (AE722F80F55D5LS) - 5.5 MRAM / 13.5 SRAM (default)
2 - E7 (AE722F80F55D5AS) - 5.5 MRAM / 13.5 SRAM
3 - E5 (AE512F80F55D5LS) - 5.5 MRAM / 13.5 SRAM
4 - E5 (AE512F80F5582AS) - 5.5 MRAM / 8.25 SRAM
5 - E5 (AE512F80F55D5AS) - 5.5 MRAM / 13.5 SRAM
6 - E5 (AE512F80F5582LS) - 5.5 MRAM / 8.25 SRAM
7 - E3 (AE302F80F55D5LE) - 5.5 MRAM / 13.5 SRAM
8 - E3 (AE302F80F5582LE) - 5.5 MRAM / 8.25 SRAM
9 - E3 (AE302F80F55D5AE) - 5.5 MRAM / 13.5 SRAM
10 - E3 (AE302F80F5582AE) - 5.5 MRAM / 8.25 SRAM
11 - E3 (AE302F80C1557LE) - 1.5 MRAM / 5.75 SRAM
12 - E3 (AE302F40C1537LE) - 1.5 MRAM / 3.75 SRAM
13 - E1 (AE101F4071542LH) - 1.5 MRAM / 4.5 SRAM
14 - E1C (AE1C1F4051920PH) - 1.86 MRAM / 2.0 SRAM
15 - E1C (AE1C1F4051920HH) - 1.86 MRAM / 2.0 SRAM
16 - E1C (AE1C1F40319205H) - 1.86 MRAM / 2.0 SRAM
17 - E1C (AE1C1F1041010PH) - 1.0 MRAM / 1.0 SRAM
18 - E1C (AE1C1F1041010HH) - 1.0 MRAM / 1.0 SRAM
19 - E1C (AE1C1F10410105H) - 1.0 MRAM / 1.0 SRAM
20 - E1C (AE1C1F1040505PH) - 0.5 MRAM / 0.5 SRAM
21 - E1C (AE1C1F1040505HH) - 0.5 MRAM / 0.5 SRAM
22 - E1C (AE1C1F10405055H) - 0.5 MRAM / 0.5 SRAM

@iabdalkader
Copy link
Collaborator

How about this? It was actually easier than I thought.

diff --git a/toolkit/updateSystemPackage.py b/toolkit/updateSystemPackage.py
index a6287b8..d607364 100755
--- a/toolkit/updateSystemPackage.py
+++ b/toolkit/updateSystemPackage.py
@@ -112,6 +112,8 @@ def main():
     parser.add_argument(
         "-V", "--version", help="Display Version Number", action="store_true"
     )
+    parser.add_argument("--part", type=str, help="Part Number")
+    parser.add_argument("--rev", type=str, help="Part Revision")
     parser.add_argument("-v", "--verbose", help="verbosity mode", action="store_true")
     args = parser.parse_args()
def load_global_config(part_num=None, part_rev=None):
    global DEVICE_PART_NUMBER
    global DEVICE_REVISION
    global MRAM_BURN_INTERFACE
    global JTAG_ADAPTER
    global HASHES_DB

    if part_num and part_rev:
        DEVICE_PART_NUMBER = getPartDescription(part_num)
        DEVICE_REVISION = part_rev
        MRAM_BURN_INTERFACE = "isp"
        JTAG_ADAPTER = "J-Link"
    else:
        # load from config file.
        cfg = read_global_config(CONFIG_FILE)

        # validate configuration parameters
        # check parameter is configured...
        checkAttribute(cfg["DEVICE"], "Revision")

        DEVICE_PART_NUMBER = cfg["DEVICE"]["Part#"]
        DEVICE_REVISION = cfg["DEVICE"]["Revision"]

        # retrieve DEV Environments
        HASHES_DB = hashes

        # set MRAM BURNER Access Interface
        MRAM_BURN_INTERFACE = cfg["MRAM-BURNER"]["Interface"]

        # set JTAG Adapter
        JTAG_ADAPTER = cfg["MRAM-BURNER"]["Jtag-adapter"]

    # read hashes DB
    hashes = read_global_config(HASHES_DB_FILE)

    # load rest of config params
    load_device_config(DEVICE_PART_NUMBER, DEVICE_REVISION)

Invoked like:

python updateSystemPackage.py --port /dev/ttyUSB0 --part AE302F80F55D5AE --rev B4
Burning: System Package in MRAM
Selected Device:
Part# E3 (AE302F80F55D5AE) - 5.5 MRAM / 13.5 SRAM - Rev: B4

Connecting to the target device...
[INFO] baud rate  55000
[INFO] dynamic baud rate change  Enabled
[INFO] /dev/ttyUSB0 open Serial port success
Bootloader stage: SERAM
[INFO] Detected Device:
Part# AE302F80F55D5AE - Rev: B4
- MRAM Base Address: 0x80580000
Maintenance Mode = Enabled 
Authenticate Image:  True
Verify Certificate
Signature File:  alif/SP-AE302F80F55D5AE-rev-b4.bin.sign
Download Image
alif/SP-AE302F80F55D5AE-rev-b4.bin[####################]100%: 270368/270368 bytes
Verify Image
Done

@dpgeorge
Copy link
Member Author

Closing in favour of #6.

@dpgeorge dpgeorge closed this Mar 14, 2025
@dpgeorge dpgeorge deleted the use-custom-global-cfg branch March 14, 2025 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants