1
General Development / Re: Canon Basic scripting (DIGIC 6, DIGIC 7 models)
« on: February 07, 2022, 12:05:39 AM »
This could possibly be used over PTP (for creating event procedures). See this for details.
Etiquette, expectations, entitlement...
@autoexec_bin | #magiclantern | Discord | Reddit | Server issues
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Is there the way to run event procedures with arguments?Yes. Thanks to petabyte for publishing the first usage details.
Due to the forced repo change, the hash in this module can't be used to find the base commit.I have a working copy of the old repo, the output of hg log does list the following changeset:
changeset: 17218:b2db3dc9dd4f
branch: sd_uhs
user: alex@thinkpad
date: Wed Apr 04 22:32:31 2018 +0200
summary: sd_uhs: minor fixes and fine-tunings
The hash also appears as one of the last commits of the sd_uhs branch on heptapod. Searching for that hash or the commit msg (on the heptapod web interface) gets me no results though.
And source code of:To get the source code of a binary module, follow this guide.sd_uhs_d.mo (rename to sd_uhs.mo, otherwise it doesn't work for some reason)
The chdk links are dead.The CHDK forum is up again, links should be working.
Do you know if existing code ever uses 0xff for cpu_requested? I'm wondering if/when Canon would want tasks to be scheduled opportunistically on either CPU."CreateTask_on_core" asserts if the core parameter is not 0 or 1. If what you're saying about task_create is true then I guess this DryOS configuration does not support that.
Are we cpu bound for recording video?I'm not in the position to answer that, but I can say that the ARM core of DIGIC 6 is clocked faster than previous DIGICs and the primary ARM cores of DIGIC 7 are clocked 4x the clock of DIGIC 6. In my cameras - DSLRs might differ, I don't know.
this may allow ML to choose which cpu tasks run onFWIW, there are versions of CreateTask that allow specifying the CPU core to run on.
I was suggesting that maybe having access to Basic might ‘satisfy’ those of us that script, rather than waiting for a Lua implementation.I don't think so.
Try dumping it in a buffered way, not directly.Code: [Select]dump_file("RAM41.BIN", 0x80000000, 0x40000000);
Didnt started to dump and made my led blink in a different pattern suddenly, so it brought my camera in some glitched state which was fixed after a battery pull.
Hey Srsa that script worked on the R6.I used ExecuteEventProcedure to avoid crashing cameras that don't have smemShowFix. As I mentioned, the R6 is missing that event procedure. Your log is therefore only a regular log without memory range info.
It's a logfile of 170KB. Is this log file publically shareable?These logs are regularly shared in this forum, so I guess yes. But in this case, it would be pointless.
private sub Initialize()
ExecuteEventProcedure("smemShowFix")
dumpf()
end sub
The output of smemShowFix can be found in the log. 1993: 1320.904 [RSC] --- Common Lower ----
1994: 1320.934 [RSC] LIME_HEAP 0x00000000 0x00000000 0 [Cacheable!
1995: 1320.940 [RSC] DAF_WORK 0x00000000 0x00000000 0 [Cacheable!
1996: 1320.945 [RSC] DAF_RAW 0x00000000 0x00000000 0 [Cacheable!
1997: 1320.952 [RSC] MOVIE_CFILTER_SEED 0x00000000 0x00000000 0 [Cacheable!
1998: 1320.959 [RSC] OMAR COM 0x00000000 0x00000000 0 [Cacheable!
1999: 1320.964 [RSC] ENGINE_MIRROR 0x00000000 0x00000000 0 [Cacheable!
2000: 1320.970 [RSC] TUNE 0x4046C000 0x001C0000 1835008
2001: 1320.975 [RSC] LIME 0x41800000 0x00500000 5242880
2002: 1320.980 [RSC] NETWORK_HEAP 0x41D00000 0x00300000 3145728
2003: 1320.985 [RSC] ZICO 0x42000000 0x00180000 1572864
2004: 1320.991 [RSC] APROC 0x42180000 0x00021000 135168
2005: 1320.995 [RSC] ARIMA 0x421A1000 0x0006C000 442368
2006: 1321.000 [RSC] SHIRAHAMA 0x4220D000 0x0002E000 188416
2007: 1321.006 [RSC] RENDERING WORK 0x4223B000 0x00CE4000 13516800
2008: 1321.011 [RSC] FILE HEADER 0x42F1F000 0x00100000 1048576
2009: 1321.016 [RSC] FANCING_WORK 0x432CF000 0x001C2000 1843200
2010: 1321.021 [RSC] JOB OBJECT 0x43491000 0x00320000 3276800
2011: 1321.027 [RSC] TUNE2 0x437B1000 0x00160000 1441792
2012: 1321.032 [RSC] SITTERVCODEC WORK 0x43911000 0x00207000 2125824
2013: 1321.038 [RSC] FIX 0x43B95000 0x00170000 1507328
2014: 1321.042 [RSC] DCFNO 0x43D05000 0x00004000 16384
2015: 1321.048 [RSC] DARKCUR_COMP_WORK 0x43D0F000 0x00022000 139264
2016: 1321.053 [RSC] FACTORY/TVAFDEBUG 0x43D0F000 0x00080000 524288
2017: 1321.057 [RSC] VSHADING_COMP_WORK 0x43D31000 0x00027C00 162816
2018: 1321.062 [RSC] CAPTURE_WORK 0x44DB0000 0x015BA800 22784000
2019: 1321.067 [RSC] DANCING 0x7F113000 0x00309800 3184640
2020: 1321.072 [RSC] --- Common Upper ----
2021: 1321.081 [RSC] BITMAP VRAM 0x41100000 0x002F8000 3112960
2022: 1321.086 [RSC] IMG_VRAM1 0x7F41C800 0x003F4800 4147200
2023: 1321.090 [RSC] IMG_VRAM2 0x7F811000 0x003F4800 4147200
2024: 1321.095 [RSC] IMG_VRAM3 0x7FC05800 0x003F4800 4147200
2025: 1321.099 [RSC] --- Normal ----
2026: 1321.128 [RSC] LV_SERVO_WORK 0x00000000 0x00000000 0 [Cacheable!
2027: 1321.134 [RSC] DARK_MEM1_1 0x00000000 0x00000000 0 [Cacheable!
2028: 1321.140 [RSC] DARK_MEM1_2 0x00000000 0x00000000 0 [Cacheable!
2029: 1321.146 [RSC] WORK_HILLTON_1 0x00000000 0x00000000 0 [Cacheable!
2030: 1321.151 [RSC] WORK_HILLTON_2 0x00000000 0x00000000 0 [Cacheable!
2031: 1321.157 [RSC] LV_AE_WORK 0x43B18000 0x0007D000 512000
2032: 1321.163 [RSC] LV_SERVO_WORK_L 0x43D90000 0x01020000 16908288
2033: 1321.167 [RSC] EXMEM3_AREA 0x4636A800 0x02235800 35870720
2034: 1321.173 [RSC] ALGS_AREA_1L 0x485A0000 0x02340000 36962304
2035: 1321.177 [RSC] ALGS_AREA_2L 0x4A8E0000 0x02340000 36962304
2036: 1321.183 [RSC] DIGEST_STREAM 0x4A8E0000 0x05340000 87293952
2037: 1321.187 [RSC] EXALGS_AREA_L 0x512A0000 0x00010000 65536
2038: 1321.193 [RSC] CAPMEM1_AREA_L 0x512B0000 0x02340000 36962304
2039: 1321.198 [RSC] TWAIN_AREA_L 0x535F0000 0x002B0000 2818048
2040: 1321.203 [RSC] DECMEM1_AREA_L 0x538A0000 0x02340000 36962304
2041: 1321.208 [RSC] DIGEST_RECWORK 0x538A0000 0x0871E000 141680640
2042: 1321.212 [RSC] SS_L 0x55BE0000 0x05040000 84148224
2043: 1321.217 [RSC] YUV 1st_L 0x5AC20000 0x029F0000 43974656
2044: 1321.222 [RSC] WORK_GAIN_MAP 0x5AC2A000 0x021EEC80 35581056
2045: 1321.226 [RSC] YUV 2nd_L 0x5D610000 0x029F0000 43974656
2046: 1321.231 [RSC] SS_U 0x60000000 0x05040000 84148224
2047: 1321.236 [RSC] YUV 2nd_U 0x65040000 0x029F0000 43974656
2048: 1321.242 [RSC] YUV 1st_U 0x67A30000 0x029F0000 43974656
2049: 1321.247 [RSC] SUSANYUV 0x6A420000 0x0309B000 50966528
2050: 1321.253 [RSC] DECMEM1_AREA_U 0x6D4BB000 0x02340000 36962304
2051: 1321.258 [RSC] CAPMEM1_AREA_U 0x6F7FB000 0x02340000 36962304
2052: 1321.264 [RSC] TWAIN_AREA_U 0x71B3B000 0x002B0000 2818048
2053: 1321.269 [RSC] YUV Thumb 0x71DF0000 0x02170000 35061760
2054: 1321.274 [RSC] ALGS_AREA_1U 0x73F60000 0x02340000 36962304
2055: 1321.279 [RSC] ALGS_AREA_2U 0x762A0000 0x02340000 36962304
2056: 1321.284 [RSC] EXALGS_AREA_U 0x7CC60000 0x00010000 65536
2057: 1321.289 [RSC] EXMEM3_AREA_2 0x7CC70000 0x014A0000 21626880
2058: 1321.294 [RSC] LV_SERVO_WORK_U 0x7E210000 0x00E20000 14811136
2059: 1321.303 [RSC] --- Movie ----
2060: 1321.312 [RSC] CINEMA_FILTER_WORK 0x00000000 0x00000000 0 [Cacheable!
2061: 1321.317 [RSC] MOVIE_RECYUV 0x00000000 0x00000000 0 [Cacheable!
2062: 1321.322 [RSC] AUDIO WORK 0x41426000 0x00241400 2364416
2063: 1321.327 [RSC] MOVIE_STREAM 0x485A0000 0x04D00000 80740352
2064: 1321.332 [RSC] MOVIE_STREAM 0x485A0000 0x04D00000 80740352
2065: 1321.336 [RSC] MOVIE_RECWORK 0x4D2A0000 0x10910000 277938176
2066: 1321.341 [RSC] 4K_LINEVRAM 0x60000000 0x0B1FA800 186624000
2067: 1321.345 [RSC] LV_WORK 0x63B60000 0x0C270000 203882496
2068: 1321.349 [RSC] --- Play ----
2069: 1321.357 [RSC] JPEG_WORK_4K 0x00000000 0x00000000 0 [Cacheable!
2070: 1321.362 [RSC] SLIDE_SHOW_WORK 0x512B0000 0x01FA4000 33177600
2071: 1321.366 [RSC] IMGPLAY_WORK 0x5A6FE800 0x04C00000 79691776
2072: 1321.371 [RSC] MOVIE_PLAYWORK 0x63B60000 0x10840000 277086208
2073: 1321.375 [RSC] --- Multishot ----
2074: 1321.397 [RSC] HDR/GIS_WORK1 0x00000000 0x00000000 0 [Cacheable!
2075: 1321.402 [RSC] HDR/GIS_WORK2 0x00000000 0x00000000 0 [Cacheable!
2076: 1321.407 [RSC] HDR/GIS_WORK3 0x00000000 0x00000000 0 [Cacheable!
2077: 1321.413 [RSC] HDR/GIS_WORK4 0x00000000 0x00000000 0 [Cacheable!
2078: 1321.418 [RSC] HDR/GIS_COMP_WORK 0x00000000 0x00000000 0 [Cacheable!
2079: 1321.424 [RSC] HDR/GIS_SS-1 0x00000000 0x00000000 0 [Cacheable!
2080: 1321.431 [RSC] HDR/GIS_YUV 1st-1 0x00000000 0x00000000 0 [Cacheable!
2081: 1321.436 [RSC] HDR/GIS_YUV 2nd-1 0x00000000 0x00000000 0 [Cacheable!
2082: 1321.441 [RSC] HDR/GIS_EXMEM3_AREA 0x00000000 0x00000000 0 [Cacheable!
2083: 1321.447 [RSC] HDR/GIS_SS-2 0x00000000 0x00000000 0 [Cacheable!
2084: 1321.452 [RSC] HDR/GIS_YUV 1st-2 0x00000000 0x00000000 0 [Cacheable!
2085: 1321.458 [RSC] HDR/GIS_YUV 2nd-2 0x00000000 0x00000000 0 [Cacheable!
2086: 1321.463 [RSC] HDR/GIS_YUV Thumb 0x00000000 0x00000000 0 [Cacheable!
2087: 1321.469 [RSC] HDR/GIS_MOVIE_RECWORK 0x00000000 0x00000000 0 [Cacheable!
2088: 1321.474 [RSC] HDR/GIS_AUDIO WORK 0x00000000 0x00000000 0 [Cacheable!
2089: 1321.479 [RSC] HDR/GIS_MOVIE_STREAM 0x00000000 0x00000000 0 [Cacheable!
2090: 1321.484 [RSC] HDR/GIS_MOVIE_PLAYWORK 0x00000000 0x00000000 0 [Cacheable!
2091: 1321.489 [RSC] HDR/GIS_4K_LINEVRAM 0x00000000 0x00000000 0 [Cacheable!
2092: 1321.495 [RSC] HDR/GIS_IMGPLAY_WORK 0x00000000 0x00000000 0 [Cacheable!
2093: 1321.501 [RSC] HDR/GIS_SLIDE_SHOW_WORK 0x00000000 0x00000000 0 [Cacheable!
2094: 1321.506 [RSC] HDR/GIS_LV_WORK 0x00000000 0x00000000 0 [Cacheable!
2095: 1321.512 [RSC] HDR/GIS_MOVIE_RECYUV 0x00000000 0x00000000 0 [Cacheable!
2096: 1321.518 [RSC] HDR/GIS_SUSAN_YUV 0x00000000 0x00000000 0 [Cacheable!
2097: 1321.524 [RSC] HDR/GIS_KAITO_YUV 0x00000000 0x00000000 0 [Cacheable!
2098: 1321.529 [RSC] HDR/GIS_LV_SERVO_WORK 0x00000000 0x00000000 0 [Cacheable!
2099: 1321.535 [RSC] HDR/GIS_DANCING_WORK 0x00000000 0x00000000 0 [Cacheable!
2100: 1321.540 [RSC] HDR/GIS_IMGVRAM 0x00000000 0x00000000 0 [Cacheable!
2101: 1321.546 [RSC] HDR/GIS_JPEG_WORK 0x00000000 0x00000000 0 [Cacheable!
2102: 1321.551 [RSC] HDR/GIS_EXMEM3_2 0x00000000 0x00000000 0 [Cacheable!
2103: 1321.557 [RSC] HDR/GIS_FLEXIBLE_MEM3_1 0x00000000 0x00000000 0 [Cacheable!
2104: 1321.562 [RSC] HDR/GIS_FLEXIBLE_MEM3_2 0x00000000 0x00000000 0 [Cacheable!
2105: 1321.567 [RSC] --- Indev ----
2106: 1321.583 [RSC] INDEV_SS-1 0x00000000 0x00000000 0 [Cacheable!
2107: 1321.588 [RSC] INDEV_YUV 1st-1 0x00000000 0x00000000 0 [Cacheable!
2108: 1321.593 [RSC] INDEV_YUV 2nd-1 0x00000000 0x00000000 0 [Cacheable!
2109: 1321.597 [RSC] INDEV_BASIC 0x00000000 0x00000000 0 [Cacheable!
2110: 1321.603 [RSC] INDEV_SS-2 0x00000000 0x00000000 0 [Cacheable!
2111: 1321.607 [RSC] INDEV_YUV 1st-2 0x00000000 0x00000000 0 [Cacheable!
2112: 1321.612 [RSC] INDEV_YUV 2nd-2 0x00000000 0x00000000 0 [Cacheable!
2113: 1321.617 [RSC] INDEV_YUV Thumb 0x00000000 0x00000000 0 [Cacheable!
2114: 1321.622 [RSC] INDEV_SUSAN_YUV 0x00000000 0x00000000 0 [Cacheable!
2115: 1321.627 [RSC] INDEV_KAITO_YUV 0x00000000 0x00000000 0 [Cacheable!
2116: 1321.633 [RSC] INDEV_MOVIE_REC_YUV 0x00000000 0x00000000 0 [Cacheable!
2117: 1321.638 [RSC] INDEV_EXMEM3_AREA 0x4636A800 0x03C95800 63526912
2118: 1321.643 [RSC] INDEV_SLIDE_SHOW_WORK 0x512B0000 0x01FA4000 33177600
2119: 1321.648 [RSC] INDEV_IMGPLAYWORK 0x5A6FE800 0x04C00000 79691776
2120: 1321.653 [RSC] INDEV_WORK 0x63B53800 0x099C6000 161243136
2121: 1321.658 [RSC] INDEV_YUV_IN 0x6D519800 0x02671800 40310784
2122: 1321.662 [RSC] INDEV_YUV_OUT 0x6FB8B000 0x02671800 40310784
2123: 1321.667 [RSC] INDEV_TRIMING_VIEW_WORK 0x72200000 0x02200000 35651584
2124: 1321.672 [RSC] INDEV_EXMEM3_AREA 0x78000000 0x06110000 101777408
2125: 1321.677 [RSC] --- DP ----
2126: 1321.689 [RSC] DP_SS-1 0x00000000 0x00000000 0 [Cacheable!
2127: 1321.694 [RSC] DP_YUV 1st-1 0x00000000 0x00000000 0 [Cacheable!
2128: 1321.699 [RSC] DP_YUV 2nd-1 0x00000000 0x00000000 0 [Cacheable!
2129: 1321.704 [RSC] DP_YUV_IN 0x00000000 0x00000000 0 [Cacheable!
2130: 1321.709 [RSC] DP_YUV_OUT 0x00000000 0x00000000 0 [Cacheable!
2131: 1321.714 [RSC] DP_MULTI_CHUNK 0x00000000 0x00000000 0 [Cacheable!
2132: 1321.719 [RSC] DP_WORK 0x00000000 0x00000000 0 [Cacheable!
2133: 1321.724 [RSC] DP_SINGLE_CHUNK 0x00000000 0x00000000 0 [Cacheable!
2134: 1321.729 [RSC] DP_SS-2 0x00000000 0x00000000 0 [Cacheable!
2135: 1321.733 [RSC] DP_YUV 1st-2 0x00000000 0x00000000 0 [Cacheable!
2136: 1321.739 [RSC] DP_YUV 2nd-2 0x00000000 0x00000000 0 [Cacheable!
2137: 1321.743 [RSC] DP_YUV Thumb 0x00000000 0x00000000 0 [Cacheable!
2138: 1321.749 [RSC] DP_SLIDE_SHOW_WORK 0x00000000 0x00000000 0 [Cacheable!
2139: 1321.754 [RSC] DP_SUSAN_YUV 0x00000000 0x00000000 0 [Cacheable!
2140: 1321.758 [RSC] DP_KAITO_YUV 0x00000000 0x00000000 0 [Cacheable!
2141: 1321.763 [RSC] DP_MOVIE_REC_YUV 0x00000000 0x00000000 0 [Cacheable!
I don't have a good way to check if the output is sensible.The output is correct. The parsed text can be added to this thread.
@srsa - can I ignore memmapping_vmsa(), or is it important to get that working?That is only usable on camera, and only makes sense if one is trying to make changes to the memory translation.
gcc -m32 -o cpuinfo.exe -DCPUINFO_STANDALONE cpuinfo.c
32-bit only due to arch-dependent types in source.Index: modules/cpuinfo.c
===================================================================
--- modules/cpuinfo.c (revision 5570)
+++ modules/cpuinfo.c (working copy)
@@ -1,3 +1,5 @@
+#ifndef CPUINFO_STANDALONE
+
#include "stdlib.h"
#include "gui_mbox.h"
#include "gui.h"
@@ -4,6 +6,24 @@
#include "gui_lang.h"
#include "lang.h"
+#else // CPUINFO_STANDALONE
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define THUMB_FW 1
+
+const char *fni;
+const char *fno;
+static int is_vmsa = 1;
+
+int cpu_is_vmsa() {
+ return is_vmsa;
+}
+
+#endif // CPUINFO_STANDALONE
+
struct cpuinfo_bitfield_desc_s {
unsigned bits;
const char *name;
@@ -67,6 +87,7 @@
char *p;
#ifdef THUMB_FW
struct cpuinfo_word_desc_s *cpuinfo_desc;
+#ifndef CPUINFO_STANDALONE
if (cpu_is_vmsa()) {
FILE *f=fopen("A/MMU_MAP.CSV", "wb");
memmapping_vmsa(f);
@@ -77,10 +98,36 @@
cpuinfo_get_info_pmsa(cpuinfo);
cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_pmsa;
}
+#endif // CPUINFO_STANDALONE
+
+#else // THUMB_FW
+ cpuinfo_get_info(cpuinfo);
+#endif // THUMB_FW
+
+#ifndef CPUINFO_STANDALONE
+ finfo=fopen("A/CPUINFO.TXT", "wb");
#else
- cpuinfo_get_info(cpuinfo);
+ finfo = fopen(fni,"rb");
+ if (!finfo) {
+ fprintf(stderr, "Failed to open input file\n\n");
+ return;
+ }
+ else {
+ fread(cpuinfo, 4, NUM_CPUINFO_WORDS, finfo);
+ fclose(finfo);
+ }
+ if (cpu_is_vmsa()) {
+ cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_vmsa;
+ }
+ else {
+ cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_pmsa;
+ }
+ finfo=fopen(fno, "wb");
+ if (!finfo) {
+ fprintf(stderr, "Failed to open output file\n\n");
+ return;
+ }
#endif
- finfo=fopen("A/CPUINFO.TXT", "wb");
for(i = 0; cpuinfo_desc[i].name; i++) {
wordval = cpuinfo[i];
sprintf(buf,"%-10s 0x%08X\n",cpuinfo_desc[i].name,wordval);
@@ -88,7 +135,7 @@
for(j=0; cpuinfo_desc[i].fields[j].name; j++) {
p=buf;
bits = cpuinfo_desc[i].fields[j].bits;
- mask = ~(0xFFFFFFFF << bits);
+ mask = (bits==32) ? 0xffffffff : ~(0xFFFFFFFF << bits);
fieldval = wordval & mask;
p+=sprintf(p," %-20s 0x%X %d",cpuinfo_desc[i].fields[j].name,fieldval,fieldval);
if(cpuinfo_desc[i].fields[j].desc_fn) {
@@ -100,10 +147,14 @@
}
}
fclose(finfo);
+#ifndef CPUINFO_STANDALONE
sprintf(buf, lang_str(LANG_CPUINFO_WROTE), "A/CPUINFO.TXT");
gui_mbox_init(LANG_MENU_DEBUG_CPU_INFO,(int)buf,MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, cpuinfo_finish);
+#endif // CPUINFO_STANDALONE
}
+#ifndef CPUINFO_STANDALONE
+
int basic_module_init() {
cpuinfo_write_file();
return 1;
@@ -136,3 +187,25 @@
/*************** END OF AUXILARY PART *******************/
+#else // CPUINFO_STANDALONE
+
+char *usage = "\nUsage: %s <cpuinfo.dat> <output file> [-p]\n\n";
+
+
+int main(int ac, const char **av) {
+
+ if (ac < 3) {
+ fprintf(stderr, usage, av[0]);
+ exit(0);
+ }
+ else if (ac > 3) {
+ if (strcmp(av[3], "-p") == 0) {
+ is_vmsa = 0;
+ }
+ }
+ fni = av[1];
+ fno = av[2];
+ cpuinfo_write_file();
+}
+
+#endif // CPUINFO_STANDALONE
Index: modules/cpuinfo_v7.c
===================================================================
--- modules/cpuinfo_v7.c (revision 5570)
+++ modules/cpuinfo_v7.c (working copy)
@@ -535,6 +535,7 @@
{}
};
+#ifndef CPUINFO_STANDALONE
void __attribute__((naked,noinline)) cpuinfo_get_info_pmsa(unsigned *results) {
asm (
@@ -809,6 +810,8 @@
);
}
+#endif // CPUINFO_STANDALONE
+
static const char * tlb_unified(unsigned val) {
switch(val) {
case 0: return "Unified TLB";
@@ -1007,6 +1010,8 @@
{}
};
+#ifndef CPUINFO_STANDALONE
+
void __attribute__((naked,noinline)) cpuinfo_get_info_vmsa(unsigned *results) {
asm (
".syntax unified\n"
@@ -1512,4 +1517,6 @@
fclose(f);
}
+#endif // CPUINFO_STANDALONE
+
Thanks, this is quite interesting. Are you aware of Scout debugger?It was mentioned in their ransomware article. Never tried to use it.
https://github.com/CheckPointSW/Scout
In theory this can be loaded into Canon cams and act as a network debugger.They mention it worked, but the subject was a DIGIC 6 camera. DIGIC 7 and later has a separate core for networking. The firmware refers to it as "Lime". That CPU is not ARM, it's Xtensa. And that architecture is not supported by Scout.
After that I'll try getting the cpuinfo code running, do a dump of it on the real hardware and post its output here.If you do that, please use the updated code from CHDK svn. The old Cortex R4 specific code is not very useful on Cortex A9.
' firmware function addresses with thumb bit
dim a_fio_readf=0xE0520E8B ' FIO_ReadFile
dim a_fio_writef=0xE0521027 ' FIO_WriteFile
dim a_fio_removf=0xE0520DF1 ' FIO_RemoveFile (newer cams have an equivalent RemoveFile eventproc)
dim a_umalloc=0xE053A0B1 ' AllocateUncacheableMemory
dim a_ufree=0xE053A0E5 ' used to free AllocateUncacheableMemory allocations (not named)
dim cpuinf_binary="B:/CPUINFO.BIN"
dim cpuinf_data="B:/CPUINFO.DAT"
private sub reg_funcs1()
ExportToEventProcedure("FIO_ReadFile",a_fio_readf|1)
ExportToEventProcedure("FIO_WriteFile",a_fio_writef|1)
ExportToEventProcedure("FIO_RemoveFile",a_fio_removf|1)
ExportToEventProcedure("umalloc",a_umalloc|1)
ExportToEventProcedure("ufree",a_ufree|1)
end sub
private sub Initialize()
reg_funcs1()
buf = umalloc(0x1000)
if buf=0 then
exit sub
end if
bufo = umalloc(0x1000)
if bufo=0 then
ufree(buf)
exit sub
end if
memset(bufo,0,0x1000)
f = OpenFileRD(cpuinf_binary)
FIO_ReadFile(f,buf,0x1000)
CloseFile(f)
ExportToEventProcedure("cpuinfo",buf|1)
cpuinfo(bufo)
FIO_RemoveFile(cpuinf_data)
f = OpenFileCREAT(cpuinf_data)
CloseFile(f)
f = OpenFileWR(cpuinf_data)
FIO_WriteFile(f,bufo,0x1000)
CloseFile(f)
ufree(bufo)
ufree(buf)
end sub
Assembly source for the current CPUINFO code from here. It now supports ARMv7 VMSA (such as Cortex A9) CPUs.@ compile with:
@ arm-none-eabi-gcc -Wl,-N,-Ttext,0x800000 -nostdlib -march=armv7 -mthumb cpuinfo.s -o cpuinfo.elf
@ and extract the needed bytes from the binary:
@ arm-none-eabi-objcopy -O binary cpuinfo.elf cpuinfo.bin
@ toolchain: [url]https://launchpad.net/gcc-arm-embedded[/url]
@ 0x00800000 is an arbitrary address, code is position independent anyway
.macro NHSTUB name addr
.globl _\name
.weak _\name
_\name:
ldr.w pc, _\addr
_\addr:
.long \addr
.endm
.globl _start
.org 0
_start:
.text
@ force thumb
.code 16
@ allow new instructions (ldr.w)
.syntax unified
MRC p15, 0, R1,c0,c0 @ ident
STR R1, [R0]
MRC p15, 0, R1,c0,c0,1 @ CTR, cache
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c0,2 @ TCMTR, TCM
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c0,3 @ TLBTR
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c2,c0,2 @ TTBCR
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c2,c0,0 @ TTBR0
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c2,c0,1 @ TTBR1
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c0,5 @ MPIDR
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c0,6 @ REVIDR
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,0 @ ID_PFR0
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,1 @ ID_PFR1
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,2 @ ID_DFR0
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,3 @ ID_AFR0
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,4 @ ID_MMFR0
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,5 @ ID_MMFR1
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,6 @ ID_MMFR2
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c1,7 @ ID_MMFR3
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c2,0 @ ID_ISAR0
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c2,1 @ ID_ISAR1
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c2,2 @ ID_ISAR2
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c2,3 @ ID_ISAR3
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c2,4 @ ID_ISAR4
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c0,c2,5 @ ID_ISAR5
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 1, R1,c0,c0,1 @ CLIDR
ADD R0, R0, #4
STR R1, [R0]
MOV R1, #0
MCR p15, 2, R1,c0,c0,0 @ CSSELR (data cache, level0)
MRC p15, 1, R1,c0,c0,0 @ CCSIDR (the currently selected one)
ADD R0, R0, #4
STR R1, [R0]
MOV R1, #1
MCR p15, 2, R1,c0,c0,0 @ CSSELR (inst cache, level0)
MRC p15, 1, R1,c0,c0,0 @ CCSIDR (the currently selected one)
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c1,c0,0 @ SCTLR
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c1,c0,1 @ ACTLR
ADD R0, R0, #4
STR R1, [R0]
@#ifndef CONFIG_QEMU
MRC p15, 0, R1,c15,c0,0 @ ACTLR2
ADD R0, R0, #4
STR R1, [R0]
@#endif
MRC p15, 0, R1,c1,c0,2 @ CPACR
ADD R0, R0, #4
STR R1, [R0]
@"MRC p15, 0, R1,c9,c1,1 @ ATCM region reg, Cortex R4
@"ADD R0, R0, #4
@"STR R1, [R0]
@"MRC p15, 0, R1,c9,c1,0 @ BTCM region reg, Cortex R4
@"ADD R0, R0, #4
@"STR R1, [R0]
MRC p15, 0, R1,c1,c1,2 @ NSACR
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c3,c0,0 @ DACR
ADD R0, R0, #4
STR R1, [R0]
MRC p14, 0, R1,c0,c0,0 @ DBGDIDR
ADD R0, R0, #4
STR R1, [R0]
MRC p14, 0, R1,c1,c0,0 @ DBGDRAR
ADD R0, R0, #4
STR R1, [R0]
MRC p14, 0, R1,c2,c0,0 @ DBGDSAR
ADD R0, R0, #4
STR R1, [R0]
MRC p14, 0, R1,c0,c1,0 @ DBGDSCR
ADD R0, R0, #4
STR R1, [R0]
@".word 0xEEF01A10 @"VMRS R1, FPSID @ Floating Point System ID register
@"ADD R0, R0, #4
@"STR R1, [R0]
@".word 0xEEF71A10 @"VMRS R1, MVFR0 @ Media and VFP Feature Register 0
@"ADD R0, R0, #4
@"STR R1, [R0]
@".word 0xEEF61A10 @"VMRS R1, MVFR1 @ Media and VFP Feature Register 1
@"ADD R0, R0, #4
@"STR R1, [R0]
MRC p15, 4, R1,c15,c0,0 @ config base addr reg (Cortex A9)
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c11,c0,0 @ PLEIDR (Cortex A9)
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c10,c0,0 @ TLB lockdown reg (Cortex A9)
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c10,c2,0 @ PRRR (Cortex A9)
ADD R0, R0, #4
STR R1, [R0]
MRC p15, 0, R1,c10,c2,1 @ NMRR (Cortex A9)
ADD R0, R0, #4
STR R1, [R0]
BX LR
I already executed this on my camera and found no big differences from DIGIC 7.Index: modules/cpuinfo.c
===================================================================
--- modules/cpuinfo.c (revision 5564)
+++ modules/cpuinfo.c (working copy)
@@ -66,17 +66,36 @@
char buf[100];
char *p;
#ifdef THUMB_FW
+ int pmsa = 0;
struct cpuinfo_word_desc_s *cpuinfo_desc;
- if (cpu_is_vmsa()) {
- FILE *f=fopen("A/MMU_MAP.CSV", "wb");
- memmapping_vmsa(f);
- cpuinfo_get_info_vmsa(cpuinfo);
+
+ finfo = fopen("A/CPUI_V7V.DAT","rb");
+ if (!finfo) {
+ finfo = fopen("A/CPUI_V7P.DAT","rb");
+ pmsa = 1;
+ }
+ if (!finfo) {
+ pmsa = !cpu_is_vmsa();
+ if (cpu_is_vmsa()) {
+ FILE *f=fopen("A/MMU_MAP.CSV", "wb");
+ memmapping_vmsa(f);
+ cpuinfo_get_info_vmsa(cpuinfo);
+ }
+ else {
+ cpuinfo_get_info_pmsa(cpuinfo);
+ }
+ }
+ else {
+ fread(cpuinfo, 4, NUM_CPUINFO_WORDS, finfo);
+ fclose(finfo);
+ }
+ if (!pmsa) {
cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_vmsa;
}
else {
- cpuinfo_get_info_pmsa(cpuinfo);
cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_pmsa;
}
+
#else
cpuinfo_get_info(cpuinfo);
#endif
Nothing there, but thx.https://web.archive.org/web/20200622002229/https://bitbucket.org/daniel_fort/magic-lantern/downloads/
Thanks! Cam is 250D, not 200D. ;-)Corrected.
Maybe subject needs to be chanced a bit. My 250D/200D Mark II/Rebel SL3/Kiss X10 does execute Canon Basic script and produces ROM.TXT.Hmmm, what an avalanche. Changed the 1st post and thread title.
private sub Initialize()
r = ExecuteEventProcedure("SaveAllRomImageToFile")
if r = -1 then
ExecuteEventProcedure("SaveBootableToFile")
end if
end sub
I gladly accept (links to) dumps in PM.
Does anyone know what that "better way" is? I sent srsa a PM asking about it.Replying here.
ExecuteEventProcedure("Peek32",0x1000)
is equivalent toPeek32(0x1000)
and will return the word read from address 0x1000ExecuteEventProcedure("arbitrary_invalid_function")
will return -1ExportToEventProcedure("my_func",0xe1234567)
will make the firmware function at 0xe1234566 (with thumb bit) available for script as eventproc my_funcprivate sub Initialize()
SaveBootableToFile()
end sub
ROM dumper, not working on M50 due to missing eventprocprivate sub Initialize()
SaveAllRomImageToFile()
end sub
Enable bootflagprivate sub Initialize()
EnableBootDisk()
end sub
Disable bootflagprivate sub Initialize()
DisableBootDisk()
end sub
Dumping camera log (current session)private sub Initialize()
dumpf()
end sub
On my M100, the basic scripts only start every second time (on average).I don't remember seeing that on my cameras. If the script card is prepared correctly, the script can be started reliably.
Does the R5 support Canon Basic?It's not hard to try if you have access to one. Prepare a script card (confirm that it's working on one of your cameras), copy the script from this post put it in camera and try starting it. If it writes something on card or crashes, then the answer is yes.
Couldn't trigger it on M2 or 200D - don't know if it's supposed to work thereNo, those are fully EOS models codebase-wise.
' hex dumper
dim start = 0xe0000000
dim length = 0x100000
private sub save_as_hex(fn,addr,size)
f = OpenFileCREAT(fn)
CloseFile(f)
f = OpenFileWR(fn)
p = addr
' 1MB ~ 64 sec
do while p < (addr+size)
p1 = *p
p = p + 4
p2 = *p
p = p + 4
p3 = *p
p = p + 4
p4 = *p
p = p + 4
p5 = *p
p = p + 4
p6 = *p
p = p + 4
p7 = *p
p = p + 4
p8 = *p
p = p + 4
WriteFileString(f,"%08x%08x%08x%08x%08x%08x%08x%08x\n",p1,p2,p3,p4,p5,p6,p7,p8)
loop
CloseFile(f)
end sub
private sub Initialize()
save_as_hex("B:/ROM.TXT",start,length)
end sub
I have not been able to find "normal" read()- and write()-like event procedures, thus the hex dump. You may want to adjust 'start' and 'length' at the beginning of the script, but note the time requirement. Camera user interface will be locked up while the script runs.#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
const char *usage = "Decode hex files made with CBasic EOS dumper (LE words)\n"
"\nUsage: %s <input> <output>\n\n";
int32_t hex2char(uint8_t a) {
if (a<0x30) {
return -1;
}
else if (a<=0x39) {
return a-0x30;
}
a = a & 0xdf;
if (a<0x41) {
return -1;
}
else if (a<=0x46) {
return a - 0x41 + 10;
}
return -1;
}
int hex2uint32(FILE *f, uint32_t *u) {
int32_t n,m;
uint8_t c;
int ret = 0;
*u = 0;
for (n=7; n>=0; n--) {
int r;
c = 0;
r = fread(&c,1,1,f);
if (c == '\n') {
r = fread(&c,1,1,f);
}
if (r<1) {
ret = -1;
break;
}
m = hex2char(c);
if (m>=0) {
*u |= ((uint32_t)m)<<(n*4);
}
}
return ret;
}
FILE *fil;
FILE *filp;
int main(int ac, const char **av) {
if (ac < 3) {
fprintf(stderr, usage, av[0]);
exit(0);
}
const char *fi = av[1];
const char *fp = av[2];
filp = fopen(fp, "w+b");
if (!filp) {
fprintf(stderr,"Failed to open output file\n");
return -1;
}
fil = fopen(fi, "r+b");
if (!fil) {
fprintf(stderr,"Failed to open input file\n");
fclose(filp);
return -2;
}
uint32_t u;
while ( !hex2uint32(fil, &u) ) {
fwrite(&u, 1, 4, filp);
}
fclose(filp);
fclose(fil);
exit(0);
}