Skip to content

Commit 6e7eea8

Browse files
committed
setup the loader, blink in the boot section
1 parent d1bd751 commit 6e7eea8

File tree

4 files changed

+86
-18
lines changed

4 files changed

+86
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ lib/lang/lang_str.h
2222
modules/exportlist.inc
2323
modules/module_exportlist.h
2424
modules/module_hashlist.c
25+
doc/camnotes.txt
26+
doc/readme.txt
2527

2628
tools/finsig_thumb2
2729
tools/code_gen

loader/m6/main.c

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,56 @@
11
#include "../generic/check_compat.c"
22

3+
#define LED 0xD20801E0
4+
35
extern long *blob_chdk_core;
46
extern long blob_chdk_core_size;
57

8+
typedef struct {
9+
const char *str;
10+
const char *fw_str;
11+
void (*dcc_by_mva)(void *addr, long len);
12+
void (*ici_by_mva)(void *addr, long len);
13+
void (*core_unblock)(unsigned coreid);
14+
} ld_ver_t;
15+
16+
ld_ver_t fw = { "GM1.01A", //
17+
(void*) 0xE03CFDF0, //
18+
(void*) 0xE036BA79, // dcache_clean_range
19+
(void*) 0xE036BB4D, // icache_flush_range
20+
(void*) 0xE0523D73 //
21+
};
22+
23+
int __attribute__((naked)) get_core_id() {
24+
asm volatile (
25+
"mrc p15, #0, r0, c0, c0, #5\n"
26+
"ands r0, #0xf\n"
27+
"bx lr\n"
28+
);
29+
}
30+
31+
/**
32+
* @see loader entry
33+
*/
634
void __attribute__((noreturn)) my_restart() {
7-
check_compat();
35+
void (*cont)(int coreid) = (void*)(MEMISOSTART | 1);
36+
int coreid = get_core_id();
37+
38+
if (!coreid) { /* core 0 only */
39+
check_compat();
40+
41+
long *dst = (long*)MEMISOSTART;
42+
const long *src = blob_chdk_core;
43+
long length = (blob_chdk_core_size + 3) >> 2;
44+
45+
core_copy(src, dst, length);
46+
47+
set_led(LED, 1, LEDCNTRL_NEW4); /* green LED on */
48+
49+
fw.dcc_by_mva(dst, length<<2);
50+
fw.ici_by_mva(dst, length<<2);
51+
fw.core_unblock(1); /* core 1 */
52+
}
853

9-
while (1)
10-
;
54+
cont(coreid);
55+
while(1);
1156
}

platform/m6/main.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
#include "core.h"
44
#include "keyboard.h"
55

6+
extern int _GetLensCurrentFocalLength(void);
7+
extern int _GetLensWideFocalLength(void);
68
extern long link_bss_start;
79
extern long link_bss_end;
810
extern void boot();
911

10-
void startup() {
11-
long *bss = &link_bss_start;
12-
// sanity check
13-
if ((long) &link_bss_end > (MEMISOSTART + MEMISOSIZE)) {
14-
started();
15-
shutdown();
12+
void startup(int core) {
13+
if (!core) { // core 0 only
14+
long *bss = &link_bss_start;
15+
// sanity check
16+
if ((long) &link_bss_end > (MEMISOSTART + MEMISOSIZE)) {
17+
while (1)
18+
;
19+
}
20+
// initialize .bss segment
21+
while (bss < &link_bss_end)
22+
*bss++ = 0;
1623
}
17-
// initialize .bss senment
18-
while (bss < &link_bss_end)
19-
*bss++ = 0;
2024
boot();
2125
}
2226

23-
const int zoom_points = 1;
24-
extern int _GetLensCurrentFocalLength(void);
25-
extern int _GetLensWideFocalLength(void);
26-
2727
/**
2828
* @header shooting.h
2929
*/
@@ -43,7 +43,8 @@ int get_focal_length(__attribute__ ((unused))int zp) {
4343
*/
4444
int get_zoom_x(__attribute__ ((unused))int zp) {
4545
// TODO: why the 100 ?
46-
return _GetLensCurrentFocalLength() * 100/ (_GetLensWideFocalLength() * 100);
46+
return _GetLensCurrentFocalLength() * 100
47+
/ (_GetLensWideFocalLength() * 100);
4748
}
4849

4950
/**

platform/m6/sub/101a/boot.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
#define LED 0xD20801E0
2+
3+
void sleep(int duration) {
4+
int i;
5+
for (i = 0; i < duration; i++) {
6+
asm volatile( "nop\n" );
7+
}
8+
}
9+
10+
void blink() {
11+
volatile long *led = (long*) LED;
12+
13+
while (1) {
14+
*led = 0x24D0002; /* on */
15+
sleep(10000000);
16+
*led = 0x24C0003; /* off */
17+
sleep(10000000);
18+
}
19+
}
20+
121
/**
222
* @see main startup
323
*/
424
void __attribute__((naked,noinline)) boot() {
5-
25+
blink();
626
}

0 commit comments

Comments
 (0)