Skip to content

Commit b998f2f

Browse files
committed
Clean up stub_main a bit
There is no particular requirement for stack_end to always follow stack in memory, don't rely on it.
1 parent db91e49 commit b998f2f

File tree

6 files changed

+20
-11
lines changed

6 files changed

+20
-11
lines changed

.clang-format

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BasedOnStyle: Google
2+
AllowShortFunctionsOnASingleLine: false
3+
SpaceAfterCStyleCast: true
4+
PointerBindsToType: false
5+
DerivePointerBinding: false
6+
IncludeBlocks: Preserve

cli/flash/esp/stub/stub_flasher.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "esp32/rom/miniz.h"
3232
#include "esp32/rom/spi_flash.h"
3333
#include "soc/uart_reg.h"
34+
3435
#include "led.h"
3536
#endif
3637

@@ -564,13 +565,15 @@ void stub_main1(void) {
564565
}
565566

566567
/* miniz requires at least 12K of stack */
567-
uint32_t stack[3071];
568-
uint32_t stack_end;
568+
uint32_t _stack[3072];
569569

570570
void stub_main(void) {
571571
memset(&_bss_start, 0, (&_bss_end - &_bss_start));
572-
__asm volatile("movi a1, stack_end\n");
572+
uint32_t *stack_end = &_stack[3071];
573+
__asm volatile("mov a1, %0\n"
574+
: // output
575+
: "a"(stack_end) // input
576+
: // scratch
577+
);
573578
stub_main1();
574-
// Keep the stack vars alive.
575-
stack[0] = stack_end = 0xff;
576579
}

cli/flash/esp32/bindata.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)