@@ -357,7 +357,7 @@ static void disableOutputs(Json::Value& disables) {
357
357
}
358
358
}
359
359
}
360
- static void processBootConfig (Json::Value& bootConfig) {
360
+ static bool processBootConfig (Json::Value& bootConfig) {
361
361
#if defined(PLATFORM_PI)
362
362
const std::string fileName = FPP_BOOT_DIR " /config.txt" ;
363
363
#elif defined(PLATFORM_BBB)
@@ -373,13 +373,12 @@ static void processBootConfig(Json::Value& bootConfig) {
373
373
#endif
374
374
375
375
if (fileName.empty ())
376
- return ;
376
+ return false ;
377
377
378
378
int len = 0 ;
379
379
uint8_t * data = get_file_contents (fileName, len);
380
380
if (len == 0 ) {
381
- remove (" /.fppcapereboot" );
382
- return ;
381
+ return false ;
383
382
}
384
383
std::string current = (char *)data;
385
384
std::string orig = current;
@@ -406,21 +405,20 @@ static void processBootConfig(Json::Value& bootConfig) {
406
405
}
407
406
}
408
407
}
409
- if (current != orig) {
410
- put_file_contents (fileName, (const uint8_t *)current.c_str (), current.size ());
408
+ free (data);
409
+ return current != orig;
410
+ }
411
+ static void handleReboot (bool r) {
412
+ if (r) {
413
+ const uint8_t data[2 ] = { 32 , 0 };
414
+ put_file_contents (" /.fppcapereboot" , data, 1 );
411
415
sync ();
412
- if (!file_exists (" /.fppcapereboot" )) {
413
- const uint8_t data[2 ] = { 32 , 0 };
414
- put_file_contents (" /.fppcapereboot" , data, 1 );
415
- sync ();
416
- setuid (0 );
417
- reboot (RB_AUTOBOOT);
418
- exit (0 );
419
- }
416
+ setuid (0 );
417
+ reboot (RB_AUTOBOOT);
418
+ exit (0 );
420
419
} else {
421
420
remove (" /.fppcapereboot" );
422
421
}
423
- free (data);
424
422
}
425
423
static void copyFile (const std::string& src, const std::string& target) {
426
424
int s, t;
@@ -488,6 +486,29 @@ bool setFilePerms(const std::string& filename) {
488
486
return true ;
489
487
}
490
488
489
+ static bool handleCapeOverlay () {
490
+ #if defined(PLATFORM_BB64)
491
+ static std::string src = " /home/fpp/media/tmp/fpp-cape-overlay.dtb" ;
492
+ if (file_exists (" /home/fpp/media/tmp/fpp-cape-overlay.dtb" )) {
493
+ std::string target = " /boot/firmware/overlays/fpp-cape-overlay.dtb" ;
494
+
495
+ int slen = 0 ;
496
+ int tlen = 0 ;
497
+ uint8_t * sd = get_file_contents (src, slen);
498
+ uint8_t * td = get_file_contents (target, tlen);
499
+ if (slen != tlen || memcmp (sd, td, slen) != 0 ) {
500
+ copyFile (src, target);
501
+ free (sd);
502
+ free (td);
503
+ return true ;
504
+ }
505
+ free (sd);
506
+ free (td);
507
+ }
508
+ #endif
509
+ return false ;
510
+ }
511
+
491
512
#ifdef PLATFORM_BBB
492
513
bool isPocketBeagle () {
493
514
bool ret = false ;
@@ -996,20 +1017,12 @@ class CapeInfo {
996
1017
}
997
1018
}
998
1019
1020
+ bool reboot = false ;
999
1021
if (result.isMember (" bootConfig" )) {
1000
1022
// if the cape requires changes/update to config.txt (Pi) or uEnv.txt (BBB)
1001
1023
// we need to process them and see if we have to apply the changes and reboot or not
1002
1024
processBootConfig (result[" bootConfig" ]);
1003
1025
}
1004
-
1005
- if (result.isMember (" modules" )) {
1006
- // if the cape requires kernel modules, load them at this
1007
- // time so they will be available later
1008
- for (int x = 0 ; x < result[" modules" ].size (); x++) {
1009
- std::string v = " /sbin/modprobe " + result[" modules" ][x].asString () + " 2> /dev/null > /dev/null" ;
1010
- exec (v.c_str ());
1011
- }
1012
- }
1013
1026
if (result.isMember (" copyFiles" )) {
1014
1027
// if the cape requires certain files copied into place (asoundrc for example)
1015
1028
for (auto src : result[" copyFiles" ].getMemberNames ()) {
@@ -1025,6 +1038,17 @@ class CapeInfo {
1025
1038
setFilePerms (target);
1026
1039
}
1027
1040
}
1041
+ reboot = handleCapeOverlay ();
1042
+ handleReboot (reboot);
1043
+ if (result.isMember (" modules" )) {
1044
+ // if the cape requires kernel modules, load them at this
1045
+ // time so they will be available later
1046
+ for (int x = 0 ; x < result[" modules" ].size (); x++) {
1047
+ std::string v = " /sbin/modprobe " + result[" modules" ][x].asString () + " 2> /dev/null > /dev/null" ;
1048
+ exec (v.c_str ());
1049
+ }
1050
+ }
1051
+
1028
1052
if (result.isMember (" i2cDevices" ) && !readOnly) {
1029
1053
// if the cape has i2c devices on it that need to be registered, load them at this
1030
1054
// time so they will be available later
@@ -1125,7 +1149,7 @@ class CapeInfo {
1125
1149
std::string mapV5Config (const std::string& orig) {
1126
1150
std::string stringsConfigFile = " " ;
1127
1151
std::string platformDir = " /opt/fpp/capes/" + getPlatformCapeDir ();
1128
- #if defined(PLATFORM_BBB) || defined(PLATFORM_BB64)
1152
+ #if defined(PLATFORM_BBB) || defined(PLATFORM_BB64)
1129
1153
stringsConfigFile = " /home/fpp/media/config/co-bbbStrings.json" ;
1130
1154
#elif defined(PLATFORM_PI)
1131
1155
stringsConfigFile = " /home/fpp/media/config/co-pixelStrings.json" ;
0 commit comments