[Solved] Convert the new .kicad_sch to the old .sch

Fixed my comment here to avoid any misunderstanding.

I have these 2 in the same folder

_eeschema.kiface
kicad_6.0.2-0-ubuntu21-sch.diff

Being inside of this folder, I am applying it with

➜  eeschema git apply kicad_6.0.2-0-ubuntu21-sch.diff

warning: _eeschema.kiface has type 100755, expected 100644

Without -R (this is to revert the patch).

1 Like

Of course, sorry. It workd. Let me test

With

cmp -l _eeschema.kiface.orig _eeschema.kiface

you can see that only 2 bytes have been changed.

Sorry, the permission bits are wrong (didn’t notice it on Windows :man_facepalming:). Fix with

chmod 644 _eeschema.kiface

chmod 755 _eeschema.kiface

or change 100644 to 100755 in the diff file first.
Edit: Now fixed above.

Ok, here I go again.

This is the patch fixed

diff --git a/_eeschema.kiface b/_eeschema.kiface
index 1008ed7985ca10dee7e122164e90e9d2b7deb11e..9f3fe6a21e4ad86a6c8dbdd5062823cd80ae8ed4 100755
GIT binary patch
delta 22
dc-ouse?R98ApUU6I+<yL;rBb%$$Ji;0RWQ245k18

delta 22
dc-ouse?R98ApUU6I+@9(^ZOm^<UNPa005HL46*<K

Copying the original file and applying the patch

eeschema="/usr/bin/_eeschema.kiface"
cp -f ${eeschema} ./
git apply kicad_6.0.2-0-ubuntu21-sch.diff

Ok, now I pre-append the PATH to the folder with this new __eeschema.kiface. I am not sure yet if this is going to work. Maybe I have to replace it directly in /usr/share/bin instead.

Then I am launching the .kicad_sch.
Now, what should I do?
Save it or Save it as?
Both did not work still.

I am going to place it in the original path, since eeschema may have hardcoded paths

Checking

➜  eeschema cmp -l /usr/bin/_eeschema.kiface.bkp /usr/bin/_eeschema.kiface
 6503387 104 220
 6503388 211  61

Nice, the file still has the same name (extension), even if I change it. But it has the .sch syntax inside.

➜  eeschema cat board.kicad_sch | head -50
EESchema Schematic File Version 5
EELAYER 36 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "Astharot SoC"
Date "2020-10-28"
Rev "0.1"
Comp "GAPH"
Comment1 "Author Leandro Heck"
Comment2 "leoheck@gmail.com"
Comment3 ""
Comment4 ""
Comment5 ""
Comment6 ""
Comment7 ""
Comment8 ""
Comment9 ""
$EndDescr
Connection ~ 1375 1475
Connection ~ 1375 1800
Connection ~ 1625 5425
Connection ~ 1650 3275
Connection ~ 1675 7225
Connection ~ 1675 7425
Connection ~ 1775 3700

I don’t know if it’s working with PATH (it’s a shared library or module). This is only to test if it’s worthwhile, so just temporarily replace it in /usr/bin. If it’s working with your script, you probably want to compile a more modified version.

Now, this has limitations, like coordinates are truncated or rounded, and it doesn’t change the symbol libraries. While the code is still there, it has not been tested and might even crash if a new feature of KiCad 6 is used…

I could copy eeschema to the same folder that was apprehended in the PATH, and it worked too. So eeschema has this __eeschema.kicade hardcoded inside to get it from the same folder.

This way I don’t need to replace system’s version of it. I can have patched file and eeschema in a different folder and load this whenever I need.

1 Like

Now, this has limitations, like coordinates are truncated or rounded, and it doesn’t change the symbol libraries. While the code is still there, it has not been tested and might even crash if a new feature of KiCad 6 is used…

Sure, this is a good warning and also makes sense.

Alternativelly I am finishing Kicad’s build for the first time. I am going to try to update this directly in the code. If that works, then I can change it a bit to use it from the command line as a standalone tool.

Yeah, but I am waiting for this API thing for 2 years already. I have no idea when it is going to be released. I just wanted to have this export svg function so bad. Now since you have mentioned 6.99, it may be landing to the nightly builds sometime soon. I will keep an eye on it then. Thanks a lot for this whole tutorial dude!

git diff and git apply are very similar to the traditional diff and patch commands but can also handle binary data (and not just open files in binary mode), although only for the files that exactly match the hashes in the diff.

The diffs had been created using the following (actually, git had been modified to use pack v3 format to get shorter deltas but the result after applying is the same):

git diff --binary file.orig file | sed 1s/\\.orig// > patch.diff

hey, @mgyger by any chance do you know where in the code eeschama loads/opens schematics when I run from the command line with the following command, for instance?

eeschema board.kicad_sch

I just want to put a code to save the schematics end exit, right after.

In this way, I will pass the main schematic through the command line which already works by default. Eeschema will load it with other dependent schematics, and then it will save it immediately using the old file format and leave.

That is all I need.

Sorry, don’t know, but I guess somewhere where SCH_IO_MGR::FindPlugin is called as well… Maybe ask a developer…

You could set a break point in a debug build and print a stack trace, or pretend to have loaded a 5.1 schematic so that it wants to migrate it to presumed 6.0, or mark it as modified and skip the confirmation dialog on exit…

Sure. The question is for anyone that may have an idea.

Thanks for your help and tips @mgyger

@Munyua_wa_Mugo I believe I could implement what I wanted.

Here is the link to the post where I am showing this working.

As soon as I clean my fork and push it to GitLab I will share it here if you are interested.

1 Like

Here it is my fork and branch kicad_sch2sch-6.0.2

And it has a NOTES.md with some instructions.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.