Database Support

I successfully compile the legato app with developer studio with wp76 r10.1 package, maybe you can try the same.

I’m not entirely sure what change made it work. I’ve tried a bunch. I know for sure that I’m using a modified version of this command:

mkapp -t wp750x testdata.adef -i “${LEGATO_ROOT}/third-party/sqlite3/lib /third-party/sqlite3/inc” -L “${LEGATO_ROOT}/third-party/sqlite3/lib/sqlite3.so”

I removed the bold portion of the -i parameter because that directory doesn’t exist on my machine and I obviously changed the target to wp77xx. I’m not sure if that helps.

1 Like

I tried with VSCode on your testsql, and got this:

.
.
.
Apr 1 22:43:05 swi-mdm9x28-wp user.debug Legato: DBUG | UNKNOWN[5111]/ T=main | _componentMain.c _testsqlComponent_Init() 26 | Initializing testsqlComponent component library.
Apr 1 22:43:05 swi-mdm9x28-wp user.debug Legato: DBUG | testsql[5111]/framework T=main | mem.c InitPool() 400 | Memory pool name ‘framework.msgs-LogControlProtocol’ is truncated to ‘framework.msgs-LogControlProtoc’
Apr 1 22:43:05 swi-mdm9x28-wp user.debug Legato: DBUG | testsql[5111]/framework T=main | messagingSession.c le_msg_SetSessionRecvHandler() 2078 | SetSessionRecv: Unix socket session
Apr 1 22:43:05 swi-mdm9x28-wp user.debug Legato: DBUG | testsql[5111]/framework T=main | mem.c le_mem_ForceAlloc() 1172 | Memory pool ‘framework.SigMonitor’ overflowed. Expanded to 1 blocks.
Apr 1 22:43:05 swi-mdm9x28-wp user.debug Legato: DBUG | testsql[5111]/framework T=main | mem.c le_mem_ForceAlloc() 1172 | Memory pool ‘framework.SigHandler’ overflowed. Expanded to 1 blocks.
Apr 1 22:43:05 swi-mdm9x28-wp user.debug Legato: DBUG | testsql[5111]/testsql_exe T=main | _main.c main() 60 | == Starting Event Processing Loop ==
Apr 1 22:43:05 swi-mdm9x28-wp user.info Legato: INFO | testsql[5111]/testsqlComponent T=main | testsqlComponent.c _testsqlComponent_COMPONENT_INIT() 134 | Component SQLAppComponent started.
Apr 1 22:43:05 swi-mdm9x28-wp user.info Legato: INFO | testsql[5111]/testsqlComponent T=main | testsqlComponent.c createDb() 27 | Error in Opening / creating DB :unable to open database file

I guess it’s successfully running as I didn’t get any compilation error, isn’t it?
Do I need to install sqlite3 on wp7702 to avoid that “DB creation” error?
(“make sure you define macro with path where you want to create database” I’m not sure what does this mean… Do I need to run apt-get install sqlite3 on my dev machine, then use sqlite3 command to create a .db file?)

-----------------------------------------------------Update---------------------------------------------------------
Actually, I think there is a compilation error:

Apr 1 17:51:56 swi-mdm9x28-wp user.info Legato: INFO | supervisor[1048]/supervisor T=main | app.c CreateFileLink() 2084 | Skipping file link ‘/legato/systems/current/apps/testsql/read-only/lib/libsqlite3.so’ to '/legato/systems/current/appsWriteable/testsql/lib/libsqlite3.s

the sqlite3 library didnt get linked successfully I guess?
I’m using VSCode BTW…

You can try to create the database in /tmp folder

I actually have tried manually to create a db in data/Database/internal.db, but it didnt work.


I just found out VSCode doesn’t prompt compilation errors.
I intentionally removed the “;” after LE_INFO("Successfully Created ") and the app was installed successfully…

Executing task: update /home/chenweiz/myWorkspace/testsql/Target_Legato_Debug/testsql.wp76xx.update <

Applying update from file ‘/home/chenweiz/myWorkspace/testsql/Target_Legato_Debug/testsql.wp76xx.update’ to device at address ‘192.168.2.2’.
root@192.168.2.2’s password:
Unpacking package: 100% ++++++++++++++++++++++++++++++++++++++++++++++++++
Applying update: 100% ++++++++++++++++++++++++++++++++++++++++++++++++++
SUCCESS
Done

You need to bundle it in .adef file

I think I already did, did you mean to add another line here?

bundles:

{

file:

{

[r] third-party/lib/libsqlite3.so /lib/

}

}

something I just found very strange is that, the app that had been reinstalled on the device over and over again through VSCode was not the ones I modified, it just keeps reinstalling the very very original version of code despite of the changes I have made and saved…

Maybe you delete the original one first

I think I got it running now. I figured out I have to compile it using leaf profile with legato version 18 and <= 19, otherwise I ran into the compilation errors. However, with legato 18 I can’t run my other apps(especially the one with SMS APIs), it gave me:

Client (uid 1027 ‘appsmsApp’, pid 14241) disagrees with server (uid 0 ‘root’, pid 1665) on max message size (205 vs. 201) of

I know that error is caused by the mismatch of leaf profile and firmware version, but how could I use both splite3 db and SMS APIs in one app though?

This is my firmware version: SWI9X06Y_02.35.02.00 5208b3 jenkins 2020/06/10 00:30:12
Legato version: 19.11.2_625c7d1acfd1ca45b2dbe189b4cb1ce7_modified

so far I have tested the following SDKs:
Leaf profiles that can compile sqlite3 but incompatible with smsApp:
p1_red77_18: swi-wp77_2.0.0 │ SDK for WP77 (Release 11 + Legato 18.09.2)
p1_red77_R91_19: swi-wp77_1.9.0 │ SDK for WP77 (Release 9.1 + Legato 19.01.0)

Compatible with smsApp, but can’t compile sqlite3:
swi-wp77_1.11.0 │ SDK for WP77 (Release 9.1 + Legato 19.04.0) │ wp77xx,dev
swi-wp77_5.0.1 │ SDK for WP77 (Release 14.1 + Legato 19.11.5) │latest,wp77xx,stable
swi-wp77_4.0.0 │ SDK for WP77 (Release 13 + Legato 19.11.2) │ wp77xx,stable

You need to figure out why there is compilation error when legato version >19

Or you can compile other app with legato 18

BTW, I don’t see problem to compile my testsql application with WP76 R13 which is using legato 19.2.0.