Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E3V3SE SD Bootloader

A drop-in SD card bootloader for the Creality Ender-3 V3 SE (C14 motherboard, STM32F401RET6).

If you bricked your printer by flashing a bad bootloader — or your stock bootloader just stopped working — this project gives you a clean, open-source replacement. Drop firmware.bin on an SD card, power on, done.


What It Does

  1. Power on → bootloader initializes the MCU and mounts the SD card via SDIO
  2. Checks for firmware.bin on the SD card root
  3. Validates the binary (stack pointer in SRAM, reset vector in flash, Thumb bit set)
  4. Erases application flash sectors 4–7
  5. Writes the firmware byte-by-byte with readback verification
  6. Renames firmware.binfirmware.CUR so it doesn't re-flash on next boot
  7. Jumps to the application at 0x08010000

If there's no SD card or no firmware.bin, it boots whatever app is already flashed.


Flash Memory Layout

 Sector   Address Range        Size    Usage
 ──────   ─────────────────    ─────   ────────────────────
 0        0x08000000-0x08003FFF  16 KB   Bootloader
 1        0x08004000-0x08007FFF  16 KB   Bootloader
 2        0x08008000-0x0800BFFF  16 KB   Bootloader
 3        0x0800C000-0x0800FFFF  16 KB   (reserved/padding)
 4        0x08010000-0x0801FFFF  64 KB   Application ←─┐
 5        0x08020000-0x0803FFFF 128 KB   Application    │ 448 KB total
 6        0x08040000-0x0805FFFF 128 KB   Application    │
 7        0x08060000-0x0807FFFF 128 KB   Application ←─┘

This matches the Creality stock layout — official Marlin firmware binaries work without modification.


Hardware Requirements

Item Details
Printer Creality Ender-3 V3 SE
Motherboard C14 revision (HW ID: CR4NS200320C14)
MCU STM32F401RET6 (ARM Cortex-M4, 512 KB flash, 96 KB SRAM)
SD Interface SDIO 4-bit wide bus (PC8–12 data/clock, PD2 CMD, PC7 detect)
Programmer ST-Link V2 (or any SWD programmer) — only needed once to flash the bootloader
SD Card FAT32 formatted, any size

Note: This is specifically for the C14 board with the STM32F401 chip. If your board says C13 or has a GD32F303, this bootloader is NOT for you.


Quick Start — I Just Want My Printer Working Again

Step 1: Flash the Bootloader (one time, via SWD)

You need an ST-Link V2 and either STM32CubeProgrammer or OpenOCD.

With STM32CubeProgrammer:

  1. Connect ST-Link to the board's SWD header (SWDIO, SWCLK, GND, 3.3V)
  2. Open STM32CubeProgrammer → Connect
  3. Open Tab: Erasing & Programming
  4. Browse to E3V3SE_SDBootloader.bin
  5. Start Address: 0x08000000
  6. Click Start Programming

With OpenOCD:

openocd -f interface/stlink.cfg -f target/stm32f4x.cfg \
  -c "program E3V3SE_SDBootloader.bin 0x08000000 verify reset exit"

Step 2: Flash Firmware (every time, via SD card)

  1. Format your SD card as FAT32
  2. Copy Creality's firmware .bin file to the SD card root
  3. Rename it to exactly firmware.bin
  4. Insert SD card into the printer
  5. Power on — wait a few seconds
  6. Marlin boots. Check the SD card: firmware.bin is now firmware.CUR

Future updates: just put a new firmware.bin on the card and power cycle.


Building From Source

Prerequisites

  • arm-none-eabi-gcc (any recent version — tested with 14.2)
  • make (GNU Make)
  • STM32CubeF4 HAL — the Makefile expects PlatformIO's copy:
    ~/.platformio/packages/framework-stm32cubef4/
    
    You can also point CUBE_DIR to any STM32CubeF4 SDK directory.

Build

# If PlatformIO HAL is in the default location:
make

# Or specify a custom path:
make CUBE_DIR=/path/to/STM32CubeF4

Output: build/E3V3SE_SDBootloader.bin (~16 KB)

Project Structure

