Skip to content

Commit

Permalink
Clean up stub_main a bit
Browse files Browse the repository at this point in the history
There is no particular requirement for stack_end to always follow stack
in memory, don't rely on it.
  • Loading branch information
rojer committed Nov 15, 2021
1 parent db91e49 commit b998f2f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: false
SpaceAfterCStyleCast: true
PointerBindsToType: false
DerivePointerBinding: false
IncludeBlocks: Preserve
13 changes: 8 additions & 5 deletions cli/flash/esp/stub/stub_flasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "esp32/rom/miniz.h"
#include "esp32/rom/spi_flash.h"
#include "soc/uart_reg.h"

#include "led.h"
#endif

Expand Down Expand Up @@ -564,13 +565,15 @@ void stub_main1(void) {
}

/* miniz requires at least 12K of stack */
uint32_t stack[3071];
uint32_t stack_end;
uint32_t _stack[3072];

void stub_main(void) {
memset(&_bss_start, 0, (&_bss_end - &_bss_start));
__asm volatile("movi a1, stack_end\n");
uint32_t *stack_end = &_stack[3071];
__asm volatile("mov a1, %0\n"
: // output
: "a"(stack_end) // input
: // scratch
);
stub_main1();
// Keep the stack vars alive.
stack[0] = stack_end = 0xff;
}
4 changes: 2 additions & 2 deletions cli/flash/esp32/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b998f2f

Please sign in to comment.