{"action":"created","comment":{"url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/comments/135945117","pull_request_review_id":59418336,"id":135945117,"diff_hunk":"@@ -115,39 +116,80 @@ static App *_appmanager_create_app(char *name, uint8_t type, void *entry_point,\n     app->type = type;\n     app->header = NULL;\n     app->next = NULL;\n-    app->slot_id = slot_id;\n+    app->app_file = app_file;\n+    app->resource_file = resource_file;\n     app->is_internal = is_internal;\n     \n     return app;\n }\n \n \n+struct appdb\n+{\n+    uint32_t paged_incr;  //0x58F6AExx\n+    uint16_t app_cache_id; //  B5 3E trek v2 also appears in app cache\n+    uint16_t unk;  // 0x0FC13Exx\n+    uint32_t application_id; // in app as @000037f\n+    Uuid app_uuid;  // 16 bytes\n+    uint32_t unk_13;\n+    uint32_t unk_17;\n+    uint16_t sdk_version;\n+    uint16_t app_version;\n+    uint16_t zeros;\n+    uint8_t app_name[32];\n+    uint8_t unk_arr_company[32];  // always blank\n+    uint8_t unk_arr[32]; // always blank\n+} __attribute__((__packed__));\n+\n+\n /*\n  * Load the list of apps and faces from flash\n  * The app manifest is a list of all known applications we found in flash\n- * We scan all block regions and look for app signatures.\n- * TODO The real app likely does nothing quite so crude. We need to find the app table!\n+ * We load all entries from `appdb` file.\n+ * TODO: appdb seems to have duplicates (in my case), maybe we should use `pmap`, but it was missing some entries for me\n  */\n void _appmanager_flash_load_app_manifest(void)\n {\n+    File appdb_file;\n+    if (!fs_find_file(&appdb_file, \"appdb\"))\n+    {\n+        KERN_LOG(\"app\", APP_LOG_LEVEL_ERROR, \"APPDB file not found\");\n+        return;\n+    }\n+\n+    char buffer[14];\n+    struct appdb appdb;\n     ApplicationHeader header;\n-    char buf[16];\n-    // super cheesy\n-    // 8 app slots\n-    for(uint8_t i = 0; i < 32; i++)\n+\n+    // skipping 8 bytes for appdb file header\n+    for (uint32_t offset = 8; offset < appdb_file.size; offset += sizeof(struct appdb))\n     {\n-        flash_load_app_header(i, &header);\n-        \n+        flash_read_file_bytes(&appdb_file, offset, (void*) &appdb, sizeof(struct appdb));\n+        if (appdb.application_id == 0xFFFFFFFFu)\n+            break;\n+\n+        File app_file;\n+        snprintf(buffer, 14, \"@%08d/app\", appdb.application_id);\n+        if (!fs_find_file(&app_file, buffer))\n+            continue;\n+\n+        File res_file;","path":"rcore/appmanager.c","position":111,"original_position":111,"commit_id":"75b3757e4c0b506d3633af98390e7a9f7c6d2ef3","original_commit_id":"75b3757e4c0b506d3633af98390e7a9f7c6d2ef3","user":{"login":"jwise","id":87427,"avatar_url":"https://avatars3.githubusercontent.com/u/87427?v=4","gravatar_id":"","url":"https://api.github.com/users/jwise","html_url":"https://github.com/jwise","followers_url":"https://api.github.com/users/jwise/followers","following_url":"https://api.github.com/users/jwise/following{/other_user}","gists_url":"https://api.github.com/users/jwise/gists{/gist_id}","starred_url":"https://api.github.com/users/jwise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwise/subscriptions","organizations_url":"https://api.github.com/users/jwise/orgs","repos_url":"https://api.github.com/users/jwise/repos","events_url":"https://api.github.com/users/jwise/events{/privacy}","received_events_url":"https://api.github.com/users/jwise/received_events","type":"User","site_admin":false},"body":"could potentially save some stack memory by having only one file open at a time and loading these sequentially","created_at":"2017-08-30T00:26:56Z","updated_at":"2017-08-30T00:26:56Z","html_url":"https://github.com/ginge/FreeRTOS-Pebble/pull/23#discussion_r135945117","pull_request_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/comments/135945117"},"html":{"href":"https://github.com/ginge/FreeRTOS-Pebble/pull/23#discussion_r135945117"},"pull_request":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23","id":138284707,"html_url":"https://github.com/ginge/FreeRTOS-Pebble/pull/23","diff_url":"https://github.com/ginge/FreeRTOS-Pebble/pull/23.diff","patch_url":"https://github.com/ginge/FreeRTOS-Pebble/pull/23.patch","issue_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues/23","number":23,"state":"open","locked":false,"title":"Use appdb file to load apps from flash.","user":{"login":"zbsz","id":45746,"avatar_url":"https://avatars2.githubusercontent.com/u/45746?v=4","gravatar_id":"","url":"https://api.github.com/users/zbsz","html_url":"https://github.com/zbsz","followers_url":"https://api.github.com/users/zbsz/followers","following_url":"https://api.github.com/users/zbsz/following{/other_user}","gists_url":"https://api.github.com/users/zbsz/gists{/gist_id}","starred_url":"https://api.github.com/users/zbsz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbsz/subscriptions","organizations_url":"https://api.github.com/users/zbsz/orgs","repos_url":"https://api.github.com/users/zbsz/repos","events_url":"https://api.github.com/users/zbsz/events{/privacy}","received_events_url":"https://api.github.com/users/zbsz/received_events","type":"User","site_admin":false},"body":"Changed appmanger initialization procedure to load apps listing from appdb file.\r\nChanged `App` struct and related functions to use `File` instead of virtual slots and raw addesses.\r\n\r\nThis is initial version, will most likely need some tweaking, posting to get feedback.","created_at":"2017-08-29T21:09:34Z","updated_at":"2017-08-30T00:26:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee8e4b90ba3ad1d88ef7ae14ff5b1b1378e7787d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23/commits","review_comments_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23/comments","review_comment_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues/23/comments","statuses_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/statuses/75b3757e4c0b506d3633af98390e7a9f7c6d2ef3","head":{"label":"zbsz:app_scan","ref":"app_scan","sha":"75b3757e4c0b506d3633af98390e7a9f7c6d2ef3","user":{"login":"zbsz","id":45746,"avatar_url":"https://avatars2.githubusercontent.com/u/45746?v=4","gravatar_id":"","url":"https://api.github.com/users/zbsz","html_url":"https://github.com/zbsz","followers_url":"https://api.github.com/users/zbsz/followers","following_url":"https://api.github.com/users/zbsz/following{/other_user}","gists_url":"https://api.github.com/users/zbsz/gists{/gist_id}","starred_url":"https://api.github.com/users/zbsz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbsz/subscriptions","organizations_url":"https://api.github.com/users/zbsz/orgs","repos_url":"https://api.github.com/users/zbsz/repos","events_url":"https://api.github.com/users/zbsz/events{/privacy}","received_events_url":"https://api.github.com/users/zbsz/received_events","type":"User","site_admin":false},"repo":{"id":100112040,"name":"FreeRTOS-Pebble","full_name":"zbsz/FreeRTOS-Pebble","owner":{"login":"zbsz","id":45746,"avatar_url":"https://avatars2.githubusercontent.com/u/45746?v=4","gravatar_id":"","url":"https://api.github.com/users/zbsz","html_url":"https://github.com/zbsz","followers_url":"https://api.github.com/users/zbsz/followers","following_url":"https://api.github.com/users/zbsz/following{/other_user}","gists_url":"https://api.github.com/users/zbsz/gists{/gist_id}","starred_url":"https://api.github.com/users/zbsz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbsz/subscriptions","organizations_url":"https://api.github.com/users/zbsz/orgs","repos_url":"https://api.github.com/users/zbsz/repos","events_url":"https://api.github.com/users/zbsz/events{/privacy}","received_events_url":"https://api.github.com/users/zbsz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zbsz/FreeRTOS-Pebble","description":"basic FreeRTOS implementation for Pebble Time","fork":true,"url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble","forks_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/forks","keys_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/teams","hooks_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/hooks","issue_events_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/issues/events{/number}","events_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/events","assignees_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/assignees{/user}","branches_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/branches{/branch}","tags_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/tags","blobs_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/git/refs{/sha}","trees_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/statuses/{sha}","languages_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/languages","stargazers_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/stargazers","contributors_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/contributors","subscribers_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/subscribers","subscription_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/subscription","commits_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/commits{/sha}","git_commits_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/git/commits{/sha}","comments_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/comments{/number}","issue_comment_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/issues/comments{/number}","contents_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/contents/{+path}","compare_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/merges","archive_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/downloads","issues_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/issues{/number}","pulls_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/pulls{/number}","milestones_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/milestones{/number}","notifications_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/labels{/name}","releases_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/releases{/id}","deployments_url":"https://api.github.com/repos/zbsz/FreeRTOS-Pebble/deployments","created_at":"2017-08-12T12:50:03Z","updated_at":"2017-08-12T12:50:09Z","pushed_at":"2017-08-29T22:03:58Z","git_url":"git://github.com/zbsz/FreeRTOS-Pebble.git","ssh_url":"git@github.com:zbsz/FreeRTOS-Pebble.git","clone_url":"https://github.com/zbsz/FreeRTOS-Pebble.git","svn_url":"https://github.com/zbsz/FreeRTOS-Pebble","homepage":"","size":2387,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ginge:master","ref":"master","sha":"a8748b7193f9078ad057afd50a539622d45ad7bf","user":{"login":"ginge","id":1080244,"avatar_url":"https://avatars0.githubusercontent.com/u/1080244?v=4","gravatar_id":"","url":"https://api.github.com/users/ginge","html_url":"https://github.com/ginge","followers_url":"https://api.github.com/users/ginge/followers","following_url":"https://api.github.com/users/ginge/following{/other_user}","gists_url":"https://api.github.com/users/ginge/gists{/gist_id}","starred_url":"https://api.github.com/users/ginge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ginge/subscriptions","organizations_url":"https://api.github.com/users/ginge/orgs","repos_url":"https://api.github.com/users/ginge/repos","events_url":"https://api.github.com/users/ginge/events{/privacy}","received_events_url":"https://api.github.com/users/ginge/received_events","type":"User","site_admin":false},"repo":{"id":76677454,"name":"FreeRTOS-Pebble","full_name":"ginge/FreeRTOS-Pebble","owner":{"login":"ginge","id":1080244,"avatar_url":"https://avatars0.githubusercontent.com/u/1080244?v=4","gravatar_id":"","url":"https://api.github.com/users/ginge","html_url":"https://github.com/ginge","followers_url":"https://api.github.com/users/ginge/followers","following_url":"https://api.github.com/users/ginge/following{/other_user}","gists_url":"https://api.github.com/users/ginge/gists{/gist_id}","starred_url":"https://api.github.com/users/ginge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ginge/subscriptions","organizations_url":"https://api.github.com/users/ginge/orgs","repos_url":"https://api.github.com/users/ginge/repos","events_url":"https://api.github.com/users/ginge/events{/privacy}","received_events_url":"https://api.github.com/users/ginge/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ginge/FreeRTOS-Pebble","description":"basic FreeRTOS implementation for Pebble Time","fork":true,"url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble","forks_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/forks","keys_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/teams","hooks_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/hooks","issue_events_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues/events{/number}","events_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/events","assignees_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/assignees{/user}","branches_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/branches{/branch}","tags_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/tags","blobs_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/git/refs{/sha}","trees_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/statuses/{sha}","languages_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/languages","stargazers_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/stargazers","contributors_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/contributors","subscribers_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/subscribers","subscription_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/subscription","commits_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/commits{/sha}","git_commits_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/git/commits{/sha}","comments_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/comments{/number}","issue_comment_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues/comments{/number}","contents_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/contents/{+path}","compare_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/merges","archive_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/downloads","issues_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues{/number}","pulls_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls{/number}","milestones_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/milestones{/number}","notifications_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/labels{/name}","releases_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/releases{/id}","deployments_url":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/deployments","created_at":"2016-12-16T18:49:09Z","updated_at":"2017-08-25T21:12:47Z","pushed_at":"2017-08-29T22:03:59Z","git_url":"git://github.com/ginge/FreeRTOS-Pebble.git","ssh_url":"git@github.com:ginge/FreeRTOS-Pebble.git","clone_url":"https://github.com/ginge/FreeRTOS-Pebble.git","svn_url":"https://github.com/ginge/FreeRTOS-Pebble","homepage":"","size":2380,"stargazers_count":110,"watchers_count":110,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":2,"forks":22,"open_issues":2,"watchers":110,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23"},"html":{"href":"https://github.com/ginge/FreeRTOS-Pebble/pull/23"},"issue":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues/23"},"comments":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/ginge/FreeRTOS-Pebble/statuses/75b3757e4c0b506d3633af98390e7a9f7c6d2ef3"}},"author_association":"NONE"}}
{"actor":{"display_login":"jwise"}}