MCPcopy Create free account
hub / github.com/SmingHub/Sming / host_init_bootloader

Function host_init_bootloader

Sming/Components/rboot/src/Arch/Host/rboot.cpp:29–74  ·  view source on GitHub ↗

* Called from emulator startup code after flash has been initialised. */

Source from the content-addressed store, hash-verified

27 * Called from emulator startup code after flash has been initialised.
28 */
29void host_init_bootloader()
30{
31 rboot_config romconf = rboot_get_config();
32
33 // fresh install or old version?
34 bool init = false;
35 if(romconf.magic != BOOT_CONFIG_MAGIC) {
36 host_debug_w("MAGIC mismatch");
37 init = true;
38 } else if(romconf.version != BOOT_CONFIG_VERSION) {
39 host_debug_w("VERSION mismatch: %u found, current %u", romconf.version, BOOT_CONFIG_VERSION);
40 init = true;
41 }
42
43 if(init) {
44 // create a default config for a standard 2 rom setup
45 memset(&romconf, 0, sizeof(romconf));
46 romconf.magic = BOOT_CONFIG_MAGIC;
47 romconf.version = BOOT_CONFIG_VERSION;
48 }
49
50 // Read ROM locations from partition table
51 bool config_changed = false;
52 if(scan_partitions(&romconf)) {
53 config_changed = true;
54 }
55
56 if(romconf.count == 0) {
57 host_debug_w("Note: No App partitions found\r\n");
58 return;
59 }
60
61 if(init || config_changed) {
62 bool ok = rboot_set_config(&romconf);
63 host_debug_i("Update rBoot config: %s", ok ? "OK" : "FAIL");
64 }
65
66 String addr;
67 for(unsigned i = 0; i < romconf.count; ++i) {
68 if(i > 0) {
69 addr += ", ";
70 }
71 addr += '#' + String(i) + ": 0x" + String(romconf.roms[i], 16);
72 }
73 host_debug_i("ROM count = %u, current = %u, %s", romconf.count, romconf.current_rom, addr.c_str());
74}

Callers 1

mainFunction · 0.85

Calls 2

StringClass · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected