Skip to content

Commit f0b4d1f

Browse files
authored
esp32c3 flashless target (#627)
1 parent 7e93985 commit f0b4d1f

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

examples/espressif/esp/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ NOTE: you have to provide a [bootloader](https://docs.espressif.com/projects/esp
1919
esptool.py --chip esp32c3 --baud 460800 --before default_reset --after hard_reset write_flash 0x0 \
2020
zig-out/firmware/esp32_c3_direct_boot_blinky.bin
2121
```
22+
23+
- flashless image
24+
25+
```sh
26+
esptool.py --chip esp32c3 --baud 460800 --no-stub load_ram zig-out/firmware/esp32_c3_flashless_blinky.bin
27+
```

examples/espressif/esp/build.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub fn build(b: *std.Build) void {
1515
const targets = [_]TargetDescription{
1616
.{ .prefix = "esp32_c3", .target = mb.ports.esp.chips.esp32_c3 },
1717
.{ .prefix = "esp32_c3_direct_boot", .target = mb.ports.esp.chips.esp32_c3_direct_boot },
18+
.{ .prefix = "esp32_c3_flashless", .target = mb.ports.esp.chips.esp32_c3_flashless },
1819
};
1920

2021
const available_examples = [_]Example{

examples/espressif/esp/src/custom_clock_config.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const clocks = hal.clocks;
55
const usb_serial_jtag = hal.usb_serial_jtag;
66

77
pub const microzig_options: microzig.Options = .{
8-
.log_level = .debug,
98
.logFn = usb_serial_jtag.logger.log,
109
};
1110

examples/espressif/esp/src/systimer.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const systimer = hal.systimer;
77
const usb_serial_jtag = hal.usb_serial_jtag;
88

99
pub const microzig_options: microzig.Options = .{
10-
.log_level = .debug,
1110
.logFn = usb_serial_jtag.logger.log,
1211
.interrupts = .{
1312
.interrupt1 = timer_interrupt,

examples/espressif/esp/src/ws2812_blinky.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const hal = microzig.hal;
66
const gpio = hal.gpio;
77

88
pub const microzig_options: microzig.Options = .{
9-
.log_level = .debug,
9+
.logFn = hal.usb_serial_jtag.logger.log,
1010
};
1111

1212
pub fn main() !void {

port/espressif/esp/build.zig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Self = @This();
77
chips: struct {
88
esp32_c3: *const microzig.Target,
99
esp32_c3_direct_boot: *const microzig.Target,
10+
esp32_c3_flashless: *const microzig.Target,
1011
},
1112

1213
boards: struct {},
@@ -106,6 +107,18 @@ pub fn init(dep: *std.Build.Dependency) Self {
106107
),
107108
},
108109
}),
110+
.esp32_c3_flashless = chip_esp32_c3.derive(.{
111+
.ram_image = true,
112+
.linker_script = .{
113+
.generate = .memory_regions,
114+
.file = generate_linker_script(
115+
dep,
116+
"final.ld",
117+
b.path("ld/esp32_c3/flashless_sections.ld"),
118+
b.path("ld/esp32_c3/rom_functions.ld"),
119+
),
120+
},
121+
}),
109122
},
110123
.boards = .{},
111124
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
SECTIONS
2+
{
3+
.ram_text ORIGIN(IRAM) : AT(0)
4+
{
5+
microzig_ram_text_start = .;
6+
7+
KEEP(*(microzig_ram_start))
8+
*(.text*)
9+
KEEP(*(.ram_text))
10+
11+
} > IRAM
12+
13+
. = ALIGN(8);
14+
_iram_size = . - microzig_ram_text_start;
15+
16+
_dram_start = ORIGIN(DRAM) + _iram_size;
17+
.data _dram_start : AT(_iram_size)
18+
{
19+
microzig_data_start = .;
20+
*(.sdata*)
21+
*(.data*)
22+
*(.rodata*)
23+
} > DRAM
24+
25+
.bss (NOLOAD) :
26+
{
27+
microzig_bss_start = .;
28+
*(.bss*)
29+
*(.sbss*)
30+
microzig_bss_end = .;
31+
} > DRAM
32+
33+
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
34+
}

0 commit comments

Comments
 (0)