Skip to content

M-Film: film simulation for Canon EOS cameras with Magic Lantern. 72 film stocks (Portra, Velvia, Tri-X, CineStill…), a film-camera interface and an in-camera darkroom that develops your RAWs. 5D Mark III, 6D, 600D, 650D, 700D, EOS M and more.

Module builds: the camera's loader crashed on the film OS module; link-test it like the camera

Claude8b0bf62bd1fe
diff --git a/.github/workflows/camera.yml b/.github/workflows/camera.yml
index bd7ba10..38e746d 100644
--- a/.github/workflows/camera.yml
+++ b/.github/workflows/camera.yml
@@ -44,7 +44,7 @@ jobs:
- name: Toolchain and Magic Lantern (the commit the fork is made against)
run: |
sudo apt-get update -qq
- sudo apt-get install -y -qq gcc-arm-none-eabi binutils-arm-none-eabi zip
+ sudo apt-get install -y -qq gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi zip qemu-user
python -m pip install -q numpy scipy pillow segno docutils
git clone -q --filter=blob:none https://github.com/reticulatedpines/magiclantern_simplified.git "$HOME/ml/magiclantern_simplified"
git -C "$HOME/ml/magiclantern_simplified" checkout -q ed3e7c0dfacfdeaf3349dee73edf9e3621217462
@@ -93,7 +93,7 @@ jobs:
- name: Toolchain and Magic Lantern (the commit the fork is made against)
run: |
sudo apt-get update -qq
- sudo apt-get install -y -qq gcc-arm-none-eabi binutils-arm-none-eabi zip
+ sudo apt-get install -y -qq gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi zip qemu-user
python -m pip install -q numpy scipy pillow segno docutils
git clone -q --filter=blob:none https://github.com/reticulatedpines/magiclantern_simplified.git "$HOME/ml/magiclantern_simplified"
git -C "$HOME/ml/magiclantern_simplified" checkout -q ed3e7c0dfacfdeaf3349dee73edf9e3621217462
@@ -132,7 +132,7 @@ jobs:
- name: Toolchain and Magic Lantern (the commit the fork is made against)
run: |
sudo apt-get update -qq
- sudo apt-get install -y -qq gcc-arm-none-eabi binutils-arm-none-eabi zip
+ sudo apt-get install -y -qq gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi zip qemu-user
python -m pip install -q numpy scipy pillow segno docutils
git clone -q --filter=blob:none https://github.com/reticulatedpines/magiclantern_simplified.git "$HOME/ml/magiclantern_simplified"
git -C "$HOME/ml/magiclantern_simplified" checkout -q ed3e7c0dfacfdeaf3349dee73edf9e3621217462
diff --git a/ml-dev/build_fork.sh b/ml-dev/build_fork.sh
index 0bf8cb7..2e1536d 100644
--- a/ml-dev/build_fork.sh
+++ b/ml-dev/build_fork.sh
@@ -90,6 +90,13 @@ if [ -n "$MODULE" ]; then
arm-none-eabi-objcopy --wildcard --keep-global-symbol='__module_*' \
--keep-global-symbol=filmos_key_used --keep-global-symbol=filmos_menu_open \
--keep-global-symbol=filmos_overlays "$MOD/build/filmos.mo"
+ # libgcc's and libm's unwind tables: Magic Lantern's TCC crashes loading them, and the camera
+ # hangs in its module loader with no film OS and no Modules tab (#46, #48). Nothing unwinds here.
+ arm-none-eabi-objcopy --remove-section=.ARM.exidx --remove-section=.rel.ARM.exidx \
+ --remove-section=.ARM.extab "$MOD/build/filmos.mo"
+ if arm-none-eabi-readelf -SW "$MOD/build/filmos.mo" | grep -q "\.ARM\.ex"; then
+ echo "the film OS module still has unwind tables, which the camera's loader can't load"; exit 1
+ fi
arm-none-eabi-readelf -sW "$MOD/build/filmos.mo" | awk '$5 == "GLOBAL" && $7 == "UND" {print $8}' | sort -u > "$MOD/build/filmos.dep"
# every symbol the module needs must be in this camera's autoexec.bin, or the loader refuses it
# the symbol file the camera's module loader reads (5D2_212.sym, t3_105.sym on the 1100D ...)
@@ -105,6 +112,15 @@ if [ -n "$MODULE" ]; then
echo "the film OS module defines names autoexec.bin already has:"; echo "$CLASH"
exit 1
fi
+ # link it as the camera's loader will, with ML's own TCC, where qemu-arm can run it (fork/module/linktest.c)
+ if command -v qemu-arm > /dev/null; then
+ arm-none-eabi-gcc -march=armv5te -O1 -I"$SRC/tcc" -o "$MOD/build/linktest" "$HERE/fork/module/linktest.c" \
+ "$SRC/platform/$PLAT/build/tcc/libtccx.o" --specs=rdimon.specs -lc -lrdimon -lm >> "$LOG" 2>&1 \
+ || { echo "linktest didn't build, see $LOG"; exit 1; }
+ (cd "$MOD/build" && qemu-arm -cpu arm926 ./linktest filmos.mo "$SYM") || { echo "the camera's loader wouldn't take the film OS module"; exit 1; }
+ else
+ echo "(no qemu-arm: the module isn't link-tested; apt install qemu-user)"
+ fi
# next to ML's own modules, in the zip's spelling (the card doesn't care, a computer unzipping it does)
mkdir -p "$OUT/ML/modules" "$OUT/ML/SETTINGS"
cp "$MOD/build/filmos.mo" "$OUT/ML/modules/filmos.mo"
diff --git a/ml-dev/fork/film-mode.patch b/ml-dev/fork/film-mode.patch
index ebdb235..6f5b319 100644
--- a/ml-dev/fork/film-mode.patch
+++ b/ml-dev/fork/film-mode.patch
@@ -1,26 +1,29 @@
diff --git a/platform/100D.101/Makefile b/platform/100D.101/Makefile
-index 05832de0d..9e706a32e 100644
+index 05832de0d..6aeb6422b 100644
--- a/platform/100D.101/Makefile
+++ b/platform/100D.101/Makefile
@@ -15,6 +15,7 @@ PLATFORM_ARCH = armv5te
RESTARTSTART = 0x44C100
ML_BOOT_OBJ = boot-d45-am.o
ML_SRC_EXTRA_OBJS = $(BUILD_DIR)/reloc.o
-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o
++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmhook.o
include ../Makefile
.DEFAULT_GOAL := $(BUILD_DIR)/cam_complete
diff --git a/platform/100D.101/features.h b/platform/100D.101/features.h
-index 18fa340fe..0a9fb2e00 100644
+index 18fa340fe..cb0f612f5 100644
--- a/platform/100D.101/features.h
+++ b/platform/100D.101/features.h
-@@ -12,3 +12,6 @@
+@@ -12,3 +12,9 @@
/* Not working */
#undef FEATURE_TRAP_FOCUS
#undef FEATURE_MAGIC_ZOOM_FULL_SCREEN // https://bitbucket.org/hudson/magic-lantern/issues/2842
+
+/* film camera mode (src/filmroll.c) */
+#define FEATURE_FILMROLL
++
++/* film-mode fork: the film OS is a module (build_fork.sh --module) */
++#define FEATURE_FILMOS_MODULE
diff --git a/platform/100D.101/modules.included b/platform/100D.101/modules.included
index 8428d3c4b..a3be71e80 100644
--- a/platform/100D.101/modules.included
@@ -384,16 +387,36 @@ index 9e9650596..452e67a8d 100644
include ../Makefile
.DEFAULT_GOAL := $(BUILD_DIR)/cam_complete
diff --git a/platform/650D.104/features.h b/platform/650D.104/features.h
-index 0c94cb713..cbe511db9 100644
+index 0c94cb713..abaa2d836 100644
--- a/platform/650D.104/features.h
+++ b/platform/650D.104/features.h
-@@ -29,3 +29,6 @@
+@@ -29,3 +29,26 @@
#define FEATURE_FOCUS_PEAK_DISP_FILTER
#define FEATURE_CROP_MODE_HACK
+
+/* film camera mode (src/filmroll.c) */
+#define FEATURE_FILMROLL
++
++/* film-mode fork: lean, to fit at boot */
++#undef FEATURE_ZEBRA
++#undef FEATURE_ZEBRA_FAST
++#undef FEATURE_FOCUS_PEAK
++#undef FEATURE_GHOST_IMAGE
++#undef FEATURE_SPOTMETER
++#undef FEATURE_FALSE_COLOR
++#undef FEATURE_WAVEFORM
++#undef FEATURE_RAW_SPOTMETER
++#undef FEATURE_RAW_ZEBRAS
++#undef FEATURE_HDR_VIDEO
++#undef FEATURE_MOVIE_LOGGING
++#undef FEATURE_GRADUAL_EXPOSURE
++#undef FEATURE_TRAP_FOCUS
++#undef FEATURE_FOLLOW_FOCUS
++#undef FEATURE_RACK_FOCUS
++#undef FEATURE_AUDIO_METERS
++#undef FEATURE_HDR_BRACKETING
++#undef FEATURE_FOCUS_PEAK_DISP_FILTER
diff --git a/platform/650D.104/modules.included b/platform/650D.104/modules.included
index 8428d3c4b..a3be71e80 100644
--- a/platform/650D.104/modules.included
@@ -445,28 +468,48 @@ index eddc7617e..6bfdee970 100644
mlv_play
mlv_snd
diff --git a/platform/700D.115/Makefile b/platform/700D.115/Makefile
-index af9eb604f..373803523 100644
+index af9eb604f..0db8c8efa 100644
--- a/platform/700D.115/Makefile
+++ b/platform/700D.115/Makefile
@@ -15,6 +15,7 @@ PLATFORM_ARCH = armv5te
#
MAIN_FIRMWARE_ADDR = 0xFF0C0000
RESTARTSTART = 0x7EC00
-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_dark.o $(BUILD_DIR)/fos_dev.o $(BUILD_DIR)/fos_lab.o $(BUILD_DIR)/fos_looks.o $(BUILD_DIR)/fos_jpeg.o
++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o
include ../Makefile
.DEFAULT_GOAL := $(BUILD_DIR)/cam_complete
diff --git a/platform/700D.115/features.h b/platform/700D.115/features.h
-index 42be326e4..9eee68b47 100644
+index 42be326e4..73db5f8d4 100644
--- a/platform/700D.115/features.h
+++ b/platform/700D.115/features.h
-@@ -23,3 +23,6 @@
+@@ -23,3 +23,26 @@
#define FEATURE_FOCUS_PEAK_DISP_FILTER
#define FEATURE_CROP_MODE_HACK
#define FEATURE_EYEFI_TRICKS
+
+/* film camera mode (src/filmroll.c) */
+#define FEATURE_FILMROLL
++
++/* film-mode fork: lean, to fit at boot */
++#undef FEATURE_ZEBRA
++#undef FEATURE_ZEBRA_FAST
++#undef FEATURE_FOCUS_PEAK
++#undef FEATURE_GHOST_IMAGE
++#undef FEATURE_SPOTMETER
++#undef FEATURE_FALSE_COLOR
++#undef FEATURE_WAVEFORM
++#undef FEATURE_RAW_SPOTMETER
++#undef FEATURE_RAW_ZEBRAS
++#undef FEATURE_HDR_VIDEO
++#undef FEATURE_MOVIE_LOGGING
++#undef FEATURE_GRADUAL_EXPOSURE
++#undef FEATURE_TRAP_FOCUS
++#undef FEATURE_FOLLOW_FOCUS
++#undef FEATURE_RACK_FOCUS
++#undef FEATURE_AUDIO_METERS
++#undef FEATURE_HDR_BRACKETING
++#undef FEATURE_FOCUS_PEAK_DISP_FILTER
diff --git a/platform/700D.115/modules.included b/platform/700D.115/modules.included
index 8428d3c4b..a3be71e80 100644
--- a/platform/700D.115/modules.included
diff --git a/ml-dev/fork/module/linktest.c b/ml-dev/fork/module/linktest.c
new file mode 100644
index 0000000..1036956
--- /dev/null
+++ b/ml-dev/fork/module/linktest.c
@@ -0,0 +1,48 @@
+/* linktest: link ML/modules/filmos.mo the way the camera's module loader does,
+ * with Magic Lantern's own TCC (platform/<cam>/build/tcc/libtccx.o), on a PC
+ * under qemu-arm. build_fork.sh --module runs it when qemu-arm is installed.
+ *
+ * linktest filmos.mo <cam>.sym exit 0: linked, and the module's info found
+ *
+ * It caught the module that crashed the camera's loader in 0.1.4 (#46, #48):
+ * libgcc's unwind tables (.ARM.exidx), which ML's TCC can't load. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "libtcc.h"
+
+/* what ML's TCC asks of its host (src/tcc-glue.c, src/mem.c on the camera) */
+void *__mem_malloc(size_t n, unsigned flags, const char *file, unsigned line) { (void) flags; (void) file; (void) line; return malloc(n); }
+void __mem_free(void *p) { free(p); }
+void _tcc_exit(int code) { printf("linktest: tcc exit(%d)\n", code); exit(3); }
+int _tcc_open(const char *path, int flags) { (void) flags; return open(path, O_RDONLY); }
+int _tcc_read(int fd, void *buf, int n) { return read(fd, buf, n); }
+int _tcc_close(int fd) { return close(fd); }
+int _tcc_lseek(int fd, int off, int whence) { return lseek(fd, off, whence); }
+
+int main(int argc, char **argv)
+{
+ if (argc != 3) { printf("usage: linktest filmos.mo <cam>.sym\n"); return 2; }
+ TCCState *s = tcc_new();
+ tcc_set_options(s, "-nostdlib");
+ FILE *f = fopen(argv[2], "r");
+ if (!f) { printf("linktest: can't read %s\n", argv[2]); return 2; }
+ char line[256];
+ int n = 0;
+ while (fgets(line, sizeof(line), f))
+ {
+ unsigned a;
+ char name[200];
+ if (sscanf(line, "%x %199s", &a, name) == 2) { tcc_add_symbol(s, name, (void *) a); n++; }
+ }
+ fclose(f);
+ if (tcc_add_file(s, argv[1]) < 0) { printf("linktest: TCC can't load %s\n", argv[1]); return 1; }
+ int size = tcc_relocate(s, NULL);
+ void *buf = size > 0 ? malloc(size) : 0;
+ if (!buf || tcc_relocate(s, buf) < 0) { printf("linktest: TCC can't link %s\n", argv[1]); return 1; }
+ if (!tcc_get_symbol(s, "__module_info_filmos")) { printf("linktest: no module info in %s\n", argv[1]); return 1; }
+ printf("linktest: %s links (%d bytes, %d core symbols)\n", argv[1], size, n);
+ return 0;
+}