Turbo Resin: open-source firmware for resin printers
Turbo Resin is an open-source firmware for chitu based controller board printers.
It currently supports:
- Anycubic Photon Mono 4K
To add support for other printers, I need some help. If people could share photos of the circuit boards of various printers, that would be a great start!
This is the implementation of a firmware based on Reverse engineering the Anycubic Photon Mono 4K
Roadmap
Drivers:
- Read the touch screen
- Display on the touch screen
- Use the LVGL UI library
- Control the stepper motor
- Read/write to external Flash
- Read/write to external EEPROM
- Drive the LCD panel (anti-aliasing support confirmed!)
- Read from USB flash drive
- Control the UV light
- Z=0 detection
Printing features:
- Better Z-Axis motion control for faster prints with fast deceleration
- Z=0 calibration
- Read .pwma files from USB flash drive
- Support multiple exposure (like RERF but configurable)
- Print algorithm
- Support more file formats to support various slicers
- Add support for other printers (help needed!)
- Build-plate force feedback for speed optimization. Following the work of Jan Mrázek
- Over-expose structural region of the print to add strength while letting edges be normally exposed
Flashing the firmware
As of now, there's no official distribution to flash the firmware via a USB stick. You'll need:
- A programmer like JLink or ST-Link V2 ($11)
- A 3mm hex screwdriver
Compiling the firmware
Prerequisites
Install the Rust toolchain. Follow instruction in the installation section of the Rust Embedded Book. For the target, use thumbv7em-none-eabihf
.
Use the nightly toolchain for the project (otherwise you will have some no_std
errors from memchr
):
rustup override set nightly
Finally, export this environment variable set to the root of the project. It's for the lvgl dependency so it locates the lv_conf.h
file.
export DEP_LV_CONFIG_PATH=`pwd`
Build
» make
cargo build --release
Finished release [optimized + debuginfo] target(s) in 0.15s
cargo objdump --release -- -h | ./stuff/rom_stats.py
.vector_table DATA 0.3K (0.1%)
.lvgl.text TEXT 136.3K (53.3%)
.lvgl.rodata DATA 27.8K (10.9%)
.libs.text TEXT 39.0K (15.2%)
.libs.rodata DATA 8.4K (3.3%)
.text TEXT 13.1K (5.1%)
.rodata DATA 2.8K (1.1%)
.data DATA 0.1K (0.1%)
.bss BSS 65.2K (67.9%)
.uninit BSS 0.1K (0.1%)
Total ROM 227.8K (89.0%)
Total RAM 65.4K (68.1%)
Connect to the printer
First, connect your programmer to the SWD header on the board. Pinout is shown in Reverse engineering the Anycubic Photon Mono 4K Part1
Then, configure your programming interface
JLink
Run:
make -j2 start_jlink start_jlink_rtt
ST-Link or any OpenOCD compatible interface
- Export this variable (or edit the Makefile) to select the stlink interface:
export OPENOCD_INTERFACE=stuff/stlink.cfg
- Edit
gdb/main.gdb
and pick your JLink or OpenOCD interface:
source ./gdb/jlink.gdb
# source ./gdb/openocd.gdb
- Start the OpenOCD server:
make start_opencd
cargo-flash
You can also use cargo-flash but I haven't tried.
Flash the new firmware
make run
» make run
cargo run --release -q
Reading symbols from target/thumbv7em-none-eabihf/release/app...
0xf4133022 in ?? ()
Loading section .vector_table, size 0x150 lma 0x8000000
Loading section .lvgl.text, size 0x22148 lma 0x8000150
Loading section .lvgl.rodata, size 0x6f2f lma 0x8022298
Loading section .libs.text, size 0x9bfa lma 0x80291c8
Loading section .libs.rodata, size 0x217f lma 0x8032dc4
Loading section .text, size 0x3439 lma 0x8034f43
Loading section .rodata, size 0xb14 lma 0x8038380
Loading section .data, size 0x7c lma 0x8038e94
Start address 0x08034f44, load size 233225
Transfer rate: 37959 KB/sec, 12275 bytes/write.
Resetting target
A debugging session is active.
Inferior 1 [Remote target] will be killed.
Quit anyway? (y or n) [answered Y; input not from terminal]
[main●] turbo-resin »
Debugging
Use make attach
, c
, and ctrl+c
to get a gdb instance connected to the device.
» make attach
arm-none-eabi-gdb -q -x gdb/main.gdb target/thumbv7em-none-eabihf/release/app
Reading symbols from target/thumbv7em-none-eabihf/release/app...
0xdeadbeee in ?? ()
(gdb) c
Continuing.
^C
Program received signal SIGTRAP, Trace/breakpoint trap.
0x080193ca in draw_letter_normal (map_p=0x80245fa
"", g=0x20017c88, pos=
, dsc=
, draw_ctx=
) at /Users/pafy/.cargo/git/checkouts/lvgl-rs-9408c72813c5388a/bf6ee92/lvgl-sys/vendor/lvgl/src/draw/sw/lv_draw_sw_letter.c:257
257 letter_px = (*map_p & bitmask) >> (col_bit_max - col_bit);
1: x/5i $pc
=> 0x80193ca
: ands r3, r1 0x80193cc
: lsr.w r3, r3, r12 0x80193d0
: ands.w r3, r3, #255 ; 0xff 0x80193d4
: it ne 0x80193d6
: ldrbne.w r3, [r11, r3] (gdb)
Alternatively, you can use VSCode's Run -> Start Debugging graphical debugger.
Restore the original firmware
If you are done with your changes, you can restore the original firmware with the following:
make restore_rom
License
Turbo Resin is licensed under the GPLv3