Go Down

Topic: Issue with custom board package json file. (Read 811 times) previous topic - next topic

jopiek

Dec 31, 2018, 10:21 am Last Edit: Dec 31, 2018, 10:22 am by jopiek
We needed to modify the boot loader for custom boards that we use (we basically removed the double tap option of the SAMD21 to get a faster boot time needed for our push button controller).

So far so good. When I manually add the new variant to the desired folder:
~/Library/Arduino15/packages/Manufacturer/hardware/1.0.0/
(Where manufacturer is in this case RobotPatient)
- the new board shows up under Tools | Board

But I want to do it more like the official way since we might also involve students in the project (since it is part of a larger research project together with a college) etc.

So I created a package json file (package_robotpatient_index.json)
I really don't like the manual work involved in creating such a file so I though it would be useful to create a python script that does most of the work (no different versions for now). It can be improved but seems to do the job for now (I checked and double checked the output). This includes adding all package files inside a subfolder "package" into a tar.bz2 file, computing file size and SHA256 hash.

If I add the JSON to the Board Manager URL's it is downloaded. But then when I go to the boards manager and try to install I get ugly Java errors in the console:
Code: [Select]
ava.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onInstallPressed$2(ContributionManagerUI.java:175)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:273)
at java.nio.file.Paths.get(Paths.java:84)
at cc.arduino.contributions.DownloadableContributionsDownloader.download(DownloadableContributionsDownloader.java:60)
at cc.arduino.contributions.DownloadableContributionsDownloader.download(DownloadableContributionsDownloader.java:55)
at cc.arduino.contributions.packages.ContributionInstaller.install(ContributionInstaller.java:101)
at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onInstallPressed$2(ContributionManagerUI.java:172)
... 1 more


Apparently the (tar.bz2) file can't be downloaded and extracted? But I don't see the issue: the links work in my browser. Hope someone else has had the same problem and found a solution? Otherwise at least enjoy the Python script, I think it would be useful.

pert

There were several errors in your JSON file:
  • archive_file_name should be archiveFileName
  • website_url should be websiteURL
  • tools_dependencies should be toolsDependencies
  • the value of size should be in quotes


After fixing that, there is still an error caused by the structure of your installation archive (https://robotpatient.com/modules/boards/RobotPatient-samd-1.0.0.tar.bz2). You have all the files of the package just dumped right into the root of the archive file. That is not allowed. You need to have a valid folder structure. Download an established hardware package to see how it should be:
http://downloads.arduino.cc/cores/samd-1.6.20.tar.bz2

The structure should be something like this:

RobotPatient
|_bootloaders
|_cores
|_libraries
|_variants
|_boards.txt
|_platform.txt

It doesn't matter what the name of the root folder of the package is (because the installation folder will be named according to the "name" value in your JSON file, but there does need to be a root folder in the archive. If you want the package to actually work (instead of installing but then compilations for your board failing), you also need to make sure the various files are in the correct subfolders.

pert

We've done a pretty thorough job of documenting the requirements for the Boards Manager support. You might find it useful to refer to it:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.6.x-package_index.json-format-specification

jopiek

#3
Dec 31, 2018, 11:33 am Last Edit: Dec 31, 2018, 11:38 am by jopiek
Thanks pert, I did use that format specification though, but I took some shortcut that now bytes me, by looking into other JSON files, (maybe they have the same problem). Will try to fix it and report the outcomes.

B.t.w. the dump must have been caused by me trying to not at the root itself in python, my previous version had "package" and then the structure like you explained in it.

Aha. Something else happend I do use archiveFileName etc. but it is incorrectly converted by my Python script!

pert

Here's the fixed JSON file:
Code: [Select]
{
    "packages": [
        {
            "email": "info@robotpatient.com",
            "help": {
                "online": "https://robotpatient.com/modules/"
            },
            "maintainer": "RobotPatient Simulators BV",
            "name": "RobotPatient",
            "platforms": [
                {
                    "architecture": "samd",
                    "archiveFileName": "RobotPatient-samd-1.0.0.tar.bz2",
                    "boards": [
                        {
                            "name": "RobotPatient SAMD21"
                        }
                    ],
                    "category": "Contributed",
                    "checksum": "SHA-256:8c8b295543c86ba07e11cdb46b41e1ec8e13f321ab4e82882f801755f018923f",
                    "help": {
                        "online": "https://robotpatient.com/modules/"
                    },
                    "name": "RobotPatient SAMD21",
                    "size": "4070993",
                    "toolsDependencies": [
                        {
                            "name": "arm-none-eabi-gcc",
                            "packager": "arduino",
                            "version": "4.8.3-2014q1"
                        },
                        {
                            "name": "bossac",
                            "packager": "arduino",
                            "version": "1.6.1-arduino"
                        },
                        {
                            "name": "openocd",
                            "packager": "arduino",
                            "version": "0.9.0-arduino"
                        },
                        {
                            "name": "CMSIS",
                            "packager": "arduino",
                            "version": "4.0.0-atmel"
                        }
                    ],
                    "url": "https://robotpatient.com/modules/boards/RobotPatient-samd-1.0.0.tar.bz2",
                    "version": "1.0.0"
                }
            ],
            "tools": [],
            "websiteURL": "http://robotpatient.com/"
        }
    ]
}

The URL if you want to try it out:
https://gist.githubusercontent.com/per1234/4c1b089181e9a946e0bf83d01bb26f53/raw/2f0d666bf08fa31d66b484eb357c5f9834f4e2f6/package_robotpatient_index.json

jopiek

Thanks again. Was a simple but very nasty problem that I just overlooked (aren't all the bugs). Fresh eyes...

pert

The JSON generator script looks interesting. I am in charge of adding entries for new releases to the JSON files of several hardware packages and I've been meaning to do something of the sort for a while. Ideally, the whole process would happen automatically every time a Git tag was pushed to the repository, probably as part of the continuous integration system.

jopiek

#7
Dec 31, 2018, 11:49 am Last Edit: Dec 31, 2018, 12:04 pm by jopiek
It was a very tiny bug in the script: pickle_platform = jsonpickle.encode(myBoards.to_dict(), unpicklable=False)

I forgot the to_dict()! Now it works (it then translates it back to correct keynames instead of the variable names of the objects). Thanks for showing me my mistake pert :) Happy to improve the script etc. I think it will really help the community indeed!

Go Up