Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,81 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/mman.h>
#include <fcntl.h>
#include "clar_asserts.h"
#include "drivers/flash.h"
#include "flash_region/flash_region.h"
#include "services/normal/filesystem/pfs.h"
#include "util/math.h"
#include "stubs_analytics.h"
#include "stubs_hexdump.h"
#include "stubs_logging.h"
#include "stubs_mutex.h"
#include "stubs_passert.h"
#include "stubs_pbl_malloc.h"
#include "stubs_pebble_tasks.h"
#include "stubs_print.h"
#include "stubs_prompt.h"
#include "stubs_serial.h"
#include "stubs_sleep.h"
#include "stubs_task_watchdog.h"
#include "fake_spi_flash.h"
void flash_region_erase_optimal_range_no_watchdog(
uint32_t min_start, uint32_t max_start,
uint32_t min_end, uint32_t max_end) {
}
static int prv_prebake_pfs(const char *filename) {
struct stat st;
if (stat(filename, &st) != 0) {
return 1;
}
fake_spi_flash_init(0, st.st_size);
fake_spi_flash_populate_from_file((char*)filename, 0);
pfs_init(true);
int fd = open(filename, O_RDWR);
uint8_t *spi_image_file = mmap(NULL, st.st_size, PROT_WRITE, MAP_SHARED, fd, 0);
flash_read_bytes(spi_image_file, 0, st.st_size);
munmap(spi_image_file, st.st_size);
close(fd);
fake_spi_flash_cleanup();
return 0;
}
int main(int argc, const char* argv[]) {
// SPI image file path always passed in as first argument
if (argc == 1) {
printf("No file specified. Pass a path to a QEMU SPI image. "
"(e.g. qemu_spi_cooker <spi_flash_img>)\n");
return 1;
}
return prv_prebake_pfs(argv[1]);
}

View file

@ -0,0 +1,53 @@
import os
import sh
from waflib import Logs
def build(bld):
qemu_spi_cooker_env = bld.all_envs['32bit'].derive()
output = bld.path.get_bld().parent.parent.make_node('qemu_spi_cooker')
sources = ["../../src/fw/services/normal/filesystem/flash_translation.c",
"../../src/fw/services/normal/filesystem/pfs.c",
"../../src/fw/flash_region/filesystem_regions.c",
"../../tests/fakes/fake_rtc.c",
"../../tests/fakes/fake_spi_flash.c",
"../../tests/stubs/stubs_clar.c",
"../../src/libutil/list.c",
"../../src/fw/util/crc8.c",
"../../src/fw/util/util_platform.c",
"../../src/fw/util/legacy_checksum.c"]
sources = [bld.path.find_node(s) for s in sources]
sources.extend(bld.path.ant_glob('src/*.c'))
includes = ["../clar",
"../../tests/stubs",
"../../tests/fakes",
"../../tests/test_includes",
"../../tests/overrides/default/",
"../../src/include",
"../../src/fw",
"../../src/libos/include",
"../../src/libutil/includes",
"../../src/fw/util/time",
"../../src/fw/vendor/FreeRTOS/Source/include",
"../../src/fw/vendor/FreeRTOS/Source/portable/GCC/ARM_CM3_PEBBLE"]
includes = [bld.path.find_node(i).abspath() for i in includes]
# # time_t is defined in sys/types in newlib, and time.h on recent Linux
# # so just force the defined type for testing time
# qemu_spi_cooker_env.CFLAGS.append('-Dtime_t=__SYSCALL_SLONG_TYPE')
platform_define = "PLATFORM_%s" % bld.get_platform_name().upper()
bld.program(source=sources,
target=output,
includes=includes,
defines=['UNITTEST', 'DUMA_DISABLED', 'PBL_COLOR', 'PBL_RECT', platform_define],
cflags='-Wno-format-security',
env=qemu_spi_cooker_env)
# vim:filetype=python