E3V3SE_SDBootloader/
├── Core/
│   ├── Inc/
│   │   ├── bootloader.h          # Flash layout, firmware filename, API
│   │   ├── ffconf.h              # FatFS configuration
│   │   ├── fatfs.h               # FatFS link driver header
│   │   ├── main.h                # Pin defines, extern declarations
│   │   ├── sd_diskio.h           # SD disk I/O header
│   │   ├── stm32f4xx_hal_conf.h  # HAL module enables
│   │   └── stm32f4xx_it.h        # Interrupt handler prototypes
│   └── Src/
│       ├── bootloader.c          # Core logic: mount, validate, erase, write, jump
│       ├── fatfs.c               # FatFS driver registration
│       ├── main.c                # MCU init (clock, SDIO, GPIO) + entry point
│       ├── sd_diskio.c           # SDIO-based FatFS disk I/O
│       └── stm32f4xx_it.c        # SysTick + fault handlers
├── STM32F401RETX_FLASH.ld        # Linker script (48 KB flash, 96 KB RAM)
├── Makefile
├── LICENSE
└── README.md

How It Works (Technical Details)

Clock configuration: HSI 16 MHz → PLL (M=/8, N=x168, P=/4, Q=/7) → SYSCLK 84 MHz, SDIOCLK 48 MHz

SD card initialization: Starts in 1-bit mode at ~4 MHz, then widens to 4-bit SDIO for faster reads.

Firmware validation (before erasing anything):

  • Stack pointer (word 0) must be in SRAM range: 0x200000000x20018000
  • Reset vector (word 1) must be in app flash: 0x080100000x08080000
  • Reset vector must have Thumb bit set (odd address)

Flash programming: HAL byte-by-byte with FLASH_TYPEPROGRAM_BYTE, verified with memcmp readback after each chunk.

Application jump: Disables all IRQs, clears NVIC, sets SCB->VTOR to 0x08010000, sets MSP, re-enables IRQs, calls reset vector.

Failure modes:

Scenario Behavior
No SD card Boots existing app
No firmware.bin Boots existing app
File too large (>448KB) Boots existing app
Invalid header Boots existing app
Erase fails Hangs (re-flash via SWD)
Write/verify fails Hangs (re-flash via SWD)
No valid app Hangs (re-flash via SWD)

Troubleshooting

Printer is completely dead after flashing bootloader:

  • Re-check SWD wiring. Re-flash the bootloader binary at 0x08000000.

firmware.bin not renamed to firmware.CUR:

  • SD card didn't mount. Reformat as FAT32 (allocation size 4096). Try a different card.
  • Make sure the file is named exactly firmware.bin (case-sensitive on some cards).

Bootloader flashes but Marlin doesn't start:

  • Confirm your firmware binary is for the STM32F401 / C14 board, not the GD32F303 / C13.
  • Check that the binary is < 448 KB.

How do I get back to stock?

  • The stock Creality bootloader binary is not publicly available, but you don't need it — this bootloader is functionally identical. Any official Creality firmware .bin file will work.

Background

This bootloader was born out of necessity. The stock Creality bootloader on an Ender-3 V3 SE C14 board got replaced with an incompatible one (meant for the GD32F303/C13 board), completely bricking the printer's SD card flashing capability.

After discovering that no open-source SDIO-based bootloader existed for this specific board, this project was written from scratch — with a lot of late-night debugging, HAL datasheet diving, and determination to avoid buying a whole new motherboard.

If you're here because you're in the same boat: you're going to be fine. Flash this, put your firmware on the SD card, and get back to printing.


Credits

  • ewatts104-bit — Project owner. Diagnosed the bricked bootloader, sourced the pin mappings, tested on real hardware.
  • GitHub Copilot (Claude, Anthropic) — AI pair-programmer that wrote the bootloader code, HAL configuration, FatFS integration, Makefile, and this README during an extended debugging and development session. Yes, an AI helped unbrick a 3D printer. The future is now.
  • Revoxxi — Marlin fork for the C14 board, which provided the critical SDIO pin mapping (pins_CREALITY_F401.h).
  • quangcaol/SDBootloader — SPI-based STM32 SD bootloader that served as the initial reference architecture.
  • STMicroelectronics — STM32CubeF4 HAL and FatFS middleware.

License

MIT — Use it, modify it, share it. If it saves your printer, that's all the thanks we need.

About

A bootloader for when you delete the factory bootloader Verified working.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages