Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5f1be2e
first draft on the M6 platform based on the signature finder
cedricbompart Jun 28, 2022
357a69b
second round of creating a skeleton platform for the M6
cedricbompart Jun 28, 2022
2e9d5ff
updated the platform ID
cedricbompart Jun 28, 2022
43b214c
updated platform camera with guessable entries
cedricbompart Jun 29, 2022
56affbf
updated platform camera with guessable entries (round 2)
cedricbompart Jun 29, 2022
3da9d5e
first draft on matching the missing functions from the M100 in Ghidra
cedricbompart Jun 29, 2022
3b45de7
added some alternative function names found in Ghidra
cedricbompart Jun 30, 2022
fb10643
defined the 3 args debug assert (checked in Ghidra)
cedricbompart Jun 30, 2022
4897cb0
used aperture sizes and shutter speeds from the M3
cedricbompart Jun 30, 2022
c036e0a
added a minimum capture modemap until the rest are verified
cedricbompart Jun 30, 2022
fd461f5
copied common bits from the M3 and M100
cedricbompart Jun 30, 2022
82682dc
copied common bits from the M3 and M100 (round 2)
cedricbompart Jun 30, 2022
ca38323
formatted with Eclipse
cedricbompart Jun 30, 2022
d1bd751
added header comments so it's easy to figure out where a method is de…
cedricbompart Jul 1, 2022
6e7eea8
setup the loader, blink in the boot section
cedricbompart Jul 5, 2022
39af23a
finally got the M6 to blink in the boot method
cedricbompart Jul 6, 2022
dc63f2d
added the M6 dump
cedricbompart Jul 6, 2022
7a820de
added headers for the loader and platform main
cedricbompart Jul 6, 2022
4630c5f
added MMU utils, removed source includes
cedricbompart Jul 8, 2022
b0d009d
first draft on loading the Canon FW
cedricbompart Jul 20, 2022
5e37640
removed private dump
cedricbompart Jul 20, 2022
8852416
removed hardcoded base address
cedricbompart Jul 20, 2022
b317607
added method addresses used by the Canon startup
cedricbompart Jul 21, 2022
c5854dc
added more camera props
cedricbompart Jul 21, 2022
923879a
added empty sub address
cedricbompart Jul 21, 2022
b7173e4
got CHDK initialised and the basic overlays
cedricbompart Jul 22, 2022
ca8521e
added a subs_min to defined constants
cedricbompart Jul 25, 2022
980949b
fixed shutdown functions
cedricbompart Jul 25, 2022
a1b5b92
Initialised the file modules
cedricbompart Jul 25, 2022
97f1284
found address for writing to the SD, added viewport functions for PTP
cedricbompart Jul 25, 2022
7c8e171
tried to override the keyboard task (doesn't boot)
cedricbompart Jul 27, 2022
62af92e
fixed patching keyboard task, updated camera info
cedricbompart Jul 29, 2022
de47e6c
make it compiled against the latest trunk
cedricbompart May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
*.o
*.BIN
*.bin
*.lua
*.a
*.elf
*.elf.syms
*.dump
.project

**/.o3
**/.o5
bin
CHDK/MODULES

platform/**/sub/**/bin_compat.h
platform/fi2.inc

tools/ghidra_scripts/**

CHDK/DATA/logo.dat
lib/font/font_8x16_uni_packed.h
lib/lang/lang_str.h
modules/exportlist.inc
modules/module_exportlist.h
modules/module_hashlist.c
doc/camnotes.txt
doc/readme.txt

tools/finsig_thumb2
tools/code_gen
tools/code_gen2
tools/dancingbits
tools/elf2flt/elf2flt
tools/elf2flt/fltdump
tools/finsig_dryos
tools/finsig_vxworks
tools/font_8x16_pack
tools/gen_conf_lua
tools/gensig_dryos
tools/gensig_vxworks
tools/makeexport
tools/makelang
tools/packfi2/fi2enc
tools/pakwif
tools/capdis
tools/dumpchk
tools/extract_error_table
tools/find_eventproc
tools/find_levent
tools/rawconvert
tools/yuvconvert
2 changes: 2 additions & 0 deletions camera_info.csv
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ m10,111a,ALPHA,,,,12960,dryos,57,60,0xFC000000,0x8000,0x1fffffff,d4g,W,13,1,,0x0
sx710hs,100a,,,,,12966,dryos,57,60,0xFC000000,0x8000,0x1fffffff,d4g,,13,1,1,0x006ce000 ,0x00022000 ,,,,,,7
sx710hs,101a,,,,,12966,dryos,57,60,0xFC000000,0x8000,0x1fffffff,d4g,,13,1,1,0x006ce000 ,0x00022000 ,,,,,,7
ixus285_elph360hs,100b,ALPHA,,,SKIP,12989,dryos,58,41,0xff010000,0x1900,0x1FFFFFF,d4i,W,16,,,,,,,,,,10
ixus285_elph360hs,100c,ALPHA,,,SKIP,12989,dryos,58,41,0xff010000,0x1900,0x1FFFFFF,d4i,W,16,,,,,,,,,,10
sx420is,100a,BETA,,,,12991,dryos,58,41,0xff010000,0x1900,0x1FFFFFF,d4i,W,16,,,,,,,,,,10
ixus175_elph180,100a,,100c,,,12993,dryos,58,41,0xFF810000,0x1900,0x07ffffff,d4i,W,16,,,,,,,,,,10
ixus175_elph180,100b,,100c,,,12993,dryos,58,41,0xFF810000,0x1900,0x07ffffff,d4i,W,16,,,,,,,,,,10
Expand All @@ -395,5 +396,6 @@ sx730hs,100b,,100c,,,13014,dryos,59,60,0xFC000000,0x8000,0x1fffffff,d4j,W,17,1,,
sx730hs,100c,,,,,13014,dryos,59,60,0xFC000000,0x8000,0x1fffffff,d4j,W,17,1,,,,,,,,,12
sx730hs,100d,,,,,13014,dryos,59,60,0xFC000000,0x8000,0x1fffffff,d4j,W,17,1,,,,,,,,,12
sx730hs,100e,,100d,,,13014,dryos,59,60,0xFC000000,0x8000,0x1fffffff,d4j,W,17,1,,,,,,,,,12
m6,101a,ALPHA,,,,12997 ,dryos,59,70,0xE0000000,0x8000,0x3fffffff,d7,W,19,1,,0x006ce000,,,,,,,12

Generated file - run 'make camera-info' to update
1 change: 1 addition & 0 deletions camera_list.csv
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ m10,110d,BETA,,
m10,110f,BETA,,
m10,110g,BETA,110f,
m10,111a,ALPHA,,
m6,101a,ALPHA,,
sx710hs,100a,,,
sx710hs,101a,,,
sx700hs,100d,,,
Expand Down
34 changes: 18 additions & 16 deletions loader/generic/compat_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@
{ 12638,1,0xc02200c4,0xfffe0130 }, // sx100is
{ 12639,1,0xc02200cc,0xfffe0130 }, // ixus960_sd950
{ 12640,1,0xc02200cc,0xfffe0130 }, // ixus860_sd870
#elif (NEED_ENCODED_DISKBOOT == 1)
{ 12659,1,0xc02200d4,0xfffe0130 }, // ixus970_sd890
{ 12660,1,0xc0220130,0xfffe0130 }, // ixus90_sd790
{ 12661,1,0xc02200d4,0xfffe0130 }, // ixus85_sd770
{ 12662,1,0xc02200c4,0xfffe0130 }, // a590
{ 12663,1,0xc02200c4,0xfffe0130 }, // a580
{ 12666,1,0xc0220084,0xfffe0130 }, // a470
{ 12676,1,0xc02200d4,0xfffe0130 }, // ixus80_sd1100
{ 12685,1,0xc0220060,0xfffe0130 }, // sx10
{ 12686,1,0xc02200c4,0xfffe0130 }, // a1000
{ 12687,1,0xc02200d4,0xfffe0130 }, // g10
{ 12689,1,0xc02200c4,0xfffe0130 }, // a2000
{ 12690,1,0xc02200c4,0xfffe0130 }, // sx110is
{ 12691,1,0xc02200bc,0xfffe0130 }, // ixus980_sd990
{ 12693,0,0,0xfffe0130 }, // sx1
{ 12694,1,0xc02200d4,0xfffe0130 }, // ixus870_sd880
#elif (NEED_ENCODED_DISKBOOT == 10)
{ 12894,2,0xc022c30c,0xfff40040 }, // n
{ 12895,4,0xd20b0994,0xfff60040 }, // sx280hs
Expand All @@ -77,6 +61,22 @@
{ 12916,4,0xd20b0994,0xfff20040 }, // g16
{ 12918,1,0xc0220120,0xfffe0040 }, // sx170is
{ 12919,1,0xc022302c,0xfff40040 }, // sx510hs
#elif (NEED_ENCODED_DISKBOOT == 1)
{ 12659,1,0xc02200d4,0xfffe0130 }, // ixus970_sd890
{ 12660,1,0xc0220130,0xfffe0130 }, // ixus90_sd790
{ 12661,1,0xc02200d4,0xfffe0130 }, // ixus85_sd770
{ 12662,1,0xc02200c4,0xfffe0130 }, // a590
{ 12663,1,0xc02200c4,0xfffe0130 }, // a580
{ 12666,1,0xc0220084,0xfffe0130 }, // a470
{ 12676,1,0xc02200d4,0xfffe0130 }, // ixus80_sd1100
{ 12685,1,0xc0220060,0xfffe0130 }, // sx10
{ 12686,1,0xc02200c4,0xfffe0130 }, // a1000
{ 12687,1,0xc02200d4,0xfffe0130 }, // g10
{ 12689,1,0xc02200c4,0xfffe0130 }, // a2000
{ 12690,1,0xc02200c4,0xfffe0130 }, // sx110is
{ 12691,1,0xc02200bc,0xfffe0130 }, // ixus980_sd990
{ 12693,0,0,0xfffe0130 }, // sx1
{ 12694,1,0xc02200d4,0xfffe0130 }, // ixus870_sd880
#elif (NEED_ENCODED_DISKBOOT == 12)
{ 12933,4,0xd20b0994,0xfff20040 }, // sx700hs
{ 12935,3,0xc022d1fc,0xffff0040 }, // ixus150_elph140
Expand Down Expand Up @@ -110,6 +110,8 @@
{ 13012,3,0xc022d1fc,0xffff0270 }, // ixus185_elph185
{ 13013,3,0xc022d1fc,0xfffe0270 }, // sx430is
{ 13014,4,0xd20b0994,0xfff20270 }, // sx730hs
#elif (NEED_ENCODED_DISKBOOT == 19)
{ 12997,5,0xD20801E0,0xe1f20270 }, // m6
#elif (NEED_ENCODED_DISKBOOT == 2)
{ 12732,1,0xc0220134,0xfffe0130 }, // d10
{ 12733,1,0xc0220130,0xfffe0130 }, // ixus110_sd960
Expand Down
1 change: 1 addition & 0 deletions loader/m6/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../makefile_loader.inc
8 changes: 8 additions & 0 deletions loader/m6/entry.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.section .entry

// ordinary startup...
.code 16
.align 2
.syntax unified
LDR SP, =MEMBASEADDR
B my_restart
45 changes: 45 additions & 0 deletions loader/m6/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "main.h"

#include "../generic/check_compat.c"

ld_ver_t fw = { "GM1.01A", //
(void*) 0xE03CFDF0, //
(void*) 0xE036BA79, // dcache_clean_range
(void*) 0xE036BB4D, // icache_flush_range
(void*) 0xE0523D73 //
};

int __attribute__((naked)) get_core_id() {
asm volatile (
" mrc p15, #0, r0, c0, c0, #5\n"
" ands r0, #0xf\n"
" bx lr\n"
);
}

/**
* @see loader entry
*/
void __attribute__((noreturn)) my_restart() {
void (*cont)(int coreid) = (void*)(MEMISOSTART | 1);
int coreid = get_core_id();

if (!coreid) { /* core 0 only */
check_compat();

long *dst = (long*)MEMISOSTART;
const long *src = blob_chdk_core;
long length = (blob_chdk_core_size + 3) >> 2;

core_copy(src, dst, length);

set_led(LED, 1, LEDCNTRL_NEW4); /* green LED on */

fw.dcc_by_mva(dst, length<<2);
fw.ici_by_mva(dst, length<<2);
fw.core_unblock(1); /* core 1 */
}

cont(coreid);
while(1);
}
17 changes: 17 additions & 0 deletions loader/m6/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef M6_LOADER_MAIN_H
#define M6_LOADER_MAIN_H

#define LED 0xD20801E0

extern long *blob_chdk_core;
extern long blob_chdk_core_size;

typedef struct {
const char *str;
const char *fw_str;
void (*dcc_by_mva)(void *addr, long len);
void (*ici_by_mva)(void *addr, long len);
void (*core_unblock)(unsigned coreid);
} ld_ver_t;

#endif
105 changes: 105 additions & 0 deletions localbuildconf.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!build time optional components - comment out the features you dont want to have in your build or copy this file to localbuildconf.inc and override settings there
OPT_CURVES=1
OPT_DEBUGGING=1

# Force config option on to allow Lua to call arbitrary ROM functions and eventprocs
# By default this is a user controlled setting in the CHDK UI.
# Setting this build option will permanently enable native calls
# WARNING: This is DANGEROUS. e.g. call_event_proc("EraseSectorOfRom",...)
#OPT_FORCE_LUA_CALL_NATIVE=1

# experimental - allocate memory from alternate heap. Default 2MB from EXMEM_RAMDISK
# See exmem_malloc_init in generic/wrappers.c
#OPT_EXMEM_MALLOC=1
# Set OPT_CHDK_IN_EXMEM to build and load CHDK into EXMEM memory
# Need to define MEMISOSTART and EXMEM values in PLATFORM/PLATFORMSUB/makefile.inc (see G12 or SX30 for example)
# (if setting this must also set OPT_EXMEM_MALLOC !)
#OPT_CHDK_IN_EXMEM=1
# set this to enable exmem corruption testing (see wrappers.c). (Don't set OPT_CHDK_IN_EXMEM with this !)
#OPT_EXMEM_TESTING=1

# experimental PTP/USB interface
OPT_PTP=1

# record asserts in lua C code with dbg_dump_assert
#OPT_DBG_LUA_ASSERT=1

# Enable this to include debug code in the motion_detect module
#OPT_MD_DEBUG=1

# Enable this for an extra misc value display showing viewport history and FPS. Requires active_viewport_buffer FW variable.
#OPT_VIEWPORT_DEBUG=1

# needs proper fi2.inc in platform/ !!! see http://chdk.setepontos.com/index.php/topic,2995.0.html
#OPT_FI2=1

# if enabled, compiler will produce a lot of warnings, maybe not always correct ones, see http://chdk.setepontos.com/index.php/topic,2509.msg32191.html#msg32191
#OPT_WARNINGS=1

# If enabled (and reference binaries are present in /tools), compiler will generate function signatures
OPT_GEN_SIGS=1
# If enabled (and firmware binaries are present) compiler will update "stubs_entry.S"
OPT_GEN_STUBS=1

# Define this to add a 100K block of 0 bytes to the end of main.bin
#OPT_ZERO100K

# for CHDK-DE presets without OPT_DEFAULT_LANG
#OPT_DE_VERSION=1

# make the build show an "expired" notice after N days. To encourage users of test builds to provide feedback
#OPT_EXPIRE_TEST=

# Generate firmware calls and branches as PC24 relative offsets instead of long calls (saves 2.5 - 3K on core build size)
# - requires a 32 bit version of ARM GCC (tested on Windows with GCC 4.4.0, 4.5.1 & 4.6.2), fails on 64 bit GCC (Linux & OSX)
# - CHDK must be loaded in the lowest 16MB of RAM, firmware must be in upper 16MB
# - will be disabled if OPT_CHDK_IN_EXMEM is enabled
# - linker will generate errors if any calls/branches are out of range
#OPT_FIRMWARE_PC24_CALL=1

# Define this to enable camera to run with the battery door open
# Note: not implemented for all cameras
#OPT_RUN_WITH_BATT_COVER_OPEN=1

# Define to enable capture of stats in file IO functions
#OPT_FILEIO_STATS=1

# Create module .elf and .flt dump files
#OPT_GEN_MODULE_DUMPS=1

# Define this to disable runtime compatibility check in loader
#OPT_DISABLE_COMPAT_CHECK=1

# Define this to enable building of tools using the capstone library (http://www.capstone-engine.org/)
# Required to rebuild stubs for thumb2 / digic 6 firmware
#OPT_CAPSTONE_TOOLS=1

# Set the following if capstone includes are not in the default search path
#CAPSTONE_TOOLS_INC=-I/path/to/capstone/include

# Set the following to the options required to link to the capstone library.
# At a minimum, -lcapstone or similar is required. If the library is not
# on the default search path, -L/path/to/capstone is also required
#CAPSTONE_TOOLS_LINK=-L/path/to/capstone -lcapstone

# Define this to disable E32 error (caused by broken image stabilizer)
# Only enable for newer cameras with optical image stabilizer, otherwise build will fail (due to missing fw function)
#OPT_DISABLE_CAM_ERROR=1

# ***please new entries above this line for protecting the chdk shell against errors***

# Override the value below to compile a different default language into
# the core CHDK code. This will save memory by not loading both english and the
# desired language.
# Set the value to the language file name without extension - e.g. OPT_DEFAULT_LANG=russian
#OPT_DEFAULT_LANG=

# Default svn revision. Used when svnversion fail.
DEF_SVN_REF=0

PLATFORM=m6
PLATFORMSUB=101a
OPT_CAPSTONE_TOOLS=1
CAPSTONE_TOOLS_INC=-I/usr/include/capstone
CAPSTONE_TOOLS_LINK=-lcapstone

6 changes: 6 additions & 0 deletions platform/fi2.inc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ ifeq ($(KEYSYS), d4e)
FI2KEY=
FI2IV =
endif

# m6
ifeq ($(KEYSYS), d7)
FI2KEY=
FI2IV=
endif
Loading